You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Windows, when resolveId returns a virtual module ID starting with / (e.g. /__virtual/1, as used by unplugin-vue-router), webpack and rspack load loaders decoded the virtual module prefix and then passed id through normalizeAbsolutePath(id). Because path.win32.isAbsolute('/__virtual/1') is true, path.win32.normalize rewrote / to \ (\__virtual\1), while loadInclude and filter received /__virtual/1.
Changes
src/webpack/loaders/load.ts & src/rspack/loaders/load.ts: apply normalizeAbsolutePath only to non-virtual resource paths alongside unescapeResourcePath, keeping decoded virtual module IDs untouched.
test/unit-tests/webpack/loaders/load.test.ts, test/unit-tests/rspack/loaders/load.test.ts, & test/unit-tests/virtual-id/virtual-id.test.ts: add unit and integration tests verifying / prefixed virtual module IDs across webpack, rspack, vite, rollup, esbuild, and bun.
Summary by CodeRabbit
Bug Fixes
Fixed handling of virtual module IDs that begin with a slash, so they are passed to plugin load handlers in the expected form.
Improved consistency when loading these modules across Vite, Rollup, Webpack, Rspack, esbuild, and Bun.
Added coverage to verify virtual modules load correctly and, where applicable, appear in the resulting bundle.
No actionable comments were generated in the recent review.
Walkthrough
Webpack and Rspack now normalize non-virtual resource IDs before calling the load hook. Tests verify that slash-prefixed virtual IDs retain their leading slash across six bundlers.
Both loaders normalize non-virtual IDs before calling the load hook. They pass the resulting ID directly to the hook, preserving decoded virtual IDs.
Test slash-prefixed virtual IDs test/unit-tests/rspack/loaders/load.test.ts, test/unit-tests/webpack/loaders/load.test.ts, test/unit-tests/virtual-id/virtual-id.test.ts
Loader tests check that /__virtual/1 reaches the load hook with its leading slash. Cross-bundler tests cover Vite, Rollup, Webpack, Rspack, esbuild, and Bun. Webpack and Rspack tests also check generated bundle contents.
This fixes slash-prefixed virtual module IDs being rewritten to backslashes on Windows in webpack and rspack. The change is small and localized, with added tests, and no merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the two packages affected (webpack and rspack) and the core change: the load hook no longer normalizes virtual module IDs. The raw summary and objectives confirm that normalization now…
Linked Issues check
Issue #421 requires that /-prefixed virtual module IDs reach the load hook unchanged on Windows. At the reviewed head, src/webpack/loaders/load.ts decodes IDs that start with `plugin.__virtualMo…
Out of Scope Changes check
All reported changes relate to #421. The source changes in the webpack and rspack load loaders apply the fix only to virtual module ID handling. The added unit tests cover the webpack and rspack loa…
Full details: Title check
Explanation
The title names the two packages affected (webpack and rspack) and the core change: the load hook no longer normalizes virtual module IDs. The raw summary and objectives confirm that normalization now applies only to non-virtual resource paths, which fixes the Windows backslash issue in issue #421. The title is specific and matches the main change. It uses the conventional commit format and is 70 characters long.
Full details: Linked Issues check
Explanation
Issue #421 requires that /-prefixed virtual module IDs reach the load hook unchanged on Windows. At the reviewed head, src/webpack/loaders/load.ts decodes IDs that start with plugin.__virtualModulePrefix and does not pass them through normalizeAbsolutePath. Only non-virtual resources run normalizeAbsolutePath(unescapeResourcePath(id, 'webpack')). This removes the / to \ rewrite that caused \__virtual\1 in the issue. The PR summary and raw summary report the same change in src/rspack/loaders/load.ts (+2/-2). I could not read the rspack diff or file, so the rspack result relies on the reported summary. The PR also adds tests in test/unit-tests/webpack/loaders/load.test.ts, test/unit-tests/rspack/loaders/load.test.ts, and test/unit-tests/virtual-id/virtual-id.test.ts for /__virtual/1. I did not execute these tests. No non-coding requirements exist in #421.
Full details: Out of Scope Changes check
Explanation
All reported changes relate to #421. The source changes in the webpack and rspack load loaders apply the fix only to virtual module ID handling. The added unit tests cover the webpack and rspack loaders. The integration tests in test/unit-tests/virtual-id/virtual-id.test.ts cover /-prefixed virtual IDs across bundlers, which supports the same objective. The summary reports no changes to exported declarations. I found no unrelated changes in the evidence reviewed. Verification of the rspack diff and of the Windows behavior was not possible, so this result relies on the reported summaries.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
src/rspack/loaders/load.ts
ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
src/webpack/loaders/load.ts
ESLint skipped: the matched ESLint configuration already failed (missing-dependency).
test/unit-tests/rspack/loaders/load.test.ts
ESLint skipped: the matched ESLint configuration already failed (missing-dependency).
2 others
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 5b725553-df6f-42b8-aa1e-cfc0bb39adde
Commits
Reviewing files that changed from the base of the PR and between 5daf6e6 and 785cc7e.
Files selected for processing: 5
src/rspack/loaders/load.ts
src/webpack/loaders/load.ts
test/unit-tests/rspack/loaders/load.test.ts
test/unit-tests/virtual-id/virtual-id.test.ts
test/unit-tests/webpack/loaders/load.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #421
Summary
On Windows, when
resolveIdreturns a virtual module ID starting with/(e.g./__virtual/1, as used byunplugin-vue-router), webpack and rspackloadloaders decoded the virtual module prefix and then passedidthroughnormalizeAbsolutePath(id). Becausepath.win32.isAbsolute('/__virtual/1')istrue,path.win32.normalizerewrote/to\(\__virtual\1), whileloadIncludeandfilterreceived/__virtual/1.Changes
src/webpack/loaders/load.ts&src/rspack/loaders/load.ts: applynormalizeAbsolutePathonly to non-virtual resource paths alongsideunescapeResourcePath, keeping decoded virtual module IDs untouched.test/unit-tests/webpack/loaders/load.test.ts,test/unit-tests/rspack/loaders/load.test.ts, &test/unit-tests/virtual-id/virtual-id.test.ts: add unit and integration tests verifying/prefixed virtual module IDs across webpack, rspack, vite, rollup, esbuild, and bun.Summary by CodeRabbit