Proper usage with selective polyfilling?
jquense opened this issue · comments
Is there a good, or preferable setup using preset-modules, along with `preset-env' auto polyfilling? Perhaps all the transforms disabled so the polyfills are also included?
We will move this preset into preset-env
soon (either in the next Babel minor release or in the one after), so it will be enough to use @babel/preset-env
with the esmodules: true
option.
Right - I believe even with all transforms enabled right now preset-env would produce polyfill imports since it isn't aware preset-modules is transforming things. I believe the useBuiltIns:entry
option should work in tandem, though.
At the moment i've got them working together but have had to manually exclude
any transforms in preset-env. On a tangent it'd be nice to have a leaner polyfill option as well, corejs is thorough, maybe too much so :P
@jquense I couldn't agree more! :)
FWIW I've found myself using polyfill.io's configurator tool and then grabbing the resulting polyfills (with the ?flags=always
parameter) and just inlining that. I tend to conditionally load it using <script nomodule>
.
BTW if you have a working exclude
list handy I would love to take a peek. It might be worth dropping it in this issue so we can pin it for folks wondering the same as you were.
its luckily as easy as using a regex since the babel plugins are consistently named https://github.com/4Catalyzer/javascript/blob/esm/packages/babel-preset/esm.js#L25
oh, brilliant haha. One thing potentially worth trying would be to exclude known false positive inclusions of corejs:
exclude: [
/transform/,
'es.map',
'es.set',
'es.object.assign'
]
We will move this preset into
preset-env
soon (either in the next Babel minor release or in the one after), so it will be enough to use@babel/preset-env
with theesmodules: true
option.
Babel 8 is planned to be released in March. Any chance it will be included then? :)
It will! And in case we release 7.9.0 before 8.0.0, it will be already included in 7.9.0.
You can turn on notifications for babel/babel#11083 😉
I don't know where to post this, but the Safari 10 polyfill for supporting "nomodule", is this part of this plugin, or do we still need to include that ourselves?