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
Chunk graph / "available modules optimisation" refactor in 4.38.0 breaks our bundles #9634
Comments
Yep, I think so too. One thing makes me wondering: There is no sync dependency from entry-a to module-a, so there is no reason why module-a should be included in entry-a. Maybe intermediate-a to intermediate-b is a sync dependency instead of an async one? |
Ok I was able to reproduce it, thanks |
Great news! Curious as to what the minimal reproduction case is, as a colleague and I spent some time on this today without much luck. |
After looking at my real dependency graph some more you're right - the shortest path from |
Path from entry-a to module-a need to have less async dependencies than from entry-b to module-a. |
Confirm that applying your PR as a patch to webpack in my |
Thanks for the report. The graph was very helpful |
Bug report
What is the current behavior?
We have a large, 25,000+ module, build with multiple entry points and judicious usage of code splitting. In the latest version of Webpack we have a scenario where one of our async bundles when loaded through a chain starting from a particular entry point cannot find one of the modules it requires, because it is only included in a different entry point. Running a
git bisect
identified the commit where this behaviour changed as 126fb99Unfortunately at this stage I am unable to produce a minimal reproduction, and our codebase is not public. The commit in question moved code as well as refactored, so it's hard to tell from the diff exactly what changed in the chunk graph algorithm, however based on what we're seeing I am suspecting the "available modules optimization" is at fault, where a module is not being bundled where it should be because it's considered "available" when it isn't.
Here is the scenario, slightly simplified:
entry-a
andentry-b
entry-a
eventually depends onmodule-a
via a mix of sync & async imports (code splits)entry-a
also depends onmodule-b
via a mix of sync & async imports (code splits), through a path includingshared-module-a
.module-b
depends onmodule-a
entry-b
depends onshared-module-a
through a mix of sync & sync imports (and so eventually depends onmodule-a
viamodule-b
(Dashes are code splits, solid are direct imports - there's a lot more of these in the real codebase, which might be relevant)
After commit 126fb99,
module-a
is bundled intoentry-a
, so when we loadentry-b
andmodule-b
tries to loadmodule-a
a runtime error is thrown becausemodule-a
cannot be found.Before commit 126fb99,
module-a
will be bundled intomodule-b
(andentry-a
), so when we loadentry-b
it can be found whenmodule-b
tries to load it.If the current behavior is a bug, please provide the steps to reproduce.
As above, I cannot currently provide a minimal reproduction, but I am working on it and will update the issue when I have narrowed it down further.
It does not appear that any optimisation settings affect this - I can repro in dev mode, prod mode, with webpack-dev-server, and anything in between - it's, to my current understanding, a fundamental bug in the graph building code.
I have tried to produce a simplified scenario as described above, but it's something more specific about our particular combination of sync/async imports that is obviously causing this issue to occur, hopefully if I can identify which part of 126fb99 causes the issue I can work how to reproduce the issue (and/or provide a fix).
What is the expected behavior?
I expect that when
module-b
is loaded viaentry-b
, it can still accessmodule-a
because it has been bundled somewhere in the modules available toentry-b
.Other relevant information:
webpack version: 4.39.2
Node.js version: 10.9.0
Operating System: macOS 10.14.6
Additional tools:
The text was updated successfully, but these errors were encountered: