-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
CJS re-export regression with externalLiveBindings: false #5377
Copy link
Copy link
Closed
Labels
Description
Rollup Version
^4.9.3
Operating System (or Browser)
any
Node Version (if applicable)
No response
Link To Reproduction
Expected Behaviour
Generated code can be used with named imports from es modules in Node.js.
Actual Behaviour
Code generated before #5313:
// out.js
const vue = require('vue');
Object.keys(vue).forEach(function (k) {
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = vue[k];
});After #5313:
// out.js
const vue = require('vue');
Object.keys(vue).forEach(function (k) {
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) k === '__proto__' ? Object.defineProperty(exports, k, {
enumerable: true,
value: vue[k]
}) : exports[k] = vue[k];
});When imported from an es module, e.g.
// test.mjs
import { computed } from 'vue'
console.log(computed)Code generated before #5313 is compatible with Node.js' cjs re-exports detection (via cjs-module-lexer), but code after is not, causing the esm usage to fail.
Reactions are currently unavailable