4 ms·
You can use it now if you preprocess with babel - https://babeljs.io/ https://babeljs.io/
by zaius 11y ago
You can use it now if you preprocess with babel - https://babeljs.io/ https://babeljs.io/
- lobster_johnson 11y agoYou can also use it in Node.js if you install the Babel require extension, or run under the babel-node wrapper. It's not super convenient, though; I'm looking forward to a time when Node has full ES6 support.
- untog 11y agoIt's not ideal in Node but I haven't found it to be that bad - I've gotten into the habit of making a bootstrap.js file that just has: require('babel/register') require('./main.js') and carrying on like nothing ever happened.
- lobster_johnson 11y agoAbsolutely. I talked about this in the Babel chat room, though, and was told it was an antipattern, without being explained why. I still don't know why. Apparently some people prefer to build a distribution of the entire project with Babel on deploy, which is fine, but it does cause an impedance mismatch with how projects are developed on the developer's machine; obviously both ways have to work. A real problem with babel/register is the interface for including node modules, which I think needs improvement. You can't selectively include individual modules because the {only} option isn't additive, it replaces the default setting.
- untog 11y agoMaybe it is an anti-pattern because it alters the default - I mean, I guess it means it's processing node modules through the transpiler unnecessarily as well? I can't say I've experienced a performance hit myself.
- lobster_johnson 11y agoBabel doesn't touch node_modules only you explicitly include it. Browserify lets you add this to an NPM package's package.json: "browserify": { "transform": [ "babelify" ] } ...which is great, but Babel doesn't have anything like it for server-side stuff.
- spion 11y agoIts not an anti pattern unless you are writing a libray. Just remember that your application is recompiled by babel every single time you run it and on every process restart (if any), which may or may not be unacceptably slow.
- taco_emoji 11y agoThanks for the link!