fix(vite): dev-bundler externality (#1507)

This commit is contained in:
Anthony Fu 2021-10-27 18:55:08 +08:00 committed by GitHub
parent 0326a31990
commit 00e25fa8e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
],