tapable icon indicating copy to clipboard operation
tapable copied to clipboard

.tap() `before` parameter do not respects existing befores

Open Rulexec opened this issue 4 years ago • 1 comments

Hello. I have three plugins:

  • A depends on B
  • B depends on C
  • C

They tap some hook with same stage in the following order:

  • A, B, C

Then inside https://github.com/webpack/tapable/blob/9d647f86ddb2930c6e24950a1edd2778453e92a1/lib/Hook.js#L136 they got position incorrectly as:

  • B, A, C

It happens because current logic looks like:

  • Adding A, no taps, just add
  • Adding B, B has before, so if (before.size > 0) allows to skip A and be inserted in the start of taps (e.g. order now is B, A)
  • Adding C to the top, since it has no before rules

Rulexec avatar Jan 04 '22 15:01 Rulexec

Also it's will be good to throw exception if circular dependency is detected.

Rulexec avatar Jan 04 '22 15:01 Rulexec