Turbopack: skip static/media writing for metadata files in dev mode - #89457
Turbopack: skip static/media writing for metadata files in dev mode#89457devjiwonchoi wants to merge 1 commit into
Conversation
In development mode, static metadata files (favicon.ico, opengraph-image.png, etc.) are now served directly from the app/ directory via the route handler, instead of being written to `/_next/static/media/`. This change introduces a new `MetadataStaticImageSource` that extracts image metadata (width, height) and computes a content hash for cache-busting, without creating a `StaticOutputAsset`. Production builds continue to work as before. Changes: - Add `MetadataStaticImageSource` for dev-mode metadata image handling - Add `create_metadata_module()` to `StructuredImageModuleType` - Pass `NextMode` through `AppPageLoaderTreeBuilder` to conditionally use the lightweight module in development
Merging this PR will not alter performance
Comparing Footnotes
|
Stats from current PR🔴 2 regressions, 1 improvement
📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles: **437 kB** → **432 kB** ✅ -4.89 kB81 files with content-based hashes (individual files not comparable between builds) Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📝 Changed Files (25 files)Files with changes:
View diffsapp-page-exp..ntime.dev.jsfailed to diffapp-page-exp..time.prod.jsfailed to diffapp-page-tur..ntime.dev.jsfailed to diffapp-page-tur..time.prod.jsfailed to diffapp-page-tur..ntime.dev.jsfailed to diffapp-page-tur..time.prod.jsfailed to diffapp-page.runtime.dev.jsfailed to diffapp-page.runtime.prod.jsfailed to diffapp-route-ex..ntime.dev.jsDiff too large to display app-route-ex..time.prod.jsDiff too large to display app-route-tu..ntime.dev.jsDiff too large to display app-route-tu..time.prod.jsDiff too large to display app-route-tu..ntime.dev.jsDiff too large to display app-route-tu..time.prod.jsDiff too large to display app-route.runtime.dev.jsDiff too large to display app-route.ru..time.prod.jsDiff too large to display pages-api-tu..ntime.dev.jsDiff too large to display pages-api-tu..time.prod.jsDiff too large to display pages-api.runtime.dev.jsDiff too large to display pages-api.ru..time.prod.jsDiff too large to display pages-turbo...ntime.dev.jsDiff too large to display pages-turbo...time.prod.jsDiff too large to display pages.runtime.dev.jsDiff too large to display pages.runtime.prod.jsDiff too large to display server.runtime.prod.jsDiff too large to display |
Summary
In development mode, static metadata files (favicon.ico, opengraph-image.png, etc.) are now served directly from the app/ directory via the route handler, instead of being written to
/_next/static/media/.This change introduces:
MetadataStaticImageSourcethat extracts image metadata (width, height) and computes a content hash for cache-busting, without creating aStaticOutputAssetcreate_metadata_module()method onStructuredImageModuleTypefor dev-mode metadata handlingNextModethroughAppPageLoaderTreeBuilderto conditionally use the lightweight module in developmentProduction builds continue to work as before, writing files to
/_next/static/media/.Test plan
pnpm test-dev-turbo test/e2e/app-dir/metadata/metadata.test.ts -t "should render icon"- passespnpm test-dev-turbo test/e2e/app-dir/metadata/metadata.test.ts -t "should have icons as route"- passespnpm test-dev-turbo test/e2e/app-dir/metadata/metadata.test.ts -t "should pick up opengraph-image"- passespnpm test-start-turbo test/e2e/app-dir/metadata/metadata.test.ts -t "should render icon"- passes (production mode still works)