News for hackers. Stuff that matters.
Re:Node.js v6.0 Released by hiphipjorge on Tuesday April 26, 2016 @05:24PM (#11575774)
Is there a plan for Node.js to get `import` any times soon? Will we need babel in order to use this for months? years? ever?
Re:Node.js v6.0 Released by bmeck on Tuesday April 26, 2016 @06:50PM (#11576404)
https://github.com/nodejs/node-eps/blob/master/002-es6-modul... was merged today; v8 C++ API for node to truly support it has not been implemented yet, should be in next LTS at current pace (next year).
Re:Node.js v6.0 Released by spankalee on Tuesday April 26, 2016 @10:13PM (#11577369)
Wow, a new extension for ES modules? That seems really unfortunate.

Why can't node parse a file to detect if it's a module? The presence of a top-level import or export means it's a module. If it's not, then the parsed file can be kept if the file is also in strict mode. If it's sloppy, it'll have to be re-parsed. Seems like a small penalty if the goal is to enable migration.

Also, why worry about ES modules importing Common JS? Just disallow that and let projects migrate to ES modules bottom-up. Then you don't have to worry about executing a Common JS module to determine what its exports are or circular dependency problems.

Re:Node.js v6.0 Released by bmeck on Tuesday April 26, 2016 @11:22PM (#11577632)
There is a pretty epic thread that I suggest you just read the tail end of https://github.com/nodejs/node-eps/pull/3#issuecomment-21476... . Basically we tried detection via source code as the first proposal; ambiguities at runtime that do not throw errors make it absolutely impossible to do safely, performance problems, and tooling integration problems.
Re:Node.js v6.0 Released by gedy on Wednesday April 27, 2016 @01:46AM (#11578070)
Subjective, but .mjs just sounds horrid..
Re:Node.js v6.0 Released by bmeck on Wednesday April 27, 2016 @01:49AM (#11578081)
We looked at several alternative extensions and it was the least egregious of them: https://github.com/nodejs/node-eps/blob/master/002-es6-modul...
Re:Node.js v6.0 Released by inglor on Tuesday April 26, 2016 @05:53PM (#11576028)
There is/was a vote on this pretty soon. We are deciding how modules would work - with a new file extension? With a module.json? With a separate entry entry in package.json? Lots of decisions to be made :)
Re:Node.js v6.0 Released by abritinthebay on Tuesday April 26, 2016 @06:45PM (#11576385)
Surely they should work the way they work in ES6?

Any solution that requires extra work (file extension, another file to maintain) is a non-starter.

Frankly it should work how Babel transpiles it - because there's no reason for it not to.

Re:Node.js v6.0 Released by mudetroit on Tuesday April 26, 2016 @09:37PM (#11577238)
ES6 didn't define precisely how module loading worked, one of the reasons it isn't actually implemented yet. And there are actual reasons why the method babel currently uses won't precisely match the actual implementations (see hierarchal v flat dependencies)
Re:Node.js v6.0 Released by abritinthebay on Tuesday April 26, 2016 @09:38PM (#11577242)
Those problems are just as present in CJS as far as I'm aware though...?

Yet they were solved for that.

Re:Node.js v6.0 Released by bmeck on Tuesday April 26, 2016 @06:49PM (#11576400)
Re:Node.js v6.0 Released by banhfun on Tuesday April 26, 2016 @05:26PM (#11575793)
It needs to be implemented in V8 before Node.js can support it.
Re:Node.js v6.0 Released by hiphipjorge on Tuesday April 26, 2016 @05:34PM (#11575864)
Are there any plans for V8 to do that soon?
Re:Node.js v6.0 Released by empyrical on Tuesday April 26, 2016 @05:41PM (#11575928)