Repository navigation
Split module paths on both separators so Windows modules are not dropped - #745
Conversation
🦋 Changeset detectedLatest commit: 4e3015b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughModule path parsing now recognizes both forward and backslash separators. A new test checks that a Windows drive-qualified module name is reported as Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #745 +/- ##
==========================================
+ Coverage 89.92% 90.54% +0.61%
==========================================
Files 17 17
Lines 1132 1132
Branches 420 420
==========================================
+ Hits 1018 1025 +7
+ Misses 105 99 -6
+ Partials 9 8 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
webpack#745 stopped dropping modules whose names use Windows path separators, but it kept `slice(1)`, so the drive letter of an absolute path was still cut off: `C:\shared\lib\util.js`, `D:\shared\lib\util.js` and `./shared/lib/util.js` all became the same node, and the treemap showed one module with the sum of their sizes. Keep a `[A-Za-z]:` first part and drop all leading empty parts of absolute and UNC names. Update the webpack#745 expectation that pinned the old behavior and add coverage for the cross-drive, absolute and UNC cases.
* fix: keep the drive letter of absolute Windows module paths #745 stopped dropping modules whose names use Windows path separators, but it kept `slice(1)`, so the drive letter of an absolute path was still cut off: `C:\shared\lib\util.js`, `D:\shared\lib\util.js` and `./shared/lib/util.js` all became the same node, and the treemap showed one module with the sum of their sizes. Keep a `[A-Za-z]:` first part and drop all leading empty parts of absolute and UNC names. Update the #745 expectation that pinned the old behavior and add coverage for the cross-drive, absolute and UNC cases. * fix: keep UNC module names distinct from relative paths Dropping every leading empty part made `\\server\share\x.js` produce the same path parts as `./server/share/x.js`, so the two modules were merged into one node. Keep the UNC server as a `UNC:server` marker instead: it cannot be produced by a relative path and the displayed path stays free of empty segments. Add a regression test that puts a UNC module and a relative module with the same path into one chunk; it fails on the previous commit and passes now.
What
Modules whose names use Windows path separators are silently dropped from the report.
Folder.addModule()(src/tree/Folder.js:79-83) then returns without a warning, so the module ismissing 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.namewhen the module lives on adifferent drive than the project (
webpack/lib/util/identifier.js,absoluteToRequest()returns theabsolute path when
path.win32.relative()still produces one). A real webpack 5 build with the projecton
D:and a module onC:produced 140 bytes of modules butstatSize = 102, withcross.jsabsentfrom the report.
The change
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
test/analyzerUtils.js:1 failed, 12 passedbefore (./shared/lib/util.jsmissingfrom the parsed path array),
13 passedafter;statSize102 → 140 andcross.jsreappears;expected-chart-datafixtures produce identicalgetViewerData()output before andafter (including
with-module-concatenation-infoand the gzip column);prettier --check,tsc --noEmitclean;git apply(withcore.autocrlf=false) on a pristine tarball reproducesfiles/byte-for-byte.The new test is a pure string assertion with no
path.sepor platform constants, so it behaves the sameon 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