-
-
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
plugin-legacy: modernTargets not respected when renderLegacyChunks is false #15788
Comments
Start a new pull request in StackBlitz Codeflow. |
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`.
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`.
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`. Also, config.build.target must be set from the `modernTargets`, even if `genLegacy` is to set.
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 (the default?) target instead of the specified `modernTargets`.
After pondering this comment in the review I realized that the bug described here isn't quite accurate. The syntax transforms are applied correctly if |
Describe the bug
I'm using
@vitejs/plugin-legacy
with this configuration:The
modernTargets
option is only respected if I also setrenderLegacyChunks
totrue
.Reproduction
https://stackblitz.com/edit/vitejs-vite-nagbo9?file=vite.config.js
Steps to reproduce
A (fairly) minimal reproduction is provided under the Stackblitz link. Run
DEBUG=vite:legacy npm run build
and you will see that themodernTargets
option is not logged. In the generated bundle (dist/assets/index-[hash].js
), you will be able to find a null coalescing operation (??
) that isn't compatible with the browsers given inmodernTargets
.If you change
renderLegacyChunks
totrue
, you get the expected log output:Also, in the generated bundle the null coalescing operator does not longer exist and has been replaced with code compatible with older browsers.
System Info
Local environment
The text was updated successfully, but these errors were encountered: