next.js
7873aeaa - Perf: Simplify static metadata handling (#92630)

Commit
23 days ago
Perf: Simplify static metadata handling (#92630) ### What? Avoid running the generic `fillMetadataSegment(..., true)` path for static metadata routes. This PR adds a dedicated static metadata URL resolver, uses it from the existing TypeScript static call sites, and precomputes static metadata URLs in Turbopack loader tree codegen instead of waiting on `props.params` at runtime. ### Why? Static metadata files like `favicon.ico`, `icon.png`, and other static metadata images do not need request-time dynamic path interpolation. The old path reused logic that was designed to also support dynamic metadata routes, which meant extra route-regex work even when the final URL was already statically known apart from the existing `-` placeholder and route-group / parallel-route suffix semantics. ### How? - Added a static-only metadata URL helper in `get-metadata-route.ts` that: - normalizes app path segments, - replaces dynamic and catch-all segments with `-`, - preserves the existing metadata filename suffix logic for route groups and parallel routes. - Kept `fillMetadataSegment()` for dynamic metadata routes, but short-circuited the `isStatic` path to the new helper. - Switched TypeScript static metadata call sites to use the static helper directly: - build tree display path generation, - dev bundler static metadata mapping, - webpack static metadata image loader output. - Updated Turbopack static metadata codegen to emit the final static URL string instead of calling `fillMetadataSegment(..., true)` with `await props.params`. - Added focused coverage for: - root favicon, - static metadata under dynamic parents, - route-group / parallel-route suffix behavior, - unchanged dynamic metadata interpolation. Closes NEXT- Fixes # <!-- NEXT_JS_LLM_PR -->
Author
Parents
Loading