I have something similar mounted on an app that I’m working on. Then I mix things from Browserify and Babel because I import modules I want to have on the client with npm. But only Babel version could be like this:
"use strict";
var exec = require('child_process').exec;
function babel(){
return new Promise(resolve, reject){
exec('babel --presets es2015 js --out-dir public/js', {
cwd: __dirname + '/../'
}, (err) => {
if (err) reject(err);
else resolve();
});
});
}
module.exports = Promise.all([babel]);
I use Promise.all because I put more things into this array that I need to compile. You can link with .then()
and call the Córdova compiler next if you are calling via command line.
In my briefcase I’m running this module in root/lib
, the original files are in root/js
and I’m compiling all the .js
for root/public/js
.
Dependencies are:
"babel-cli": "^6.4.5",
"babel-preset-es2015": "^6.3.13",
You are in Node.js right? You can put the code of the file that compiles?
– Sergio
@Sergio The project is Cordova, not Ode. But I have Ode. I can post yes.
– ropbla9
@Sergio Updated the question with the directories.
– ropbla9
Utilise Rollup + Bublé, worth taking a look, in my case the compilation is much faster.
– Jonatas Walker
@Jonataswalker Da to convert directory or just file this Bumblé?
– ropbla9
As you wish, directory or file (example), I personally use this design model.
– Jonatas Walker