Skip to content

feat(watcher): enable rspack native watcher#1441

Draft
stormslowly wants to merge 1 commit into
mainfrom
feat/enable-native-watcher
Draft

feat(watcher): enable rspack native watcher#1441
stormslowly wants to merge 1 commit into
mainfrom
feat/enable-native-watcher

Conversation

@stormslowly

Copy link
Copy Markdown

Why

Rstest has been using the JS file watcher in watch mode because the rspack native (Rust) watcher had a macOS flake — stale FSEvents replayed an empty rerun (expected '' to match 'other.test.ts'), failing ~7.5% on macos-14 runners.

That root cause is now fixed upstream in rspack 2.1.0-beta.0:

With the fix shipped, rstest can switch to the native watcher.

Validation: native watcher on rsbuild 2.1.0-beta.0 was stress-tested on macos-14 (node 22/24, path-reuse condition) — 80/80 green, zero watcher flake.

What

  • Upgrade @rsbuild/core / @rspack/core to 2.1.0-beta.0 across the workspace.
  • Enable experiments.nativeWatcher in watch mode.
  • Raise the default watch aggregateTimeout 5 → 100ms — on macOS the native watcher needs the FSEvent → vnode cache invalidation window to elapse before rspack stats the changed file, otherwise the rebuild reads stale content. Drop the now-redundant per-fixture aggregateTimeout: 10 overrides in the watch e2e configs so this default applies.
  • Make config-file watching reliable on macOS: poll the small config-file set (chokidar v5 dropped fsevents and fs.watch silently drops single-file change events on macOS) and await the initial scan so the first change is never missed.
  • adapter-rspack: drop the top-level snapshot mapping — snapshot was removed from RspackOptions in rspack 2.1 (it now lives under persistent cache).

@stormslowly stormslowly marked this pull request as draft June 20, 2026 08:49
@stormslowly

Copy link
Copy Markdown
Author

Held as draft — blocked on an upstream rspack 2.1 source-map regression.

CI fails on 3 non-watcher e2e tests (list/index, list/json, test-api/timeout) that assert includeTaskLocation source columns. rspack 2.1.0-beta.0 changed the source-map mapping for ESM interop member-call expressions:

(0, _core.describe)('test a', ...)   // bundled

The call-site column now resolves to the source ( instead of the describe/it identifier:

location rspack 2.0.x rspack 2.1.0-beta.0
describe('test a' (L3) 3:1 3:9
it('test a-1' (L4) 4:3 4:5
it('test a-2' (L9) 9:1 9:3

Root cause confirmed via minimal repro + source-map decode. Not configurable (tested experiments.sourceImport, optimization.concatenateModules, devtool, output.column), not yet fixed on rspack main, and rspack 2.1 is required for the native-watcher fix (so downgrading is not an option).

Holding this PR until the upstream regression is fixed; the task locations will then snap back without any test changes here.

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.

1 participant