Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Error: only one instance of babel-polyfill is allowed #450

Closed
or2008 opened this issue Dec 4, 2018 · 3 comments
Closed

Error: only one instance of babel-polyfill is allowed #450

or2008 opened this issue Dec 4, 2018 · 3 comments

Comments

@or2008
Copy link

or2008 commented Dec 4, 2018

Version of EOSJS
20.0.0-beta2

Describe the bug
When a project that already use babel-polyfill, include this library, an exception occur:

Uncaught Error: only one instance of babel-polyfill is allowed

To Reproduce

check here the code to reproduce:
https://codesandbox.io/s/q33k7vmk14

import '@babel/polyfill';
import { JsSignatureProvider } from 'eosjs';

as far as I know, 3rd party libraries, such this one, should not include babel-polyfill, check the answer here for more info:
https://stackoverflow.com/questions/34962902/should-javascript-library-which-uses-es6-and-es7-features-require-babel-polyfill

@WarrickFitz
Copy link

I'm also running into this. It's cost me a lot of time at this point.

@blackwatertepes
Copy link

According to this thread, we should either be attaching babel-polyfill to global and checking the global before import, or we should be using idempotent-babel-polyfill. Can someone fix this, asap?

GreenBusDriver added a commit that referenced this issue Oct 16, 2019
Fix Issue #450: Removing babel-cli removes need for babel-polyfill
@GreenBusDriver
Copy link
Contributor

Fixed in PR #600
It turns out that @babel/polyfill was being included by @babel/cli, which the project was not using, so I just removed that dependency, which removed the @babel/polyfill dep. This is by far the preferred solution, given ~"libraries shouldn't be changing global state"
babel/babel#4019 (comment)

Thanks to @or2008 !!
The codesandbox.io you setup was super useful in quickly reproducing the issue and testing a couple things.

There are lots of people solving this on the client side as well, given how often this problem arises. See these example solutions.
NYPL/nypl-dgx-react-header#7
https://github.com/sprucelabsai/workspace.sprucebot-skills-kit/pull/114/files
https://github.com/codex-team/editor.js/pull/424/files

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants