So I follow the installation here, but babel takes very long time to compile, even small files:
app.js
let app = 1;
.babelrc
{ "presets": ["es2015"] }
package.json
"scripts": {
"build": "babel app.js -o dist/app.js"
},
"devDependencies": {
"babel-cli": "^6.4.5",
"babel-preset-es2015": "^6.3.13"
}
Then npm run build
will take ~30s to compile.
I'm using [email protected]
You might be compiling node_modules
and bower_components
too.
You can try adding the ignore
property in your projects .babelrc
like so:
{
...
"ignore": /(node_modules|bower_components)/
...
}
Hope this solves your issue
Update September 2019
Found upgrading to Babel 7 solved this. Perhaps try:
$ npm install --save-dev @babel/core @babel/node @babel/preset-env
Your package.json should contain something like:
"devDependencies": {
"@babel/core": "^7.6.0",
"@babel/node": "^7.6.1",
"@babel/preset-env": "^7.6.0"
}
My .babelrc
file is as follows:
{
"presets": ["@babel/preset-env"]
}
Now, when I run:
npx babel-node src/index.js
the performance is almost instantaneous (it was taking 20+ seconds with babel 6).
See the babel 7.5 docs for more details on this.
Also, for reference on the upgrade, see this stackoverflow question & answer.
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