circular-dependency-plugin icon indicating copy to clipboard operation
circular-dependency-plugin copied to clipboard

Log to file?

Open Nantris opened this issue 3 years ago • 2 comments

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?

Nantris avatar Jun 23 '21 19:06 Nantris

Hard to guess... But logging to a file I found that the order of operations looks like this on startup:

  1. onStart <<< What's going on here?
  2. onEnd <<< What's going on here?
  3. onStart
  4. onDetected (however many times a circular dependency is detected
  5. 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.

Nantris avatar Jun 23 '21 20:06 Nantris

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.

Nantris avatar Jun 23 '21 20:06 Nantris