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 moduleran
babel-node app.js
with.babelrc
:{ "presets": ["es2015", "react"], "ignore": "node_modules\/(?!react-components)" }
result:
SyntaxError: Unexpected token <
for the require jsx node moduleran
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: