GeezerVison is showing github.com — test(alias): cover compileAliasOptions bucketing and the onlyModule flag by alexander-akait · Pull Request #679 · webpack/enhanced-resolve
Conversation
alexander-akait
commented
Sep 21, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Picks up @hey-amanthakur's #628, which went stale against main (conflicted, lint red) — original commit kept as co-author. Closes #628.
compileAliasOptions builds the structure every resolve reads: the first-char buckets, the useBuckets switch that decides whether the hot path pays for a Map.get, and the per-option precomputed strings (nameWithSlash, absolutePath, wildcardPrefix/wildcardSuffix, firstCharCode, arrayAlias). Both bucket layouts resolve identically, so no resolve-level test can tell them apart — a regression in the layout, or in the conditions that turn bucketing off, is invisible until it silently stops aliasing something. These assert the compiled shape directly.
Worth being precise about what this buys: lib/AliasUtils.js is already at 100% line coverage on main (333/333), so this is not a coverage patch. What it adds is behavioural pinning that line coverage does not give — declaration order inside a bucket (alias precedence depends on it), useBuckets off for a single first char and for an empty-prefix wildcard, the any-first-char entry (firstCharCode === -1) being kept out of the buckets, and the fact that a windows-style name normalizes absolutePath with a trailing \ while nameWithSlash appends /, which is exactly why aliasResolveHandler compares against both.
Changes from #628 as submitted:
- Rebased onto current
main; test(alias): add unit tests for compileAliasOptions bucketing and onl… #628 also carried a types.d.ts reformat that an older Prettier had produced. That file is now a two-line stub over generated types/ (refactor: generate types with typescript instead of webpack/tooling #675), so the churn is gone rather than reapplied.
- The
compileAliasOptions tests used a { join: (filePath, ext) => filePath + ext } stub, which made absolutePath come out as /abs/path and the test pinned that. The resolver builds it as join(name, "_").slice(0, -1), so the real value is /abs/path/ — the stub was pinning a shape the resolver never produces. These use a real resolver instead.
- Added: declaration order within a bucket, a two-wildcard name (not treated as a wildcard alias), the windows
absolutePath form, arrayAlias, and the onlyModule normalization. The onlyModule resolve tests now build one resolver per case through a helper rather than repeating the fixture three times, and cover a subpath (real/sub/file) as well as a relative request.
What kind of change does this PR introduce?
test — no lib/ change, so resolution behaviour and performance are untouched.
Did you add tests for your changes?
That is the change: 13 tests in test/alias.test.js. The suite is 1629 tests, all passing, and npm run lint is clean across all five stages.
Does 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?
n/a — test-only, so no changeset either (nothing published changes).
Use of AI
Written with Claude Code, on top of @hey-amanthakur's original commit. It checked the assertions against the code rather than carrying them over: it measured lib/AliasUtils.js at 333/333 lines on main both with and without these tests, which is why the summary above does not claim a coverage gain; it ran compileAliasOptions with a real resolver to find that the submitted absolutePath assertion pinned the stub's output rather than the resolver's; and it confirmed the windows-name case is host-independent (join dispatches to winNormalize on the path type, not on the platform) before relying on it off Windows. Reviewed by me before opening.
🤖 Generated with Claude Code
https://claude.ai/code/session_016aGHrb1YaEvaGwNELGEHjF
Generated by Claude Code
Summary by CodeRabbit
- Tests
- Added coverage for alias configuration handling, including wildcard patterns, path normalization, and option flags.
- Added tests verifying exact-match-only aliasing and subpath resolution behavior.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
`compileAliasOptions` builds the structure every resolve reads — the
first-char buckets, the `useBuckets` switch that decides whether the hot
path pays for a `Map.get`, and the per-option precomputed strings. Both
bucket layouts resolve identically, so the resolve-level tests cannot
tell them apart and a change to the layout can only be caught by
asserting the compiled shape directly.
- compileAliasOptions: bucket construction and declaration order within
a bucket, `useBuckets` off for a single first char and for an
empty-prefix wildcard, wildcard prefix/suffix splitting (including a
two-wildcard name, which is not a wildcard alias), `absolutePath`
normalization for posix and windows names, the `arrayAlias` and
`onlyModule` flags, and the empty list
- onlyModule: the exact request is still aliased, while a subpath and a
relative request are not; both are aliased when the flag is off
Co-authored-by: jhonsnow456 <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016aGHrb1YaEvaGwNELGEHjF
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codecov
Bot
commented
Sep 21, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.46%. Comparing base (f07a030) to head (f4dfa6d).
Additional details and impacted files
@@ Coverage Diff @@
## main #679 +/- ##
=======================================
Coverage 98.46% 98.46%
=======================================
Files 52 52
Lines 10903 10903
=======================================
Hits 10736 10736
Misses 167 167
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Sep 21, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
 
