3 ms·
I haven’t seen CommonJS modules for years now, only ES modules. Didn’t realize this was such an issue still. > You can’t require() ESM scripts That’s one way
by draw_down 6y ago
I haven’t seen CommonJS modules for years now, only ES modules. Didn’t realize this was such an issue still.
> You can’t require() ESM scripts
That’s one way to put it! Another would be to say that you don’t have to. require() came about because we didn’t have the import keyword.
- dimgl 6y agoI guess you don't work on Node.js backends.
- dfabulich 6y ago(Author here.) You were not using native ESM in Node years ago. Node 14 shipped with unflagged ESM support just this year. (If I had to take a guess, you were probably transpiling "import" statements into "require" statements and/or bundles, which honestly works better than native ESM, because there's no interop issue.) Almost all of the most depended on NPM packages are CJS, and provide no ESM exports. https://www.npmjs.com/browse/depended https://www.npmjs.com/browse/depended lodash, react, chalk, commander, moment, express, axios, and vue are all CJS.