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

Babel as dev-dependency #47

Closed
klausbayrhammer opened this issue Aug 6, 2015 · 2 comments
Closed

Babel as dev-dependency #47

klausbayrhammer opened this issue Aug 6, 2015 · 2 comments

Comments

@klausbayrhammer
Copy link

Currently we are trying to execute ES6 tests in a module where we have the json-api as a dependency. When I require 'babel/register' in one of my build steps I get the error only one instance of babel/polyfill is allowed
The problem is, that we have two different versions of babel as dependencies (the one we specified in our top-level-module and the other one which is the json-api's dependency) and both try to add the `global._babelPolyfill´. Even though I've seen #11 this causes us serious headaches. Could you consider specifying babel as a dev-dependency again?

@loganfsmyth
Copy link

This was initially brought up in Babel's support chat. The recommended approach is for libraries to use the http://babeljs.io/docs/usage/runtime/ transformation to rewrite global usage to point at a non-global version of the polyfill. The downside of this is that libraries cannot use new ES6 prototype methods methods because these cannot be polyfilled without mutating globals. When using runtime you can however access these methods using non-standard names like Array.includes instead of Array.prototype.includes.

@ethanresnick
Copy link
Owner

Thanks for reporting this @klausbayrhammer, and for your advice @loganfsmyth!

I've been loading the polyfill thus far precisely to handle the cases the runtime transformer doesn't support (though I've also been loading the runtime transformer, which I guess is a little redundant...whoops). But if ditching the polyfil and the prototype methods now is the only option for solving this issue, I'm willing to do that.

Patch coming momentarily.

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

No branches or pull requests

3 participants