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 . 。 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
Nope, 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 the reactify/react-tools/jsx-loader/etc. tools from the react team do a subset of what babel does, so you can remove them entirely if you're using babel.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.