I installed babel cli and created a .babelrc
file with presets
set to es2015
. I've also installed the es2015
preset. But when I use the command babel script.js --out-file script-compiled.js
and check the output file, I still find arrow function syntax (=>
) in the code, and browsers that don't support arrow functions are unable to run my code even though it has been transpiled with babel. What might be going on here? If it matters, the project is using react and I'm using browserify to create app.js
, and then passing that file to babel.
Edit: here's an example of code that isn't being properly converted:
this._accountModel.fetch({
success: (res) => {
console.log('success');
},
error: () => {
console.log('error');
}
});
That preset includes the arrow transform. Reference : https://babeljs.io/docs/plugins/preset-es2015/
Most likely the project is configured wrong.
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