Skip to content

Commit

Permalink
fix: always read targets options (fix: vitejs#15788)
Browse files Browse the repository at this point in the history
If `modernPolyfills` is set to `true`, but `renderLegacyChunks` is set
to false, `genLegacy` will be false and we would return early. If this
return happens before `modernTargets` is initialized, the modern
polyfills will be generated with the wrong (default?) target instead of
the specified `modernTargets`.
  • Loading branch information
jgosmann committed Feb 2, 2024
1 parent 775bb50 commit 50b5fdb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,6 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
}
config = _config

if (!genLegacy || config.build.ssr) {
return
}

targets =
options.targets ||
browserslistLoadConfig({ path: config.root }) ||
Expand All @@ -339,6 +335,10 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
isDebug &&
console.log(`[@vitejs/plugin-legacy] modernTargets:`, modernTargets)

if (!genLegacy || config.build.ssr) {
return
}

const getLegacyOutputFileName = (
fileNames:
| string
Expand Down

0 comments on commit 50b5fdb

Please sign in to comment.