kinto-react-boilerplate icon indicating copy to clipboard operation
kinto-react-boilerplate copied to clipboard

Investigate if babel/polyfill is relevant

Open leplatrem opened this issue 10 years ago • 2 comments
trafficstars

It is currently imported in index.js, and thus packed and minified in the build.

It may be removed in order to reduce the output size, and get rid of obsolete browsers support.

  • [ ] Remove import babel/polyfill
  • [ ] Switch dep from babel to babel-core

leplatrem avatar Aug 04 '15 14:08 leplatrem

Basically babel inlines most es6 features without messing with prototypes or globals... If you uses promises, babe will see them and inline it without attaching it to global/window. This is really nice because other libs that might depend on old or new apis that are different to the polyfill will still work, and your code will have the same lib you used while testing.

But there are some things that need global scope, like the regenerator runtum and stuff like:

[1,2,3].any()

Mostly because babel doesnt know that you want Array.prototype.any due to dynamic typing. I generally try to avoid using most native prototypes of es6 features anyway. https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime should be perfect for modern nodejs.

Its essential babel-polyfill is not used in libs.

nelix avatar Dec 18 '15 15:12 nelix

Thanks for the insights !

In kinto.js we added a new distribution target that creates a dist file without any polyfill. Especially to let developers rely on third-parties polyfills (and share them accross dependancies) instead of distributing them along kinto.js.

The transform runtime approach seems interesting though! Thanks!

leplatrem avatar Dec 21 '15 11:12 leplatrem