I know babel-node
ignores node_modules
by default, so I ran it three different ways to override it, all failed:
ran babel-node app.js
with .babelrc
:
{
"presets": ["es2015", "react"],
"only": [
"app",
"node_modules/react-components"
]
}
result: SyntaxError: Unexpected token <
for the required jsx node module
ran babel-node app.js
with .babelrc
:
{
"presets": ["es2015", "react"],
"ignore": "node_modules\/(?!react-components)"
}
result: SyntaxError: Unexpected token <
for the require jsx node module
ran babel-node ./bin/www --ignore '/node_modules/(?!react-components)
with .babelrc
:
{
"presets": ["es2015", "react"]
}
result:
[project]/node_modules/babel-preset-react/node_modules/babel-plugin-transform-react-jsx/lib/index.js:12
var visitor = require("babel-helper-builder-react-jsx")({
^
TypeError: object is not a function
Using the register hook with the ignore option worked correctly.
ran node app.js
with this code in the beginning of app.js
require('babel-core/register')({
ignore: /node_modules\/(?!react-components)/
});
Even though this works, I still want to know why my implementations with babel-node
does not work. Thanks.
references:
This is a known bug in babel, where it ignores only
and ignore
.
The relevant bug is T6726, which has been fixed in babel 6.14.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With