Maven Plugin which transpiles ES6 to ES5 which uses Traceur or Babel

Daniel K. picture Daniel K. · Feb 16, 2015 · Viewed 7.6k times · Source

Is there already a preferred way how to transpile ECMAScript6 code to ECMAScript5 using traceur or Babel (formely named 6to5) in a maven project? I have already searched the net without any success.

Answer

Morné Louis de Jongh picture Morné Louis de Jongh · Mar 10, 2015

This might not be the exact solution to your problem, but the way I do this is by using https://github.com/eirslett/frontend-maven-plugin , which in turns allows me to use Grunt tasks during the build process (and in different phases of the build). Then by having Grunt available to me, I created a grunt task to use grunt-babel to convert my files.

The plugin also allows you to use gulp if that is your preference.

I also use the same setup to run Karma and JSHint during the test phase.

Hope this helps,

M

Edit: its worth noting that the node installation that the plugin does is local to the project. So no need to have node globally installed.