Skip to content

perf: lazily resolve immutable asset info#38

Merged
chenjiahan merged 2 commits intomainfrom
chenjiahan/perf-lazy-immutable-asset-info
Apr 15, 2026
Merged

perf: lazily resolve immutable asset info#38
chenjiahan merged 2 commits intomainfrom
chenjiahan/perf-lazy-immutable-asset-info

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

This PR removes the per-request asset info map construction in dev middleware and resolves immutable asset metadata lazily for the matched asset only. This keeps the existing cache header behavior while avoiding compilation.getAssets() on the request hot path.

Related Links

Copilot AI review requested due to automatic review settings April 15, 2026 03:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes dev-middleware request handling by avoiding per-request asset info map creation and instead resolving immutable asset metadata only for the matched asset.

Changes:

  • Update getPaths to return the compilation object instead of precomputing an assetsInfo map.
  • Update filename resolution to lazily query compilation.getAsset(assetName)?.info?.immutable for immutable cache behavior.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
types/utils/getPaths.d.ts Updates typings to reflect getPaths returning compilation and removing assetsInfo.
src/utils/getPaths.js Stops building an assets info map on every request; returns compilation for later lookup.
src/utils/getFilenameFromUrl.js Switches immutable detection from prebuilt map to per-asset lazy lookup via compilation.getAsset.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/getFilenameFromUrl.js
@chenjiahan chenjiahan merged commit b4c7dfc into main Apr 15, 2026
5 checks passed
@chenjiahan chenjiahan deleted the chenjiahan/perf-lazy-immutable-asset-info branch April 15, 2026 05:21
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.

2 participants