Skip to content

feat(core): virtual file entry and native watcher for watch mode - #1550

Draft
stormslowly wants to merge 11 commits into
mainfrom
virtual_file_and_native_watcher
Draft

stormslowly wants to merge 11 commits into
mainfrom
virtual_file_and_native_watcher

Conversation

@stormslowly

Copy link
Copy Markdown
Contributor

Why

In watch mode the CLI "rerun all" shortcut re-ran tests without recompiling, so newly added test files were never picked up (the old // TODO: should rerun compile with new entries).

This PR drives every rerun through Rspack's compile pipeline by writing to a virtual entry module, and switches watch mode to Rspack's native (Rust) file watcher.

What

  • Virtual file entry: register a per-environment VirtualModulesPlugin entry. triggerRerun() rewrites it with a fresh value to force a recompile, and the recompile drives the test run through the normal onAfterDevCompile path.
  • Route the "rerun all" shortcut through triggerRerun() + forceRerunOnce so it recompiles with the current entries instead of re-running the stale build.
  • Native watcher: enable experiments.nativeWatcher in watch mode and lower watchOptions.aggregateTimeout to 5ms for snappier reruns.
  • e2e coverage for watch / restart / shortcuts.

Verification

Locally verified the native watcher end-to-end on examples/node:

step result
initial run 3 passed
edit a source dependency (src/index.ts) rerun within ~0.5s, test flips to failed
revert back to 3 passed

Runtime-confirmed the flag selects the native FS: experiments.nativeWatcher: trueNativeWatchFileSystem, falseNodeWatchFileSystem (rspack 1.5.0).

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rstest with  Cloudflare Pages  Cloudflare Pages

Latest commit: 19892c5
Status: ✅  Deploy successful!
Preview URL: https://909d15d8.rstest.pages.dev
Branch Preview URL: https://virtual-file-and-native-watc.rstest.pages.dev

View logs

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