imperodesign / generator-impero

Impero's website skeleton generator, courtesy of Yeoman
Other
1 stars 1 forks source link

Stop transpiling ES2015/ES6 for modern browser config #51

Open samhh opened 7 years ago

samhh commented 7 years ago

Looks like modern browsers now have nearly perfect ES2015/ES6 support, so we could remove the ES2015 preset from Babel for modern browsers?

See: http://kangax.github.io/compat-table/es6/

samhh commented 7 years ago

In this case we'll need to minify with something new in production, as UglifyJs does not support ES2015 syntax at all. See: https://github.com/imperodesign/generator-impero/blob/master/generators/app/templates/webpack.production.config.js#L26

samhh commented 7 years ago

See also: https://github.com/webpack/webpack/issues/2836#issuecomment-237258899

samhh commented 7 years ago

This will also involve changing the require.ensure() code example to the newer System.import(), which as far as I can tell is a polyfill of sorts for the stage 2 dynamic import (import()) proposal: https://github.com/domenic/proposal-dynamic-import (they're aiming for import() eventually: https://github.com/webpack/webpack/issues/3098)

samhh commented 7 years ago

Okay, so the blocker here is that there isn't actually anything yet fully capable of minifying ES2015 code. See here: https://github.com/webpack/webpack/issues/2545

Otherwise this issue will be smooth sailing.

samhh commented 7 years ago

Once this issue is closed, take another look at: https://github.com/imperodesign/generator-impero/issues/52

samhh commented 7 years ago

Also relevant: https://babeljs.io/blog/2016/08/30/babili

MrSlide commented 7 years ago

I'd say we should keep transpiling for now. The bigger the audience we can support, the better. The only problem the transpiled code brings is a slightly larger file size.

samhh commented 7 years ago

@MrSlide If anyone needs to target older browsers there is always the legacy option which will keep transpiling ES2015 plus add in a few polyfills. If the modern config is defined as latest Chrome, Firefox, Edge and Safari then with such strong native ES2015 support there's arguably no point to transpiling ES2015 there.

samhh commented 7 years ago

Or better yet (thanks to dotJS for this!): https://github.com/babel/babel-preset-env

Also: https://babeljs.io/docs/plugins/preset-latest/

Seems like es2017 preset perhaps only includes the finalised stuff? Unsure. Needs more research.

See also: #35

samhh commented 7 years ago

Worth trying babili via https://github.com/boopathi/babili-webpack-plugin.

samhh commented 7 years ago

Webpack still the blocker on this: https://github.com/webpack/webpack/issues/2545