BuildCycleError with a module blocking itself
See original GitHub issueDISCLAIMER: I don’t have a minimal reproduction example, I only have this issue in a big project which I can’t share. I understand that the issue might be closed because of this, but maybe you’ll help me to understand if it’s even a bug of webpack
Bug report
What is the current behavior?
I have a big project that uses https://github.com/4Catalyzer/astroturf for styling. I have several places where I have a ton of styles interpolating each other but this is working fine with webpack@4.
Now I am trying to upgrade to webpack@5 and I’m getting an error saying There is a circular build dependency, which makes it impossible to create this module
If the current behavior is a bug, please provide the steps to reproduce.
Unfortunately, I am unable to create a minimal example, see the disclaimer above.
What is the expected behavior?
There should not be any unsolvable cyclic dependencies because webpack 4 is able to build the same app
I’ve tried to solve it myself which lead me to here https://github.com/webpack/webpack/blob/b7f382878e50452d02c7ad1eeaf28f14d40b29ce/lib/Compilation.js#L1814-L1831
After some debugging I found out that the blockReasons of the module that causes the cycle is that same module (and it is the only item in the blockReasons), so looks like it “imports itself”. This might be an issue in astroturf (so I’m tagging @jquense as its author) but my question to webpack team is the following:
Is it an intended thing that a module can potentially end up blocking itself?
I’ve tried adding a line if (item === module) continue
after line 1821 and this resolved all my issues so there’s no real deadlock - the build completes
Other relevant information: webpack version: 5.55.1 Node.js version: v14.17.0 Operating System: MacOS Additional tools: astroturf version 1.0.0-beta22 (latest)
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (7 by maintainers)
Top GitHub Comments
I also encountered
BuildCycleError
being incorrectly reported when porting a Webpack 4.x build to 5.x. I looked into it and found an error in the cycle tracking code which is fixed in the linked PR.Will be great to report it to
astroturf
, we don’t have special magic forloadModule