webpack icon indicating copy to clipboard operation
webpack copied to clipboard

Compilation._handleModuleBuildAndDependencies's callback should get module when no error happening.

Open hiyuki opened this issue 2 years ago • 4 comments

Bug report

What is the current behavior? When module is being processed in processDependenciesQueue, compilation._handleModuleBuildAndDependencies callback with empty. https://github.com/webpack/webpack/blob/1132eb3f38cc5d3365646e06022aef64b8015c61/lib/Compilation.js#L1939-L1942

If the current behavior is a bug, please provide the steps to reproduce. Module with circular dependencies.

What is the expected behavior? I'm writing a webpack plugin which need call compilation.addEntry and get the entry root module from callback, but in the circular case I can't get the entry root module from callback and without any error.

I don't know is this a intentional design but in my opinion module should be callbacked when no error happening, like this:

// This avoids deadlocks for circular dependencies
if (this.processDependenciesQueue.isProcessing(module)) {
	return callback(null, module);
}

Other relevant information: webpack version:
Node.js version: Operating System: Additional tools:

hiyuki avatar Jul 13 '22 12:07 hiyuki

Directly callback with module is not accurate, perhaps it is better to wait for the current module's dependencies processing to be finished, and then invoke the outer callback such as compilation.addEntry.

hiyuki avatar Jul 14 '22 04:07 hiyuki

You are right. Send a PR

sokra avatar Jul 25 '22 07:07 sokra

I'll like to submit a PR, please assign it to me.

AnmolBansalDEV avatar Aug 06 '22 07:08 AnmolBansalDEV

I sent a PR making the changes mentioned by @hiyuki in the desc. If any modification is required let me know.

AnmolBansalDEV avatar Aug 06 '22 12:08 AnmolBansalDEV

This issue had no activity for at least three months.

It's subject to automatic issue closing if there is no activity in the next 15 days.

webpack-bot avatar Nov 06 '22 07:11 webpack-bot

bump

alexander-akait avatar Nov 07 '22 15:11 alexander-akait