CommonJS Require vs ES6 Import
This has been a hot topic for quite some time, and the bottom line is that yes, Node will eventually support the ES2015 syntax for importing/exporting modules - most likely this will happen when thespec for loading modules is finalized and agreed upon. Presently Node.js supports 96% of ES6 features:
$ node --v8-options | grep harmony > --harmony_modules (enable "harmony modules" (in progress))
Presently, nobody knows for sure but there are a couple of proposals on how Node might achieve this:
I won’t provide an opinion on the aforementioned, but read through to get more acquainted with the possibilities. If i took a stab at what Node.js might do at a high level they would support import/export for static loading in addition the the new System.import for dynamic loading, while retaining require for legacy code.
Note: there are ways to start using ES2015 modules in Node right now, but for me it isn’t worth it - Im going to stick to require, Browserify and WebPack for now instead of adding wrappers. Read more if you’re curious:
- es6-module-loader -S
- ES6 Traceur compiler