-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat(plugin-legacy): add modernTargets
option
#15506
feat(plugin-legacy): add modernTargets
option
#15506
Conversation
Run & review this pull request in StackBlitz Codeflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks great! Thanks for updating it. Would you be able to update the README about the new modernTargets
option too?
modernTargets
optionsmodernTargets
option
@undermoonn, we discussed this PR in the last team meeting and decided to move forward with it. The only thing is that we should add a warning using |
Thanks for replies and specific guidance! Love vite ❤️ |
Thanks for this feature. Do you have an ETA for the next release (I'm not demanding, just asking) |
No problem @jderusse. Thanks for the nudge, I just cut a release for plugin-legacy v5.3.0 |
This PR does not work as intended. if (!genLegacy || config.build.ssr) {
return;
}
targets = options.targets || browserslistLoadConfig({ path: config.root }) || "last 2 versions and not dead, > 0.3%, Firefox ESR";
isDebug && console.log(`[@vitejs/plugin-legacy] targets:`, targets);
modernTargets = options.modernTargets || modernTargetsBabel; Notice that the function returns before the This means that later on, the variable is undefined, and we're back to the original behavior: if (options.modernPolyfills && !Array.isArray(options.modernPolyfills) && genModern) {
await detectPolyfills(raw, modernTargets, modernPolyfills); // modernTargets is undefined
} |
Thanks for flagging that @C-Higgins. That condition does seem oddly placed, the |
Sorry to that @C-Higgins I didn't check the code when Maybe I can fix it with code below if (options.modernPolyfills && !Array.isArray(options.modernPolyfills) && genModern) {
await detectPolyfills(raw, options.modernTargets || modernTargetsBabel, modernPolyfills);
} Place |
Description
When
renderLegacyChunks
option enabled, legacy plugin will force setbuild.target
to['es2020', 'edge79', 'firefox67', 'chrome64', 'safari12']
rendering modern chunks.Additional context
fix #14527
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).