r/node • • Feb 01 '22

Fetch API has landed into Node.js

https://github.com/nodejs/node/commit/6ec225392675c92b102d3caad02ee3a157c9d1b7
280 Upvotes

31 comments sorted by

View all comments

62

u/Zipdox Feb 01 '22

Now we can finally ditch node-fetch, which I've wanted to do ever since it switched to ESM.

13

u/Solonotix Feb 01 '22

Isn't ESM the "way forward" for Node.js? I've seen tons of posts a out how TypeScript allows use of modules, and that's always seen as a good thing, but then discussion of ESM always seems to be met with disdain.

26

u/codyebberson Feb 01 '22

Yes, ESM is the way forward. Server-side ESM is still a bit clunky. The gentle migration path is to dual build CommonJS + ESM. The node-fetch team took a hard stance of ESM-only, which breaks a lot of projects.

18

u/Guisseppi Feb 01 '22

Node’s module management has been a clusterfuck and I get that there’s history behind it but damn how long have we have ESM in feature flags only for a half baked release, I hate the semantics of using .mjs or adding type module, and if all the planets align then node will read it as an external module