You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In vite plugin legacy docs, it says the following on the option modernpolyfills:
Note it is not recommended to use the true value (which uses auto-detection) because core-js@3 is very aggressive in polyfill inclusions due to all the bleeding edge features it supports. Even when targeting native ESM support, it injects 15kb of polyfills!
Now I wonder - why can't this plugin somehow, will take the generated polyfill list, and substruct from this list every polyfill that isn't required for any modern browser - meaning every feature such that every targeted browser either doesn't fully support ESModules, or already supports this specific polyfill feature.
I believe this can reduce the modern polyfill output drastically.
It kinda reminding issue #6922, but tries to solve the huge polyfill output problem from another direction.
Suggested solution
Use some library that can tell us for every feature in the polyfill, which browsers already support this feature, then filter this browser lists to the target browser list, and then check whether there is some browser in which the minimal version that the polyfill is already supported is bigger than the version of this browser with a full ESModule support.
If the answer is "yes" - add this polyfill (to modern). Otherwise - don't bundle this polyfill.
This is already the case I believe, just that corejs's browser compat table is more aggresive, e.g. if an API that works perfectly fine in browser A, but has this one edgecase bug, it will get polyfilled. We can't simply subtract it out as it means we need to build our own compat table, and it's HUGE. Another alternative would be doing something like #2433 (comment) too, and you can subtract those out yourself. Closing as this likely won't be implemented.
Description
In vite plugin legacy docs, it says the following on the option
modernpolyfills
:Now I wonder - why can't this plugin somehow, will take the generated polyfill list, and substruct from this list every polyfill that isn't required for any modern browser - meaning every feature such that every targeted browser either doesn't fully support ESModules, or already supports this specific polyfill feature.
I believe this can reduce the modern polyfill output drastically.
It kinda reminding issue #6922, but tries to solve the huge polyfill output problem from another direction.
Suggested solution
Use some library that can tell us for every feature in the polyfill, which browsers already support this feature, then filter this browser lists to the target browser list, and then check whether there is some browser in which the minimal version that the polyfill is already supported is bigger than the version of this browser with a full ESModule support.
If the answer is "yes" - add this polyfill (to modern). Otherwise - don't bundle this polyfill.
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: