Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin-legacy): don't include SystemJS in modern polyfills #6902

Merged
merged 3 commits into from Jun 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/plugin-legacy/src/index.ts
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