From eb47b1e2580cd6f8285dadba8f943e1b667ec390 Mon Sep 17 00:00:00 2001 From: Menci Date: Tue, 14 Jun 2022 22:44:00 +0800 Subject: [PATCH] fix(plugin-legacy): don't include SystemJS in modern polyfills (#6902) Co-authored-by: sapphi-red --- packages/plugin-legacy/src/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/plugin-legacy/src/index.ts b/packages/plugin-legacy/src/index.ts index 4aaab1aab2412d..0c9fb1c8c68d33 100644 --- a/packages/plugin-legacy/src/index.ts +++ b/packages/plugin-legacy/src/index.ts @@ -134,7 +134,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { config.build, 'es', opts, - options.externalSystemJS + true ) return } @@ -566,7 +566,7 @@ async function buildPolyfillChunk( buildOptions: BuildOptions, format: 'iife' | 'es', rollupOutputOptions: NormalizedOutputOptions, - externalSystemJS?: boolean + excludeSystemJS?: boolean ) { let { minify, assetsDir } = buildOptions minify = minify ? 'terser' : false @@ -575,7 +575,7 @@ async function buildPolyfillChunk( root: path.dirname(fileURLToPath(import.meta.url)), configFile: false, logLevel: 'error', - plugins: [polyfillsPlugin(imports, externalSystemJS)], + plugins: [polyfillsPlugin(imports, excludeSystemJS)], build: { write: false, target: false, @@ -614,7 +614,7 @@ const polyfillId = '\0vite/legacy-polyfills' function polyfillsPlugin( imports: Set, - externalSystemJS?: boolean + excludeSystemJS?: boolean ): Plugin { return { name: 'vite:legacy-polyfills', @@ -627,7 +627,7 @@ function polyfillsPlugin( if (id === polyfillId) { return ( [...imports].map((i) => `import "${i}";`).join('') + - (externalSystemJS ? '' : `import "systemjs/dist/s.min.js";`) + (excludeSystemJS ? '' : `import "systemjs/dist/s.min.js";`) ) } }