sagui icon indicating copy to clipboard operation
sagui copied to clipboard

Add Babel polyfill when configured

Open pirelenito opened this issue 9 years ago • 7 comments

see: http://babeljs.io/docs/usage/polyfill/

pirelenito avatar Jan 05 '16 21:01 pirelenito

Should I have it setup automatically?

pirelenito avatar Mar 21 '16 20:03 pirelenito

I think this could be pretty useful to have by default, since we have to assume that many users of Sagui are not aware of the differences in ES feature support in the different environments. It feels that the polyfill goes hand to hand with using Babel.

That said I also would like a flag to disable it if needed.

xaviervia avatar Sep 20 '16 19:09 xaviervia

An alternative: https://github.com/Financial-Times/polyfill-service

pirelenito avatar Oct 04 '16 08:10 pirelenito

I second @xaviervia's opinion about polyfill being enabled by default.

Since some of the sagui's dependencies depend upon new ES features (css-modules depending on Object.assign), it would make sense to include it out of the box. I'm having my website breaking on older browsers, which could have easily been avoided using polyfill. We could also avoid issues like this: http://www.andrewzey.com/google-seo-with-create-react-app-fixing-the-hidden-gotcha/

Also, what would be the preferred way to include polyfill for now?

karthikiyengar avatar Jan 16 '17 12:01 karthikiyengar

I think the simplest way right now is to install it in the project (npm install babel-polyfill) and include it as the first line in the entrypoint (ie. import 'babel-polyfill' in the src/index.js).

It might be good to have that as part of the index.js template, although that would imply installing the polyfill automatically and I am not sure how that would work.

The alternative is to make it part of the build so that Sagui concatenates the polyfill with the JS entrypoints by default. That might be easier to set up than adding it in the template, and it's consistent with Sagui's philosophy of making it easy to consumers. If we do this we should of course include a flag in the configuration to disable the polyfill, since it's pretty heavy and some consumers might not want it.

xaviervia avatar Jan 16 '17 12:01 xaviervia

You might also consider using babel-preset-env. This way the user can configure which environments to support.

fhelwanger avatar Jan 16 '17 12:01 fhelwanger

that is awesome @fhelwanger! sounds like something we should consider having by default!

pirelenito avatar Jan 16 '17 12:01 pirelenito