Closed mohamnag closed 8 years ago
I finally succeed using ES7 and wanted to let others know too, maybe this can even go to docs here. First step, installing dependencies (I gave up on traceur and used babel):
npm i babel-cli
npm i babel-preset-es2015
npm i babel-preset-stage-0
npm i babel-register
then creating a shim bin/es7-shim
script (sets up the necessary babel translator and then calls express 4's www script created by express generator):
#!/usr/bin/env node
require('babel-polyfill');
require("babel-register")({
presets: [
"es2015",
"stage-0"
]
});
require('./www');
and finally tuning express-server grunt config:
express: {
options: {
},
dev: {
options: {
script: 'bin/es7-shim',
debug: true
}
}
},
and thats it!
Babel is definitely the way to go. Traceur has major performance penalties & little community behind it by comparison.
You should be able to use babel-node path/to/my/script.js
alongside a .babelrc
file with your presets & settings without creating a shim script.
should I set babel-node path/to/my/script.js
as cmd
in options
?
Correct!
after switching to following settings
express: {
options: {
// Override defaults here
cmd: "node_modules/babel-cli/bin/babel-node.js"
},
dev: {
options: {
script: 'bin/www',
debug: true
}
}
}
now the watch task does not work as expected. after detecting changes the last thing is logs is:
Stopping Express server
Starting background Express server
Error: listen EADDRINUSE :::5858
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at Agent.Server._listen2 (net.js:1234:14)
at listen (net.js:1270:10)
at Agent.Server.listen (net.js:1366:5)
at Object.start (_debug_agent.js:21:9)
at startup (node.js:72:9)
at node.js:974:3
I suppose stopping server does not work.
now looking more closely, my server runs on 3000 and not 5858, not sure what the reason for message is.
I have been using this grunt plugin and just tried to use https://www.npmjs.com/package/traceur as a preprocessor to enable await/async style but no success until now.
I tried using traceur like coffee:
but interestingly the server just starts and stops:
I also tried a shim:
where
shim
is:but this seems not to work at all, as I get syntax errors:
is it possible to use traceur here?