-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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] finer control for modern/legacy target polyfills #6922
Comments
Any update? |
I'm waiting for Vite maintainers' opinions before I could create a PR for
this.
…On Wed, Sep 14, 2022 at 14:44 Season Chen ***@***.***> wrote:
Any update?
—
Reply to this email directly, view it on GitHub
<#6922 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACWRBA3WYHUUQ6GFNQQZHO3V6FX4LANCNFSM5OMHRFCQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I suggest you to send first the PR if you already implement it, they give more opinions while they see the implementation details in my experience. |
OK. I will.
…On Thu, Sep 29, 2022 at 18:56 Tal500 ***@***.***> wrote:
I'm waiting for Vite maintainers' opinions before I could create a PR for
this.
… <#m_2926676529368159112_>
On Wed, Sep 14, 2022 at 14:44 Season Chen *@*.*> wrote: Any update? —
Reply to this email directly, view it on GitHub <#6922 (comment)
<#6922 (comment)>>, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ACWRBA3WYHUUQ6GFNQQZHO3V6FX4LANCNFSM5OMHRFCQ
<https://github.com/notifications/unsubscribe-auth/ACWRBA3WYHUUQ6GFNQQZHO3V6FX4LANCNFSM5OMHRFCQ>
. You are receiving this because you authored the thread.Message ID: @.*>
I suggest you to send first the PR if you already implement it, they give
more opinions while they see the implementation details in my experience.
—
Reply to this email directly, view it on GitHub
<#6922 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACWRBAZSWDB2C26KZEVQCLDWAVYVBANCNFSM5OMHRFCQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Am I right in saying that, without this feature implemented, E.g. // vite.config.js
plugins: {
legacy({
modernPolyfills: true,
renderLegacyChunks: false,
targets: 'chrome > 100',
ignoreBrowserslistConfig: true
})
} ignores the |
Any follow-up to this issue? |
Clear and concise description of the problem
The current implementation of
plugin-legacy
forcesdynamic-import
as the modern target (which means, browser supportingdynamic-import
will load the modern bundle and others will load the legacy bundle).But the proportion of browsers that support newer feature is gradually increasing so we can choose a higher feature as the modern target to decrease the bundle size of "modern" target. For the browsers have no support for the given feature, let them load the legacy bundle.
Additionally, we uses
@babel/preset-env
which generates too many polyfills (even for modern build). For example, if we usednew URL
in default target (esmodules: true
), it generates URL polyfill since Safari < 14 implementsURLSearchParams.prototype.delete
wrongly. But in most cases we won't care of this so we won't need a 100% right polyfill.Suggested solution
We already generate code to test legacy/modern browsers. We can change to provide an option to customize it:
Then generate the testing and gate-keeping code like:
For example, if I want to target browsers supporting
Object.fromEntries
, we could use:Additionally, we could accept two functions to filter-out the polyfills we don't want to exclude:
Alternative
Change the way of "testing if the client browser should use modern build" to just test if it matches a browserslist. But it may be hard to do this in a code snippet in
index.html
.Additional context
I have implemented all I mentioned features and ready for creating a pull request.
Validations
The text was updated successfully, but these errors were encountered: