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

Explore babel-preset-env #312

Open
tizmagik opened this issue Nov 1, 2016 · 4 comments
Open

Explore babel-preset-env #312

tizmagik opened this issue Nov 1, 2016 · 4 comments
Assignees

Comments

@tizmagik
Copy link
Contributor

tizmagik commented Nov 1, 2016

With #255 we now have babel-polyfill in place both on the client and server for necessary ES6+ support. In the case of the client, relatively modern browsers don't need the entire polyfill, and for the server since node 6 is already a pre-req for kyt, most of the polyfill is also unnecessary there.

Although it's arguably still early for babel-preset-env, I think it might be good to experiment with it and see if we can use it to polyfill only what's necessary for newer browsers in the client bundle and node 6+ in the server bundle.

@delambo
Copy link
Member

delambo commented Nov 1, 2016

I can't get a good read on babel-preset-env. Does it actually include polyfills or is it for transformation only? If it's the latter, I don't think it would be a replacement for babel-polyfill.

@tizmagik
Copy link
Contributor Author

tizmagik commented Nov 1, 2016

No, unfortunately it's not a replacement for babel-polyfill, it just results in less code being transpiled and, presumably, a smaller overall bundle size.

However, something to only polyfill what's needed seems like it's in the cards for babel-preset-env, see this issue: babel/babel-preset-env#20

With that being said, on the server-side we might be able to get away with only polyfilling what's missing (e.g. generator functions, etc) and leave off the rest since node 6 has pretty decent ES6 coverage and it's a more predictable environment. We wouldn't be able to leave off the polyfill for the browser, however.

@hzoo
Copy link

hzoo commented Nov 1, 2016

Babel itself only transforms syntax so the preset just determines the least common denominator of plugins to run on the browsers/environments you specify in the options. Instead of changing your set of plugins yourself (turning off plugins over time) it should calculate that for you.

@hzoo
Copy link

hzoo commented Dec 7, 2016

I'm working on the polyfill part in babel/babel-preset-env#56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants