ESM re-exports from CJS module not included in exports
Open
Nobody has claimed this yet.
loaders
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
Version
node-v
Platform
Microsoft Windows NT 10.0.26100.0 x64
Subsystem
No response
What steps will reproduce the bug?
// main.mjs
import * as mod from "./mod.js";
console.log(mod);
// mod.js
module.exports = {
...require("./other.js")
};
// other.js
export function test() {}
> node main.mjs
[Module: null prototype] {
default: { test: [Function: test] },
'module.exports': { test: [Function: test] }
}
> deno -A --unstable-detect-cjs main.mjs
[Module: null prototype] {
default: { test: [Function: test] },
"module.exports": { test: [Function: test] },
test: [Function: test]
}
How often does it reproduce? Is there a required condition?
Every time.
What is the expected behavior? Why is that the expected behavior?
It should detect the "test" export from the ES module.
What do you see instead?
It's missing.
Additional information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with main.mjs, mod.js, and other.js using node main.mjs, then compare Node's namespace output with the Deno example. Trace Node's CommonJS-to-ESM export detection and verify that the test export from other.js is included in the namespace.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100