News for hackers. Stuff that matters.
Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge... by maple3142 on Thursday August 06, 2020 @04:11AM (#24069030)
I think CJS can export 1 more thing than ESM is a problem too.

    // cjs.js
    module.exports = (a, b) => a + b
    exports.default = 'default'
    exports.nice = 69
    // esm.js
    import * as mod from './cjs'
    // what is `mod` now?
In babel, `mod` will be `{ default: [Function], nice: 69 }`, and the string 'default' will be discarded because ESM always exports a `{ [key: string]: any }` while CJS can export whatevey they want (`any`).

There are no comments on this comment yet.