Skip to content

Commit

Permalink
fix(plugin-legacy): don't include SystemJS in modern polyfills (#6902)
Browse files Browse the repository at this point in the history
Co-authored-by: sapphi-red <green@sapphi.red>
  • Loading branch information
Menci and sapphi-red authored Jun 14, 2022
1 parent d1ba059 commit eb47b1e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
config.build,
'es',
opts,
options.externalSystemJS
true
)
return
}
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -614,7 +614,7 @@ const polyfillId = '\0vite/legacy-polyfills'

function polyfillsPlugin(
imports: Set<string>,
externalSystemJS?: boolean
excludeSystemJS?: boolean
): Plugin {
return {
name: 'vite:legacy-polyfills',
Expand All @@ -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";`)
)
}
}
Expand Down

0 comments on commit eb47b1e

Please sign in to comment.