fix: parse Webpack 5 module maps nested in UMD wrappers - #733
Conversation
🦋 Changeset detectedLatest commit: fee1368 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 |
Discover nested Webpack bootstrap IIFEs and select the correct non-empty module map using stats IDs and runtime structure, preserving accurate parsed module attribution. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a2cd1d86-732d-44fb-b556-cf0b08f9906c
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a2cd1d86-732d-44fb-b556-cf0b08f9906c
791cc23 to
fee1368
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #733 +/- ##
==========================================
+ Coverage 76.29% 76.67% +0.37%
==========================================
Files 17 17
Lines 983 1046 +63
Branches 358 382 +24
==========================================
+ Hits 750 802 +52
- Misses 206 215 +9
- Partials 27 29 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
valscion
left a comment
There was a problem hiding this comment.
Looks good to me! Can you take a look at the coverage report? To my eyes it looks like some branches you added are lacking code coverage. Ideally we'd have more tests that verify a real webpack bundle parses correctly without having to pass any custom optiona ourselves in test.
I'm ready to merge this once the coverage question has been dealt with
|
Looks like that #723 getting merged also caused a merge conflict here which needs to be resolved. |
Summary
Related to #372.
Webpack 5 UMD output nests its bootstrap IIFE inside the UMD factory. The analyzer previously missed that module map, while empty or unrelated competing IIFEs could also be selected incorrectly.
This change:
A patch Changeset is included.
What kind of change does this PR introduce?
Fix.
Did you add tests for your changes?
Yes. The tests cover unhinted, partially hinted, tied, and non-matching candidate selection, analyzer module-ID plumbing, and single-pass asset-module collection.
Validation:
npm test -- test/parseUtils.js test/analyzerUtils.js— 27 passednpm run build— passednpm run test:coverage— 136 passed, 4 skippednpm run lint— ESLint, TypeScript, and Prettier passedgit diff --check— passedDoes this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
No documentation changes are required. This corrects existing bundle parsing behavior.
Use of AI
GitHub Copilot assisted with reproducing the failure, drafting the implementation and regression tests, and iterating on review feedback.
Human verification: I reviewed every generated change and the complete final diff, verified the behavior against Webpack 5.105.2 output, and ran all validation commands listed above. The patch also received independent review before publication. I understand the implementation and remain responsible for the contribution.