-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Bundle splitting - common chunk has wrong order of modules #1048
Comments
I think i've figured it out. It's a circular import. The Closing for now, will re-open I find something different. |
I just spent a long time trying to figure out why one of our common modules was randomly I finally realized that esbuild was putting the chunks in the wrong order because of a circular import It would be cool if when bundling esbuild could detect if a circular import has occurred and throw an error. Would've saved me the debugging time 😅 |
We are seeing a severe issue with splitting related to the ordering of modules within a common chunk. When the app code is bundled with splitting, we have a logger utility which imports a logger context class from a separate file.
When bundling, we correctly see split files and common chunks. However the app crashes because the chunk containing the logger code has the wrong ordering of modules.
Resulted (usage first, then class definition):
Expected order (class first, then usage):
Many of the split-point pages import
appLogger
(all synchronously) but none other thanappLogger
directly refer to theLoggerContext
implementation directly, so it's unclear why the class definition is being inserted after usage. Nothing looks off about how things are imported.If we comment out some of the app imports to try isolating, we have narrowed down some code which when commenting out, changes the common chunk module ordering to be correct. It's unclear specifically why, still investigating. We tried setting up a simple repro, but so far haven't pinpointed the right set of conditions to recreate it.
In looking for related issues, we found this: #399
The title is close to what I'm describing, but I believe that issue is more related to side effects and how chunking can violate assumptions of side effect code. In my scenario, we don't have side effects here - everything is imported as expected. The chunk simply has the wrong order.
I will continue working on an isolated repro, but wanted to get the issue going in case this is known already.
The text was updated successfully, but these errors were encountered: