I have just created a new project with browserify-rails
and Rails 4.2. My package.json
looks like this:
{
"name": "neat-verify",
"dependencies": {
"browserify": "~> 10.2.4",
"browserify-incremental": "^3.0.1",
"es6ify": "^1.6.0",
"nuclear-js": "^1.1.1",
"react": "^0.13.3",
"reactify": "^1.1.1"
},
"browserify": {
"transform": [
[
"reactify",
"es6ify"
]
]
},
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
}
Everything installs just fine, but when I try to load my very simple es6 file with this:
module.exports = n => n * 11;
The file contents are exactly as above, which isn't what I expected as this is not valid ES5.
How do I get it to actually transpile this?
So, after trying a lot I gave up using
browserify-rails
to perform the transpilation and decided to usereact-rails
, much simpler and all I needed to transpile JSX and ES6 was include this config:Now a file called
foo.js.jsx
with:Gets correctly transpiled and included at
application.js
.