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
throw new Error("only one instance of babel/polyfill is allowed"); #1019
Comments
The error message is pretty clear, only one instance of the polyfill should be used at all times. You have two modules with different versions of |
When running So I hacked it in the var escape = function (str) {
return str.replace(/[\[\]\/{}()*+?.\\^$|-]/g, "\\$&");
};
var regexp = ['lib', 'test', 'node_modules/god'].map(function (i) {
return '^' + escape(path.join(__dirname, i) + path.sep);
}).join('|');
require('babel/register')({
only: new RegExp('(' + regexp + ')'),
ignore: [ 'node_modules' ],
loose: 'all'
}); And the Maybe this will be better: var shouldIgnore = function shouldIgnore(filename) {
if (onlyRegex && onlyRegex.test(filename)) {
return false;
}
return ignoreRegex && ignoreRegex.test(filename);
}; @sebmck Do you need I submit a PR for this? |
I think |
This issue should be reopen. It's impossible to control all the deps (and the deps of a dep) to use same version (and even same versions still throw error) or use runtime transformer. So I believe it's the duty of babel itself to solve the problem. |
@hax Dependencies should not be loading the polyfill at all. If they rely on global ES6 features, then they need to document that and the root application should ensure that a polyfill is loaded, or the deps should use the |
@loganfsmyth I assume all you said is correct , then:
|
If you use react.js on client and server, you might have babel/polyfill already loaded in node.js but not browser. This is how i solved it:
|
@ruslansavenok thx, works for me. |
@fundon I agree with you that babel should support compiling module by checking the fields in package.json (maybe |
@hax thx. |
So what are we supposed to do with Babel 6? It looks like the runtime is no longer used. I'm trying to write a library using ES6 and I do not want to pollute the global namespace with polyfills. |
@jameslk Please see our README:
|
@loganfsmyth Thanks. I figured it out anyway. It looks like babel-runtime has been moved to babel-plugin-transform-runtime and this needs to be added to the list of plugins to use it. Would of helped if that was documented somewhere. |
babel/polyfill
problemdirs tree:
Both
server.js
andnode_modules/trek
use ES6+ syntax.server.js
index.js of trek module
run the server.js
output:
How to solve it?
The text was updated successfully, but these errors were encountered: