dimanche 29 mars 2015

Using babel.js instead of browserify to compile to bundle

I am starting out with babel.js to make use of JavaScript ES6 features, however I have run in to a problem


I am currently building my app using browserify and reactify with the following command.



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


Now I want to use an equivalent command in babel to bundle up my required modules, written in ES6 to a bundle.js. This doesn't work, just giving me an ES5 version of the main.js file.



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


However I could compile my bundle.js file to an ES6 version with babel, having 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 correct way to use babel with browserify? to bundle your modules with browserify and then convert the bundle to ES6?


Aucun commentaire:

Enregistrer un commentaire