Understand this PR’s impact
Explore downstream dependencies and potential security impact with Blast Radius.
View blast radius →
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: c2a72e81-a074-4534-bbf3-37540f1297c2
📥 Commits
Reviewing files that changed from the base of the PR and between f07a030 and 85d83be.
📒 Files selected for processing (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.
Walkthrough
Adds tests for compileAliasOptions output, including first-character buckets, wildcard metadata, absolute-path normalization, alias flags, and empty inputs. Adds AliasPlugin tests for onlyModule, covering exact requests, subpath requests, and relative requests with the flag enabled and disabled.
Priority: ⬇️ Low
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| 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 changes: adding tests for compileAliasOptions bucketing and the onlyModule flag. |
| Linked Issues check |
✅ Passed |
The pull request satisfies the coding requirements in issue #628. It adds tests for first-character bucket construction, useBuckets disabling conditions, wildcard prefix and suffix splitting, `absol… |
| Out of Scope Changes check |
✅ Passed |
The changes stay within issue #628. The pull request adds tests in test/alias.test.js and does not change lib/ or published behavior. The added tests directly support the linked issue objectives. |
| Docstring Coverage |
✅ Passed |
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1… |
✨ Finishing Touches
📝 Generate docstrings
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
- Commit to this branch
- Create a new PR
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codspeed
Bot
commented
Sep 21, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Merging this PR will degrade performance by 5.61%
⚠️ Different runtime environments detected
Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.
Open the report in CodSpeed to investigate
⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 139 untouched benchmarks
Performance Changes
Tip Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing claude/enhanced-resolve-660-qo14h7 (f4dfa6d) with main (f07a030)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
CodSpeed is red on 85d83be ("Performance Regression: -10.05%"). It is not this PR's, and the report says why in its own footer: it compared 85d83be against main (f07a030), which is #676 — merged ~10 minutes before this branch was pushed. The branch was cut from d9a13d7, so the arms differed by #676's lib/ changes, not by anything here.
The diff is one file:
test/alias.test.js | 236 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 236 insertions(+)
No lib/ change at all, and the flagged benchmark imports only ../../../lib/index.js, fs and path — nothing in the benchmark harness loads test/. A test file cannot move a benchmark.
The mirror-image confirms the base skew rather than a real delta. realistic-midsize: mixed batch (cold cache) was reported on #676 as an improvement, 18.1 ms → 15.4 ms (+17.34%). Here, with the arms swapped, the same task is reported as a regression, 15.7 ms → 18.2 ms (-13.69%). Same pair of readings, opposite sign, because this branch was the side without #676.
Rather than argue it from the report, I have merged main into the branch (f4dfa6d). git diff HEAD origin/main -- lib/ is now empty, so the next CodSpeed run compares identical lib/ on both sides and anything it still reports is instrument noise. Locally after the merge: 1635 tests pass and npm run lint is clean across all five stages.
I have not spent a manual re-run — the push re-runs the benchmarks on an aligned base, which is the better measurement. Acknowledging anything in the CodSpeed dashboard is a maintainer action, so I am leaving that to you.
Generated by Claude Code
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Correcting my previous comment: aligning the base did not clear CodSpeed. It is still red on f4dfa6d (-9.27%, same two benchmarks). My prediction there was wrong — but the result is more conclusive than the base-skew explanation was, not less.
After the merge, f4dfa6d differs from main (f07a030) by exactly this:
$ git diff f07a030 f4dfa6d --stat
test/alias.test.js | 236 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 236 insertions(+)
$ git diff f07a030 f4dfa6d -- lib/ benchmark/ package.json package-lock.json | wc -l
0
lib/, benchmark/, package.json and the lockfile are byte-identical on the two sides. CodSpeed is measuring the same code against itself and reporting a 9.27% difference, so the difference is the instrument, not the code. The report says as much in its own header: "Different runtime environments detected — some benchmarks with significant performance changes were compared across different runtime environments, which may affect the accuracy of the results."
alias-wildcard-scan: 100+1 wildcard + 1 exact in particular reports 1.5 KB → 2.7 KB, -46.84% — the identical figures it gave for 85d83be, a different commit. A reading that does not move when the commit does is pinned to the environment, not to the tree.
I have now spent the one re-run (Benchmarks run 35573756485). Whatever it returns, there is nothing in this PR to fix: there is no lib/ change to revert, tune or bisect. Acknowledging it in the CodSpeed dashboard is a maintainer action, so I am leaving that to you, and I will keep watching the PR until it merges or closes.
Generated by Claude Code
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|