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

feat(plugin-legacy): support additionalModernPolyfills #16514

Merged
merged 1 commit into from Apr 30, 2024

Conversation

iammminzzy
Copy link
Contributor

@iammminzzy iammminzzy commented Apr 23, 2024

Description

This PR introduces additionalModernPolyfills option that mirrors the existing additionalLegacyPolyfills option.
The reason this is needed for the modern chunk is because due to #5142 the following is not actually true, and the only way to ensure polyfills are loaded before application code is to use plugin-legacy:

Note: if additional polyfills are needed for both the modern and legacy chunks, they can simply be imported in the application source code.

For example, this option can be used when an application only configures modernPolyfills but wishes to add custom polyfills for non-legacy browsers.

Copy link

stackblitz bot commented Apr 23, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@Shakeskeyboarde
Copy link
Contributor

Shakeskeyboarde commented Apr 24, 2024

Can you explain what you mean when you say the existing docs are untrue? Why and in what case does importing polyfills in your source code not work?

@NMinhNguyen
Copy link
Contributor

NMinhNguyen commented Apr 24, 2024

Can you explain what you mean when you say the existing docs are untrue? Why and in what case does importing polyfills in your source code not work?

Per the referenced issue, if you import a side-effectful module and you have chunking (e.g. in MPA mode), there’s no guarantee that it will run before other code that relies on that side effect to have executed.

@bluwy
Copy link
Member

bluwy commented Apr 29, 2024

#5142 is about the bug in dev in prebundled dependencies. I think this issue is different?

But putting that issue aside and using the same arguments as the current additionalLegacyPolyfills option, this seems like a fine addition to me.

@bluwy bluwy added plugin: legacy p2-nice-to-have Not breaking anything but nice to have (priority) labels Apr 29, 2024
@NMinhNguyen
Copy link
Contributor

#5142 is about the bug in dev in prebundled dependencies. I think this issue is different?

It might be rollup/rollup#3888 that I ran into (which also references #5142). But thanks for approving the PR, can’t wait to try it out 🙂

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could merge this one without going through a team meeting. It seems a non-controversial addition.

@bluwy bluwy merged commit 2322657 into vitejs:main Apr 30, 2024
11 checks passed
@NMinhNguyen
Copy link
Contributor

@bluwy apologies for the direct ping, but when do you expect to publish a new version?

@bluwy
Copy link
Member

bluwy commented May 1, 2024

I think as soon as after #16566 is merged, which is also plugin-legacy related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority) plugin: legacy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants