Using babel.js instead of a browser to compile for binding

I start with babel.js to use the ES6 JavaScript features, however I ran into a problem

I am currently creating my application using a browser and repeating it with the following command.

browserify -t reactify app/main.js -o public/scripts/bundle.js 

Now I want to use the equivalent command in babel to combine my required ES6 modules into bundle.js . This will not work just providing me the main.js file for ES5.

 babel app/main.js -o public/scripts/bundle.js 

However, I could compile my bundle.js file into ES6 version with babel with 2 commands

 browserify -t reactify app/main.js -o public/scripts/bundle.js babel app/main.js -o public/scripts/babel.js 

Is this the right way to use babel with a browser? combine your modules using a browser and then convert the package to ES6?

+7
javascript reactjs babeljs browserify
source share
1 answer

No, the correct way is to use babelify.

 # from browserify -t reactify app/main.js -o public/scripts/bundle.js # to browserify -t babelify app/main.js -o public/scripts/bundle.js 

Also reactivate / react-tools / jsx-loader / etc. tools from the responsive team do a subset of what Babel does, so you can completely remove them if you use babel.

+11
source share

All Articles