I'm using Webpack 5 for a project, and just tried to move some logic out into a WebWorker. Here's how I'm creating the worker:
persistenceWorker = new Worker(
new URL('app/engine/persistence/worker', import.meta.url),
);
However, I now have this warning from webpack:
Circular dependency between chunks with runtime (main, src_app_engine_index_ts)
This prevents using hashes of each other and should be avoided.
It seems like this is because my worker file imports code that transitively imports the file that is creating the worker. I don't think this is avoidable in the architecture of my program. I don't see how this is a problem, though - nothing imports the worker module, so the references should all go one direction. It seems like it's counting creating the worker as a dependency, even though the file creating the worker is not actually importing the code in the worker file.
Is there a way to fix this? Refactoring my project to remove the "circular dependency" is probably a no go.
And how much of a problem is this warning? Everything works fine if I close the warning out, and I'm not clear what "This prevents using hashes of each other" means in practical terms.