Node.JS v0.11.3 claims to have support for ECMAScript 6 modules with the flag --harmony_modules
.
I have tried various examples, such as the following.
module math {
export var pi = 3.141593;
}
What is the syntax to get modules working in Node.JS?
Node.JS v0.11.3 claims to have support for ECMAScript 6 modules with the flag --harmony_modules
.
I have tried various examples, such as the following.
module math {
export var pi = 3.141593;
}
What is the syntax to get modules working in Node.JS?
Share Improve this question edited Jul 10, 2013 at 19:42 Carol Skelly 362k91 gold badges735 silver badges646 bronze badges asked Jun 26, 2013 at 20:41 RandomblueRandomblue 116k150 gold badges362 silver badges557 bronze badges 4- 2 Your link doesn't work. – user2437417 Commented Jun 26, 2013 at 20:48
- @CrazyTrain: It works the second time only :-/ – Bergi Commented Jun 26, 2013 at 22:57
- 1 Seems like Chrome doesn't support modules yet. Based on this, can we say that V8 in general doesn't support it then? – gustavohenke Commented Jul 10, 2013 at 20:15
- Looks like NodeJS is looking into it: git#5 – Endless Commented Dec 14, 2015 at 21:28
2 Answers
Reset to default 14 +50The modules implementation in V8 is incomplete. There's parsing support when enabled with --harmony-modules, but support of the actual functionality was put on hold. The reason for this is because the specification for how ES6 modules will actually work has been in the works and is still not fully nailed down.
The implementation in Continuum (the linked screenshot from Crazy Train's answer) dates back to an interim spec from November 2012 and is now woefully out of date because of the ongoing changes to the ES6 module's spec. This is why the V8 devs put development of support for modules on hold.
It seems like the modules spec is approaching stability (though I expect we'll see small refinements for a while) and I think (hope at least) that we'll see SpiderMonkey and V8 moving forward with implementations over the next 6 months.
Useful links:- V8 modules bug: https://code.google.com/p/v8/issues/detail?id=1569
- SpiderMonkey modules bug: https://bugzilla.mozilla.org/show_bug.cgi?id=harmony%3Amodules
You can use Continuum, which is an ES6 virtual machine written in (current) JavaScript.