Repository navigation
Replies: 1 comment
|
Confirmed with your repro on 29.0.3. The ES bundle throws Your diagnosis is right. The top-level I've opened a PR with the fix: #2046. When a module is wrapped, it marks Until that's released, adding any other plain use of |
Uh oh!
There was an error while loading. Please reload this page.
In
@rollup/plugin-commonjs29.0.3 (withrollup4.68.0), when a CommonJS module's only reference toexportsis a top-levelObject.defineProperty(exports, "__esModule", { value: true })and the module also referencesmodule, it is wrapped in(function (module) { ... }())without passingexportsor rewriting thedefinePropertycall.Running the generated ES bundle throws
ReferenceError: exports is not defined in ES module scopebecauserequireMemits a freeexportsidentifier inside the wrapper:m.jsshould either receive(module, exports)in the wrapper or haveexportsrewritten, matching Node's CommonJS wrapper where bothmoduleandexportsare in scope. TheCallExpressionhandler for__esModuleskipsexportswithout markinguses.exports = true, so wrapping triggered byuses.moduleomitsexportsfrom the wrapper parameters.Credit: https://ucsbplse.github.io/
All reactions