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

Proper usage with selective polyfilling? #9

Open
jquense opened this issue Dec 20, 2019 · 9 comments
Open

Proper usage with selective polyfilling? #9

jquense opened this issue Dec 20, 2019 · 9 comments
Labels
discussion enhancement New feature or request

Comments

@jquense
Copy link

jquense commented Dec 20, 2019

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?

@nicolo-ribaudo
Copy link
Member

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.

@developit
Copy link
Member

developit commented Jan 7, 2020

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.

@jquense
Copy link
Author

jquense commented Jan 8, 2020

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

@developit
Copy link
Member

developit commented Jan 9, 2020

@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.

@developit developit added discussion enhancement New feature or request labels Jan 9, 2020
@jquense
Copy link
Author

jquense commented Jan 9, 2020

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

@developit
Copy link
Member

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'
]

@ba55ie
Copy link

ba55ie commented Feb 6, 2020

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.

Babel 8 is planned to be released in March. Any chance it will be included then? :)

@nicolo-ribaudo
Copy link
Member

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 😉

@BregtDeLange
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants