Skip to content

feat: support mixed glob and RegExp arrays in the ignored option - #336

Merged
alexander-akait merged 1 commit into
webpack:mainfrom
stormslowly:mixed_ignore
Sep 11, 2026
Merged

alexander-akait merged 1 commit into
webpack:mainfrom
stormslowly:mixed_ignore

Conversation

@stormslowly

Copy link
Copy Markdown
Contributor

Why

Framework authors who wrap watchpack cannot merge their own ignore patterns with the user's when the two use different forms. If a user configures ignored: /\.git/ and the framework wants to append **/dist, there is no value that expresses both: an array is assumed to contain only glob strings, so putting a RegExp in it throws TypeError: Expected a string.

// before — the framework has to hand-build a predicate to combine the two
const userIgnored = /\.git/;
new Watchpack({
  ignored: (item) => userIgnored.test(item) || item.includes("/dist"),
});

// after
new Watchpack({ ignored: [/\.git/, "**/dist"] });

This is the underlying limitation behind web-infra-dev/rspack#10596, where rspack users hit the same wall through watchOptions.ignored.

What

ignoredToFunction now splits an array into glob strings and RegExp instances. Glob strings are still merged into a single RegExp as before; that combined pattern and any user RegExps are then tested against the separator-normalized path.

Ignored becomes (string | RegExp)[] | RegExp | string | IgnoredFunction. Behaviour for string-only arrays, single strings, single RegExps and functions is unchanged.

`ignored` now accepts `(string | RegExp)[]` so glob patterns and regular
expressions can be combined in a single array.
@changeset-bot

changeset-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 596dc8c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
watchpack Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codspeed

codspeed Bot commented Sep 9, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 36 untouched benchmarks


Comparing stormslowly:mixed_ignore (596dc8c) with main (e8ef260)

Open in CodSpeed

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.19%. Comparing base (e8ef260) to head (596dc8c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #336      +/-   ##
==========================================
+ Coverage   91.91%   92.19%   +0.27%     
==========================================
  Files           8        8              
  Lines        1299     1307       +8     
  Branches      384      385       +1     
==========================================
+ Hits         1194     1205      +11     
+ Misses         99       96       -3     
  Partials        6        6              
Flag Coverage Δ
integration 92.19% <100.00%> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexander-akait
alexander-akait merged commit b84d6e3 into webpack:main Sep 11, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants