Zorgatone Zorgatone -4 years ago 267
Node.js Question

NodeJS plans to support import/export es6 (es2015) modules

I've been looking all over the internet without a clear answer for this.

Currently NodeJS uses only CommonJS syntax to load modules, and if you really want to use the standard ES2015 modules syntax, you either have to transpile it beforehand or use an external module loader at runtime.

Currently I'm not too positive to use either of those two methods, are the NodeJS maintainers even planning to support ES2015 modules or not?
I haven't found an hint at all about this.

At the moment NodeJS 6.x claims to support 96% of the ES2015 features, but there isn't any reference to modules (NodeJS ES2105 support link).

Do you know if NodeJS will support these modules out of the box, in the near future?

Answer Source

This has been a hot potato for quite some time. Bottom line is that yes, Node will eventually support the ES2015 syntax for importing/exporting modules - most likely when the spec for loading modules is finalized and agreed upon.

Here is a good overview of what's holding NodeJS up. Essentially, they need to make sure that the new spec works for Node which is primarily conditional, synchronous loading and also HTML which is primarily asynchronous.

Nobody knows for sure right now, but I imagine Node will support import/export for static loading, in addition to the new System.import for dynamic loading - while still keeping require for legacy code.

Here's a few proposals on how Node might achieve this:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download