3

As performance is always important I was wondering how to best include polyfills. I'd prefer to use codesplitting and then lazyload each polyfill if the current environment doesn't that support it.

Doing this manually requires more work which I would happily put in. eslint-plugin-compat would be a good helper in this case I guess.

Automating this process with sth. like babel-preset-env reduces the effort but does it bring the same performance benefits as doing it "manually"?

From my understanding, babel-preset-env is transpiling all that stuff out of the box but when you use useBuiltIns it adding the corresponding polyfills, right? -> https://babeljs.io/docs/plugins/preset-env/#usebuiltins

But then again, does it always load all polyfills (files/modules) and checks within those if the polyfill is needed or does it load the polyfill modules conditionally if the fn isn't available on the window or prototype?

If you could point me in a direction or explain the way babel-preset-env works that would be great.

Help is much appreciated :)

danielreiser
  • 5,292
  • 5
  • 31
  • 43
  • I'm just wondering the same and found your question. No answer since Feb... Looks like this subject is difficult indeed :) Up-voted. – szegheo Oct 03 '18 at 09:00
  • Polyfills needed are decided at compile time. At run time, it always loads all polyfills compiled – David Lin Aug 08 '19 at 06:13

0 Answers0