Files
Tim NeutkensandGitHub 3a48dd6a6c Optimize app page entry analysis (#96058)
## Summary

- Extract the invariant app-page handler into a shared runtime module
while keeping each generated route entry as a small wrapper.
- Keep the `interopDefault` binding in the route wrapper because the
injected Turbopack metadata loader tree references it, and pass the same
binding into the shared runtime.
- Add a focused 14-route navigation benchmark with static metadata
coverage.

## Why

Turbopack gives every generated app-page entry a route-specific identity
because its loader tree, page name, pathname, and module hooks are
injected into the template. This caused the full app-page handler to be
analyzed independently for every route.

A clean native trace of the benchmark shows app-page analysis CPU
falling from 1,619.39 ms across 14 route copies to 153.92 ms total
across 14 small wrappers plus one shared runtime, a 90.5% reduction.
Concurrency-corrected analysis time falls from 181.63 ms to 97.87 ms.
The post-change fixture also includes a static icon to cover the
injected metadata loader binding.

## Verification

- `pnpm test-dev-turbo
test/e2e/app-dir/metadata-icons/metadata-icons.test.ts`
- `pnpm test-start-turbo
test/production/adapter-config/adapter-config-export.test.ts`
- `pnpm test-dev-turbo
test/development/app-dir/app-page-entry-prefetch-performance/app-page-entry-prefetch-performance.test.ts`
- `pnpm test-dev-webpack
test/development/app-dir/app-page-entry-prefetch-performance/app-page-entry-prefetch-performance.test.ts`
- Clean native reproduction: the metadata suite failed with
`ReferenceError: interopDefault is not defined` before the binding fix
and passed all 9 cases afterward.

<!-- NEXT_JS_LLM -->
2026-07-24 11:55:49 +02:00
..