const kSymbol = Symbol();
class Foo {
[kSymbol] = 1;
}
export default new Foo()[kSymbol];
The above fails when run under esm, the [kSymbol] = 1; throws a syntax error (under node.js 12). node.js 12 has no problem with this syntax, replacing export default with module.exports = makes this code work even with esm (I assume ESM detects lack of import/export and disables itself).
The above fails when run under
esm
, the[kSymbol] = 1;
throws a syntax error (under node.js 12). node.js 12 has no problem with this syntax, replacingexport default
withmodule.exports =
makes this code work even with esm (I assume ESM detects lack of import/export and disables itself).