circular-dependency-plugin
circular-dependency-plugin copied to clipboard
Log to file?
We tried wiring things up to have a file generated at startup, but unfortunately we can't find a way to prevent the plugin from constantly re-creating the files when the project is refreshed. If we try something like setting isCompleted = true
inside of onEnd()
- but isCompleted
ends up being set to true
before we'd expect and so no report files are generated. I looked at the code but can't figure out what might cause this. Maybe there's something I don't understand about how Webpack runs plugins?
Hard to guess... But logging to a file I found that the order of operations looks like this on startup:
-
onStart
<<< What's going on here? -
onEnd
<<< What's going on here? -
onStart
-
onDetected
(however many times a circular dependency is detected -
onEnd
Anybody have any insights?
I was guessing maybe this has to do with multiple entry points, but we have three entry points and only two instances of onStart
and onEnd
.
The only workaround we can find is to do this in onEnd
if (numCyclesDetected) isCompleted = true;
When we do this, we avoid the false instant-completion from the initial onStart
/onEnd
runs. I have no idea what might cause this, but the workaround works, at least somewhat.