You can transpile server-side Node.js code using grunt-traceur in the same manner you compile client-side code. In order to use this Grunt task for Node.js source code, you will need to set the module
flag to commonjs
.
Here's an example Grunt config:
grunt.initConfig({
traceur: {
options: {
experimental: true,
modules: 'commonjs'
},
server: {
files: [{
expand: true,
cwd: 'src/server',
src: ['**/*.js'],
dest: 'build/server'
}]
}
}
});
When the traceur
grunt task is run, it will output the ES5 version of your source to the output directory.