Hacker News new | ask | show | jobs
by rektide 1092 days ago
ESM was a part of es2015. It's been 8 years that we've had to tangle with both cjs & esm. It's been absolutely awful for everyone.

This crusade is nowhere near zealous nor righteous enough against the infidels & non-believers.

But it also hasn't been effective enough at supporting/supplying the crusade either.

Matteo's statement was that Node hasn't stabilized their loader support so tools have a harm time migrating to esm. Imo it's a pity ecmascript never stabilized a module registry, that esm 1.0 shipped & most people thought it would happen; it's long felt like a bait & switch. But it wasn't a feature browsers needed or really wanted so that unfulfillment was unsurprising. Anyhow, IMO Matteo is making a technical point that it's still hard to finish the move, which is a different spin IMO than a "advocated a moderate approach".

Given the hurt we legitimately experience, I really wish Node and/or WinterCG or someone would prioritize figuring out & implementing whatever needs to go into a module registry/loader. And then beg the big tool chains that need this stuff to expedite their migrations, pretty pretty please.

2 comments

> ESM was a part of es2015. It's been 8 years

Okay, but let's not resist inconveniencing ourselves with the facts.

ESM got browser support in 2017 and stable Node.js support in 2020.

> It's been absolutely awful for everyone.

It only became awful for me when people started publishing pure ESM packages; `npm i node-fetch` suddenly began resulting in broken scripts and I had to learn why. Prior to that, I happily used CJS outside of the browser and what I suppose is ESM in the browser (the `import` syntax provided by bundlers).

> a different spin IMO than a "advocated a moderate approach".

He said, "If your module target the Browser only, go for ESM. If your module target Node.js only, go for CJS."

This is moderate compared to the "Pure ESM" approach. The fetch API is built into browsers so I don't see why anyone would use `node-fetch` outside of Node.js, and yet the maintainers of `node-fetch` went Pure ESM anyway. Also that GitHub issue is titled "When will CommonJS modules (require) be deprecated and removed?" and his response was "There is no plan to deprecate CommonJS"[0].

0 - https://github.com/nodejs/node/issues/33954#issuecomment-776...