Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use babel transform runtime over babel polyfill #429



Copy link

evan-10e commented May 22, 2019


Projects that depend on babel-polyfill and fetch-mock will crash with the following error.


In short: Libraries should not be using babel-polyfill, but rather babel transform runtime.

Additional Context

Babel team members warn that if you are writing a library - babel polyfill should not be used because it can pollute the globals used by project owners.

If you are writing a library, you should not be using babel-polyfill. Having a library mutate the global state of the browser environment is not a good idea. If you need a standalone library you should be using babel-runtime via transform-runtime, or if you don't want to do that, you should make it a requirement that uses of your library load a polyfill first, and your code should assume it is there.

Logan Smyth (member and contributor of babel) babel/babel#4019 (comment)

As such, Fetch-mock's improper use of babel is causing projects to crash in this fashion. babel/babel#4019 (comment)


This comment has been minimized.

Copy link

wzph-10e commented May 22, 2019



This comment has been minimized.

Copy link

wheresrhys commented May 27, 2019

Hi. Sorry for the slow response. Not had much time to maintain the library lately.

I agree with your appraisal, but don't think I can release this as a patch - babel polyfilling has been a discussion point in issues before, and I think this will break lots of people's tests. I don't want to deal with the fallout from that.

So I think this should be released as v8 of the library. Please could you search the repo (mainly docs) for mentions of v7 and update to say v7/8 I will add a changelog note once released to explain what the difference between v7 and 8 is.


This comment has been minimized.

Copy link

ndelangen commented Jul 23, 2019

Could this be combined with an upgrade to core-js v3?

Or would this remove the need for core-js entirely?

Some users of storybook are hitting the core-js 3 incompatibility with this lib:

I would be open to helping resolve this, Are you still working on this @evan-10e @wheresrhys ?


This comment has been minimized.

Copy link
Contributor Author

evan-10e commented Jul 23, 2019

@ndelangen I discovered that my bundle script was duplicated in the page head. Removing the dup solved the issue for me.


This comment has been minimized.

Copy link

wheresrhys commented Oct 26, 2019

v8.0.0-alpha.2 attempts to address this issue. Please leave a 👍 on the pull request #457 if your problem is solved, or alternatively leave a comment @evan-10e @ndelangen @wzph-10e

@wheresrhys wheresrhys closed this Oct 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.