Repository navigation
fix(resolver): keep RegExp restrictions in ResolverFactory cache key - #16054
Merged
Merged
Conversation
JSON.stringify serializes every RegExp as {}, so resolve options that
differ only in RegExp restrictions shared one cached resolver.
Closes #15826
Contributor
📦 Binary Size-limit
🙈 Size remains the same at 67.25MB |
Contributor
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
stormslowly
enabled auto-merge (squash)
October 12, 2026 06:37
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ResolverFactory.get()keys its string cache withJSON.stringify(resolveOptions), which serializes everyRegExpas{}. Resolve options that differ only in RegExprestrictions(e.g.[/\.css$/]vs[/\.js$/], or/x/vs/x/i) therefore got the same cached resolver, so whichever was created first won.withOptions()goes through the same cache and had the same problem.The cache key now serializes a
RegExpas{ regexp: String(value) }, which keeps both source and flags and cannot collide with a plain string restriction.Before:
get('normal', { restrictions: [/\.js$/] })after a[/\.css$/]lookup returned the CSS resolver and resolvedstyletoindex.css.After: each pattern gets its own resolver, and the JS one resolves to
index.js.Related links
Closes #15826
Checklist
configCases/resolver-factory/restriction-cache-key, which fails without the fix and covers different patterns, different flags,withOptions(), and that the same pattern still hits the cache)