Re:Finally, a guide for Node.js and TypeScript and ESM that ...
by brundolf on Tuesday November 21, 2023 @12:41PM
(#38367009)
Being imperative instead of declarative, it hinders a host of key optimizations like parallel loading and dead code elimination
[ Parent
| on HN ]
Re:Finally, a guide for Node.js and TypeScript and ESM that ...
by jampekka on Tuesday November 21, 2023 @12:53PM
(#38367200)
This is discussed in the link I posted. Bundlers manage to statically analyze CommonJS just fine. With require("stringliteral") and
exports.thing = thing, that cover 99.9% or so usage, this is just as easy to statically analyze as ESM.
Saying that you need declarative for static analysis is like saying tail call optimization is impossible.
And if a stricter module system would be still required, it could have been quite easy to make compatible with, well, require.
Re:Finally, a guide for Node.js and TypeScript and ESM that ...
by petre on Tuesday November 21, 2023 @03:29PM
(#38369606)
Require is fine but I totally hate the CJS exports. Feels like writing '90s era Perl code. On the other hand ESM dynamic imports like
import('this').then(r => that())
rather suck.