Kinto / kinto-react-boilerplate

An UNMAINTAINED Kinto.js+React project boilerplate.
67 stars 9 forks source link

Investigate if babel/polyfill is relevant #3

Open leplatrem opened 9 years ago

leplatrem commented 9 years ago

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.

nelix commented 8 years ago

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.

leplatrem commented 8 years ago

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!