3 ms·
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.n
by maple3142 6y ago
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`).