webpack / webpack/tapable

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

Open
#168 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
3.9k
Forks
390
Avg merge
40m
Merged PRs (30d)
3

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/Hook.js around line 136, where tap ordering and the before parameter are processed. Reproduce the A/B/C dependency sequence described in the issue, then verify that adding taps with the same stage preserves the expected A, B, C order and add or update coverage for that case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.