Replies: 4 comments 4 replies
-
Elaborate on “huge”? type module is simply not required - or even advisable - to use native ESM, so there’s no burden here. Duplicate of #75. Also, CJS isn’t “legacy”, isn’t ever going away, and will be present in most applications for the foreseeable future. |
Beta Was this translation helpful? Give feedback.
-
I feel like no answer you're going to get is going to convince you of its adoption if your view is that CJS is not a legacy system. CJS was invented to overcome the lack of modules in JS, it was a Node-specific solution to a real problem with the JS language that got an official language level solution quite a few years ago now (and that Node's has supported since V14) and that the Node ecosystem should at this point in time be promoting as the proper way to write JS imports and exports, with CJS being deprioritized. It's a legacy solution from an era that we're no longer in. Lots of code uses it, but there is zero reason to perpetuate it as "the main way new projects do modules". Keeping up with JS is a worthwhile effort, one that Node and its tooling, including NPM, have a pretty good track record of these days.
this is... not true? Node will error out if you run JS with ESM import/exports without either the type indicator in package.json, which it should be adding as default these days (people who want CJS know they want CJS, and can either say "no" during init, or they can delete the type indicator, not that much work: every single person who wants to use normal ESM currently has to do the reverse of that), or by using the crux |
Beta Was this translation helpful? Give feedback.
-
It was a while ago, but the npm team had agreed that moving these opinions out of Additionally, the package maintenance working group in collaboration with @darcyclarke (former npm team manager) had plans to build |
Beta Was this translation helpful? Give feedback.
-
@wesleytodd good to know! |
Beta Was this translation helpful? Give feedback.
-
It's late 2023, ESM has huge adoption, and so it would be nice if
npm init
added"type": "module"
to thepackage.json
it generates by default instead of requiring folks to put that in themselves despite that being the official JS module system for quite some time now. Rather that putting the burden on folks who want to use modern JS, it would at this point in time make more sense to generate an ESM project when folks run theinit
command, and move the burden of removing that for CJS onto folks who want to create new projects but for some reason still want that to use the legacy CJS system.Beta Was this translation helpful? Give feedback.
All reactions