babel: Error in babel-register 6.16.0
After updating to babel register 6.16.0 I started getting the following error.
/myproject/node_modules/babel-core/lib/transformation/file/options/option-manager.js:319
throw e;
^
SyntaxError: (While processing preset: "/myproject/node_modules/babel-preset-es2015/lib/index.js")
.babelrc
{
"presets": [
["es2015", { "modules": false }],
"stage-1",
"react"
],
"plugins": [
"transform-runtime"
],
"env": {
"development": {
"plugins": ["react-hot-loader/babel", "transform-runtime"]
},
"test": {
"presets": ["es2015", "stage-1", "react"],
}
},
"compact": true
}
package.json
{
"dependencies": {
...
"babel-core": "^6.3.26",
"babel-loader": "^6.2.0",
"babel-plugin-transform-runtime": "^6.12.0",
"babel-polyfill": "^6.9.0",
"babel-preset-es2015": "^6.13.0",
"babel-preset-react": "^6.11.0",
"babel-preset-stage-1": "^6.13.0",
"babel-register": "^6.8.0",
"babel-runtime": "^6.11.6",
...
}
}
After resetting babel-register
to 6.14.0 the error went away.
I’m thinking it might have something to do with this commit https://github.com/babel/babel/commit/71dff8c834191356bfc58d24f37e3601df96987e
software | version |
---|---|
Babel | 6.16.0 |
node | 6.6.0 |
npm | 3.10.3 |
Operating System | OS X 10.11.6 (15G1004) |
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 13
- Comments: 24 (10 by maintainers)
Commits related to this issue
- Freeze babel-* packages to avoid bug in 6.16.0 that's breaking the build (#60) Related: https://github.com/babel/babel/issues/4592 — committed to Clever/components by kofi-clever 8 years ago
We also started seeing a strange error:
The release of babel 6.16.0 triggered this, and explicitly adding babel-register 6.14 to our package.json alleviates the issue.
Edit: We ended up having to pin both babel-core and babel-register to 6.14.0.
@danez Ok, so my investigation is complete 😃
In the enzyme solution, they suggest doing the following for every property of
jsdom('').defaultView
:One of the properties overloaded is
XMLHttpRequest
.Adding the following solves the issue.
Can you please check why having a global.XMLHttpRequest screws up babel?
FYI - Updated my example to be even more minimal. See
initJsdom
in the spec/setup.js@danez , @3LOK ,
It may be this snippet, which is recommended by the folks who make the enzyme library, https://github.com/airbnb/enzyme/blob/master/docs/guides/jsdom.md
I have added a call at the top of that:
Could that combination be causing the error in the new version?
@danez ,
I only see the error when I upgrade both
babel-core
andbabel-register
, and when I try to run Mocha tests, because I only use babel-register in my test setup helper, not my build process. (I use Webpack’s babel-loader in the build.)Here’s the error I was getting:
I downgraded just babe-register, which seems to fix it, but I then downgraded babel-core, too, just to be safe.