question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Load polyfills from polyfill.io rather than babel-polyfill

See original GitHub issue

babel-polyfill is very heavy, and the REPL loads it when you select the “evaluate” option. Let’s instead use a conditional polyfilling service like polyfill.io that only loads the polyfills your browser actually needs. I’d say that most users of the REPL would be using a relatively modern browser, so this should reduce load time.

We’ll need to be sure to load the regenerator runtime though.

import "regenerator-runtime/runtime";

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

8reactions
zloirockcommented, Jun 5, 2018

@thedamon by my opinion, polyfill.io is a good service with bad polyfills.

You can see polyfill.io position about the correctness of polyfills here. You can check the source code of polyfills from polyfill.io in their repo. Just an example - leaking WeakMap polyfill. They have some progress in the previous year, but because they regularly have issues like this, I can’t recommend it for usage. polyfill.io use polyfills from different authors/projects which doesn’t well play together.

core-js / babel-polyfill includes much more features than polyfill.io. Just some example - regenerator runtime for generators / async functions, polyfills for ES proposals, typed arrays, the logic of almost all well-known symbols, etc.

105kb of babel-polyfill you will have only with full bundle, but it’s modular. You can load only required part of core-js. You can automatize this process with preset-env with useBuiltIns option.

polyfill.io service approach definitely makes sense, it can by applied to core-js in the future, but now I haven’t any time and motivation for working on it.

2reactions
zloirockcommented, Sep 1, 2017

I’m strictly against of usage polyfill.io in the REPL because it contains very incorrect polyfills and only a little part of polyfilled features from babel-polyfill.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to load polyfills only when needed
The best solution would be a custom one: something that combines benefits of polyfill.io and Babel's useBuiltIns but doesn't incur their costs.
Read more >
babel/polyfill
Babel includes a polyfill that includes a custom regenerator runtime and core-js. This will emulate a full ES2015+ environment (no < Stage 4...
Read more >
Differential serving vs. polyfill service: How to ... - Dong Chen
Instead, babel will import the corresponding polyfills on top of each of your file. Also, you don't need to worry about including the...
Read more >
Polyfills and transpilers - The Modern JavaScript Tutorial
js and polyfill.io do. Anyway; to make things a little bit more confusing Babel in addition to transpiling has some sort of post-process...
Read more >
Why do I need @babel/polyfill at all, using Babel?
Both polyfill and transpilation enable you to use new features in old environments (think of old vs new browsers for example), ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found