Skip to content

perf: monomorphic ResolveRequest object literals (#445 backwards-compatible)#533

Closed
alexander-akait wants to merge 0 commit intomainfrom
claude/implement-pr445-perf-0SWZl
Closed

perf: monomorphic ResolveRequest object literals (#445 backwards-compatible)#533
alexander-akait wants to merge 0 commit intomainfrom
claude/implement-pr445-perf-0SWZl

Conversation

@alexander-akait
Copy link
Copy Markdown
Member

Re-implements the perf wins from PR #445 (constant-shape ResolveRequest
objects so V8 keeps a single hidden class on the resolver hot path)
without the breaking change for plugin authors that attach custom
properties directly to a request.

Each plugin now builds the new ResolveRequest as an explicit object
literal in a fixed property order. A new lib/util/cloneRequest.js
helper exports copyExtras(target, source) which copies any
non-canonical own string keys plus any symbol keys from the source
request, preserving the historical behavior of { ...request, ... }
for callers that pass through values via custom keys (e.g. webpack's
ResolverCachePlugin).

ParsePlugin keeps its public (source, requestOptions, target)
constructor; the partial overrides are applied via Object.assign
after the canonical literal so the { fullySpecified } use case used
by ResolverFactory does not transition the hidden class. MainFieldPlugin
keeps its alreadyTriedMainField Symbol-based recursion guard, set
after copyExtras so the current attempt's value always wins.

Adds a regression test in test/plugins.test.js that taps the resolve
hook to attach both a string-keyed and a Symbol-keyed property and
asserts both survive through the plugin chain to hooks.result.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 17, 2026

⚠️ No Changeset found

Latest commit: 42b6620

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 17, 2026

CLA Signed

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.66%. Comparing base (42b6620) to head (9d3549d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #533      +/-   ##
==========================================
+ Coverage   96.52%   96.66%   +0.13%     
==========================================
  Files          50       51       +1     
  Lines        2651     2726      +75     
  Branches      808      813       +5     
==========================================
+ Hits         2559     2635      +76     
+ Misses         77       76       -1     
  Partials       15       15              
Flag Coverage Δ
integration 96.66% <100.00%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 17, 2026

Merging this PR will degrade performance by 44.79%

⚠️ 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 regressed benchmark
✅ 58 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
concurrent-batch: Promise.all of 15 resolves (warm) 2.9 ms 5.3 ms -44.79%

Comparing claude/implement-pr445-perf-0SWZl (9d3549d) with main (3c4e574)

Open in CodSpeed

@alexander-akait alexander-akait force-pushed the claude/implement-pr445-perf-0SWZl branch from 9d3549d to 42b6620 Compare April 17, 2026 15:59
@alexander-akait alexander-akait deleted the claude/implement-pr445-perf-0SWZl branch April 17, 2026 16:07
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