standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 146 forks source link

[Node.js 12] Does not work with "type": "module" in "package.json" #789

Closed cedx closed 5 years ago

cedx commented 5 years ago

I'm using the new ES modules features from Node.js 12 (the next LTS).

If I set my package to be an ESM one with the field type set to module in package.json file, the esm package stops working as expected.

import {spawn} from 'child_process';
       ^
SyntaxError: Unexpected token {

If I set the type field to commonjs, esm works as expected (but not my code which uses only ES modules). It would be nice if esm could manage this case (i.e. that the new ESM parser is already enabled).

dnalborczyk commented 5 years ago

hey @cedx this is related to #784 and should be fixed with the next release.

cedx commented 5 years ago

OK, closing as probable duplicate.