-
-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[commonjs] cross import between entry commonjs modules is broken #411
Comments
Not the same as #400. @lukastaegert Can you please explain the role of |
@lukastaegert Okay I think I got it. Trying to find a way to make it play well with multiple entries. |
That’s good because honestly I do not know, this was apparently from before I started on this project 🙄 |
@lukastaegert Ok so just in case I forget later - it's basically a shortcut to the stuff that's stuffed onto Also most of its references gets shaken off by rollup and replaced with My other PR from today actually has a test that fails when I remove the whole |
@danielgindi |
@csr632 Could you add a test in the commonjs package? I think we can't use the git |
@danielgindi cd /rollup-plugins/packages/commonjs
yarn build
yarn link
cd /path/to/reproduce/repo
yarn link @rollup/plugin-commonjs
yarn build I am currently working on other stuff, I can add the test later. |
@csr632 I want to see a REPL with the problem reproduced with latest |
@danielgindi Checkout the |
@lukastaegert For some reason, when debugging this earlier (probably a different |
|
So I see only two solutions
|
If I recall correctly- this was to avoid conflicts where a member named We can always guess, but we will miss. |
Then maybe go for the simple solution now, and we can think if we can do better when people are actually annoyed. |
@lukastaegert Can we at least detect inside the plugin that it has multiple entry points? This would allow reducing the cases where it will pollute the output |
Not reliably. Even if there is only a single entry, plugins can theoretically emit additional entries at any time until building the graph is complete. E.g. the transform hook of a module could emit a new chunk for a worker that is created in the module. |
Well, I tried. exports.__moduleExports = 'BAZBAZ';
exports.default = 'BAZBAZ'; Yeah we said it will pollute. But the problem is that this is actually instead of: module.exports = 'BAZBAZ'; So it always results in the following warning:
Which is a very important warning. I'm starting to think there's no good solution for this. |
I started #481 to move all interop issues including this one forward. |
I can confirm this is resolved by #501. |
How Do We Reproduce?
https://repl.it/@csr632/rollup-plugin-repro
Expected Behavior
checkout
dist/test1.js
, it access test2 module astest2.__moduleExports
, which is clearly undefined.Actual Behavior
dist/test1.js
should logtest2
correctlyOutput format is esm, so maybe related to #400. But in my case, I have multi entry modules.
The text was updated successfully, but these errors were encountered: