Skip to content

feat(watch): support mixed ignored patterns#13795

Open
Perfecto23 wants to merge 1 commit intoweb-infra-dev:mainfrom
Perfecto23:feature-mixed-ignored
Open

feat(watch): support mixed ignored patterns#13795
Perfecto23 wants to merge 1 commit intoweb-infra-dev:mainfrom
Perfecto23:feature-mixed-ignored

Conversation

@Perfecto23
Copy link
Copy Markdown
Contributor

@Perfecto23 Perfecto23 commented Apr 22, 2026

Summary

Extend watchOptions.ignored to accept string | RegExp | (string | RegExp)[], so framework authors can merge user-supplied RegExp ignores with framework-appended glob ignores in a single array.

This is a Rspack extension for framework composition use cases (see #10596), not webpack watchOptions.ignored parity.

What changed

  • Rust watcher data model — new FsWatcherIgnored::Mixed(Vec<FsWatcherIgnoredItem>) variant that matches both glob paths and RspackRegex patterns in a single pass.
  • Glob parent-path matchingglob_match_path now walks parent directories so that patterns like **/.cache correctly ignore child paths (e.g. /project/.cache/file.js). This applies to all glob-based ignored variants, not only mixed arrays.
  • Native watcher event filteringTrigger::on_event now checks ignored at the event entry point (via to_string_lossy for non-UTF-8 safety), preventing ignored sub-paths from triggering rebuilds through parent directory association.
  • NAPI bindingNativeWatcherOptions.ignored extended to string | (string | RegExp)[] | RegExp with Either4 dispatch.
  • Node/watchpack fallback — mixed arrays are normalized into a predicate function: string globs are converted via glob-to-regexp (prebundled) and merged into one RegExp; user RegExp instances are tested individually with lastIndex reset to handle stateful /g /y flags.
  • RSC coordinator — client compiler "watch nothing" override changed from () => true to /.*/ to stay compatible with native watcher's function rejection.
  • Browser build — added resolve alias for glob-to-regexp in rslib.browser.config.ts, consistent with the existing watchpack alias pattern.
  • Tests — new compilerCases/watch-options-ignored.js covering both node and native watcher paths: verifies ignored glob/regex files do not trigger invalid/rebuild, and normal watched files still trigger rebuild.
  • Docs — updated English and Chinese watchOptions.ignored docs with mixed array examples; softened glob description to "glob semantics" without referencing the internal implementation.

Related links

Closes #10596

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@Perfecto23 Perfecto23 requested a review from hardfist as a code owner April 22, 2026 10:22
@github-actions github-actions Bot added the release: feature release: feature related release(mr only) label Apr 22, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2dca99a612

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/rspack/src/node/NodeWatchFileSystem.ts Outdated
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 22, 2026

Merging this PR will degrade performance by 4.09%

❌ 2 regressed benchmarks
✅ 32 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation rust@persistent_cache_restore@basic-react-development 24 ms 25.1 ms -4.09%
Simulation rust@create_chunk_ids 9.9 ms 10.2 ms -3.58%

Comparing Perfecto23:feature-mixed-ignored (4603b93) with main (5862c86)

Open in CodSpeed

@Perfecto23 Perfecto23 force-pushed the feature-mixed-ignored branch 4 times, most recently from 99befcb to b4fd17f Compare April 22, 2026 12:40
@chenjiahan chenjiahan requested a review from stormslowly April 22, 2026 14:18
@Perfecto23 Perfecto23 force-pushed the feature-mixed-ignored branch 2 times, most recently from f2044b4 to f8ade0c Compare April 22, 2026 14:45
@Perfecto23 Perfecto23 force-pushed the feature-mixed-ignored branch from f8ade0c to 4603b93 Compare April 23, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: watchOptions.ignored support (string | RegExp)[] type

1 participant