News for hackers. Stuff that matters.
Re:Node.js v6.0 Released by olalonde on Tuesday April 26, 2016 @03:31PM (#11574838)
On a related note, does anyone know if there's a way to tell Babel that your compilation target is Node.js v6.0 and only have it compile stuff that isn't natively supported yet?

Edit: Thanks for all the answers. I just went through the list of unsupported features and as I'm not using any of the remaining 7%, I might be able to get rid of Babel during development if I'm lucky.

Edit 2: Oops, still no es6 module support :(

Re:Node.js v6.0 Released by emgee3 on Tuesday April 26, 2016 @03:40PM (#11574929)
I've not tried it but there is this preset https://github.com/jhen0409/babel-preset-es2015-node6
Re:Node.js v6.0 Released by Touche on Tuesday April 26, 2016 @03:36PM (#11574895)
Babel 6+ is configuration hell, you can do whatever you want provided you have the patience/knowledge to plug together the right plugins.

So take the Node 6.0 compatibility table, find out what features it supports and create a "Babel preset" that has those excluded.

Re:Node.js v6.0 Released by untog on Tuesday April 26, 2016 @03:42PM (#11574946)
...or just use a preset someone else made:

https://github.com/jhen0409/babel-preset-es2015-node6

Re:Node.js v6.0 Released by komali2 on Tuesday April 26, 2016 @03:53PM (#11575048)
Now that's thinking the npm way
Re:Node.js v6.0 Released by nemild on Tuesday April 26, 2016 @04:52PM (#11575519)
Especially since this preset is two lines long, referring to two other plugins
Re:Node.js v6.0 Released by jsprogrammer on Tuesday April 26, 2016 @03:41PM (#11574934)
It looks like the primary thing missing is 'iterator closing'.

http://node.green/

Re:Node.js v6.0 Released by SomeCallMeTim on Tuesday April 26, 2016 @05:18PM (#11575730)
Instead of Babel, you might want to look at Rollup.js for ES6 module support. [1]

You can have Rollup spit out CommonJS require commands for things that aren't part of your project, or you can use rollup-plugin-commonjs to wrap your entire app into one big bundle, including the CommonJS includes.

And as much faster as Node 6 has gotten with module importing, it almost can't be as fast as Rollup's module loader, which is more optimal than Browserify and WebPack, in that ES6 modules don't even get wrapped in "requires", but instead included inline. It just parses the code to ensure no variable names collide.

[1] http://rollupjs.org

Re:Node.js v6.0 Released by hzoo on Tuesday April 26, 2016 @05:01PM (#11575589)
As others have mentioned there are node and browser specific presets you can use.

Also opened a PR for discussion about adding an environment award preset in babel or supporting it in core at https://github.com/babel/babel/pull/3476.

Re:Node.js v6.0 Released by fooey on Tuesday April 26, 2016 @11:44PM (#11577706)
I'd love to see a Babel sort of thing that backs away from transpiling as much as possible and functions more as execution time polyfill.

Maybe an http2 server that uses browser detection to push polyfills so that your app can just assume everything works without transpiling up front?

I'm super hopeful http2 with es2015 modules will make web dev tooling drastically more streamlined in the nearish future.

Re:Node.js v6.0 Released by dangoor on Tuesday April 26, 2016 @03:33PM (#11574866)
I don't know the answer, but this would be useful in general given that much of ES2015 is supported by Firefox, Chrome and Edge. It's enough that I can imagine having an "evergreen browsers" build and an "everybody else" build.
Re:Node.js v6.0 Released by streptomycin on Tuesday April 26, 2016 @05:33PM (#11575852)
It'd be not super useful yet, because there's no good way to minify ES2015 code.
Re:Node.js v6.0 Released by benologist on Tuesday April 26, 2016 @03:33PM (#11574852)
Isn't Babel 93% redundant on the server side now? If you're not very dependent on the last 7% I'd just remove it.
Re:Node.js v6.0 Released by matt4077 on Tuesday April 26, 2016 @03:46PM (#11574982)
There's one remaining problem: V8 ES6 support is quite new and less optimized. If you're looking for optimal performance, you'll be transpiling for a long time (or possibly forever, 'cause those ES7 features are tempting, aren't they?)
Re:Node.js v6.0 Released by grayrest on Tuesday April 26, 2016 @04:04PM (#11575138)
Can't wait on that Exponentiation Operator and A.p.includes!
Re:Node.js v6.0 Released by SerpentJoe on Tuesday April 26, 2016 @05:10PM (#11575653)
As you indicated, almost none of what was once called ES7 made it into the final spec: http://www.2ality.com/2016/01/ecmascript-2016.html

At least exponentiation is slightly cool. Hasta la ES8 siempre I guess.

Re:Node.js v6.0 Released by savanaly on Tuesday April 26, 2016 @04:40PM (#11575438)
The javscript version of the hedonic treadmill ensures there will always be a juicy new feature that node/browsers don't have yet but Babel/other transpilers usually will. Just because it's 93% of the way there on ES6 at this moment doesn't mean that a few months from now people, your team included, won't be clamoring to be able to write with the new sweet features from ECMAScript 2017 or whatever. The only solution is to keep Babel a part of your stack perpetually and really that's not so bad in my opinion.
Re:Node.js v6.0 Released by nemild on Tuesday April 26, 2016 @04:51PM (#11575505)
Remember that performance with Babel transpiled code is still sometimes faster (in some cases, substantially so) than the native ES6 implementations, as optimizing continues on V8's end.

And be sensible about how much transpilation you want, you can use newer presets that don't need to transform the code as much, while still having the ability to layer in newer features (async/await, ES7, etc).

Re:Node.js v6.0 Released by nostrademons on Tuesday April 26, 2016 @03:57PM (#11575082)
The big missing thing is modules, which aren't in the kangax compatibility table.
Re:Node.js v6.0 Released by bmeck on Tuesday April 26, 2016 @06:54PM (#11576435)
ES2015 did not include a loader specification, only a module specification. https://github.com/nodejs/node-eps/blob/master/002-es6-modul... is the interop that will be present for node but it is outside of JS spec itself.
Re:Node.js v6.0 Released by tracker1 on Tuesday April 26, 2016 @05:03PM (#11575611)
In fairness, the babel approach to module handling is probably better than an in-browser es6 module implementation, or what may follow... compatibility with npm packages (cjs) will be significant for a while.
Re:Node.js v6.0 Released by nostrademons on Tuesday April 26, 2016 @07:06PM (#11576496)
My understanding is that V8 will provide hooks that parse the module imports, then delegate to the embedder to fetch the actual source code and hand it back to V8 to load. I'd expect that the Node implementation of these hooks would work the same way as the existing require() machinery, so that existing libraries will continue to work.
Re:Node.js v6.0 Released by veeti on Tuesday April 26, 2016 @03:45PM (#11574972)
I use it to transform async/await into generators for Koa. The module syntax is also much nicer to use.
Re:Node.js v6.0 Released by tracker1 on Tuesday April 26, 2016 @05:00PM (#11575575)
Came to note the same... really like async functions.
Re:Node.js v6.0 Released by koolba on Tuesday April 26, 2016 @04:18PM (#11575272)
Maybe I've got Stockholm syndrome but I prefer the module.exports style.
Re:Node.js v6.0 Released by Scarbutt on Tuesday April 26, 2016 @06:26PM (#11576259)
How will es6 module support work in the long run, will node.js have to support two modules systems?
Re:Node.js v6.0 Released by bmeck on Tuesday April 26, 2016 @06:51PM (#11576411)
Re:Node.js v6.0 Released by joombaga on Tuesday April 26, 2016 @04:28PM (#11575338)
Hmm... I get the same thing on the REPL. Can you share what you see?
Re:Node.js v6.0 Released by olalonde on Tuesday April 26, 2016 @05:18PM (#11575727)
Oops, I was mistaken about that. It looks like all core modules are in local scope when in the REPL which is why `os.arch()` was working.
Re:Node.js v6.0 Released by iamflimflam1 on Tuesday April 26, 2016 @03:35PM (#11574878)
This should do what you want. Don't know if it needs to be updated for v6.0

https://www.npmjs.com/package/babel-preset-es2015-auto