Is your feature request related to a problem? Please describe.
NodeJS is currently not supporting ES / CommonJS imports & exports
import x from 'x';
(function (exports, require, module, __filename, __dirname) { import x from 'x';
^
SyntaxError: Unexpected identifier
Describe the solution you'd like
NodeJS 11+ starting to natively support ES6 import/export module syntax
Describe alternatives you've considered
Using Babel to transpile es6 import/export to es5 require syntax
cc @nodejs/modules
I'm reading node-eps: 002-es-modules and trying to understand the long-term usage... Does it mean that mjs will be the way to write es6 import/export going forward in node and that there will be the good ole common-js and es-module way and developers will maintain two different type of mime-types in their repos? Just want to get a sense if I should adopt the es-module syntax of mjs or if I should wait for it to stabilize? I'd hate to end up having to rename a bunch of file's extensions down the road.
Cheers!
@mgan59 I'd recommend using .mjs for esm always, even when not using node.js
also, that EP is out of date, check out https://github.com/nodejs/modules for more up to date stuff
@devsnek thanks for the following up, reading up. And I get your point about using the file extensions. Cheers! 馃槃
Most helpful comment
https://nodejs.org/api/esm.html