-
-
Couldn't load subscription status.
- Fork 28
Closed
Description
Since Rollup@^2.39.0, the cjs output for re-exports has changed a bit:
Object.keys(foo).forEach(function (k) {
- if (k !== 'default') Object.defineProperty(exports, k, {
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
enumerable: true,
get: function () {
return foo[k];
}
});
});The extra hasOwnProperty check breaks re-exports detection of cjs-module-lexer.
The implication of this:
cjs-module-lexeris used in Node.js' ESM mode to detect named exports compatibility for CJS modules- Many packages use Rollup to bundle for CJS distribution (e.g. Vue 3.0)
- Previously, these packages "just worked" for named imports from Node.js in ESM mode because
cjs-module-lexerwas able to detect the re-exports - After upgrading Rollup to 2.39.0, the named imports are broken.
Reproduction
https://github.com/yyx990803/cjs-module-lexer-rollup-reexports
- Install deps
npm run build(which buildssrc/index.jswith Rollup toout.js)node lex.js(which runscjs-module-lexeronout.js)
Metadata
Metadata
Assignees
Labels
No labels