-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
preserveModules mess with import order in esm/system output with circular dependencies #3834
Comments
To fix this rollup shouldn't play with import chain simplifying, at least if imported file participates in some circular chains. |
I tried running both the code in ReferenceError: Cannot access 'data' before initialization was When running Also note that "import chain simplification" should no change relevant execution order as additional side-effect imports are generated as needed. But I am open to counter-examples. That is not to say that there are no issues with execution order in Rollup, but all known issues are based on the fact that Rollup sometimes creates too few chunks and will never manifest if you use |
Admittedly, TDZ errors are not tracked properly as side-effects... |
It's really strange, since on node 14 at my computer main is working as supposed. I'll dive into it later. |
Ok, I managed to fix your example and yes, there is an issue, but no, it is not about import chain simplification. Because all imports are still in place, Rollup just "fixes" the order. And by fixing I mean: Sorting them by their (correct!) execution order. But you are right, with circular dependencies this sorting is actually breaking our neck because |
I actually managed to set up a patch that will fix or rather replace the sorting with something that should handle circular dependencies well: #3840 |
Expected Behavior
After build module tree should working.
Actual Behavior
It don't works, because of wrong import order (tag.js run before data.js).
Additional: read this for rationale of such import structure. In our real project there is muuuuuuch more files instead of single tag.js, and in webpack (or simple rollup build, or in browser after simple babel transpilation) all is working good.
https://medium.com/visual-development/how-to-fix-nasty-circular-dependency-issues-once-and-for-all-in-javascript-typescript-a04c987cf0de
The text was updated successfully, but these errors were encountered: