Stephan-v Stephan-v - 5 months ago 78
Node.js Question

Vueify not working with ES2015 - Gulp

I'm stuck on trying to get browserify/vueify to output ES2015 with Gulp. I did what the documentation said which is:


npm install\
babel-core\
babel-preset-es2015\
babel-runtime\
babel-plugin-transform-runtime\
--save-dev


And I have this in my gulpfile:

gulp.task('browserify', function() {
browserify('./js/entry.js')
.transform(vueify)
.bundle()
.pipe(fs.createWriteStream('./js/bundle.js'))
});


The documentation states:


Support ES2015 by default.


Am I suppose to require or import all the npm modules in my gulpfile or something? What am I missing here? Browserify works fine but as soon as I use ES2015 gulp errors out on me with:

SyntaxError: Unexpected token (32:6) while parsing...

Answer

Vueify supports es2015 inside Vue files, but you also need to pipe through browserify with es2015 enabled if you use it in entry.js. Browserify handles .js files and it needs to know es2015 too :)