Open GauBen opened 4 months ago
I think my use case is related. I noticed that Object.defineProperty(exports, ...)
syntax is also detected by cjs-module-lexer.
My input file input.js
:
import {foo} from "foo"
console.log(foo)
The foo
package is a pure CJS package and has the following content:
// foo/index.js
Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return 123; } });
A bundle produced by Rollup outputs undefined
when executed, while it should output value of foo
- 123
.
I'm trying to transpile CJS to ESM until https://github.com/prisma/prisma/issues/5030 is addressed. I'm having a hard time doing so as I can't quite get the pieces together.
Expected Behavior
The commonjs plugin properly detects all named exports
Actual Behavior
No named exports are found
Additional Information
There is a node-backed package that does a pretty solid named exports analysis, which works for my specific use case. I've added a
npm run cjs-lex
command in the repro to show how it works