plugins: [commonjs] cross import between entry commonjs modules is broken
- Rollup Plugin Name: @rollup/plugin-commonjs
- Rollup Plugin Version: Latest
- Rollup Version: Latest
- Operating System (or Browser): MacOS, Repl.it
- Node Version: v12.16.3
How Do We Reproduce?
https://repl.it/@csr632/rollup-plugin-repro
Expected Behavior
checkout dist/test1.js , it access test2 module as test2.__moduleExports, which is clearly undefined.
Actual Behavior
dist/test1.js should log test2 correctly
Output format is esm, so maybe related to https://github.com/rollup/plugins/issues/400. But in my case, I have multi entry modules.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 19 (19 by maintainers)
Commits related to this issue
- reprocude https://github.com/rollup/plugins/issues/411 — committed to csr632/rollup-issue by csr632 4 years ago
@lukastaegert Ok so just in case I forget later - it’s basically a shortcut to the stuff that’s stuffed onto
module.exports.foo = bar(vs.module.exports = ...), for other internal modules (in the same rollup) to use, to avoid theunwrapExports(...)from pulling a member nameddefaultin case it exists. It basically allows to workaround all the babel__esModule/defaulthacks internally, so it refers to the right objects.Also most of its references gets shaken off by rollup and replaced with
defaultimport when relevant and possible. That’s why it’s hard to see the source of the problem in the REPL.My other PR from today actually has a test that fails when I remove the whole
__moduleExportsthing, and that is what clarified things to me. Pure luck.I can confirm this is resolved by #501.
I started #481 to move all interop issues including this one forward.