Is there any difference between using babel-register or babel-node when running my code in development? The two options are:
require('babel-register')({ "presets": ["es2015"] });at entry-point.js and npm start scriptnode entry-point.jssimply have npm start script
babel-node entry-point.js --preset=es2015
Do they do the exact same thing? And is one way recommended over the other?
I asked around at work and got an answer. I'm going to post it here in case anyone else is interested.
babel-nodebasically callsbabel-registerinternally. see source. The differences arewhen using
babel-nodethe entry-point itself will also run through babel vs.babel-registeronly files required afterbabel-registeris required will be run through babel.if you need
babel-polyfill(for eg. generators)babel-nodewill pull it in automatically, vs.babel-registeryou'd need to do that yourself. This is something to keep in mind when building for production. If you needbabel-polyfilland you are usingbabel-nodein development, you'd need to make sure you are building w/babel-polyfillwhen building for production.One way doesn't seem to be recommended over the other. However,
babel-nodeis a little cleaner b/c it'll keep therequire ('babel-register')out of the codebase. It also seems to be a bit more intuitive to someone new to all this stuff.