From 00e25fa8e8893054a8087077e6f4c1e9e5174f27 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 27 Oct 2021 18:55:08 +0800 Subject: [PATCH] fix(vite): dev-bundler externality (#1507) --- packages/vite/src/dev-bundler.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/dev-bundler.ts b/packages/vite/src/dev-bundler.ts index 7ec7b7a033..23a1d3370e 100644 --- a/packages/vite/src/dev-bundler.ts +++ b/packages/vite/src/dev-bundler.ts @@ -25,12 +25,19 @@ function isExternal (opts: TransformOptions, id: string) { // Externals const ssrConfig = (opts.viteServer.config as any).ssr + // Vite's alias have two possible formats + // https://vitejs.dev/config/#resolve-alias + const alias = opts.viteServer.config.resolve.alias || {} + const aliasKeys = Array.isArray(alias) + ? alias.map(i => i.find).filter(Boolean) + : Object.keys(alias) + const externalOpts: ExternalsOptions = { inline: [ /virtual:/, /\.ts$/, // Things like '~', '@', etc. - ...Object.keys(opts.viteServer.config.resolve.alias), + ...aliasKeys, ...ExternalsDefaults.inline, ...ssrConfig.noExternal ],