Skip to content

Split module paths on both separators so Windows modules are not dropped - #745

Open
PerryLink wants to merge 1 commit into
webpack:mainfrom
PerryLink:fix/windows-module-paths
Open

PerryLink wants to merge 1 commit into
webpack:mainfrom
PerryLink:fix/windows-module-paths

Conversation

@PerryLink

@PerryLink PerryLink commented Oct 18, 2026 •

Copy link
Copy Markdown

What

Modules whose names use Windows path separators are silently dropped from the report.

// src/tree/utils.js:23-31
const parts = module.name.split('/')     // a name like "C:\\repo\\src\\x.js" yields one part
return parts.slice(1)                    // ... and slice(1) is empty -> null

Folder.addModule() (src/tree/Folder.js:79-83) then returns without a warning, so the module is
missing from the treemap and the JSON report, and statSize (src/analyzer.js:546) is under-counted.
The same happens to inner modules of a concatenated module (src/tree/ConcatenatedModule.js:80-84).

Reachable in practice: webpack writes an absolute path into module.name when the module lives on a
different drive than the project (webpack/lib/util/identifier.js, absoluteToRequest() returns the
absolute path when path.win32.relative() still produces one). A real webpack 5 build with the project
on D: and a module on C: produced 140 bytes of modules but statSize = 102, with cross.js absent
from the report.

The change

-  const parts = module.name.split('/')
+  const parts = module.name.split(/[\\/]/u)

One expression, slice(1) semantics unchanged, and identical results for every name that only uses /
(the existing fixtures are compared before/after and are byte-identical).

A changeset (.changeset/windows-path-module-names.md) is included, as the repository requires.

Verification

  • unit test added to test/analyzerUtils.js: 1 failed, 12 passed before (./shared/lib/util.js missing
    from the parsed path array), 13 passed after;
  • the real webpack 5 build above: statSize 102 → 140 and cross.js reappears;
  • the 8 existing expected-chart-data fixtures produce identical getViewerData() output before and
    after (including with-module-concatenation-info and the gzip column);
  • 5 non-puppeteer suites / 113 tests pass; eslint, prettier --check, tsc --noEmit clean;
  • git apply (with core.autocrlf=false) on a pristine tarball reproduces files/ byte-for-byte.

The new test is a pure string assertion with no path.sep or platform constants, so it behaves the same
on the ubuntu × Node 20/22/24 CI matrix.

The puppeteer-backed suites cannot run on this machine (no Chrome); their fixtures were compared through
getViewerData() instead, as described above.

Summary by CodeRabbit

  • Bug Fixes
    • Module paths using Windows separators now appear correctly in bundle analyzer reports, including paths resolved across drives.
    • Drive-qualified paths are normalized in the report while preserving bundle size totals.

@changeset-bot

changeset-bot Bot commented Oct 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4e3015b

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

This PR includes changesets to release 1 package
Name Type
webpack-bundle-analyzer Patch

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

@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: PerryLink / name: PerryLink (4e3015b)

@coderabbitai

coderabbitai Bot commented Oct 18, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 72d0e578-dcf6-42eb-851b-f0cd4da22edb
📥 Commits

Reviewing files that changed from the base of the PR and between 0ebe1e5 and 4e3015b.

📒 Files selected for processing: 3
  • .changeset/windows-path-module-names.md
  • src/tree/utils.js
  • test/analyzerUtils.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

Module path parsing now recognizes both forward and backslash separators. A new test checks that a Windows drive-qualified module name is reported as ./shared/lib/util.js, alongside ./src/index.js, and that the bundle stat size remains 150. A patch changeset records this change.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 4e301

Windows-style module paths are now included in reports and contribute to bundle sizes. No established issue warrants delaying the change.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: splitting module paths on both slash types to prevent Windows modules from being dropped.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 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.

test/analyzerUtils.js

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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