Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge...
by dfabulich on Thursday August 06, 2020 @01:16AM
(#24068307)
> the last 2 LTS releases of Node
(Author here.)
Node 14 supports ESM, but Node 12 only supports ESM behind the --experimental-modules flag, and its error handling for incorrectly importing CJS is not good.
In 2020, I think it's a bit early to go ESM only, especially since it's straightforward for CJS libraries to support both CJS and ESM clients. (I document how to do this in the article.)
Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge...
by colinr on Thursday August 06, 2020 @02:33AM
(#24068620)
The experimental flag was recently removed in v12.17.0 (though the release notes still say ESM is an experimental feature)
Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge...
by mantap on Thursday August 06, 2020 @03:13AM
(#24068784)
I feel the opposite. ESM is a nightmare and I hope I can avoid using it in node as long as possible.
Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge...
by pilif on Thursday August 06, 2020 @05:26AM
(#24069382)
that's the attitude that brought us sites only working in Internet Explorer (and now Chrome)
IE had many non-standard APIs that were much more convenient to use than what the standard was providing (innerHTML, document.all)
And rather than moving to the standard, more and more code was written targeting IE which also had a conveniently large user-base.
ESM is the standard. CJS is the solution proprietary to node.js.
It's time we all published standard JS modules and only standard JS modules to npm.