vinext 1.0.0-beta.9 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (800) hide show
  1. package/README.md +150 -92
  2. package/THIRD_PARTY_LICENSES.md +25 -0
  3. package/dist/_virtual/_rolldown/runtime.js +25 -0
  4. package/dist/build/action-owner-manifest.d.ts +8 -9
  5. package/dist/build/action-owner-manifest.js +23 -5
  6. package/dist/build/assets-ignore.d.ts +3 -4
  7. package/dist/build/clean-output.d.ts +2 -3
  8. package/dist/build/client-build-config.d.ts +40 -12
  9. package/dist/build/client-build-config.js +76 -6
  10. package/dist/build/css-url-assets.d.ts +4 -5
  11. package/dist/build/css-url-assets.js +5 -2
  12. package/dist/build/google-fonts/build-url.d.ts +3 -4
  13. package/dist/build/google-fonts/fallback-metrics.d.ts +3 -4
  14. package/dist/build/google-fonts/find-font-files-in-css.d.ts +2 -3
  15. package/dist/build/google-fonts/font-metadata.d.ts +2 -3
  16. package/dist/build/google-fonts/get-axes.d.ts +2 -3
  17. package/dist/build/google-fonts/sort-variants.d.ts +2 -3
  18. package/dist/build/google-fonts/validate.d.ts +2 -3
  19. package/dist/build/google-fonts/validate.js +8 -4
  20. package/dist/build/inject-pregenerated-paths.d.ts +2 -3
  21. package/dist/build/inject-pregenerated-paths.js +16 -14
  22. package/dist/build/inline-css.d.ts +3 -4
  23. package/dist/build/layout-classification-types.d.ts +4 -5
  24. package/dist/build/layout-classification.d.ts +7 -8
  25. package/dist/build/lifecycle.d.ts +42 -0
  26. package/dist/build/lifecycle.js +253 -0
  27. package/dist/build/module-dependency-cache.d.ts +2 -3
  28. package/dist/build/next-client-runtime-manifests.d.ts +4 -5
  29. package/dist/build/nitro-route-rules.d.ts +6 -7
  30. package/dist/build/nitro-route-rules.js +1 -1
  31. package/dist/build/pages-client-assets-module.d.ts +4 -8
  32. package/dist/build/pages-client-assets-module.js +1 -13
  33. package/dist/build/precompress.d.ts +2 -3
  34. package/dist/build/prerender-cloudflare-loader.d.ts +4 -0
  35. package/dist/build/prerender-cloudflare-loader.js +49 -0
  36. package/dist/build/prerender-paths.d.ts +36 -11
  37. package/dist/build/prerender-paths.js +273 -97
  38. package/dist/build/prerender-phase.d.ts +2 -3
  39. package/dist/build/prerender-server-entry.js +11 -3
  40. package/dist/build/prerender-server-pool.d.ts +9 -6
  41. package/dist/build/prerender-server-pool.js +8 -5
  42. package/dist/build/prerender.d.ts +65 -15
  43. package/dist/build/prerender.js +139 -43
  44. package/dist/build/preview-credentials.d.ts +5 -6
  45. package/dist/build/preview-credentials.js +2 -2
  46. package/dist/build/public-dir-conflict.d.ts +5 -6
  47. package/dist/build/public-dir-conflict.js +2 -1
  48. package/dist/build/report.d.ts +24 -20
  49. package/dist/build/report.js +10 -2
  50. package/dist/build/route-classification-injector.d.ts +2 -3
  51. package/dist/build/route-classification-manifest.d.ts +5 -6
  52. package/dist/build/run-prerender.d.ts +11 -9
  53. package/dist/build/run-prerender.js +25 -16
  54. package/dist/build/server-entry.d.ts +4 -0
  55. package/dist/build/server-entry.js +28 -0
  56. package/dist/build/server-manifest.d.ts +8 -3
  57. package/dist/build/server-manifest.js +14 -2
  58. package/dist/build/ssr-manifest.d.ts +5 -6
  59. package/dist/build/standalone.d.ts +2 -3
  60. package/dist/build/standalone.js +2 -2
  61. package/dist/build/static-export.d.ts +6 -7
  62. package/dist/cache/cache-adapters-virtual.d.ts +60 -20
  63. package/dist/cache/cache-adapters-virtual.js +50 -7
  64. package/dist/check.d.ts +11 -10
  65. package/dist/check.js +467 -176
  66. package/dist/cli-args.d.ts +7 -16
  67. package/dist/cli-args.js +2 -45
  68. package/dist/cli-dev-config.d.ts +10 -7
  69. package/dist/cli-dev-config.js +160 -3
  70. package/dist/cli.js +124 -442
  71. package/dist/client/app-nav-failure-handler.d.ts +6 -7
  72. package/dist/client/client-rewrite-matcher.d.ts +2 -3
  73. package/dist/client/client-rewrites.d.ts +4 -5
  74. package/dist/client/dev-error-overlay-store.d.ts +13 -14
  75. package/dist/client/dev-error-overlay.d.ts +15 -15
  76. package/dist/client/dev-error-overlay.js +8 -5
  77. package/dist/client/instrumentation-client-inject.d.ts +3 -4
  78. package/dist/client/instrumentation-client-state.d.ts +5 -6
  79. package/dist/client/instrumentation-client.d.ts +3 -4
  80. package/dist/client/navigation-runtime.d.ts +21 -17
  81. package/dist/client/navigation-runtime.js +2 -1
  82. package/dist/client/pages-router-link-navigation.d.ts +4 -5
  83. package/dist/client/react-instance.d.ts +2 -3
  84. package/dist/client/validate-module-path.d.ts +2 -3
  85. package/dist/client/vinext-next-data.d.ts +7 -10
  86. package/dist/client/window-next.d.ts +4 -5
  87. package/dist/config/config-matchers.d.ts +16 -16
  88. package/dist/config/config-matchers.js +2 -4
  89. package/dist/config/dotenv.d.ts +3 -4
  90. package/dist/config/dotenv.js +2 -1
  91. package/dist/config/next-config.d.ts +31 -27
  92. package/dist/config/next-config.js +163 -16
  93. package/dist/config/prerender.d.ts +20 -16
  94. package/dist/config/prerender.js +10 -4
  95. package/dist/config/request-context.d.ts +5 -6
  96. package/dist/config/server-external-packages.d.ts +14 -3
  97. package/dist/config/server-external-packages.js +37 -3
  98. package/dist/config/tsconfig-paths.d.ts +3 -4
  99. package/dist/deps/.pnpm/ignore@5.3.2/deps/ignore/index.js +189 -0
  100. package/dist/deps/.pnpm/ua-parser-js@1.0.35/deps/ua-parser-js/src/ua-parser.js +1057 -0
  101. package/dist/entries/app-browser-entry.d.ts +4 -5
  102. package/dist/entries/app-browser-entry.js +1 -3
  103. package/dist/entries/app-rsc-entry.d.ts +10 -3
  104. package/dist/entries/app-rsc-entry.js +502 -51
  105. package/dist/entries/app-rsc-manifest.d.ts +4 -3
  106. package/dist/entries/app-rsc-manifest.js +26 -8
  107. package/dist/entries/app-ssr-entry.d.ts +2 -3
  108. package/dist/entries/app-ssr-entry.js +8 -1
  109. package/dist/entries/pages-client-entry.d.ts +3 -3
  110. package/dist/entries/pages-client-entry.js +17 -2
  111. package/dist/entries/pages-server-entry.d.ts +13 -3
  112. package/dist/entries/pages-server-entry.js +234 -33
  113. package/dist/entries/runtime-entry-module.d.ts +4 -5
  114. package/dist/image/image-adapters-virtual.d.ts +4 -5
  115. package/dist/index.d.ts +10 -11
  116. package/dist/index.js +711 -189
  117. package/dist/init-cloudflare.d.ts +26 -17
  118. package/dist/init-cloudflare.js +710 -102
  119. package/dist/init-platform.d.ts +26 -22
  120. package/dist/init-platform.js +85 -29
  121. package/dist/init.d.ts +19 -13
  122. package/dist/init.js +123 -41
  123. package/dist/plugins/action-owner-manifest.d.ts +3 -4
  124. package/dist/plugins/action-owner-manifest.js +10 -3
  125. package/dist/plugins/ast-scope.d.ts +10 -11
  126. package/dist/plugins/ast-scope.js +10 -22
  127. package/dist/plugins/ast-utils.d.ts +16 -29
  128. package/dist/plugins/ast-utils.js +27 -71
  129. package/dist/plugins/async-hooks-stub.d.ts +2 -3
  130. package/dist/plugins/client-reference-dedup.d.ts +4 -5
  131. package/dist/plugins/css-data-url.d.ts +2 -3
  132. package/dist/plugins/css-module-imports.d.ts +3 -4
  133. package/dist/plugins/css-module-imports.js +1 -1
  134. package/dist/plugins/dynamic-preload-metadata.d.ts +3 -4
  135. package/dist/plugins/dynamic-preload-metadata.js +55 -154
  136. package/dist/plugins/environment.d.ts +2 -3
  137. package/dist/plugins/extensionless-dynamic-import.d.ts +2 -3
  138. package/dist/plugins/extensionless-dynamic-import.js +6 -10
  139. package/dist/plugins/fonts.d.ts +10 -11
  140. package/dist/plugins/fonts.js +4 -3
  141. package/dist/plugins/ignore-dynamic-requests.d.ts +3 -4
  142. package/dist/plugins/ignore-dynamic-requests.js +60 -89
  143. package/dist/plugins/import-meta-url.d.ts +6 -7
  144. package/dist/plugins/import-meta-url.js +31 -43
  145. package/dist/plugins/instrumentation-client.d.ts +3 -3
  146. package/dist/plugins/instrumentation-client.js +46 -10
  147. package/dist/plugins/middleware-export-validation.d.ts +3 -4
  148. package/dist/plugins/middleware-export-validation.js +3 -3
  149. package/dist/plugins/middleware-server-only.d.ts +2 -3
  150. package/dist/plugins/og-asset-ownership.d.ts +3 -4
  151. package/dist/plugins/og-assets.d.ts +4 -5
  152. package/dist/plugins/og-assets.js +32 -13
  153. package/dist/plugins/og-harfbuzz.d.ts +24 -0
  154. package/dist/plugins/og-harfbuzz.js +260 -0
  155. package/dist/plugins/optimize-imports.d.ts +7 -7
  156. package/dist/plugins/optimize-imports.js +32 -44
  157. package/dist/plugins/pages-node-externals.d.ts +2 -3
  158. package/dist/plugins/pages-node-externals.js +6 -11
  159. package/dist/plugins/postcss.d.ts +8 -4
  160. package/dist/plugins/postcss.js +1 -1
  161. package/dist/plugins/remove-console.d.ts +2 -3
  162. package/dist/plugins/remove-console.js +0 -1
  163. package/dist/plugins/require-condition-resolution.d.ts +3 -4
  164. package/dist/plugins/require-condition-resolution.js +17 -18
  165. package/dist/plugins/require-context.d.ts +2 -3
  166. package/dist/plugins/require-context.js +13 -21
  167. package/dist/plugins/rsc-client-reference-loaders.d.ts +2 -3
  168. package/dist/plugins/rsc-client-shim-excludes.d.ts +4 -5
  169. package/dist/plugins/rsc-client-shim-excludes.js +1 -0
  170. package/dist/plugins/rsc-reference-validation-normalizer.d.ts +2 -3
  171. package/dist/plugins/sass.d.ts +7 -8
  172. package/dist/plugins/sass.js +7 -4
  173. package/dist/plugins/server-externals-manifest.d.ts +2 -3
  174. package/dist/plugins/strip-server-exports.d.ts +5 -6
  175. package/dist/plugins/strip-server-exports.js +1 -1
  176. package/dist/plugins/styled-jsx.d.ts +2 -3
  177. package/dist/plugins/styled-jsx.js +7 -7
  178. package/dist/plugins/transform-cache.d.ts +2 -3
  179. package/dist/plugins/transform-result.d.ts +3 -4
  180. package/dist/plugins/transitive-externals.d.ts +2 -3
  181. package/dist/plugins/typeof-window.d.ts +6 -7
  182. package/dist/plugins/typeof-window.js +30 -31
  183. package/dist/plugins/use-cache-callable.d.ts +2 -5
  184. package/dist/plugins/use-cache-callable.js +43 -22
  185. package/dist/plugins/wasm-module-import.d.ts +2 -3
  186. package/dist/plugins/worker-image-imports.d.ts +2 -3
  187. package/dist/plugins/worker-image-imports.js +6 -8
  188. package/dist/routing/app-route-graph.d.ts +19 -19
  189. package/dist/routing/app-route-graph.js +3 -2
  190. package/dist/routing/app-router.d.ts +19 -6
  191. package/dist/routing/app-router.js +24 -2
  192. package/dist/routing/file-matcher.d.ts +9 -10
  193. package/dist/routing/pages-router.d.ts +6 -6
  194. package/dist/routing/pages-router.js +1 -1
  195. package/dist/routing/route-matching.d.ts +4 -5
  196. package/dist/routing/route-matching.js +4 -2
  197. package/dist/routing/route-pattern.d.ts +13 -14
  198. package/dist/routing/route-trie.d.ts +5 -6
  199. package/dist/routing/route-validation.d.ts +3 -4
  200. package/dist/routing/route-validation.js +12 -11
  201. package/dist/routing/utils.d.ts +13 -14
  202. package/dist/server/accept-encoding.d.ts +9 -10
  203. package/dist/server/api-handler.d.ts +2 -3
  204. package/dist/server/api-handler.js +9 -6
  205. package/dist/server/app-action-forwarding.d.ts +3 -4
  206. package/dist/server/app-action-forwarding.js +1 -1
  207. package/dist/server/app-action-request.d.ts +2 -3
  208. package/dist/server/app-bfcache-id.d.ts +3 -4
  209. package/dist/server/app-bfcache-identity.d.ts +8 -9
  210. package/dist/server/app-browser-action-result.d.ts +15 -16
  211. package/dist/server/app-browser-client-reuse-manifest.d.ts +2 -3
  212. package/dist/server/app-browser-entry.js +87 -34
  213. package/dist/server/app-browser-error.d.ts +5 -6
  214. package/dist/server/app-browser-error.js +9 -3
  215. package/dist/server/app-browser-history-controller.d.ts +4 -5
  216. package/dist/server/app-browser-hydration.d.ts +16 -6
  217. package/dist/server/app-browser-hydration.js +14 -1
  218. package/dist/server/app-browser-interception-context.d.ts +3 -4
  219. package/dist/server/app-browser-mpa-navigation.d.ts +4 -5
  220. package/dist/server/app-browser-navigation-abort.d.ts +3 -4
  221. package/dist/server/app-browser-navigation-controller.d.ts +8 -8
  222. package/dist/server/app-browser-navigation-controller.js +8 -4
  223. package/dist/server/app-browser-navigation-response.d.ts +2 -3
  224. package/dist/server/app-browser-popstate.d.ts +4 -5
  225. package/dist/server/app-browser-prefetch-response.d.ts +5 -6
  226. package/dist/server/app-browser-rsc-redirect.d.ts +4 -5
  227. package/dist/server/app-browser-server-action-client.d.ts +7 -6
  228. package/dist/server/app-browser-server-action-client.js +9 -5
  229. package/dist/server/app-browser-server-action-navigation.d.ts +2 -3
  230. package/dist/server/app-browser-state.d.ts +17 -17
  231. package/dist/server/app-browser-state.js +6 -2
  232. package/dist/server/app-browser-stream.d.ts +4 -5
  233. package/dist/server/app-browser-stream.js +8 -6
  234. package/dist/server/app-browser-supplemental-refresh.d.ts +11 -12
  235. package/dist/server/app-browser-visible-commit.d.ts +6 -7
  236. package/dist/server/app-client-reference-preloader.d.ts +2 -3
  237. package/dist/server/app-elements-wire-key.d.ts +25 -0
  238. package/dist/server/app-elements-wire-key.js +69 -0
  239. package/dist/server/app-elements-wire.d.ts +34 -53
  240. package/dist/server/app-elements-wire.js +4 -75
  241. package/dist/server/app-elements.d.ts +5 -5
  242. package/dist/server/app-elements.js +1 -1
  243. package/dist/server/app-fallback-renderer.d.ts +4 -4
  244. package/dist/server/app-fallback-renderer.js +6 -6
  245. package/dist/server/app-fetch-tracing.d.ts +15 -0
  246. package/dist/server/app-fetch-tracing.js +38 -0
  247. package/dist/server/app-history-state.d.ts +26 -27
  248. package/dist/server/app-history-state.js +19 -11
  249. package/dist/server/app-hook-warning-suppression.d.ts +2 -3
  250. package/dist/server/app-hydration-cache-publication.d.ts +3 -4
  251. package/dist/server/app-inline-css-client.d.ts +3 -4
  252. package/dist/server/app-interception-context-header.d.ts +2 -3
  253. package/dist/server/app-layout-param-observation.d.ts +7 -8
  254. package/dist/server/app-metadata-tracing.d.ts +12 -0
  255. package/dist/server/app-metadata-tracing.js +17 -0
  256. package/dist/server/app-middleware.d.ts +7 -7
  257. package/dist/server/app-middleware.js +2 -3
  258. package/dist/server/app-mounted-slots-header.d.ts +2 -3
  259. package/dist/server/app-mounted-slots-header.js +2 -2
  260. package/dist/server/app-optimistic-routing.d.ts +10 -11
  261. package/dist/server/app-optimistic-routing.js +3 -2
  262. package/dist/server/app-page-boundary-render.d.ts +6 -6
  263. package/dist/server/app-page-boundary-render.js +10 -4
  264. package/dist/server/app-page-boundary.d.ts +9 -10
  265. package/dist/server/app-page-boundary.js +1 -1
  266. package/dist/server/app-page-cache-finalizer.d.ts +18 -9
  267. package/dist/server/app-page-cache-finalizer.js +51 -16
  268. package/dist/server/app-page-cache-render.d.ts +8 -5
  269. package/dist/server/app-page-cache-render.js +22 -5
  270. package/dist/server/app-page-cache.d.ts +28 -9
  271. package/dist/server/app-page-cache.js +95 -24
  272. package/dist/server/app-page-dispatch.d.ts +34 -12
  273. package/dist/server/app-page-dispatch.js +181 -64
  274. package/dist/server/app-page-element-builder.d.ts +13 -11
  275. package/dist/server/app-page-element-builder.js +104 -61
  276. package/dist/server/app-page-execution.d.ts +14 -14
  277. package/dist/server/app-page-execution.js +11 -7
  278. package/dist/server/app-page-head.d.ts +19 -16
  279. package/dist/server/app-page-head.js +25 -25
  280. package/dist/server/app-page-http-access-fallback-metadata.d.ts +6 -5
  281. package/dist/server/app-page-http-access-fallback-metadata.js +9 -2
  282. package/dist/server/app-page-method.d.ts +5 -11
  283. package/dist/server/app-page-method.js +2 -9
  284. package/dist/server/app-page-params.d.ts +5 -6
  285. package/dist/server/app-page-ppr-runtime.d.ts +2 -2
  286. package/dist/server/app-page-probe.d.ts +5 -6
  287. package/dist/server/app-page-probe.js +5 -4
  288. package/dist/server/app-page-render-identity.d.ts +4 -5
  289. package/dist/server/app-page-render-observation.d.ts +8 -9
  290. package/dist/server/app-page-render-observation.js +1 -1
  291. package/dist/server/app-page-render.d.ts +41 -6
  292. package/dist/server/app-page-render.js +171 -25
  293. package/dist/server/app-page-request.d.ts +10 -9
  294. package/dist/server/app-page-request.js +16 -12
  295. package/dist/server/app-page-response.d.ts +20 -9
  296. package/dist/server/app-page-response.js +30 -12
  297. package/dist/server/app-page-route-wiring.d.ts +15 -15
  298. package/dist/server/app-page-route-wiring.js +31 -24
  299. package/dist/server/app-page-search-params-observation.d.ts +26 -5
  300. package/dist/server/app-page-search-params-observation.js +42 -6
  301. package/dist/server/app-page-segment-plan.d.ts +2 -3
  302. package/dist/server/app-page-segment-state.d.ts +11 -12
  303. package/dist/server/app-page-stream.d.ts +27 -11
  304. package/dist/server/app-page-stream.js +34 -6
  305. package/dist/server/app-page-tracing.d.ts +33 -0
  306. package/dist/server/app-page-tracing.js +49 -0
  307. package/dist/server/app-pages-bridge.d.ts +6 -6
  308. package/dist/server/app-pages-bridge.js +17 -4
  309. package/dist/server/app-post-middleware-context.d.ts +2 -3
  310. package/dist/server/app-ppr-fallback-shell-render.d.ts +3 -4
  311. package/dist/server/app-ppr-fallback-shell-render.js +3 -2
  312. package/dist/server/app-ppr-fallback-shell.d.ts +6 -7
  313. package/dist/server/app-prerender-endpoints.d.ts +5 -5
  314. package/dist/server/app-prerender-endpoints.js +3 -1
  315. package/dist/server/app-prerender-static-params.d.ts +15 -7
  316. package/dist/server/app-prerender-static-params.js +24 -9
  317. package/dist/server/app-render-dependency.d.ts +14 -13
  318. package/dist/server/app-render-dependency.js +5 -1
  319. package/dist/server/app-request-context.d.ts +3 -4
  320. package/dist/server/app-request-stage-context.d.ts +5 -0
  321. package/dist/server/app-request-stage-context.js +11 -0
  322. package/dist/server/app-request-stage-dispatch.d.ts +25 -0
  323. package/dist/server/app-request-stage-dispatch.js +54 -0
  324. package/dist/server/app-request-stage-independent-entry.d.ts +8 -0
  325. package/dist/server/app-request-stage-independent-entry.js +115 -0
  326. package/dist/server/app-response-header-provenance.d.ts +13 -7
  327. package/dist/server/app-response-header-provenance.js +34 -1
  328. package/dist/server/app-response-stage-entry.d.ts +9 -0
  329. package/dist/server/app-response-stage-entry.js +87 -0
  330. package/dist/server/app-route-handler-cache.d.ts +2 -3
  331. package/dist/server/app-route-handler-cache.js +46 -34
  332. package/dist/server/app-route-handler-dispatch.d.ts +3 -3
  333. package/dist/server/app-route-handler-dispatch.js +68 -54
  334. package/dist/server/app-route-handler-execution.d.ts +17 -13
  335. package/dist/server/app-route-handler-execution.js +69 -18
  336. package/dist/server/app-route-handler-middleware-context.d.ts +8 -0
  337. package/dist/server/app-route-handler-middleware-context.js +15 -0
  338. package/dist/server/app-route-handler-policy.d.ts +11 -11
  339. package/dist/server/app-route-handler-response.d.ts +9 -10
  340. package/dist/server/app-route-handler-response.js +2 -0
  341. package/dist/server/app-route-handler-runtime.d.ts +9 -10
  342. package/dist/server/app-route-handler-runtime.js +20 -16
  343. package/dist/server/app-route-module-loader.d.ts +6 -7
  344. package/dist/server/app-route-request-built-ins.d.ts +3 -4
  345. package/dist/server/app-route-tree-prefetch.d.ts +6 -7
  346. package/dist/server/app-route-tree-prefetch.js +2 -1
  347. package/dist/server/app-router-entry.d.ts +2 -0
  348. package/dist/server/app-router-entry.js +28 -8
  349. package/dist/server/app-rsc-cache-busting.d.ts +34 -27
  350. package/dist/server/app-rsc-cache-busting.js +14 -2
  351. package/dist/server/app-rsc-combined-handler.d.ts +9 -0
  352. package/dist/server/app-rsc-combined-handler.js +11 -0
  353. package/dist/server/app-rsc-embedded-chunks.d.ts +6 -7
  354. package/dist/server/app-rsc-error-handler.d.ts +12 -6
  355. package/dist/server/app-rsc-error-handler.js +15 -6
  356. package/dist/server/app-rsc-errors.d.ts +12 -9
  357. package/dist/server/app-rsc-errors.js +15 -13
  358. package/dist/server/app-rsc-handler.d.ts +31 -6
  359. package/dist/server/app-rsc-handler.js +411 -61
  360. package/dist/server/app-rsc-redirect-flight.d.ts +4 -5
  361. package/dist/server/app-rsc-render-mode.d.ts +8 -9
  362. package/dist/server/app-rsc-request-normalization.d.ts +3 -3
  363. package/dist/server/app-rsc-request-normalization.js +2 -1
  364. package/dist/server/app-rsc-response-finalizer.d.ts +8 -5
  365. package/dist/server/app-rsc-response-finalizer.js +6 -6
  366. package/dist/server/app-rsc-response-stage.d.ts +6 -0
  367. package/dist/server/app-rsc-response-stage.js +251 -0
  368. package/dist/server/app-rsc-route-matching.d.ts +3 -4
  369. package/dist/server/app-rsc-route-matching.js +3 -2
  370. package/dist/server/app-rsc-state-fingerprint.d.ts +3 -4
  371. package/dist/server/app-rsc-vary.d.ts +16 -0
  372. package/dist/server/app-rsc-vary.js +31 -0
  373. package/dist/server/app-segment-config.d.ts +119 -7
  374. package/dist/server/app-segment-config.js +242 -2
  375. package/dist/server/app-server-action-execution.d.ts +16 -12
  376. package/dist/server/app-server-action-execution.js +86 -33
  377. package/dist/server/app-ssr-entry.d.ts +14 -4
  378. package/dist/server/app-ssr-entry.js +61 -14
  379. package/dist/server/app-ssr-error-meta.d.ts +3 -4
  380. package/dist/server/app-ssr-error-meta.js +2 -1
  381. package/dist/server/app-ssr-router-instance.d.ts +2 -3
  382. package/dist/server/app-ssr-search-params-gate.d.ts +20 -0
  383. package/dist/server/app-ssr-search-params-gate.js +54 -0
  384. package/dist/server/app-ssr-stream.d.ts +13 -9
  385. package/dist/server/app-ssr-stream.js +33 -7
  386. package/dist/server/app-static-generation.d.ts +4 -5
  387. package/dist/server/app-visited-response-cache.d.ts +11 -12
  388. package/dist/server/app-visited-response-cache.js +2 -2
  389. package/dist/server/app-worker-stages.d.ts +112 -0
  390. package/dist/server/app-worker-stages.js +105 -0
  391. package/dist/server/artifact-compatibility.d.ts +11 -12
  392. package/dist/server/before-interactive-head.d.ts +2 -3
  393. package/dist/server/bfcache-identity.d.ts +7 -8
  394. package/dist/server/cache-control.d.ts +35 -13
  395. package/dist/server/cache-control.js +71 -5
  396. package/dist/server/cache-headers.d.ts +3 -4
  397. package/dist/server/cache-proof.d.ts +75 -70
  398. package/dist/server/cache-proof.js +9 -1
  399. package/dist/server/cacheability-limits.d.ts +4 -5
  400. package/dist/server/cacheability-limits.js +2 -2
  401. package/dist/server/cacheability-manifest.d.ts +42 -16
  402. package/dist/server/cacheability-manifest.js +60 -10
  403. package/dist/server/cacheability-request.d.ts +37 -8
  404. package/dist/server/cacheability-request.js +159 -57
  405. package/dist/server/client-reuse-manifest.d.ts +17 -18
  406. package/dist/server/client-reuse-manifest.js +2 -2
  407. package/dist/server/client-trace-metadata.d.ts +9 -6
  408. package/dist/server/client-trace-metadata.js +27 -15
  409. package/dist/server/cloudflare-workers-tracing.d.ts +1 -0
  410. package/dist/server/cloudflare-workers-tracing.js +8 -0
  411. package/dist/server/config-headers.d.ts +19 -5
  412. package/dist/server/config-headers.js +25 -11
  413. package/dist/server/cookie-utils.d.ts +2 -3
  414. package/dist/server/csp.d.ts +5 -6
  415. package/dist/server/default-global-error-module.d.ts +2 -3
  416. package/dist/server/default-global-not-found-module.d.ts +2 -3
  417. package/dist/server/default-not-found-module.d.ts +2 -3
  418. package/dist/server/defer-until-stream-consumed.d.ts +2 -3
  419. package/dist/server/defer-until-stream-consumed.js +2 -1
  420. package/dist/server/dev-initial-server-error.d.ts +3 -4
  421. package/dist/server/dev-initial-server-error.js +2 -1
  422. package/dist/server/dev-lockfile.d.ts +7 -8
  423. package/dist/server/dev-lockfile.js +4 -1
  424. package/dist/server/dev-module-runner.d.ts +2 -3
  425. package/dist/server/dev-origin-check.d.ts +5 -6
  426. package/dist/server/dev-route-files.d.ts +2 -3
  427. package/dist/server/dev-server.d.ts +4 -5
  428. package/dist/server/dev-server.js +130 -61
  429. package/dist/server/dev-stack-sourcemap.d.ts +7 -7
  430. package/dist/server/dev-stack-sourcemap.js +1 -1
  431. package/dist/server/document-initial-head.d.ts +3 -4
  432. package/dist/server/edge-api-runtime.d.ts +4 -5
  433. package/dist/server/fetch-handler.d.ts +3 -2
  434. package/dist/server/fetch-handler.js +3 -18
  435. package/dist/server/file-based-metadata.d.ts +2 -3
  436. package/dist/server/framework-tracer.d.ts +46 -0
  437. package/dist/server/framework-tracer.js +125 -0
  438. package/dist/server/fully-buffered-response.d.ts +11 -0
  439. package/dist/server/fully-buffered-response.js +19 -0
  440. package/dist/server/headers.d.ts +54 -61
  441. package/dist/server/headers.js +18 -31
  442. package/dist/server/html.d.ts +6 -27
  443. package/dist/server/html.js +16 -1
  444. package/dist/server/http-conditional.d.ts +5 -6
  445. package/dist/server/http-date.d.ts +2 -3
  446. package/dist/server/http-error-responses.d.ts +9 -10
  447. package/dist/server/http-range.d.ts +4 -5
  448. package/dist/server/hybrid-route-priority.d.ts +4 -5
  449. package/dist/server/image-optimization.d.ts +20 -21
  450. package/dist/server/implicit-tags.d.ts +3 -4
  451. package/dist/server/instrumentation-runtime.d.ts +17 -21
  452. package/dist/server/instrumentation-runtime.js +26 -8
  453. package/dist/server/instrumentation.d.ts +26 -30
  454. package/dist/server/instrumentation.js +18 -23
  455. package/dist/server/isr-cache.d.ts +28 -27
  456. package/dist/server/isr-cache.js +18 -70
  457. package/dist/server/isr-decision.d.ts +4 -4
  458. package/dist/server/metadata-route-build-data.d.ts +4 -5
  459. package/dist/server/metadata-route-cache-policy.d.ts +2 -3
  460. package/dist/server/metadata-route-response.d.ts +7 -7
  461. package/dist/server/metadata-route-response.js +68 -2
  462. package/dist/server/metadata-routes.d.ts +18 -19
  463. package/dist/server/middleware-matcher-pattern.d.ts +6 -7
  464. package/dist/server/middleware-matcher.d.ts +6 -7
  465. package/dist/server/middleware-path-to-regexp.d.ts +6 -7
  466. package/dist/server/middleware-path-to-regexp.js +11 -9
  467. package/dist/server/middleware-response-headers.d.ts +3 -4
  468. package/dist/server/middleware-runtime.d.ts +7 -8
  469. package/dist/server/middleware-runtime.js +36 -7
  470. package/dist/server/middleware.d.ts +5 -5
  471. package/dist/server/multi-stage.d.ts +141 -0
  472. package/dist/server/multi-stage.js +8 -0
  473. package/dist/server/navigation-planner.d.ts +26 -26
  474. package/dist/server/navigation-trace.d.ts +11 -12
  475. package/dist/server/next-error-digest.d.ts +4 -5
  476. package/dist/server/normalize-path.d.ts +5 -6
  477. package/dist/server/open-redirect.d.ts +2 -3
  478. package/dist/server/opentelemetry-api.d.ts +59 -0
  479. package/dist/server/opentelemetry-api.js +53 -0
  480. package/dist/server/opentelemetry-tracing.d.ts +5 -0
  481. package/dist/server/opentelemetry-tracing.js +83 -0
  482. package/dist/server/operation-token.d.ts +11 -12
  483. package/dist/server/otel-tracer-extension.d.ts +7 -9
  484. package/dist/server/otel-tracer-extension.js +37 -36
  485. package/dist/server/pages-api-route.d.ts +5 -4
  486. package/dist/server/pages-api-route.js +20 -7
  487. package/dist/server/pages-asset-tags.d.ts +6 -6
  488. package/dist/server/pages-asset-tags.js +37 -2
  489. package/dist/server/pages-body-parser-config.d.ts +4 -5
  490. package/dist/server/pages-body-parser-config.js +4 -4
  491. package/dist/server/pages-client-assets.d.ts +11 -5
  492. package/dist/server/pages-data-route.d.ts +11 -12
  493. package/dist/server/pages-data-route.js +1 -1
  494. package/dist/server/pages-default-404.d.ts +3 -4
  495. package/dist/server/pages-dev-hydration.d.ts +9 -4
  496. package/dist/server/pages-dev-hydration.js +19 -7
  497. package/dist/server/pages-dev-module-url.d.ts +3 -4
  498. package/dist/server/pages-dev-stylesheets.d.ts +5 -6
  499. package/dist/server/pages-document-asset-props.d.ts +6 -7
  500. package/dist/server/pages-document-initial-props.d.ts +5 -5
  501. package/dist/server/pages-document-initial-props.js +4 -2
  502. package/dist/server/pages-execution-tracing.d.ts +40 -0
  503. package/dist/server/pages-execution-tracing.js +80 -0
  504. package/dist/server/pages-get-initial-props.d.ts +9 -10
  505. package/dist/server/pages-i18n.d.ts +8 -8
  506. package/dist/server/pages-media-type.d.ts +4 -5
  507. package/dist/server/pages-node-compat.d.ts +11 -10
  508. package/dist/server/pages-node-compat.js +12 -4
  509. package/dist/server/pages-page-data.d.ts +18 -19
  510. package/dist/server/pages-page-data.js +11 -10
  511. package/dist/server/pages-page-handler.d.ts +7 -6
  512. package/dist/server/pages-page-handler.js +77 -39
  513. package/dist/server/pages-page-method.d.ts +2 -3
  514. package/dist/server/pages-page-response.d.ts +14 -10
  515. package/dist/server/pages-page-response.js +49 -31
  516. package/dist/server/pages-preview.d.ts +10 -11
  517. package/dist/server/pages-readiness.d.ts +2 -3
  518. package/dist/server/pages-request-pipeline.d.ts +14 -12
  519. package/dist/server/pages-request-pipeline.js +60 -30
  520. package/dist/server/pages-request-stage-entry.d.ts +23 -0
  521. package/dist/server/pages-request-stage-entry.js +314 -0
  522. package/dist/server/pages-response-stage-entry.d.ts +11 -0
  523. package/dist/server/pages-response-stage-entry.js +106 -0
  524. package/dist/server/pages-response-stage.d.ts +31 -0
  525. package/dist/server/pages-response-stage.js +49 -0
  526. package/dist/server/pages-revalidate.d.ts +3 -4
  527. package/dist/server/pages-revalidate.js +9 -4
  528. package/dist/server/pages-route-data-kind.d.ts +18 -0
  529. package/dist/server/pages-route-data-kind.js +11 -0
  530. package/dist/server/pages-router-entry.d.ts +1 -25
  531. package/dist/server/pages-router-entry.js +35 -148
  532. package/dist/server/pages-serializable-props.d.ts +3 -4
  533. package/dist/server/pregenerated-concrete-paths.d.ts +9 -7
  534. package/dist/server/pregenerated-concrete-paths.js +12 -6
  535. package/dist/server/prerender-cache-life-header.d.ts +3 -4
  536. package/dist/server/prerender-manifest.d.ts +11 -11
  537. package/dist/server/prerender-manifest.js +6 -3
  538. package/dist/server/prerender-route-params.d.ts +16 -9
  539. package/dist/server/prerender-route-params.js +18 -3
  540. package/dist/server/prerender-work-unit-setup.d.ts +2 -3
  541. package/dist/server/prerender-work-unit-setup.js +5 -5
  542. package/dist/server/prod-server.d.ts +12 -9
  543. package/dist/server/prod-server.js +124 -31
  544. package/dist/server/proxy-trust.d.ts +5 -6
  545. package/dist/server/request-log.d.ts +3 -4
  546. package/dist/server/request-pipeline.d.ts +16 -16
  547. package/dist/server/request-pipeline.js +7 -2
  548. package/dist/server/request-stage.d.ts +5 -0
  549. package/dist/server/request-stage.js +7 -0
  550. package/dist/server/request-tracing.d.ts +22 -0
  551. package/dist/server/request-tracing.js +180 -0
  552. package/dist/server/response-stage-cacheability.d.ts +37 -0
  553. package/dist/server/response-stage-cacheability.js +55 -0
  554. package/dist/server/response-stage-policy.d.ts +23 -0
  555. package/dist/server/response-stage-policy.js +89 -0
  556. package/dist/server/response-stage.d.ts +5 -0
  557. package/dist/server/response-stage.js +7 -0
  558. package/dist/server/response-start-tracing.d.ts +14 -0
  559. package/dist/server/response-start-tracing.js +80 -0
  560. package/dist/server/revalidation-host.d.ts +2 -3
  561. package/dist/server/revalidation-host.js +1 -1
  562. package/dist/server/revalidation-request.d.ts +8 -0
  563. package/dist/server/revalidation-request.js +37 -0
  564. package/dist/server/rsc-completion-metadata.d.ts +6 -7
  565. package/dist/server/rsc-stream-hints.d.ts +18 -7
  566. package/dist/server/rsc-stream-hints.js +70 -35
  567. package/dist/server/seed-cache.d.ts +2 -3
  568. package/dist/server/seed-cache.js +8 -7
  569. package/dist/server/server-action-not-found.d.ts +5 -6
  570. package/dist/server/server-globals.d.ts +2 -3
  571. package/dist/server/skip-cache-proof.d.ts +4 -4
  572. package/dist/server/socket-error-backstop.d.ts +5 -6
  573. package/dist/server/socket-error-backstop.js +1 -1
  574. package/dist/server/static-file-cache.d.ts +5 -6
  575. package/dist/server/static-file-cache.js +9 -7
  576. package/dist/server/static-file-signal.d.ts +9 -6
  577. package/dist/server/static-file-signal.js +51 -2
  578. package/dist/server/static-layout-client-reuse-proof.d.ts +4 -5
  579. package/dist/server/streaming-metadata.d.ts +2 -3
  580. package/dist/server/tracer.d.ts +5 -0
  581. package/dist/server/tracer.js +13 -0
  582. package/dist/server/worker-prerender-discovery.d.ts +5 -6
  583. package/dist/server/worker-revalidation-context.d.ts +2 -3
  584. package/dist/server/worker-revalidation-context.js +5 -5
  585. package/dist/server/worker-stages.d.ts +43 -0
  586. package/dist/server/worker-stages.js +25 -0
  587. package/dist/server/worker-utils.d.ts +5 -6
  588. package/dist/server/worker-utils.js +2 -1
  589. package/dist/server/workers-tracing.d.ts +17 -0
  590. package/dist/server/workers-tracing.js +27 -0
  591. package/dist/shims/amp.d.ts +3 -4
  592. package/dist/shims/app-router-scroll-state.d.ts +9 -10
  593. package/dist/shims/app-router-scroll.d.ts +4 -5
  594. package/dist/shims/app-router-scroll.js +2 -1
  595. package/dist/shims/app.d.ts +5 -6
  596. package/dist/shims/before-interactive-context.d.ts +5 -6
  597. package/dist/shims/cache-callable-runtime.d.ts +44 -4
  598. package/dist/shims/cache-callable-runtime.js +168 -8
  599. package/dist/shims/cache-for-request.d.ts +2 -3
  600. package/dist/shims/cache-handler.d.ts +33 -20
  601. package/dist/shims/cache-handler.js +61 -2
  602. package/dist/shims/cache-request-state.d.ts +28 -29
  603. package/dist/shims/cache-runtime.d.ts +23 -21
  604. package/dist/shims/cache-runtime.js +107 -27
  605. package/dist/shims/cache.d.ts +15 -15
  606. package/dist/shims/cache.js +15 -13
  607. package/dist/shims/cacheability-classification.d.ts +49 -28
  608. package/dist/shims/cacheability-classification.js +27 -12
  609. package/dist/shims/cdn-cache-state.d.ts +13 -0
  610. package/dist/shims/cdn-cache-state.js +23 -0
  611. package/dist/shims/cdn-cache.d.ts +50 -21
  612. package/dist/shims/cdn-cache.js +15 -38
  613. package/dist/shims/client-hook-error.d.ts +3 -4
  614. package/dist/shims/client-locale.d.ts +2 -3
  615. package/dist/shims/client-page-root.d.ts +24 -0
  616. package/dist/shims/client-page-root.js +121 -0
  617. package/dist/shims/compat-router.d.ts +2 -3
  618. package/dist/shims/config.d.ts +3 -4
  619. package/dist/shims/constants.d.ts +73 -74
  620. package/dist/shims/constants.js +1 -1
  621. package/dist/shims/default-not-found.d.ts +2 -3
  622. package/dist/shims/document.d.ts +9 -9
  623. package/dist/shims/dynamic-preload-chunks.d.ts +2 -3
  624. package/dist/shims/dynamic-preload-chunks.js +17 -13
  625. package/dist/shims/dynamic.d.ts +3 -3
  626. package/dist/shims/error-boundary-navigation.d.ts +3 -4
  627. package/dist/shims/error-boundary.d.ts +17 -18
  628. package/dist/shims/error-boundary.js +17 -11
  629. package/dist/shims/error.d.ts +4 -4
  630. package/dist/shims/error.react-server.d.ts +3 -4
  631. package/dist/shims/fetch-cache.d.ts +22 -22
  632. package/dist/shims/fetch-cache.js +42 -17
  633. package/dist/shims/font-google-base.d.ts +9 -9
  634. package/dist/shims/font-google-base.js +2 -1
  635. package/dist/shims/font-local.d.ts +3 -3
  636. package/dist/shims/font-local.js +1 -1
  637. package/dist/shims/font-utils.d.ts +14 -15
  638. package/dist/shims/form.d.ts +2 -2
  639. package/dist/shims/form.js +10 -7
  640. package/dist/shims/hash-scroll.d.ts +5 -6
  641. package/dist/shims/head-state.d.ts +4 -5
  642. package/dist/shims/head.d.ts +16 -16
  643. package/dist/shims/head.js +5 -4
  644. package/dist/shims/headers.d.ts +67 -33
  645. package/dist/shims/headers.js +93 -6
  646. package/dist/shims/i18n-context.d.ts +5 -6
  647. package/dist/shims/i18n-state.d.ts +4 -5
  648. package/dist/shims/image-config.d.ts +5 -6
  649. package/dist/shims/image-config.js +2 -0
  650. package/dist/shims/image.d.ts +5 -5
  651. package/dist/shims/image.js +12 -8
  652. package/dist/shims/internal/als-registry.d.ts +4 -5
  653. package/dist/shims/internal/api-utils.d.ts +3 -4
  654. package/dist/shims/internal/app-page-props-cache-key.d.ts +32 -4
  655. package/dist/shims/internal/app-page-props-cache-key.js +53 -1
  656. package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +5 -6
  657. package/dist/shims/internal/app-prefetch-rsc-request.d.ts +5 -17
  658. package/dist/shims/internal/app-prefetch-rsc-request.js +5 -14
  659. package/dist/shims/internal/app-route-detection.d.ts +2 -2
  660. package/dist/shims/internal/app-route-prefetch-policy.d.ts +5 -8
  661. package/dist/shims/internal/app-route-prefetch-policy.js +0 -1
  662. package/dist/shims/internal/app-router-context.d.ts +9 -10
  663. package/dist/shims/internal/cookie-serialize.d.ts +4 -5
  664. package/dist/shims/internal/format-url-object.d.ts +7 -0
  665. package/dist/shims/internal/format-url-object.js +53 -0
  666. package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +6 -7
  667. package/dist/shims/internal/hybrid-client-route-owner.d.ts +3 -3
  668. package/dist/shims/internal/hybrid-client-route-owner.js +3 -2
  669. package/dist/shims/internal/interpolate-as.d.ts +5 -6
  670. package/dist/shims/internal/interpolate-as.js +4 -2
  671. package/dist/shims/internal/link-status-registry.d.ts +5 -6
  672. package/dist/shims/internal/make-hanging-promise.d.ts +3 -4
  673. package/dist/shims/internal/navigation-untracked.d.ts +2 -3
  674. package/dist/shims/internal/normalize-router-href.d.ts +15 -0
  675. package/dist/shims/internal/normalize-router-href.js +41 -0
  676. package/dist/shims/internal/pages-data-fetch-dedup.d.ts +8 -9
  677. package/dist/shims/internal/pages-data-target.d.ts +8 -6
  678. package/dist/shims/internal/pages-data-target.js +32 -36
  679. package/dist/shims/internal/pages-data-url.d.ts +4 -5
  680. package/dist/shims/internal/pages-data-url.js +2 -1
  681. package/dist/shims/internal/pages-router-accessor.d.ts +3 -4
  682. package/dist/shims/internal/pages-router-components.d.ts +3 -4
  683. package/dist/shims/internal/route-pattern-for-warning.d.ts +5 -6
  684. package/dist/shims/internal/route-pattern-for-warning.js +3 -3
  685. package/dist/shims/internal/router-context.d.ts +2 -3
  686. package/dist/shims/internal/thenable-well-known-properties.d.ts +10 -0
  687. package/dist/shims/internal/thenable-well-known-properties.js +33 -0
  688. package/dist/shims/internal/utils.d.ts +7 -8
  689. package/dist/shims/internal/work-unit-async-storage.d.ts +10 -11
  690. package/dist/shims/layout-segment-context.d.ts +3 -4
  691. package/dist/shims/link-prefetch.d.ts +9 -10
  692. package/dist/shims/link.d.ts +4 -4
  693. package/dist/shims/link.js +56 -116
  694. package/dist/shims/metadata.d.ts +15 -16
  695. package/dist/shims/metadata.js +40 -36
  696. package/dist/shims/navigation-context-accessors.d.ts +9 -0
  697. package/dist/shims/navigation-context-accessors.js +19 -0
  698. package/dist/shims/navigation-context-state.d.ts +27 -18
  699. package/dist/shims/navigation-errors.d.ts +18 -19
  700. package/dist/shims/navigation-state.d.ts +6 -7
  701. package/dist/shims/navigation.d.ts +80 -68
  702. package/dist/shims/navigation.js +24 -16
  703. package/dist/shims/navigation.react-server.d.ts +9 -9
  704. package/dist/shims/offline.d.ts +2 -3
  705. package/dist/shims/og.d.ts +2 -2
  706. package/dist/shims/pages-router-runtime.d.ts +4 -5
  707. package/dist/shims/ppr-fallback-shell.d.ts +13 -14
  708. package/dist/shims/readonly-url-search-params.d.ts +2 -3
  709. package/dist/shims/request-context.d.ts +5 -6
  710. package/dist/shims/root-params.d.ts +14 -15
  711. package/dist/shims/router-state.d.ts +5 -6
  712. package/dist/shims/router-state.js +1 -1
  713. package/dist/shims/router.d.ts +22 -21
  714. package/dist/shims/router.js +339 -164
  715. package/dist/shims/script-nonce-context.d.ts +8 -6
  716. package/dist/shims/script-nonce-context.js +15 -6
  717. package/dist/shims/script.d.ts +4 -4
  718. package/dist/shims/script.js +9 -7
  719. package/dist/shims/search-params-gate.d.ts +35 -0
  720. package/dist/shims/search-params-gate.js +32 -0
  721. package/dist/shims/server.d.ts +19 -51
  722. package/dist/shims/server.js +14 -28
  723. package/dist/shims/slot.d.ts +33 -15
  724. package/dist/shims/slot.js +41 -9
  725. package/dist/shims/streamed-icons.d.ts +3 -4
  726. package/dist/shims/thenable-params.d.ts +5 -7
  727. package/dist/shims/thenable-params.js +3 -24
  728. package/dist/shims/unified-request-context.d.ts +34 -31
  729. package/dist/shims/unified-request-context.js +34 -24
  730. package/dist/shims/unrecognized-action-error.d.ts +3 -4
  731. package/dist/shims/url-safety.d.ts +5 -6
  732. package/dist/shims/url-utils.d.ts +12 -13
  733. package/dist/shims/use-merged-ref.d.ts +2 -3
  734. package/dist/shims/user-agent.d.ts +31 -0
  735. package/dist/shims/user-agent.js +16 -0
  736. package/dist/shims/web-vitals.d.ts +2 -2
  737. package/dist/typegen.d.ts +3 -4
  738. package/dist/utils/asset-prefix.d.ts +7 -8
  739. package/dist/utils/base-path.d.ts +5 -6
  740. package/dist/utils/built-asset-url.d.ts +2 -3
  741. package/dist/utils/built-asset-url.js +1 -1
  742. package/dist/utils/cache-control-metadata.d.ts +4 -5
  743. package/dist/utils/client-build-manifest.d.ts +6 -7
  744. package/dist/utils/client-build-manifest.js +2 -1
  745. package/dist/utils/client-entry-manifest.d.ts +6 -7
  746. package/dist/utils/client-runtime-metadata.d.ts +8 -3
  747. package/dist/utils/client-runtime-metadata.js +18 -1
  748. package/dist/utils/commonjs-loader.d.ts +4 -5
  749. package/dist/utils/compare.d.ts +2 -3
  750. package/dist/utils/deployment-id.d.ts +6 -7
  751. package/dist/utils/dev-error-recovery-event.d.ts +2 -3
  752. package/dist/utils/dev-stack-sourcemap-endpoint.d.ts +2 -3
  753. package/dist/utils/domain-locale.d.ts +7 -8
  754. package/dist/utils/encode-cache-tag.d.ts +3 -4
  755. package/dist/utils/error-cause.d.ts +2 -3
  756. package/dist/utils/external-url.d.ts +2 -3
  757. package/dist/utils/has-trailing-comma.d.ts +3 -4
  758. package/dist/utils/hash.d.ts +3 -4
  759. package/dist/utils/html-limited-bots.d.ts +3 -4
  760. package/dist/utils/lazy-chunks.d.ts +8 -9
  761. package/dist/utils/lazy-chunks.js +4 -4
  762. package/dist/utils/manifest-paths.d.ts +5 -6
  763. package/dist/utils/mdx-scan.d.ts +11 -4
  764. package/dist/utils/mdx-scan.js +27 -1
  765. package/dist/utils/middleware-request-headers.d.ts +7 -6
  766. package/dist/utils/middleware-request-headers.js +6 -1
  767. package/dist/utils/navigation-signal.d.ts +3 -3
  768. package/dist/utils/navigation-signal.js +16 -1
  769. package/dist/utils/number.d.ts +2 -3
  770. package/dist/utils/package-name.d.ts +3 -4
  771. package/dist/utils/parse-cookie.d.ts +4 -5
  772. package/dist/utils/path.d.ts +8 -9
  773. package/dist/utils/plugin-options.d.ts +2 -3
  774. package/dist/utils/precompressed-variant.d.ts +3 -4
  775. package/dist/utils/prerender-output-paths.d.ts +4 -5
  776. package/dist/utils/project.d.ts +19 -30
  777. package/dist/utils/project.js +20 -29
  778. package/dist/utils/promise.d.ts +2 -3
  779. package/dist/utils/protocol-headers.d.ts +14 -15
  780. package/dist/utils/public-file-path.d.ts +2 -3
  781. package/dist/utils/public-routes.d.ts +2 -3
  782. package/dist/utils/query.d.ts +14 -9
  783. package/dist/utils/query.js +22 -1
  784. package/dist/utils/react-compiler-support.d.ts +6 -7
  785. package/dist/utils/react-version.d.ts +4 -3
  786. package/dist/utils/react-version.js +19 -1
  787. package/dist/utils/record.d.ts +2 -3
  788. package/dist/utils/redirect-digest.d.ts +3 -4
  789. package/dist/utils/regex-safety.d.ts +4 -5
  790. package/dist/utils/regex.d.ts +2 -3
  791. package/dist/utils/safe-json-file.d.ts +2 -3
  792. package/dist/utils/sorted-array.d.ts +2 -3
  793. package/dist/utils/text-stream.d.ts +3 -4
  794. package/dist/utils/vinext-root.d.ts +2 -3
  795. package/dist/utils/virtual-module.d.ts +3 -4
  796. package/dist/utils/vite-cli-invocation.d.ts +21 -0
  797. package/dist/utils/vite-cli-invocation.js +144 -0
  798. package/dist/utils/vite-version.d.ts +5 -6
  799. package/next-package.json +4 -0
  800. package/package.json +47 -6
package/dist/index.js CHANGED
@@ -1,34 +1,45 @@
1
1
  import path, { toSlash } from "./deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
2
  import { detectPackageManager, formatMissingCloudflarePluginError, hasWranglerConfig } from "./utils/project.js";
3
- import { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
4
3
  import { buildViteResolveExtensions, createValidFileMatcher, findFileWithExts, normalizeViteResolveExtensions } from "./routing/file-matcher.js";
4
+ import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
5
+ import { claimViteCliBuildInvocation, getViteCliInvocation, isViteCliConfigFile } from "./utils/vite-cli-invocation.js";
6
+ import { VINEXT_DEV_CLI_LIFECYCLE, applyDevServerDefaults, claimViteCliDevInvocation, createDevServerLifecyclePlugin, reserveViteCliDevInvocation } from "./cli-dev-config.js";
7
+ import { isUnknownRecord } from "./utils/record.js";
8
+ import { getReactUpgradeDeps } from "./utils/react-version.js";
9
+ import { loadDotenv } from "./config/dotenv.js";
10
+ import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
11
+ import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
12
+ import { encodeMiddlewareRequestHeaders } from "./utils/middleware-request-headers.js";
13
+ import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
14
+ import { resolveAssetsDir } from "./utils/asset-prefix.js";
15
+ import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
16
+ import { VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
17
+ import { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
5
18
  import { hasBasePath, stripBasePath } from "./utils/base-path.js";
19
+ import { appRouteGraph, appRouter, invalidateAppRouteCache, matchAppRoute } from "./routing/app-router.js";
20
+ import { generateRouteTypes } from "./typegen.js";
6
21
  import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./routing/pages-router.js";
7
- import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
22
+ import { resolveRuntimeEntryModule } from "./entries/runtime-entry-module.js";
8
23
  import { INTERNAL_HEADERS, NEXTJS_DEPLOYMENT_ID_HEADER, VINEXT_INTERNAL_HEADERS, VINEXT_TIMING_HEADER } from "./server/headers.js";
9
- import { encodeMiddlewareRequestHeaders } from "./utils/middleware-request-headers.js";
10
24
  import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
11
- import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
12
25
  import { validateMiddlewareMatcherPatterns } from "./server/middleware-matcher-pattern.js";
13
26
  import { methodNotAllowedResponse } from "./server/http-error-responses.js";
14
27
  import { isOpenRedirectShaped } from "./server/open-redirect.js";
15
28
  import { canonicalizeRequestUrlPathname, filterInternalHeaders, normalizeTrailingSlash } from "./server/request-pipeline.js";
16
29
  import { resolvePagesI18nRequest, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
30
+ import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
17
31
  import { findMiddlewareFile, isProxyFile, runMiddleware } from "./server/middleware.js";
18
32
  import { extractMiddlewareMatcherConfig, extractMiddlewareMatcherConfigValue, hasExportedName } from "./build/report.js";
19
- import { generateServerEntry } from "./entries/pages-server-entry.js";
20
- import { generateClientEntry } from "./entries/pages-client-entry.js";
21
- import { appRouteGraph, appRouter, invalidateAppRouteCache, matchAppRoute } from "./routing/app-router.js";
22
- import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
23
- import { isUnknownRecord } from "./utils/record.js";
33
+ import { generatePagesRequestEntry, generatePagesResponseEntry, generateServerEntry } from "./entries/pages-server-entry.js";
34
+ import { compileClientMiddlewareMatchers, generateClientEntry } from "./entries/pages-client-entry.js";
24
35
  import { logRequest, now } from "./server/request-log.js";
25
36
  import { encodeUrlParserIgnoredCharacters, isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname, shouldAddTrailingSlashToPagesDataPath, urlParserCreatesPagesDataPath } from "./server/pages-data-route.js";
26
- import { resolveAssetsDir } from "./utils/asset-prefix.js";
27
37
  import { getPagesPreviewModeId } from "./server/pages-preview.js";
28
38
  import { createSSRHandler } from "./server/dev-server.js";
29
39
  import { handleApiRoute } from "./server/api-handler.js";
30
40
  import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath, resolveDevImageRedirect } from "./server/image-optimization.js";
31
- import { CACHEABILITY_MANIFEST_MODULE } from "./server/cacheability-manifest.js";
41
+ import { CACHEABILITY_MANIFEST_MODULE, CACHEABILITY_REQUEST_PROJECTION_MODULE } from "./server/cacheability-manifest.js";
42
+ import { PREGENERATED_CONCRETE_PATHS_MODULE } from "./server/pregenerated-concrete-paths.js";
32
43
  import { installSocketErrorBackstop } from "./server/socket-error-backstop.js";
33
44
  import { isPathInside, isPathInsideOrEqual, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
34
45
  import { invalidateMetadataFileCache, scanMetadataFiles } from "./server/metadata-routes.js";
@@ -36,24 +47,25 @@ import { shouldInvalidateAppRouteFile } from "./server/dev-route-files.js";
36
47
  import { createDirectRunner } from "./server/dev-module-runner.js";
37
48
  import { validateDevRequest } from "./server/dev-origin-check.js";
38
49
  import { createActionOwnerManifestPlugin } from "./plugins/action-owner-manifest.js";
39
- import { generateRscEntry } from "./entries/app-rsc-entry.js";
50
+ import { generateAppRequestRscEntry, generateAppResponseRscEntry, generateRscEntry } from "./entries/app-rsc-entry.js";
40
51
  import { generateSsrEntry } from "./entries/app-ssr-entry.js";
41
- import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VIRTUAL_CACHE_ADAPTERS, generateCacheAdaptersModule, hasVerbatimResponseVary } from "./cache/cache-adapters-virtual.js";
52
+ import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VIRTUAL_CACHE_ADAPTERS, VIRTUAL_CDN_CACHE_ADAPTER, generateCacheAdaptersModule, generateCdnCacheAdapterModule } from "./cache/cache-adapters-virtual.js";
42
53
  import { VIRTUAL_IMAGE_ADAPTERS, generateImageAdaptersModule } from "./image/image-adapters-virtual.js";
43
54
  import { generateBrowserEntry, toLinkPrefetchRoutes } from "./entries/app-browser-entry.js";
44
55
  import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
45
56
  import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
46
- import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
47
- import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
48
- import { VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
49
- import { loadDotenv } from "./config/dotenv.js";
50
- import { mergeServerExternalPackages } from "./config/server-external-packages.js";
57
+ import { findOpenTelemetryPackages, mergeServerExternalPackages } from "./config/server-external-packages.js";
51
58
  import { precompressAssets } from "./build/precompress.js";
59
+ import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY, normalizeVinextPrerenderConfig } from "./config/prerender.js";
60
+ import { PAGES_CLIENT_ASSETS_MODULE, buildPagesClientAssetsModule, writePagesClientAssetsModuleIfMissing } from "./build/pages-client-assets-module.js";
61
+ import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
62
+ import { VINEXT_BUILD_LIFECYCLE_CONFIG, createBuildLifecyclePlugins } from "./build/lifecycle.js";
52
63
  import { ensureAssetsIgnore } from "./build/assets-ignore.js";
53
64
  import { emitNextClientRuntimeManifests } from "./build/next-client-runtime-manifests.js";
54
65
  import { collectInlineCssManifest, injectInlineCssManifestGlobal } from "./build/inline-css.js";
55
66
  import { readTrustedRevalidationHostname } from "./server/revalidation-host.js";
56
67
  import { installDevStackSourcemapMiddleware } from "./server/dev-stack-sourcemap.js";
68
+ import { traceFrameworkRequest } from "./server/request-tracing.js";
57
69
  import { runPagesRequest } from "./server/pages-request-pipeline.js";
58
70
  import { pagesRouteHasPriorityOverAppRoute, validateHybridRouteConflicts } from "./server/hybrid-route-priority.js";
59
71
  import { hasReactCompilerPlugin, isReactCompilerPlugin, isReactCompilerRequested, reactCompilerUnsupportedMessage } from "./utils/react-compiler-support.js";
@@ -66,7 +78,7 @@ import { dataUrlCssPlugin } from "./plugins/css-data-url.js";
66
78
  import { createCssModuleImportCompatibilityPlugin } from "./plugins/css-module-imports.js";
67
79
  import { createRscClientReferenceLoadersPlugin } from "./plugins/rsc-client-reference-loaders.js";
68
80
  import { createRscReferenceValidationNormalizerPlugin } from "./plugins/rsc-reference-validation-normalizer.js";
69
- import { createInstrumentationClientTransformPlugin } from "./plugins/instrumentation-client.js";
81
+ import { createInstrumentationClientTransformPlugin, createInstrumentationServerTransformPlugin } from "./plugins/instrumentation-client.js";
70
82
  import { createStyledJsxPlugin } from "./plugins/styled-jsx.js";
71
83
  import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
72
84
  import { createMiddlewareServerOnlyPlugin } from "./plugins/middleware-server-only.js";
@@ -76,22 +88,20 @@ import { validateMiddlewareModuleExports } from "./plugins/middleware-export-val
76
88
  import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
77
89
  import { augmentSsrManifestFromBundle, relativeWithinRoot, tryRealpathSync } from "./build/ssr-manifest.js";
78
90
  import { createDynamicPreloadMetadataPlugin } from "./plugins/dynamic-preload-metadata.js";
91
+ import { createOgHarfbuzzPlugin } from "./plugins/og-harfbuzz.js";
79
92
  import { createOgAssetsPlugin, createOgInlineFetchAssetsPlugin } from "./plugins/og-assets.js";
80
93
  import { createUseCacheCallablePlugin } from "./plugins/use-cache-callable.js";
81
- import { generateRouteTypes } from "./typegen.js";
82
94
  import { SSR_EXTERNAL_REACT_ENTRIES, VINEXT_OPTIMIZE_DEPS_EXCLUDE, mergeOptimizeDepsExclude } from "./plugins/rsc-client-shim-excludes.js";
83
95
  import { createServerExternalsManifestPlugin } from "./plugins/server-externals-manifest.js";
84
96
  import { createTransitiveExternalsPlugin } from "./plugins/transitive-externals.js";
85
97
  import public_shim_map_default from "./shims/public-shim-map.json.js";
86
98
  import { VINEXT_CLIENT_ENTRY_MANIFEST } from "./utils/client-entry-manifest.js";
87
99
  import { computeClientRuntimeMetadata } from "./utils/client-runtime-metadata.js";
88
- import { PAGES_CLIENT_ASSETS_MODULE, buildPagesClientAssetsModule, setPagesClientAssetsBuildMetadata, takePagesClientAssetsBuildMetadata, writePagesClientAssetsModuleIfMissing } from "./build/pages-client-assets-module.js";
89
- import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
100
+ import { readPrerenderSecret, readServerRuntimeOutputDirs } from "./build/server-manifest.js";
90
101
  import { createModuleDependencyCache } from "./build/module-dependency-cache.js";
91
- import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
92
102
  import { markCssUrlAssetReferences, restoreDedupedCssAssetReferences } from "./build/css-url-assets.js";
93
103
  import { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter, createSassTsconfigPathImporters } from "./plugins/sass.js";
94
- import { createClientAssetFileNames, createClientCodeSplittingConfig, createClientFileNameConfig, createClientManualChunks, createRscFrameworkChunkOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfig, withBuildBundlerOptions } from "./build/client-build-config.js";
104
+ import { createClientAssetFileNames, createClientCodeSplittingConfig, createClientFileNameConfig, createClientManualChunks, createMultiStageChunkFileNames, createMultiStageCodeSplittingConfig, createRscFrameworkChunkOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfig, withBuildBundlerOptions } from "./build/client-build-config.js";
95
105
  import { hasExportAllCandidate, stripServerExports, validatePageExports } from "./plugins/strip-server-exports.js";
96
106
  import { removeConsoleCalls } from "./plugins/remove-console.js";
97
107
  import { createImportMetaUrlPlugin } from "./plugins/import-meta-url.js";
@@ -107,15 +117,15 @@ import { publicFilePathVariants } from "./utils/public-file-path.js";
107
117
  import { scanPublicFileRoutes } from "./utils/public-routes.js";
108
118
  import { createIgnoreDynamicRequestsPlugin } from "./plugins/ignore-dynamic-requests.js";
109
119
  import { assertSupportedViteVersion, getDepOptimizeNodeEnvOptions, serializeViteDefine } from "./utils/vite-version.js";
110
- import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY, normalizeVinextPrerenderConfig } from "./config/prerender.js";
111
120
  import { staticExportApp, staticExportPages } from "./build/static-export.js";
112
121
  import { createRequire } from "node:module";
113
122
  import fs from "node:fs";
114
- import { createIdResolver, createLogger, parseAst, transformWithOxc } from "vite";
115
123
  import { pathToFileURL } from "node:url";
124
+ import { createIdResolver, createLogger, isRunnableDevEnvironment, parseAst, transformWithOxc } from "vite";
125
+ import { execFileSync } from "node:child_process";
116
126
  import { createHash, randomBytes } from "node:crypto";
117
- import commonjs from "vite-plugin-commonjs";
118
127
  import MagicString from "magic-string";
128
+ import commonjs from "vite-plugin-commonjs";
119
129
  //#region src/index.ts
120
130
  const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_EXCLUDE = Object.freeze(["vinext/server/fetch-handler", "vinext/server/pages-router-entry"]);
121
131
  const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
@@ -129,6 +139,30 @@ const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
129
139
  const OPTIONAL_OPTIMIZE_DEPS_WARNING_RE = /Failed to resolve dependency: .*use-sync-external-store\/with-selector.*present in .* 'optimizeDeps\.include'/;
130
140
  const VINEXT_FILTERED_OPTIMIZE_DEPS_WARN = Symbol.for("vinext.filteredOptimizeDepsWarn");
131
141
  const ANSI_ESCAPE_RE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
142
+ const RSC_ENVIRONMENTS = /* @__PURE__ */ new Set([
143
+ "rsc",
144
+ "ssr",
145
+ "client"
146
+ ]);
147
+ function scopeRscPlugin(plugin) {
148
+ const applyToEnvironment = plugin.applyToEnvironment;
149
+ return {
150
+ ...plugin,
151
+ applyToEnvironment(environment) {
152
+ if (!RSC_ENVIRONMENTS.has(environment.name)) return false;
153
+ return applyToEnvironment?.(environment) ?? true;
154
+ }
155
+ };
156
+ }
157
+ const earlyViteCliInvocation = getViteCliInvocation();
158
+ const viteCliBuildConfigNodeEnv = earlyViteCliInvocation?.command === "build" && process.env.NODE_ENV === "test" ? "test" : void 0;
159
+ if (earlyViteCliInvocation) {
160
+ if (!process.env.NODE_ENV) Reflect.set(process.env, "NODE_ENV", earlyViteCliInvocation.command === "build" ? viteCliBuildConfigNodeEnv ?? "production" : earlyViteCliInvocation.mode === "test" ? "test" : "development");
161
+ loadDotenv({
162
+ root: earlyViteCliInvocation.root,
163
+ mode: earlyViteCliInvocation.mode
164
+ });
165
+ }
132
166
  installSocketErrorBackstop();
133
167
  function hasServerOnlyMarkerImport(code) {
134
168
  if (!code.includes("server-only")) return false;
@@ -183,6 +217,7 @@ function resolveShimModulePath(shimsDir, moduleName) {
183
217
  }
184
218
  return path.join(shimsDir, `${moduleName}.js`);
185
219
  }
220
+ const PATCHED_SERVER_PACKAGES = ["@vercel/og"];
186
221
  function isVercelOgImport(id) {
187
222
  return id === "@vercel/og" || id === "@vercel/og.js";
188
223
  }
@@ -312,7 +347,7 @@ function createDevPagesModuleDependencyReader(root, resolve) {
312
347
  if (typeof specifier !== "string") continue;
313
348
  const resolved = await resolve(specifier, cleanModulePath, { skipSelf: true });
314
349
  if (!resolved?.id) continue;
315
- if (isStylesheetSpecifier(specifier)) {
350
+ if (isStylesheetSpecifier(specifier) || isStylesheetSpecifier(resolved.id)) {
316
351
  const asset = resolvedStylesheetToDevManifestAsset(root, resolved.id);
317
352
  if (asset) dependencies.push({
318
353
  type: "stylesheet",
@@ -597,8 +632,8 @@ const tsconfigAliasCustomResolver = async function(updatedId, importer, options)
597
632
  * stylesheet-scoping resolver to entries that came from tsconfig `paths`.
598
633
  * Array order preserves the map's first-match ordering.
599
634
  */
600
- function buildResolveAliasEntries(aliasMap, tsconfigPathAliases) {
601
- return Object.entries(aliasMap).map(([find, replacement]) => tsconfigPathAliases[find] === replacement ? {
635
+ function buildResolveAliasEntries(aliasMap, tsconfigPathAliases, explicitAliases) {
636
+ return Object.entries(aliasMap).map(([find, replacement]) => Object.hasOwn(tsconfigPathAliases, find) && !Object.hasOwn(explicitAliases, find) ? {
602
637
  find,
603
638
  replacement,
604
639
  customResolver: tsconfigAliasCustomResolver
@@ -621,26 +656,49 @@ function suppressAliasCustomResolverDeprecationWarning(logger) {
621
656
  return logger;
622
657
  }
623
658
  const VIRTUAL_WORKER_ENTRY = "virtual:vinext-worker-entry";
624
- const RESOLVED_WORKER_ENTRY = "\0virtual:vinext-worker-entry";
659
+ const RESOLVED_WORKER_ENTRY = "\0" + VIRTUAL_WORKER_ENTRY;
660
+ const VIRTUAL_REQUEST_STAGE = "virtual:vinext-request-stage";
661
+ const RESOLVED_REQUEST_STAGE = "\0" + VIRTUAL_REQUEST_STAGE;
662
+ const VIRTUAL_RESPONSE_STAGE = "virtual:vinext-response-stage";
663
+ const RESOLVED_RESPONSE_STAGE = "\0" + VIRTUAL_RESPONSE_STAGE;
625
664
  const VIRTUAL_SERVER_ENTRY = "virtual:vinext-server-entry";
626
- const RESOLVED_SERVER_ENTRY = "\0virtual:vinext-server-entry";
665
+ const RESOLVED_SERVER_ENTRY = "\0" + VIRTUAL_SERVER_ENTRY;
666
+ const VIRTUAL_PAGES_REQUEST_ENTRY = "virtual:vinext-pages-request-entry";
667
+ const RESOLVED_PAGES_REQUEST_ENTRY = "\0" + VIRTUAL_PAGES_REQUEST_ENTRY;
668
+ const VIRTUAL_PAGES_RESPONSE_ENTRY = "virtual:vinext-pages-response-entry";
669
+ const RESOLVED_PAGES_RESPONSE_ENTRY = "\0" + VIRTUAL_PAGES_RESPONSE_ENTRY;
627
670
  const VIRTUAL_CLIENT_ENTRY = "virtual:vinext-client-entry";
628
- const RESOLVED_CLIENT_ENTRY = "\0virtual:vinext-client-entry";
671
+ const RESOLVED_CLIENT_ENTRY = "\0" + VIRTUAL_CLIENT_ENTRY;
629
672
  const VIRTUAL_PAGES_CLIENT_ASSETS = "virtual:vinext-pages-client-assets";
630
- const RESOLVED_PAGES_CLIENT_ASSETS = "\0virtual:vinext-pages-client-assets";
673
+ const RESOLVED_PAGES_CLIENT_ASSETS = "\0" + VIRTUAL_PAGES_CLIENT_ASSETS;
631
674
  const VIRTUAL_RSC_ENTRY = "virtual:vinext-rsc-entry";
632
- const RESOLVED_RSC_ENTRY = "\0virtual:vinext-rsc-entry";
675
+ const RESOLVED_RSC_ENTRY = "\0" + VIRTUAL_RSC_ENTRY;
633
676
  const VIRTUAL_CACHEABILITY_MANIFEST = "virtual:vinext-cacheability-manifest";
634
- const RESOLVED_CACHEABILITY_MANIFEST = "\0virtual:vinext-cacheability-manifest";
677
+ const RESOLVED_CACHEABILITY_MANIFEST = "\0" + VIRTUAL_CACHEABILITY_MANIFEST;
678
+ const VIRTUAL_CACHEABILITY_REQUEST_PROJECTION = "virtual:vinext-cacheability-request-projection";
679
+ const RESOLVED_CACHEABILITY_REQUEST_PROJECTION = "\0" + VIRTUAL_CACHEABILITY_REQUEST_PROJECTION;
680
+ const VIRTUAL_PREGENERATED_CONCRETE_PATHS = "virtual:vinext-pregenerated-concrete-paths";
681
+ const RESOLVED_PREGENERATED_CONCRETE_PATHS = "\0" + VIRTUAL_PREGENERATED_CONCRETE_PATHS;
682
+ const VIRTUAL_APP_REQUEST_ENTRY = "virtual:vinext-app-request-entry";
683
+ const RESOLVED_APP_REQUEST_ENTRY = "\0" + VIRTUAL_APP_REQUEST_ENTRY;
684
+ const VIRTUAL_APP_RESPONSE_ENTRY = "virtual:vinext-app-response-entry";
685
+ const RESOLVED_APP_RESPONSE_ENTRY = "\0" + VIRTUAL_APP_RESPONSE_ENTRY;
635
686
  const VIRTUAL_APP_SSR_ENTRY = "virtual:vinext-app-ssr-entry";
636
- const RESOLVED_APP_SSR_ENTRY = "\0virtual:vinext-app-ssr-entry";
687
+ const RESOLVED_APP_SSR_ENTRY = "\0" + VIRTUAL_APP_SSR_ENTRY;
637
688
  const VIRTUAL_APP_BROWSER_ENTRY = "virtual:vinext-app-browser-entry";
638
- const RESOLVED_APP_BROWSER_ENTRY = "\0virtual:vinext-app-browser-entry";
689
+ const RESOLVED_APP_BROWSER_ENTRY = "\0" + VIRTUAL_APP_BROWSER_ENTRY;
639
690
  const VIRTUAL_APP_CAPABILITIES = "virtual:vinext-app-capabilities";
640
- const RESOLVED_APP_CAPABILITIES = "\0virtual:vinext-app-capabilities";
691
+ const RESOLVED_APP_CAPABILITIES = "\0" + VIRTUAL_APP_CAPABILITIES;
641
692
  const RESOLVED_ROOT_PARAMS = "\0virtual:vinext-root-params";
693
+ const APP_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("app-request-stage-independent-entry");
694
+ const APP_RESPONSE_STAGE_ENTRY = resolveRuntimeEntryModule("app-response-stage-entry");
695
+ const PAGES_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("pages-request-stage-entry");
696
+ const PAGES_RESPONSE_STAGE_ENTRY = resolveRuntimeEntryModule("pages-response-stage-entry");
697
+ const WORKER_ROUTER_ENTRIES = /* @__PURE__ */ new Set([resolveRuntimeEntryModule("app-router-entry"), resolveRuntimeEntryModule("pages-router-entry")]);
642
698
  /** Virtual module that registers config-driven cache adapters (see VinextOptions.cache). */
643
699
  const RESOLVED_CACHE_ADAPTERS = "\0" + VIRTUAL_CACHE_ADAPTERS;
700
+ /** CDN-only registrar kept out of the data-cache response graph. */
701
+ const RESOLVED_CDN_CACHE_ADAPTER = "\0" + VIRTUAL_CDN_CACHE_ADAPTER;
644
702
  /** Virtual module that registers the config-driven image optimizer (see VinextOptions.images). */
645
703
  const RESOLVED_IMAGE_ADAPTERS = "\0" + VIRTUAL_IMAGE_ADAPTERS;
646
704
  /** Virtual module for composed instrumentation-client bootstrap. */
@@ -671,9 +729,10 @@ const _shimsDir = path.resolve(__dirname, "shims") + "/";
671
729
  const _serverDir = path.resolve(__dirname, "server");
672
730
  const _fontGoogleShimPath = resolveShimModulePath(_shimsDir, "font-google");
673
731
  const _appBrowserServerActionClientPath = resolveShimModulePath(_serverDir, "app-browser-server-action-client");
732
+ const _appRscCombinedHandlerPath = resolveShimModulePath(_serverDir, "app-rsc-combined-handler");
674
733
  const _appRscHandlerPath = resolveShimModulePath(_serverDir, "app-rsc-handler");
675
734
  const _pagesClientAssetsPath = resolveShimModulePath(_serverDir, "pages-client-assets");
676
- const _canExternalizeAppRscHandler = _appRscHandlerPath.endsWith(".js");
735
+ const _canExternalizeAppRscHandler = _appRscHandlerPath.endsWith(".js") && _appRscCombinedHandlerPath.endsWith(".js");
677
736
  function isValidExportIdentifier(name) {
678
737
  return /^[$A-Z_a-z][$\w]*$/.test(name);
679
738
  }
@@ -745,8 +804,10 @@ for (const [specifier, definition] of Object.entries(_publicNextShimMap)) {
745
804
  _reactServerShims.set(`${specifier}.js`, definition.shim);
746
805
  }
747
806
  _reactServerShims.set("next/dist/client/components/navigation", "navigation");
748
- const clientCodeSplittingConfig = createClientCodeSplittingConfig(createClientManualChunks(_shimsDir));
749
- const appClientCodeSplittingConfig = createClientCodeSplittingConfig(createClientManualChunks(_shimsDir, true));
807
+ const clientManualChunks = createClientManualChunks(_shimsDir);
808
+ const clientCodeSplittingConfig = createClientCodeSplittingConfig(clientManualChunks);
809
+ const appClientManualChunks = createClientManualChunks(_shimsDir, true);
810
+ const appClientCodeSplittingConfig = createClientCodeSplittingConfig(appClientManualChunks);
750
811
  function getClientOutputConfig(assetsDir, preserveAppRouteBoundaries = false) {
751
812
  const codeSplitting = preserveAppRouteBoundaries ? appClientCodeSplittingConfig : clientCodeSplittingConfig;
752
813
  return {
@@ -771,7 +832,9 @@ function createServerEnvironmentFileNameResolver(config, outputRoot) {
771
832
  };
772
833
  }
773
834
  function vinext(options = {}) {
835
+ const internalOptions = options;
774
836
  const { supportsNativeTypeofWindowFolding: useNativeTypeofWindowFolding } = assertSupportedViteVersion();
837
+ const reservedDevCliInvocation = reserveViteCliDevInvocation();
775
838
  const prerenderConfig = normalizeVinextPrerenderConfig(options.prerender);
776
839
  const cacheAdapterBuildOutputs = [options.cache?.data?.output, options.cache?.cdn?.output].filter((output) => output !== void 0);
777
840
  let root;
@@ -781,6 +844,7 @@ function vinext(options = {}) {
781
844
  let hasAppDir = false;
782
845
  let hasPagesDir = false;
783
846
  let nextConfig;
847
+ let nitroBuildDir;
784
848
  let fileMatcher;
785
849
  let middlewarePath = null;
786
850
  let instrumentationPath = null;
@@ -789,12 +853,23 @@ function vinext(options = {}) {
789
853
  let globalNotFoundCssIsolationPath = null;
790
854
  let clientAssetsInlineLimit = 0;
791
855
  let hasCloudflarePlugin = false;
856
+ let matchedMultiStageOutput;
857
+ let selectedMultiStageOutput;
858
+ const isMultiStageServerEnvironment = (environment) => isServerEnvironment(environment) && (!hasAppDir || environment.name === "rsc");
792
859
  let warnedInlineNextConfigOverride = false;
793
860
  let hasNitroPlugin = false;
861
+ let nitroHostRuntime = "node";
794
862
  let resolvedServerExternalPackages = [];
863
+ let registerNodeOpenTelemetryLoader = false;
795
864
  let pagesTsconfigAliases = {};
796
865
  let pagesBundledPackages = /* @__PURE__ */ new Set();
797
866
  let isServeCommand = false;
867
+ let buildEmptyOutDir;
868
+ let buildLifecycleEnabled = false;
869
+ let hasPlainPagesBuildEnvironments = false;
870
+ let originalPlainPagesEnvironments;
871
+ let buildLifecycleInvocation;
872
+ let reactUpgradeChecked = false;
798
873
  let pagesOptimizeEntries = [];
799
874
  const importMetaUrlCapability = createImportMetaUrlPlugin({
800
875
  getRoot: () => root,
@@ -804,7 +879,8 @@ function vinext(options = {}) {
804
879
  }
805
880
  });
806
881
  const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
807
- let pagesClientAssetsModule = null;
882
+ const resolvePagesClientAssetsOutputDir = (environmentName, outputDir) => !selectedMultiStageOutput && !hasAppDir && !hasCloudflarePlugin && environmentName === "ssr" ? path.dirname(outputDir) : outputDir;
883
+ let pagesClientAssetsModule = internalOptions.__pagesClientAssetsModule ?? null;
808
884
  let devPublicFileRoutes = null;
809
885
  let publicDirConflictOptions = null;
810
886
  let copyPublicDirIntoStaticExportBasePath = false;
@@ -812,12 +888,14 @@ function vinext(options = {}) {
812
888
  let rscCompatibilityId;
813
889
  let draftModeSecret = getPagesPreviewModeId();
814
890
  const prerenderSecret = process.env.__VINEXT_SHARED_PRERENDER_SECRET ?? randomBytes(32).toString("hex");
891
+ let revalidateSecret = process.env.__VINEXT_SHARED_REVALIDATE_SECRET;
815
892
  let previewBuildCredentials;
816
893
  const sassComposesLoader = createSassAwareFileSystemLoader();
817
- let rscClassificationManifest = null;
894
+ const rscClassificationManifests = /* @__PURE__ */ new Map();
818
895
  let rscActionOwnerRoutes = null;
819
896
  let rscActionOwnerSharedRoots = [];
820
897
  const serverEntryKindsByEnvironment = /* @__PURE__ */ new Map();
898
+ const serverRuntimeOutputDirs = /* @__PURE__ */ new Set();
821
899
  function recordServerEntryLoad(environmentName, id) {
822
900
  if (!environmentName) return;
823
901
  let entries = serverEntryKindsByEnvironment.get(environmentName);
@@ -854,7 +932,17 @@ function vinext(options = {}) {
854
932
  */
855
933
  async function generateServerEntry$1(configuredPublicDir) {
856
934
  const publicFiles = isServeCommand && devPublicFileRoutes ? [...devPublicFileRoutes].sort() : scanPublicFileRoutes(root, configuredPublicDir === "" ? false : configuredPublicDir);
857
- return generateServerEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, publicFiles, prerenderSecret);
935
+ return generateServerEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, publicFiles, {
936
+ nodeOpenTelemetryLoader: registerNodeOpenTelemetryLoader,
937
+ prerenderSecret
938
+ });
939
+ }
940
+ async function generatePagesRequestEntry$1(configuredPublicDir) {
941
+ const publicFiles = isServeCommand && devPublicFileRoutes ? [...devPublicFileRoutes].sort() : scanPublicFileRoutes(root, configuredPublicDir === "" ? false : configuredPublicDir);
942
+ return generatePagesRequestEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, publicFiles, prerenderSecret);
943
+ }
944
+ function generatePagesResponseEntry$1() {
945
+ return generatePagesResponseEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, prerenderSecret);
858
946
  }
859
947
  /**
860
948
  * Generate the virtual client hydration entry module.
@@ -881,7 +969,8 @@ function vinext(options = {}) {
881
969
  });
882
970
  }
883
971
  const autoRsc = options.rsc !== false;
884
- const earlyBaseDir = options.appDir ?? process.cwd();
972
+ const earlyRoot = earlyViteCliInvocation?.root ?? process.cwd();
973
+ const earlyBaseDir = path.resolve(earlyRoot, options.appDir ?? ".");
885
974
  const earlyAppDirExists = !options.disableAppRouter && (fs.existsSync(path.join(earlyBaseDir, "app")) || fs.existsSync(path.join(earlyBaseDir, "src", "app")));
886
975
  let resolvedReactPath = null;
887
976
  let resolvedRscPath = null;
@@ -903,14 +992,12 @@ function vinext(options = {}) {
903
992
  } });
904
993
  const useCachePlugin = await createUseCacheCallablePlugin({
905
994
  projectRoot: earlyBaseDir,
906
- cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href,
907
- getAppDir: () => appDir,
908
- matchesPageExtension: (fileName) => fileMatcher.extensionRegex.test(fileName)
995
+ cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href
909
996
  });
910
997
  const useServerIndex = plugins.findIndex((plugin) => plugin.name === "rsc:use-server");
911
998
  if (useServerIndex === -1) throw new Error("vinext: Failed to locate @vitejs/plugin-rsc use-server plugin.");
912
999
  plugins.splice(useServerIndex, 0, useCachePlugin);
913
- return plugins;
1000
+ return plugins.map(scopeRscPlugin);
914
1001
  }).catch((cause) => {
915
1002
  throw new Error("vinext: Failed to load @vitejs/plugin-rsc.", { cause });
916
1003
  });
@@ -919,8 +1006,6 @@ function vinext(options = {}) {
919
1006
  manualUseCachePluginPromise = createUseCacheCallablePlugin({
920
1007
  projectRoot: earlyBaseDir,
921
1008
  cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href,
922
- getAppDir: () => appDir,
923
- matchesPageExtension: (fileName) => fileMatcher.extensionRegex.test(fileName),
924
1009
  allowMissingRsc: true
925
1010
  });
926
1011
  }
@@ -987,9 +1072,10 @@ function vinext(options = {}) {
987
1072
  }
988
1073
  const delegate = mdxFactory(mdxOpts);
989
1074
  mdxDelegate = delegate;
990
- if (reason === "detected") if (nextConfig.mdx) console.log("[vinext] Auto-injected @mdx-js/rollup with remark/rehype plugins from next.config");
991
- else console.log("[vinext] Auto-injected @mdx-js/rollup for MDX support");
992
- else console.log("[vinext] Auto-injected @mdx-js/rollup for on-demand MDX support");
1075
+ if (reason === "detected") {
1076
+ if (nextConfig.mdx) console.log("[vinext] Auto-injected @mdx-js/rollup with remark/rehype plugins from next.config");
1077
+ else console.log("[vinext] Auto-injected @mdx-js/rollup for MDX support");
1078
+ } else console.log("[vinext] Auto-injected @mdx-js/rollup for on-demand MDX support");
993
1079
  return delegate;
994
1080
  } catch {
995
1081
  if (reason === "detected" && !warnedMissingMdxPlugin) {
@@ -1036,6 +1122,10 @@ function vinext(options = {}) {
1036
1122
  } });
1037
1123
  const commonJsTransform = commonJsPlugin.transform;
1038
1124
  if (typeof commonJsTransform === "function") commonJsPlugin.transform = function environmentAwareCommonJsTransform(code, id, ...args) {
1125
+ const normalizedId = toSlash(stripViteModuleQuery(id));
1126
+ const nitroServicePath = this.environment.name === "nitro" && nitroBuildDir && normalizedId.endsWith("/entry.js") ? path.relative(path.join(canonicalize(nitroBuildDir), "vite/services"), normalizedId) : "";
1127
+ if (/^[^/]+\/entry\.js$/.test(nitroServicePath)) return null;
1128
+ if (isPathInside(__dirname, toSlash(stripViteModuleQuery(id)))) return null;
1039
1129
  if (this.environment.mode === "dev" && this.environment.depsOptimizer?.isOptimizedDepFile(id)) return null;
1040
1130
  const isDev = this.environment.mode === "dev";
1041
1131
  const isServer = this.environment.config.consumer === "server";
@@ -1052,7 +1142,59 @@ function vinext(options = {}) {
1052
1142
  transformBundledCommonJsDependencies = previous;
1053
1143
  }
1054
1144
  };
1145
+ const buildLifecyclePlugins = createBuildLifecyclePlugins({
1146
+ isEnabled: (builder) => buildLifecycleEnabled && builder.config.build.write !== false && !builder.config.build.lib && (buildLifecycleInvocation !== void 0 || !builder.config.build.watch && !builder.config.build.ssr && getBuildBundlerOptions(builder.config.build)?.input === void 0),
1147
+ onComplete: () => buildLifecycleInvocation?.onComplete?.(),
1148
+ shouldDeferPostBuild: () => buildLifecycleInvocation !== void 0,
1149
+ shouldPrepare: (config) => buildLifecycleEnabled && config.build?.write !== false && !config.build?.lib && (buildLifecycleInvocation !== void 0 || !config.build?.watch && !config.build?.ssr && getBuildBundlerOptions(config.build)?.input === void 0),
1150
+ onPrepare: () => {
1151
+ if (!hasAppDir || reactUpgradeChecked) return;
1152
+ reactUpgradeChecked = true;
1153
+ const reactUpgrade = getReactUpgradeDeps(root);
1154
+ if (reactUpgrade.length === 0) return;
1155
+ const [packageManager, ...packageManagerArgs] = detectPackageManager(root).replace(/ -D$/, "").split(" ");
1156
+ console.log(" Upgrading React for RSC compatibility...");
1157
+ execFileSync(packageManager, [...packageManagerArgs, ...reactUpgrade], {
1158
+ cwd: root,
1159
+ stdio: "inherit",
1160
+ shell: process.platform === "win32"
1161
+ });
1162
+ },
1163
+ shouldBuildPlainPages: () => !hasAppDir && !hasCloudflarePlugin && !hasNitroPlugin,
1164
+ createContext: () => ({
1165
+ cacheConfig: options.cache ?? null,
1166
+ configNodeEnv: viteCliBuildConfigNodeEnv,
1167
+ createPagesOnlyPlugins: (pagesClientAssetsModule) => vinext({
1168
+ ...options,
1169
+ disableAppRouter: true,
1170
+ precompress: false,
1171
+ prerender: void 0,
1172
+ __skipBuildLifecycle: true,
1173
+ __pagesClientAssetsModule: pagesClientAssetsModule
1174
+ }),
1175
+ emptyOutDir: buildEmptyOutDir,
1176
+ hasAppDir,
1177
+ hasPagesDir,
1178
+ nextConfig,
1179
+ prerenderConfig,
1180
+ prerenderConcurrency: prerenderConfig?.concurrency,
1181
+ prerenderSecret,
1182
+ previewBuildCredentials,
1183
+ revalidateSecret,
1184
+ root,
1185
+ routeRootConfig: {
1186
+ appDir: options.appDir,
1187
+ disableAppRouter: options.disableAppRouter,
1188
+ rscOutDir: options.rscOutDir,
1189
+ ssrOutDir: options.ssrOutDir
1190
+ },
1191
+ rscBuildIdentity,
1192
+ rscCompatibilityId,
1193
+ skipHybridPagesBundle: hasCloudflarePlugin
1194
+ })
1195
+ });
1055
1196
  const plugins = [
1197
+ buildLifecyclePlugins[0],
1056
1198
  createStyledJsxPlugin(earlyBaseDir),
1057
1199
  mdxProxyPlugin,
1058
1200
  reactPluginPromise,
@@ -1119,6 +1261,7 @@ function vinext(options = {}) {
1119
1261
  }),
1120
1262
  dataUrlCssPlugin(),
1121
1263
  createCssModuleImportCompatibilityPlugin(),
1264
+ createDevServerLifecyclePlugin({}, (config) => config[VINEXT_DEV_CLI_LIFECYCLE] === true),
1122
1265
  {
1123
1266
  name: "vinext:config",
1124
1267
  enforce: "pre",
@@ -1126,33 +1269,48 @@ function vinext(options = {}) {
1126
1269
  [VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY]: options.nextConfig ?? null,
1127
1270
  [VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY]: {
1128
1271
  appDir: options.appDir,
1272
+ clientOutDir: options.clientOutDir,
1129
1273
  disableAppRouter: options.disableAppRouter,
1130
1274
  rscOutDir: options.rscOutDir,
1131
1275
  ssrOutDir: options.ssrOutDir
1132
1276
  },
1133
1277
  [VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY]: options.cache ?? null,
1134
1278
  async config(config, env) {
1279
+ hasPlainPagesBuildEnvironments = false;
1280
+ originalPlainPagesEnvironments = void 0;
1281
+ buildEmptyOutDir = typeof config.build?.emptyOutDir === "boolean" ? config.build.emptyOutDir : void 0;
1135
1282
  isServeCommand = env.command === "serve";
1136
- root = toSlash(config.root ?? process.cwd());
1283
+ root = path.resolve(toSlash(process.cwd()), config.root ?? ".");
1284
+ const devCliLifecycleEnabled = env.command === "serve" && env.isPreview !== true && claimViteCliDevInvocation(root, config["__vinextDevRestart"] === true, reservedDevCliInvocation && config.configFile === false);
1285
+ buildLifecycleInvocation = config[VINEXT_BUILD_LIFECYCLE_CONFIG];
1286
+ buildLifecycleEnabled = env.command === "build" && !internalOptions.__skipBuildLifecycle && (buildLifecycleInvocation !== void 0 || claimViteCliBuildInvocation());
1137
1287
  const userResolve = config.resolve;
1138
1288
  let tsconfigPathAliases = {};
1139
1289
  let sassTsconfigPathAliases = [];
1140
1290
  const swcHelpersAlias = resolveSwcHelpersAlias(root);
1141
1291
  const mode = env?.mode ?? "development";
1142
- if (config.envDir !== false) loadDotenv({
1143
- root: config.envDir ?? root,
1144
- mode
1145
- });
1292
+ if (config.envDir !== false) {
1293
+ const envDir = config.envDir ?? root;
1294
+ loadDotenv({
1295
+ root: envDir,
1296
+ mode
1297
+ });
1298
+ }
1146
1299
  let resolvedNodeEnv;
1147
1300
  if (env?.command === "build" || env?.isPreview === true) resolvedNodeEnv = "production";
1148
1301
  else if (mode === "test") resolvedNodeEnv = "test";
1149
1302
  else resolvedNodeEnv = "development";
1150
- if (process.env.NODE_ENV !== resolvedNodeEnv) Reflect.set(process.env, "NODE_ENV", resolvedNodeEnv);
1151
- if (env?.command === "build") previewBuildCredentials = getPreviewBuildCredentials() ?? createPreviewBuildCredentials();
1303
+ if (!(process.env.NODE_ENV === "test" && viteCliBuildConfigNodeEnv === "test") && process.env.NODE_ENV !== resolvedNodeEnv) Reflect.set(process.env, "NODE_ENV", resolvedNodeEnv);
1304
+ if (env?.command === "build") {
1305
+ previewBuildCredentials = getPreviewBuildCredentials() ?? createPreviewBuildCredentials();
1306
+ if (buildLifecycleEnabled) revalidateSecret ??= randomBytes(32).toString("hex");
1307
+ }
1152
1308
  draftModeSecret = previewBuildCredentials?.id ?? getPagesPreviewModeId();
1153
1309
  let baseDir;
1154
- if (options.appDir) baseDir = toSlash(path.isAbsolute(options.appDir) ? options.appDir : path.resolve(root, options.appDir));
1155
- else {
1310
+ if (options.appDir) {
1311
+ const dir = path.isAbsolute(options.appDir) ? options.appDir : path.resolve(root, options.appDir);
1312
+ baseDir = toSlash(dir);
1313
+ } else {
1156
1314
  const hasRootApp = fs.existsSync(path.join(root, "app"));
1157
1315
  const hasRootPages = fs.existsSync(path.join(root, "pages"));
1158
1316
  const hasSrcApp = fs.existsSync(path.join(root, "src", "app"));
@@ -1186,6 +1344,7 @@ function vinext(options = {}) {
1186
1344
  buildId: sharedBuildId
1187
1345
  };
1188
1346
  }
1347
+ if (env?.command === "build" && earlyViteCliInvocation?.command === "build") Reflect.set(process.env, "NODE_ENV", "production");
1189
1348
  const configuredTsconfigPath = isUnknownRecord(nextConfig.typescript) ? typeof nextConfig.typescript.tsconfigPath === "string" ? nextConfig.typescript.tsconfigPath : void 0 : void 0;
1190
1349
  const resolvedTsconfigAliases = resolveTsconfigAliases(root, configuredTsconfigPath);
1191
1350
  tsconfigPathAliases = resolvedTsconfigAliases.vite;
@@ -1260,7 +1419,6 @@ function vinext(options = {}) {
1260
1419
  defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_LOCAL_IP"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowLocalIP ?? false));
1261
1420
  defines["process.env.__VINEXT_IMAGE_UNOPTIMIZED"] = JSON.stringify(String(nextConfig.images?.unoptimized === true));
1262
1421
  defines["process.env.__VINEXT_BUILD_ID"] = JSON.stringify(nextConfig.buildId);
1263
- defines["process.env.__VINEXT_CANONICAL_RSC_REQUESTS"] = JSON.stringify(env?.command === "build" && hasVerbatimResponseVary(options.cache) ? "1" : "");
1264
1422
  defines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify(rscCompatibilityId);
1265
1423
  defines["process.env.__VINEXT_RSC_BUILD_IDENTITY"] = JSON.stringify(rscBuildIdentity ?? "");
1266
1424
  defines["process.env.__VINEXT_DEPLOYMENT_ID"] = JSON.stringify(nextConfig.deploymentId ?? "");
@@ -1318,6 +1476,9 @@ function vinext(options = {}) {
1318
1476
  }
1319
1477
  flattenPlugins(config.plugins ?? []);
1320
1478
  hasCloudflarePlugin = pluginsFlat.some((p) => p && typeof p === "object" && "name" in p && typeof p.name === "string" && (p.name === "vite-plugin-cloudflare" || p.name.startsWith("vite-plugin-cloudflare:")));
1479
+ const configuredMultiStageOutput = options.cache?.cdn?.output;
1480
+ matchedMultiStageOutput = configuredMultiStageOutput?.type === "multi-stage" && (configuredMultiStageOutput.matchesBuild?.({ plugins: pluginsFlat }) ?? true) ? configuredMultiStageOutput : void 0;
1481
+ selectedMultiStageOutput = isServeCommand ? void 0 : matchedMultiStageOutput;
1321
1482
  hasNitroPlugin = pluginsFlat.some((p) => p && typeof p === "object" && "name" in p && typeof p.name === "string" && (p.name === "nitro" || p.name.startsWith("nitro:")));
1322
1483
  let postcssOverride;
1323
1484
  if (!config.css?.postcss || typeof config.css.postcss === "string") postcssOverride = await resolvePostcssStringPlugins(root);
@@ -1327,11 +1488,20 @@ function vinext(options = {}) {
1327
1488
  const isSSR = !!config.build?.ssr;
1328
1489
  const serverTranspilePackages = [...nextConfig?.turbopackTranspilePackages ?? [], ...nextConfig?.optimizePackageImports ?? []];
1329
1490
  pagesBundledPackages = new Set(serverTranspilePackages);
1330
- const nextServerExternal = mergeServerExternalPackages(nextConfig?.serverExternalPackages, serverTranspilePackages);
1491
+ const openTelemetryPackages = findOpenTelemetryPackages(root);
1492
+ registerNodeOpenTelemetryLoader = env.command === "build" && !hasCloudflarePlugin && !hasNitroPlugin && instrumentationPath !== null && openTelemetryPackages.includes("@opentelemetry/instrumentation") && !serverTranspilePackages.includes("@opentelemetry/instrumentation") && (() => {
1493
+ try {
1494
+ createRequire(path.join(root, "package.json")).resolve("@opentelemetry/instrumentation/hook.mjs");
1495
+ return true;
1496
+ } catch {
1497
+ return false;
1498
+ }
1499
+ })();
1500
+ const nextServerExternal = mergeServerExternalPackages(nextConfig?.serverExternalPackages, serverTranspilePackages, openTelemetryPackages);
1331
1501
  resolvedServerExternalPackages = nextServerExternal;
1332
1502
  const isMultiEnv = hasAppDir || hasCloudflarePlugin || hasNitroPlugin;
1333
1503
  const hasBuildInput = getBuildBundlerOptions(config.build)?.input !== void 0;
1334
- const shouldInjectPlainPagesEnvironments = !hasAppDir && !hasCloudflarePlugin && !isSSR && !hasBuildInput;
1504
+ const shouldInjectPlainPagesEnvironments = !hasAppDir && !hasCloudflarePlugin && !isSSR && !hasBuildInput && !config.build?.lib;
1335
1505
  const hasClientBuildEnvironment = hasAppDir || hasCloudflarePlugin || hasNitroPlugin || shouldInjectPlainPagesEnvironments;
1336
1506
  const clientAssetsDir = resolveAssetsDir(nextConfig.assetPrefix ?? "");
1337
1507
  clientAssetsInlineLimit = config.build?.assetsInlineLimit ?? 0;
@@ -1340,8 +1510,22 @@ function vinext(options = {}) {
1340
1510
  overlay: false
1341
1511
  };
1342
1512
  const cssModulesOverride = config.css?.modules === false || typeof config.css?.modules === "object" && "Loader" in config.css.modules ? {} : { modules: { Loader: sassComposesLoader.Loader } };
1513
+ const explicitViteAliases = config.resolve?.alias;
1514
+ const userAliasEntries = Array.isArray(explicitViteAliases) ? explicitViteAliases : Object.entries(explicitViteAliases ?? {}).map(([find, replacement]) => ({
1515
+ find,
1516
+ replacement
1517
+ }));
1518
+ if (config.resolve) {
1519
+ config.resolve = { ...config.resolve };
1520
+ delete config.resolve.alias;
1521
+ }
1343
1522
  const viteConfig = {
1344
1523
  appType: "custom",
1524
+ ...devCliLifecycleEnabled ? { [VINEXT_DEV_CLI_LIFECYCLE]: true } : {},
1525
+ ...!hasAppDir && hasCloudflarePlugin ? { builder: {
1526
+ ...config.builder,
1527
+ sharedConfigBuild: true
1528
+ } } : {},
1345
1529
  build: {
1346
1530
  ssrEmitAssets: true,
1347
1531
  cssTarget: [
@@ -1375,7 +1559,10 @@ function vinext(options = {}) {
1375
1559
  },
1376
1560
  hmr: devHmrConfig
1377
1561
  },
1378
- ...hasCloudflarePlugin || hasNitroPlugin ? {} : config.ssr?.external === true ? { ssr: { external: true } } : { ssr: {
1562
+ ...hasCloudflarePlugin || hasNitroPlugin ? {} : config.ssr?.external === true ? { ssr: {
1563
+ external: true,
1564
+ noExternal: [...PATCHED_SERVER_PACKAGES]
1565
+ } } : { ssr: {
1379
1566
  external: [
1380
1567
  "react",
1381
1568
  "react-dom",
@@ -1387,13 +1574,16 @@ function vinext(options = {}) {
1387
1574
  noExternal: true
1388
1575
  } },
1389
1576
  resolve: {
1390
- alias: buildResolveAliasEntries({
1577
+ alias: [...userAliasEntries, ...buildResolveAliasEntries({
1391
1578
  ...swcHelpersAlias ? { "@swc/helpers/_": swcHelpersAlias } : {},
1392
1579
  ...tsconfigPathAliases,
1393
1580
  ...nextConfig.aliases,
1394
1581
  ...nextShimMap,
1395
1582
  "vinext/server/pages-client-assets": _pagesClientAssetsPath
1396
- }, tsconfigPathAliases),
1583
+ }, tsconfigPathAliases, {
1584
+ ...nextConfig.aliases,
1585
+ ...nextShimMap
1586
+ })],
1397
1587
  dedupe: [
1398
1588
  "react",
1399
1589
  "react-dom",
@@ -1468,10 +1658,60 @@ function vinext(options = {}) {
1468
1658
  }
1469
1659
  };
1470
1660
  pagesOptimizeEntries = !hasAppDir ? [...hasPagesDir ? [toRelativeFileEntry(root, pagesDir) + "/**/*.{tsx,ts,jsx,js}"] : [], ...[instrumentationPath, instrumentationClientPath].flatMap((entry) => entry ? [toRelativeFileEntry(root, entry)] : [])] : [];
1661
+ if (env.command === "serve" && !hasAppDir && !hasCloudflarePlugin && !shouldInjectPlainPagesEnvironments) viteConfig.optimizeDeps.include = [.../* @__PURE__ */ new Set([...incomingInclude, "react-dom/client"])];
1471
1662
  if (hasAppDir) {
1472
1663
  const appEntries = [`${path.relative(root, appDir)}/**/*.{tsx,ts,jsx,js}`];
1473
1664
  const explicitInstrumentationEntries = [instrumentationPath, instrumentationClientPath].flatMap((entry) => entry ? [toRelativeFileEntry(root, entry)] : []);
1474
1665
  const optimizeEntries = [.../* @__PURE__ */ new Set([...appEntries, ...explicitInstrumentationEntries])];
1666
+ const additionalRscOptimizeIncludes = [];
1667
+ if (env.command === "serve" && hasCloudflarePlugin && nextConfig?.aliases["next-intl/config"] && !(config.environments?.rsc?.optimizeDeps?.noDiscovery ?? config.optimizeDeps?.noDiscovery)) {
1668
+ const projectRequire = createRequire(path.join(root, "package.json"));
1669
+ const excluded = [...incomingExclude, ...config.environments?.rsc?.optimizeDeps?.exclude ?? []];
1670
+ for (const id of [
1671
+ "@formatjs/intl-localematcher",
1672
+ "negotiator",
1673
+ "@formatjs/fast-memoize",
1674
+ "intl-messageformat"
1675
+ ]) {
1676
+ if (excluded.includes(id)) continue;
1677
+ try {
1678
+ projectRequire.resolve(id);
1679
+ additionalRscOptimizeIncludes.push(id);
1680
+ } catch {}
1681
+ }
1682
+ }
1683
+ const additionalClientOptimizeIncludes = [];
1684
+ let hasNextIntl = Boolean(nextConfig?.aliases["next-intl/config"]);
1685
+ if (env.command === "serve" && !hasNextIntl) try {
1686
+ const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
1687
+ hasNextIntl = [
1688
+ "dependencies",
1689
+ "devDependencies",
1690
+ "optionalDependencies",
1691
+ "peerDependencies"
1692
+ ].some((field) => Object.hasOwn(pkg[field] ?? {}, "next-intl"));
1693
+ } catch {}
1694
+ if (env.command === "serve" && hasNextIntl && !(config.environments?.client?.optimizeDeps?.noDiscovery ?? config.optimizeDeps?.noDiscovery)) {
1695
+ const excluded = [...incomingExclude, ...config.environments?.client?.optimizeDeps?.exclude ?? []];
1696
+ try {
1697
+ const projectRequire = createRequire(path.join(root, "package.json"));
1698
+ const packageRequire = createRequire(projectRequire.resolve("next-intl"));
1699
+ for (const id of [
1700
+ "use-intl",
1701
+ "use-intl/react",
1702
+ "use-intl/_IntlProvider",
1703
+ "use-intl/_useLocale"
1704
+ ]) {
1705
+ const include = `next-intl > ${id}`;
1706
+ if (excluded.includes("use-intl") || excluded.includes(id) || excluded.includes(include)) continue;
1707
+ try {
1708
+ packageRequire.resolve(id);
1709
+ additionalClientOptimizeIncludes.push(include);
1710
+ } catch {}
1711
+ }
1712
+ if (!excluded.includes("next") && !excluded.includes("next/link")) additionalClientOptimizeIncludes.push("next/link");
1713
+ } catch {}
1714
+ }
1475
1715
  const appClientInput = { index: VIRTUAL_APP_BROWSER_ENTRY };
1476
1716
  if (hasPagesDir) appClientInput["vinext-client-entry"] = VIRTUAL_CLIENT_ENTRY;
1477
1717
  viteConfig.environments = {
@@ -1481,15 +1721,19 @@ function vinext(options = {}) {
1481
1721
  "satori",
1482
1722
  "@resvg/resvg-js",
1483
1723
  "yoga-wasm-web",
1484
- ...env?.command === "serve" && _canExternalizeAppRscHandler ? ["vinext/server/app-rsc-handler"] : [],
1724
+ ...env?.command === "serve" && _canExternalizeAppRscHandler ? ["vinext/server/app-rsc-combined-handler", "vinext/server/app-rsc-handler"] : [],
1485
1725
  ...userSsrExternal
1486
1726
  ],
1487
- ...userSsrExternal === true ? {} : { noExternal: true }
1727
+ noExternal: userSsrExternal === true ? [...PATCHED_SERVER_PACKAGES] : true
1488
1728
  } },
1489
1729
  optimizeDeps: {
1490
1730
  exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE),
1491
1731
  entries: optimizeEntries,
1492
- include: [.../* @__PURE__ */ new Set([...incomingInclude, "react-server-dom-webpack/static.edge"])],
1732
+ include: [.../* @__PURE__ */ new Set([
1733
+ ...incomingInclude,
1734
+ ...additionalRscOptimizeIncludes,
1735
+ "react-server-dom-webpack/static.edge"
1736
+ ])],
1493
1737
  ...depOptimizeNodeEnvOptions
1494
1738
  },
1495
1739
  build: {
@@ -1507,7 +1751,7 @@ function vinext(options = {}) {
1507
1751
  "ipaddr.js",
1508
1752
  ...externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []
1509
1753
  ],
1510
- ...userSsrExternal === true ? {} : { noExternal: true }
1754
+ noExternal: userSsrExternal === true ? [...PATCHED_SERVER_PACKAGES] : true
1511
1755
  } },
1512
1756
  optimizeDeps: {
1513
1757
  exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], userSsrExternal === true || externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []),
@@ -1526,6 +1770,7 @@ function vinext(options = {}) {
1526
1770
  entries: optimizeEntries,
1527
1771
  include: [.../* @__PURE__ */ new Set([
1528
1772
  ...incomingInclude,
1773
+ ...additionalClientOptimizeIncludes,
1529
1774
  "react",
1530
1775
  "react-dom",
1531
1776
  "react-dom/client",
@@ -1549,6 +1794,7 @@ function vinext(options = {}) {
1549
1794
  } else if (hasCloudflarePlugin) viteConfig.environments = { client: {
1550
1795
  consumer: "client",
1551
1796
  optimizeDeps: {
1797
+ include: ["react-dom/client"],
1552
1798
  ...pagesOptimizeEntries.length > 0 ? { entries: pagesOptimizeEntries } : {},
1553
1799
  ...depOptimizeNodeEnvOptions
1554
1800
  },
@@ -1563,49 +1809,55 @@ function vinext(options = {}) {
1563
1809
  })
1564
1810
  }
1565
1811
  } };
1566
- else if (shouldInjectPlainPagesEnvironments) viteConfig.environments = {
1567
- client: {
1568
- consumer: "client",
1569
- optimizeDeps: {
1570
- ...pagesOptimizeEntries.length > 0 ? { entries: pagesOptimizeEntries } : {},
1571
- ...depOptimizeNodeEnvOptions
1572
- },
1573
- build: {
1574
- outDir: "dist/client",
1575
- manifest: true,
1576
- ssrManifest: true,
1577
- assetsInlineLimit: clientAssetsInlineLimit,
1578
- ...withBuildBundlerOptions({
1579
- input: { index: VIRTUAL_CLIENT_ENTRY },
1580
- output: getClientOutputConfig(clientAssetsDir),
1581
- treeshake: getClientTreeshakeConfig()
1582
- })
1583
- }
1584
- },
1585
- ssr: {
1586
- resolve: {
1587
- external: [
1588
- "react",
1589
- "react-dom",
1590
- "react-dom/server",
1591
- "ipaddr.js",
1592
- ...nextServerExternal
1593
- ],
1594
- noExternal: true
1595
- },
1596
- optimizeDeps: {
1597
- exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], Object.keys(nextShimMap)),
1598
- ...depOptimizeNodeEnvOptions
1812
+ else if (shouldInjectPlainPagesEnvironments) {
1813
+ const plainPagesEnvironments = {
1814
+ client: {
1815
+ consumer: "client",
1816
+ optimizeDeps: {
1817
+ include: ["react-dom/client"],
1818
+ ...pagesOptimizeEntries.length > 0 ? { entries: pagesOptimizeEntries } : {},
1819
+ ...depOptimizeNodeEnvOptions
1820
+ },
1821
+ build: {
1822
+ outDir: "dist/client",
1823
+ manifest: true,
1824
+ ssrManifest: true,
1825
+ assetsInlineLimit: clientAssetsInlineLimit,
1826
+ ...withBuildBundlerOptions({
1827
+ input: { index: VIRTUAL_CLIENT_ENTRY },
1828
+ output: getClientOutputConfig(clientAssetsDir),
1829
+ treeshake: getClientTreeshakeConfig()
1830
+ })
1831
+ }
1599
1832
  },
1600
- build: {
1601
- outDir: "dist/server",
1602
- ...withBuildBundlerOptions({
1603
- input: { index: VIRTUAL_SERVER_ENTRY },
1604
- output: { entryFileNames: "entry.js" }
1605
- })
1833
+ ssr: {
1834
+ resolve: {
1835
+ external: [
1836
+ "react",
1837
+ "react-dom",
1838
+ "react-dom/server",
1839
+ "ipaddr.js",
1840
+ ...nextServerExternal
1841
+ ],
1842
+ noExternal: true
1843
+ },
1844
+ optimizeDeps: {
1845
+ exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], Object.keys(nextShimMap)),
1846
+ ...depOptimizeNodeEnvOptions
1847
+ },
1848
+ build: {
1849
+ outDir: "dist/server",
1850
+ ...withBuildBundlerOptions({
1851
+ input: { index: hasNitroPlugin ? VIRTUAL_WORKER_ENTRY : VIRTUAL_SERVER_ENTRY },
1852
+ output: { entryFileNames: "entry.js" }
1853
+ })
1854
+ }
1606
1855
  }
1607
- }
1608
- };
1856
+ };
1857
+ originalPlainPagesEnvironments = config.environments;
1858
+ viteConfig.environments = plainPagesEnvironments;
1859
+ hasPlainPagesBuildEnvironments = env.command === "build";
1860
+ }
1609
1861
  if (pagesOptimizeEntries.length > 0 && !hasCloudflarePlugin) viteConfig.optimizeDeps = {
1610
1862
  ...viteConfig.optimizeDeps,
1611
1863
  entries: pagesOptimizeEntries
@@ -1637,6 +1889,12 @@ function vinext(options = {}) {
1637
1889
  return null;
1638
1890
  },
1639
1891
  async configResolved(config) {
1892
+ if (isServeCommand && !config["__vinextDevCliLifecycle"] && config.configFile && isViteCliConfigFile(config.configFile, config.inlineConfig)) {
1893
+ if (claimViteCliDevInvocation(config.root, false, true)) {
1894
+ config[VINEXT_DEV_CLI_LIFECYCLE] = true;
1895
+ if (!config.server.middlewareMode) applyDevServerDefaults(config.server, {});
1896
+ }
1897
+ }
1640
1898
  if (isServeCommand && hasCloudflarePlugin && hasPagesDir && !hasAppDir) suppressOptionalOptimizeDepsWarnings(config.logger);
1641
1899
  if (config.worker?.rolldownOptions) {
1642
1900
  const workerFileNames = `${resolveAssetsDir(nextConfig.assetPrefix ?? "")}/workers/[name]-[hash].js`;
@@ -1722,9 +1980,16 @@ function vinext(options = {}) {
1722
1980
  }
1723
1981
  },
1724
1982
  resolveId: {
1725
- filter: { id: /(?:next\/|vinext\/(?:shims\/|server\/app-rsc-handler)|virtual:vinext-|@vercel\/og(?:\.js)?$)/ },
1983
+ filter: { id: /(?:next\/|vinext\/(?:shims\/|server\/(?:app-rsc-(?:combined-)?handler|app-router-entry|pages-router-entry))|virtual:vinext-|@vercel\/og(?:\.js)?$)/ },
1726
1984
  handler(id, importer) {
1727
1985
  const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
1986
+ if (cleanId === "vinext/server/app-rsc-combined-handler") {
1987
+ if (_canExternalizeAppRscHandler && this.environment?.name === "rsc" && this.environment.config?.command === "serve") return {
1988
+ id: _appRscCombinedHandlerPath,
1989
+ external: true
1990
+ };
1991
+ return _appRscCombinedHandlerPath;
1992
+ }
1728
1993
  if (cleanId === "vinext/server/app-rsc-handler") {
1729
1994
  if (_canExternalizeAppRscHandler && this.environment?.name === "rsc" && this.environment.config?.command === "serve") return {
1730
1995
  id: _appRscHandlerPath,
@@ -1735,11 +2000,20 @@ function vinext(options = {}) {
1735
2000
  if (isVercelOgImport(cleanId) && !isVinextOgShimImporter(importer)) return resolveShimModulePath(_shimsDir, "og");
1736
2001
  if (cleanId.startsWith("vinext/shims/")) return resolveShimModulePath(_shimsDir, stripJsExtension(stripViteModuleQuery(cleanId.slice(13))));
1737
2002
  if (cleanId === VIRTUAL_WORKER_ENTRY) return RESOLVED_WORKER_ENTRY;
1738
- if (cleanId.endsWith("/virtual:vinext-worker-entry")) return RESOLVED_WORKER_ENTRY;
2003
+ if (selectedMultiStageOutput && (cleanId === "vinext/server/app-router-entry" || cleanId === "vinext/server/pages-router-entry")) return RESOLVED_WORKER_ENTRY;
2004
+ if (cleanId.endsWith("/" + VIRTUAL_WORKER_ENTRY)) return RESOLVED_WORKER_ENTRY;
2005
+ if (cleanId === VIRTUAL_REQUEST_STAGE) return RESOLVED_REQUEST_STAGE;
2006
+ if (cleanId.endsWith("/" + VIRTUAL_REQUEST_STAGE)) return RESOLVED_REQUEST_STAGE;
2007
+ if (cleanId === VIRTUAL_RESPONSE_STAGE) return RESOLVED_RESPONSE_STAGE;
2008
+ if (cleanId.endsWith("/" + VIRTUAL_RESPONSE_STAGE)) return RESOLVED_RESPONSE_STAGE;
1739
2009
  if (cleanId === VIRTUAL_SERVER_ENTRY) return RESOLVED_SERVER_ENTRY;
2010
+ if (cleanId === VIRTUAL_PAGES_REQUEST_ENTRY) return RESOLVED_PAGES_REQUEST_ENTRY;
2011
+ if (cleanId === VIRTUAL_PAGES_RESPONSE_ENTRY) return RESOLVED_PAGES_RESPONSE_ENTRY;
1740
2012
  if (cleanId === VIRTUAL_CLIENT_ENTRY) return RESOLVED_CLIENT_ENTRY;
1741
- if (cleanId.endsWith("/virtual:vinext-server-entry")) return RESOLVED_SERVER_ENTRY;
1742
- if (cleanId.endsWith("/virtual:vinext-client-entry")) return RESOLVED_CLIENT_ENTRY;
2013
+ if (cleanId.endsWith("/" + VIRTUAL_SERVER_ENTRY)) return RESOLVED_SERVER_ENTRY;
2014
+ if (cleanId.endsWith("/" + VIRTUAL_PAGES_REQUEST_ENTRY)) return RESOLVED_PAGES_REQUEST_ENTRY;
2015
+ if (cleanId.endsWith("/" + VIRTUAL_PAGES_RESPONSE_ENTRY)) return RESOLVED_PAGES_RESPONSE_ENTRY;
2016
+ if (cleanId.endsWith("/" + VIRTUAL_CLIENT_ENTRY)) return RESOLVED_CLIENT_ENTRY;
1743
2017
  if (cleanId === VIRTUAL_RSC_ENTRY) return RESOLVED_RSC_ENTRY;
1744
2018
  if (cleanId === VIRTUAL_CACHEABILITY_MANIFEST) {
1745
2019
  if ((hasAppDir ? this.environment?.name === "rsc" : this.environment !== void 0 && isServerEnvironment(this.environment)) && this.environment.config?.command === "build") return {
@@ -1748,16 +2022,35 @@ function vinext(options = {}) {
1748
2022
  };
1749
2023
  return RESOLVED_CACHEABILITY_MANIFEST;
1750
2024
  }
2025
+ if (cleanId === VIRTUAL_CACHEABILITY_REQUEST_PROJECTION) {
2026
+ if (hasAppDir && this.environment?.name === "rsc" && this.environment.config?.command === "build") return {
2027
+ id: `./${CACHEABILITY_REQUEST_PROJECTION_MODULE}`,
2028
+ external: true
2029
+ };
2030
+ return RESOLVED_CACHEABILITY_REQUEST_PROJECTION;
2031
+ }
2032
+ if (cleanId === VIRTUAL_PREGENERATED_CONCRETE_PATHS) {
2033
+ if ((hasAppDir ? this.environment?.name === "rsc" : this.environment !== void 0 && isServerEnvironment(this.environment)) && this.environment.config?.command === "build") return {
2034
+ id: `./${PREGENERATED_CONCRETE_PATHS_MODULE}`,
2035
+ external: true
2036
+ };
2037
+ return RESOLVED_PREGENERATED_CONCRETE_PATHS;
2038
+ }
2039
+ if (cleanId === VIRTUAL_APP_REQUEST_ENTRY) return RESOLVED_APP_REQUEST_ENTRY;
2040
+ if (cleanId === VIRTUAL_APP_RESPONSE_ENTRY) return RESOLVED_APP_RESPONSE_ENTRY;
1751
2041
  if (cleanId === VIRTUAL_APP_SSR_ENTRY) return RESOLVED_APP_SSR_ENTRY;
1752
2042
  if (cleanId === VIRTUAL_APP_BROWSER_ENTRY) return RESOLVED_APP_BROWSER_ENTRY;
1753
2043
  if (cleanId === VIRTUAL_APP_CAPABILITIES) return RESOLVED_APP_CAPABILITIES;
1754
2044
  if (cleanId === "next/root-params" || cleanId === "next/root-params.js") return RESOLVED_ROOT_PARAMS;
1755
2045
  if (cleanId === "virtual:vinext-cache-adapters" || cleanId.endsWith("/virtual:vinext-cache-adapters")) return RESOLVED_CACHE_ADAPTERS;
2046
+ if (cleanId === "virtual:vinext-cdn-cache-adapter" || cleanId.endsWith("/virtual:vinext-cdn-cache-adapter")) return RESOLVED_CDN_CACHE_ADAPTER;
1756
2047
  if (cleanId === "virtual:vinext-image-adapters" || cleanId.endsWith("/virtual:vinext-image-adapters")) return RESOLVED_IMAGE_ADAPTERS;
1757
2048
  if (cleanId.startsWith("virtual:vinext-google-fonts?")) return RESOLVED_VIRTUAL_GOOGLE_FONTS + cleanId.slice(VIRTUAL_GOOGLE_FONTS.length);
1758
- if (cleanId.endsWith("/virtual:vinext-rsc-entry")) return RESOLVED_RSC_ENTRY;
1759
- if (cleanId.endsWith("/virtual:vinext-app-ssr-entry")) return RESOLVED_APP_SSR_ENTRY;
1760
- if (cleanId.endsWith("/virtual:vinext-app-browser-entry")) return RESOLVED_APP_BROWSER_ENTRY;
2049
+ if (cleanId.endsWith("/" + VIRTUAL_RSC_ENTRY)) return RESOLVED_RSC_ENTRY;
2050
+ if (cleanId.endsWith("/" + VIRTUAL_APP_REQUEST_ENTRY)) return RESOLVED_APP_REQUEST_ENTRY;
2051
+ if (cleanId.endsWith("/" + VIRTUAL_APP_RESPONSE_ENTRY)) return RESOLVED_APP_RESPONSE_ENTRY;
2052
+ if (cleanId.endsWith("/" + VIRTUAL_APP_SSR_ENTRY)) return RESOLVED_APP_SSR_ENTRY;
2053
+ if (cleanId.endsWith("/" + VIRTUAL_APP_BROWSER_ENTRY)) return RESOLVED_APP_BROWSER_ENTRY;
1761
2054
  if (cleanId.includes("/virtual:vinext-google-fonts?")) {
1762
2055
  const queryIndex = cleanId.indexOf(VIRTUAL_GOOGLE_FONTS + "?");
1763
2056
  return RESOLVED_VIRTUAL_GOOGLE_FONTS + cleanId.slice(queryIndex + VIRTUAL_GOOGLE_FONTS.length);
@@ -1772,14 +2065,41 @@ function vinext(options = {}) {
1772
2065
  load: {
1773
2066
  filter: { id: /virtual:vinext-/ },
1774
2067
  async handler(id) {
1775
- if (id === RESOLVED_WORKER_ENTRY) return `export { default } from ${JSON.stringify(hasAppDir ? "vinext/server/app-router-entry" : "vinext/server/pages-router-entry")};`;
2068
+ if (id === RESOLVED_WORKER_ENTRY) {
2069
+ if (selectedMultiStageOutput?.type === "multi-stage") return [
2070
+ `export { default } from ${JSON.stringify(selectedMultiStageOutput.entry)};`,
2071
+ `export * from ${JSON.stringify(selectedMultiStageOutput.entry)};`,
2072
+ ""
2073
+ ].join("\n");
2074
+ const entry = hasAppDir ? "vinext/server/app-router-entry" : "vinext/server/pages-router-entry";
2075
+ if (!hasAppDir && hasNitroPlugin) return [
2076
+ `import worker from ${JSON.stringify(entry)};`,
2077
+ "export default { fetch(request, env, ctx) {",
2078
+ ` return worker.fetch(request, env, { ...ctx, hostRuntime: ${JSON.stringify(nitroHostRuntime)} });`,
2079
+ "} };"
2080
+ ].join("\n");
2081
+ return `export { default } from ${JSON.stringify(entry)};`;
2082
+ }
2083
+ if (id === RESOLVED_REQUEST_STAGE) return `export { handleRequestStage } from ${JSON.stringify(hasAppDir ? APP_REQUEST_STAGE_ENTRY : PAGES_REQUEST_STAGE_ENTRY)};\n`;
2084
+ if (id === RESOLVED_RESPONSE_STAGE) return `export * from ${JSON.stringify(hasAppDir ? APP_RESPONSE_STAGE_ENTRY : PAGES_RESPONSE_STAGE_ENTRY)};\n`;
1776
2085
  if (id === RESOLVED_SERVER_ENTRY) {
1777
2086
  recordServerEntryLoad(this.environment?.name, id);
1778
2087
  return await generateServerEntry$1(this.environment.config.publicDir === "" ? false : this.environment.config.publicDir);
1779
2088
  }
2089
+ if (id === RESOLVED_PAGES_REQUEST_ENTRY) {
2090
+ recordServerEntryLoad(this.environment?.name, id);
2091
+ return await generatePagesRequestEntry$1(this.environment.config.publicDir === "" ? false : this.environment.config.publicDir);
2092
+ }
2093
+ if (id === RESOLVED_PAGES_RESPONSE_ENTRY) {
2094
+ recordServerEntryLoad(this.environment?.name, id);
2095
+ return await generatePagesResponseEntry$1();
2096
+ }
1780
2097
  if (id === RESOLVED_CLIENT_ENTRY) return await generateClientEntry$1();
1781
2098
  if (id === RESOLVED_PAGES_CLIENT_ASSETS) {
1782
- const metadata = { clientEntry: DEV_PAGES_CLIENT_ENTRY };
2099
+ const metadata = {
2100
+ clientEntry: DEV_PAGES_CLIENT_ENTRY,
2101
+ crossOrigin: nextConfig?.crossOrigin ?? ""
2102
+ };
1783
2103
  const ssrManifest = {};
1784
2104
  const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
1785
2105
  const pagesRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
@@ -1792,18 +2112,21 @@ function vinext(options = {}) {
1792
2112
  if (Object.keys(ssrManifest).length > 0) metadata.ssrManifest = ssrManifest;
1793
2113
  return `export default ${JSON.stringify(metadata)};`;
1794
2114
  }
1795
- if (id === RESOLVED_CACHEABILITY_MANIFEST) return "export default null;";
1796
- if (id === RESOLVED_RSC_ENTRY && hasAppDir) {
2115
+ if (id === RESOLVED_CACHEABILITY_MANIFEST || id === RESOLVED_CACHEABILITY_REQUEST_PROJECTION) return "export default null;";
2116
+ if (id === RESOLVED_PREGENERATED_CONCRETE_PATHS) return "export {};";
2117
+ if ((id === RESOLVED_RSC_ENTRY || id === RESOLVED_APP_REQUEST_ENTRY || id === RESOLVED_APP_RESPONSE_ENTRY) && hasAppDir) {
1797
2118
  recordServerEntryLoad(this.environment?.name, id);
1798
2119
  const routes = await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher);
1799
2120
  const metaRoutes = scanMetadataFiles(appDir);
1800
2121
  const hasServerActions = await resolveHasServerActions(this.environment.config);
1801
2122
  const globalErrorPath = findFileWithExts(appDir, "global-error", fileMatcher);
1802
2123
  const globalNotFoundPath = nextConfig?.globalNotFound ? findFileWithExts(appDir, "global-not-found", fileMatcher) : null;
1803
- rscClassificationManifest = collectRouteClassificationManifest(routes);
1804
- rscActionOwnerRoutes = this.environment.config.command === "build" && hasServerActions ? routes : null;
1805
- rscActionOwnerSharedRoots = [globalErrorPath, globalNotFoundPath].filter((path) => path !== null);
1806
- return generateRscEntry(appDir, routes, middlewarePath, metaRoutes, globalErrorPath, nextConfig?.basePath, nextConfig?.trailingSlash, {
2124
+ if (id !== RESOLVED_APP_REQUEST_ENTRY) {
2125
+ rscClassificationManifests.set(id, collectRouteClassificationManifest(routes));
2126
+ rscActionOwnerRoutes = this.environment.config.command === "build" && hasServerActions ? routes : null;
2127
+ rscActionOwnerSharedRoots = [globalErrorPath, globalNotFoundPath].filter((path) => path !== null);
2128
+ }
2129
+ return (id === RESOLVED_APP_REQUEST_ENTRY ? generateAppRequestRscEntry : id === RESOLVED_APP_RESPONSE_ENTRY ? generateAppResponseRscEntry : generateRscEntry)(appDir, routes, middlewarePath, metaRoutes, globalErrorPath, nextConfig?.basePath, nextConfig?.trailingSlash, {
1807
2130
  redirects: nextConfig?.redirects,
1808
2131
  rewrites: nextConfig?.rewrites,
1809
2132
  headers: nextConfig?.headers,
@@ -1813,7 +2136,9 @@ function vinext(options = {}) {
1813
2136
  bodySizeLimitLabel: nextConfig?.serverActionsBodySizeLimitLabel,
1814
2137
  htmlLimitedBots: nextConfig?.htmlLimitedBots,
1815
2138
  clientTraceMetadata: nextConfig?.clientTraceMetadata,
2139
+ nodeOpenTelemetryLoader: registerNodeOpenTelemetryLoader,
1816
2140
  assetPrefix: nextConfig?.assetPrefix,
2141
+ crossOrigin: nextConfig?.crossOrigin,
1817
2142
  expireTime: nextConfig?.expireTime,
1818
2143
  reactMaxHeadersLength: nextConfig?.reactMaxHeadersLength,
1819
2144
  cacheMaxMemorySize: nextConfig?.cacheMaxMemorySize,
@@ -1842,6 +2167,7 @@ function vinext(options = {}) {
1842
2167
  }
1843
2168
  if (id === RESOLVED_ROOT_PARAMS) return generateRootParamsModule((hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : []).flatMap((route) => route.rootParamNames ?? []));
1844
2169
  if (id === RESOLVED_CACHE_ADAPTERS) return generateCacheAdaptersModule(options.cache);
2170
+ if (id === RESOLVED_CDN_CACHE_ADAPTER) return generateCdnCacheAdapterModule(options.cache);
1845
2171
  if (id === RESOLVED_IMAGE_ADAPTERS) return generateImageAdaptersModule(options.images);
1846
2172
  if (id === RESOLVED_APP_SSR_ENTRY && hasAppDir) {
1847
2173
  recordServerEntryLoad(this.environment?.name, id);
@@ -1876,9 +2202,12 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1876
2202
  order: "pre",
1877
2203
  handler(code, chunk) {
1878
2204
  if (this.environment?.name !== "rsc") return null;
1879
- if (!rscClassificationManifest) return null;
1880
2205
  const hasClassificationStub = code.includes("__VINEXT_CLASS");
1881
2206
  if (!hasClassificationStub) return null;
2207
+ const rscEntryId = [RESOLVED_RSC_ENTRY, RESOLVED_APP_RESPONSE_ENTRY].find((id) => chunk.moduleIds.includes(id));
2208
+ if (!rscEntryId) return null;
2209
+ const rscClassificationManifest = rscClassificationManifests.get(rscEntryId);
2210
+ if (!rscClassificationManifest) return null;
1882
2211
  const enableClassificationDebug = Boolean(process.env.VINEXT_DEBUG_CLASSIFICATION);
1883
2212
  const patchPlan = hasClassificationStub && rscClassificationManifest ? planRouteClassificationInjection({
1884
2213
  canonicalizeLayoutPath: canonicalize,
@@ -1900,7 +2229,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1900
2229
  }) : { kind: "skip" };
1901
2230
  const nextCode = patchPlan.kind === "skip" ? code : patchPlan.code;
1902
2231
  if (patchPlan.kind === "skip") return null;
1903
- rscClassificationManifest = null;
2232
+ rscClassificationManifests.delete(rscEntryId);
1904
2233
  return {
1905
2234
  code: nextCode,
1906
2235
  map: null
@@ -1908,6 +2237,21 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1908
2237
  }
1909
2238
  }
1910
2239
  },
2240
+ {
2241
+ name: "vinext:cloudflare-framework-tracing",
2242
+ transform: {
2243
+ filter: { id: /(?:app|pages)-router-entry\.[cm]?[jt]s(?:\?|$)/ },
2244
+ handler(code, id) {
2245
+ if (!hasCloudflarePlugin) return null;
2246
+ const cleanId = toSlash(stripViteModuleQuery(id));
2247
+ if (!WORKER_ROUTER_ENTRIES.has(cleanId)) return null;
2248
+ return {
2249
+ code: `import "vinext/internal/server/cloudflare-workers-tracing";\n${code}`,
2250
+ map: null
2251
+ };
2252
+ }
2253
+ }
2254
+ },
1911
2255
  {
1912
2256
  name: "vinext:pages-client-assets-resolver",
1913
2257
  sharedDuringBuild: true,
@@ -1915,11 +2259,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1915
2259
  filter: { id: /virtual:vinext-pages-client-assets$/ },
1916
2260
  handler(id) {
1917
2261
  const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
1918
- if (cleanId !== VIRTUAL_PAGES_CLIENT_ASSETS && !cleanId.endsWith("/virtual:vinext-pages-client-assets")) return;
2262
+ if (cleanId !== VIRTUAL_PAGES_CLIENT_ASSETS && !cleanId.endsWith("/" + VIRTUAL_PAGES_CLIENT_ASSETS)) return;
1919
2263
  if (this.environment?.config.command !== "build") return RESOLVED_PAGES_CLIENT_ASSETS;
1920
2264
  const buildRoot = this.environment.config.root ?? process.cwd();
1921
2265
  const environmentOutDir = path.resolve(buildRoot, this.environment.config.build.outDir);
1922
- const sidecarDir = !hasAppDir && this.environment.name === "ssr" ? path.dirname(environmentOutDir) : environmentOutDir;
2266
+ const sidecarDir = resolvePagesClientAssetsOutputDir(this.environment.name, environmentOutDir);
1923
2267
  let externalId = path.relative(environmentOutDir, path.join(sidecarDir, PAGES_CLIENT_ASSETS_MODULE));
1924
2268
  if (!externalId.startsWith(".")) externalId = `./${externalId}`;
1925
2269
  pagesClientAssetsOutputDirs.add(sidecarDir);
@@ -1928,6 +2272,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1928
2272
  external: true
1929
2273
  };
1930
2274
  }
2275
+ },
2276
+ outputOptions(output) {
2277
+ const environment = this.environment;
2278
+ if (!selectedMultiStageOutput || !environment || !isMultiStageServerEnvironment(environment)) return;
2279
+ const buildRoot = environment.config.root ?? process.cwd();
2280
+ const outputDir = path.resolve(buildRoot, output.dir ?? environment.config.build.outDir);
2281
+ pagesClientAssetsOutputDirs.add(resolvePagesClientAssetsOutputDir(environment.name, outputDir));
1931
2282
  }
1932
2283
  },
1933
2284
  {
@@ -1949,6 +2300,49 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1949
2300
  }
1950
2301
  }
1951
2302
  },
2303
+ {
2304
+ name: "vinext:multi-stage-host-entry",
2305
+ transform: {
2306
+ filter: { id: /virtual:|\.[cm]?[jt]sx?(?:\?|$)/ },
2307
+ handler(code, id) {
2308
+ const environment = this.environment;
2309
+ if (!isServeCommand && (!environment || !isMultiStageServerEnvironment(environment))) return null;
2310
+ const transformed = matchedMultiStageOutput?.transformHostEntry?.({
2311
+ code,
2312
+ id
2313
+ });
2314
+ return transformed == null ? null : {
2315
+ code: transformed,
2316
+ map: null
2317
+ };
2318
+ }
2319
+ }
2320
+ },
2321
+ {
2322
+ name: "vinext:multi-stage-server-output",
2323
+ apply: "build",
2324
+ buildStart() {
2325
+ const entries = selectedMultiStageOutput?.entries;
2326
+ const environment = this.environment;
2327
+ if (!entries || !environment || !isMultiStageServerEnvironment(environment)) return;
2328
+ for (const [name, id] of [["vinext-request-stage", entries.request], ["vinext-response-stage", entries.response]]) this.emitFile({
2329
+ id,
2330
+ name,
2331
+ preserveSignature: "strict",
2332
+ type: "chunk"
2333
+ });
2334
+ },
2335
+ outputOptions(output) {
2336
+ const environment = this.environment;
2337
+ if (!selectedMultiStageOutput || !environment || !isMultiStageServerEnvironment(environment)) return;
2338
+ if (output.format !== void 0 && output.format !== "es" && output.format !== "esm" && output.format !== "module") throw new Error(`[vinext] Multi-stage output requires an ES module format; ${JSON.stringify(output.format)} cannot represent independently deployable request and response entries.`);
2339
+ return {
2340
+ ...output,
2341
+ chunkFileNames: createMultiStageChunkFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? ""), output.chunkFileNames),
2342
+ codeSplitting: createMultiStageCodeSplittingConfig(output.codeSplitting)
2343
+ };
2344
+ }
2345
+ },
1952
2346
  {
1953
2347
  name: "vinext:css-url-assets-defaults",
1954
2348
  apply: "build",
@@ -1957,7 +2351,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1957
2351
  if (!hasAppDir || name !== "rsc" && name !== "ssr") return null;
1958
2352
  const output = getBuildBundlerOptions(config.build)?.output;
1959
2353
  if (Array.isArray(output) || output?.assetFileNames !== void 0) return null;
1960
- return { build: { ...withBuildBundlerOptions({ output: { assetFileNames: createClientAssetFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? "")) } }) } };
2354
+ const assetFileNames = createClientAssetFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? ""));
2355
+ return { build: { ...withBuildBundlerOptions({ output: { assetFileNames } }) } };
1961
2356
  }
1962
2357
  },
1963
2358
  {
@@ -1990,6 +2385,18 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1990
2385
  fileName: CACHEABILITY_MANIFEST_MODULE,
1991
2386
  source: "export default null;\n"
1992
2387
  });
2388
+ if (hasAppDir) {
2389
+ this.emitFile({
2390
+ type: "asset",
2391
+ fileName: CACHEABILITY_REQUEST_PROJECTION_MODULE,
2392
+ source: "export default null;\n"
2393
+ });
2394
+ this.emitFile({
2395
+ type: "asset",
2396
+ fileName: PREGENERATED_CONCRETE_PATHS_MODULE,
2397
+ source: "delete globalThis.__VINEXT_PREGENERATED_CONCRETE_PATHS;\n"
2398
+ });
2399
+ }
1993
2400
  }
1994
2401
  },
1995
2402
  {
@@ -2026,7 +2433,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2026
2433
  }
2027
2434
  },
2028
2435
  asyncHooksStubPlugin,
2029
- createInstrumentationClientTransformPlugin(() => instrumentationClientPath),
2436
+ createInstrumentationClientTransformPlugin(() => instrumentationClientPath, () => nextConfig.instrumentationClientRouteManifest),
2437
+ createInstrumentationServerTransformPlugin(() => instrumentationPath, () => nextConfig.instrumentationServerValueInjections),
2030
2438
  {
2031
2439
  name: "vinext:instrumentation-client-inject",
2032
2440
  enforce: "pre",
@@ -2148,8 +2556,23 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2148
2556
  return `http://localhost:${typeof address === "object" && address ? address.port : server.config.server.port ?? 3e3}`;
2149
2557
  };
2150
2558
  let cachedSSRHandler = null;
2559
+ const devPageRouteDataKinds = /* @__PURE__ */ new Map();
2560
+ function classifyDevPageFile(filePath) {
2561
+ const cached = devPageRouteDataKinds.get(filePath);
2562
+ if (cached) return cached;
2563
+ let dataKind = "none";
2564
+ try {
2565
+ const source = fs.readFileSync(filePath, "utf8");
2566
+ dataKind = hasExportedName(source, "getStaticProps") ? "static" : hasExportedName(source, "getServerSideProps") ? "server" : "none";
2567
+ } catch {}
2568
+ devPageRouteDataKinds.set(filePath, dataKind);
2569
+ return dataKind;
2570
+ }
2151
2571
  function getPagesRunner() {
2152
- if (!pagesRunner) pagesRunner = createDirectRunner(server.environments["ssr"] ?? Object.values(server.environments).find((e) => e !== server.environments["rsc"]) ?? Object.values(server.environments)[0]);
2572
+ if (!pagesRunner) {
2573
+ const env = server.environments["ssr"] ?? Object.values(server.environments).find((e) => e !== server.environments["rsc"]) ?? Object.values(server.environments)[0];
2574
+ pagesRunner = createDirectRunner(env);
2575
+ }
2153
2576
  return pagesRunner;
2154
2577
  }
2155
2578
  /**
@@ -2198,6 +2621,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2198
2621
  }
2199
2622
  pagesRunner?.clearCache();
2200
2623
  }
2624
+ function invalidatePagesHydrationProxies() {
2625
+ const graph = server.environments.client?.moduleGraph;
2626
+ if (!graph) return;
2627
+ for (const mod of graph.idToModuleMap.values()) if (mod.id?.includes("?html-proxy&index=")) graph.invalidateModule(mod);
2628
+ }
2201
2629
  function invalidateAppRoutingModules() {
2202
2630
  invalidateAppRouteCache();
2203
2631
  invalidateMetadataFileCache();
@@ -2309,13 +2737,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2309
2737
  if (hasAppDir) invalidateRscEntryModule();
2310
2738
  if (hasCloudflarePlugin && hasPagesDir && !hasAppDir) invalidatePagesServerEntry();
2311
2739
  };
2740
+ function invalidatePagesMiddlewareMatcher(filePath) {
2741
+ if (!hasPagesDir || !middlewarePath || toSlash(filePath) !== middlewarePath) return;
2742
+ cachedSSRHandler = null;
2743
+ server.ws.send({ type: "full-reload" });
2744
+ }
2312
2745
  server.watcher.on("add", (filePath) => {
2746
+ invalidatePagesMiddlewareMatcher(filePath);
2313
2747
  updatePublicFileRoute(filePath, true);
2314
2748
  let routeChanged = false;
2315
2749
  const pagesAppChanged = isPagesAppFile(filePath);
2316
2750
  const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
2317
2751
  if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
2318
2752
  if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
2753
+ devPageRouteDataKinds.delete(toSlash(filePath));
2319
2754
  invalidateRouteCache(pagesDir);
2320
2755
  routeChanged = true;
2321
2756
  }
@@ -2326,23 +2761,37 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2326
2761
  }
2327
2762
  if (routeChanged) {
2328
2763
  invalidatePagesServerEntry();
2764
+ if (hasPagesDir) invalidatePagesHydrationProxies();
2329
2765
  if (!hasAppDir) server.ws.send({ type: "full-reload" });
2330
2766
  invalidateHybridClientEntries();
2331
2767
  revalidateHybridRoutes();
2332
2768
  }
2333
2769
  });
2334
2770
  server.watcher.on("change", (filePath) => {
2771
+ invalidatePagesMiddlewareMatcher(filePath);
2772
+ if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
2773
+ const pageFile = toSlash(filePath);
2774
+ const previousKind = devPageRouteDataKinds.get(pageFile);
2775
+ devPageRouteDataKinds.delete(pageFile);
2776
+ if (previousKind !== void 0 && previousKind !== classifyDevPageFile(pageFile)) {
2777
+ cachedSSRHandler = null;
2778
+ invalidatePagesHydrationProxies();
2779
+ server.ws.send({ type: "full-reload" });
2780
+ }
2781
+ }
2335
2782
  const pagesAppChanged = isPagesAppFile(filePath);
2336
2783
  const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
2337
2784
  if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
2338
2785
  });
2339
2786
  server.watcher.on("unlink", (filePath) => {
2787
+ invalidatePagesMiddlewareMatcher(filePath);
2340
2788
  updatePublicFileRoute(filePath, false);
2341
2789
  let routeChanged = false;
2342
2790
  const pagesAppChanged = isPagesAppFile(filePath);
2343
2791
  const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
2344
2792
  if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
2345
2793
  if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
2794
+ devPageRouteDataKinds.delete(toSlash(filePath));
2346
2795
  invalidateRouteCache(pagesDir);
2347
2796
  routeChanged = true;
2348
2797
  }
@@ -2353,6 +2802,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2353
2802
  }
2354
2803
  if (routeChanged) {
2355
2804
  invalidatePagesServerEntry();
2805
+ if (hasPagesDir) invalidatePagesHydrationProxies();
2356
2806
  if (!hasAppDir) server.ws.send({ type: "full-reload" });
2357
2807
  invalidateHybridClientEntries();
2358
2808
  revalidateHybridRoutes();
@@ -2393,7 +2843,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2393
2843
  });
2394
2844
  server.middlewares.use((req, res, next) => {
2395
2845
  if (!hasPagesDir || !handlePagesMiddleware || !isUnsupportedDevPublicRequest(req)) return next();
2396
- handlePagesMiddleware(req, res, next);
2846
+ handlePagesMiddleware(req, res, next).catch(next);
2397
2847
  });
2398
2848
  installDevStackSourcemapMiddleware(server);
2399
2849
  return () => {
@@ -2453,9 +2903,15 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2453
2903
  restore();
2454
2904
  return false;
2455
2905
  };
2456
- if (instrumentationPath && !hasAppDir) runInstrumentation(getPagesRunner(), instrumentationPath).catch((err) => {
2457
- console.error("[vinext] Instrumentation error:", err);
2458
- });
2906
+ const pagesInstrumentationReady = (async () => {
2907
+ if (!instrumentationPath || hasAppDir && hasCloudflarePlugin) return;
2908
+ if (hasAppDir) {
2909
+ const environment = server.environments["rsc"];
2910
+ if (!isRunnableDevEnvironment(environment)) return;
2911
+ return runInstrumentation(environment.runner, instrumentationPath);
2912
+ } else return runInstrumentation(getPagesRunner(), instrumentationPath);
2913
+ })();
2914
+ pagesInstrumentationReady.catch(() => {});
2459
2915
  if (hasAppDir) server.middlewares.use((req, res, next) => {
2460
2916
  const url = req.url ?? "/";
2461
2917
  const [pathname] = url.split("?");
@@ -2506,13 +2962,10 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2506
2962
  });
2507
2963
  next();
2508
2964
  });
2509
- handlePagesMiddleware = async (req, res, next) => {
2965
+ const handlePagesRequest = async (req, res, next) => {
2510
2966
  try {
2511
2967
  let url = req.url ?? "/";
2512
2968
  const originalRequestUrl = url;
2513
- if (!hasPagesDir) return next();
2514
- if (url.startsWith("/@") || url.startsWith("/__vite") || url.startsWith("/node_modules")) return next();
2515
- if (url.split("?")[0].endsWith(".rsc")) return next();
2516
2969
  const blockReason = validateDevRequest({
2517
2970
  origin: req.headers.origin,
2518
2971
  host: req.headers.host,
@@ -2706,19 +3159,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2706
3159
  const getDevApiRoutes = () => devApiRoutesPromise ??= apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
2707
3160
  let devAppRoutesPromise = null;
2708
3161
  const getDevAppRoutes = () => devAppRoutesPromise ??= hasAppDir && appDir ? appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : Promise.resolve([]);
2709
- const devPageRouteDataKinds = /* @__PURE__ */ new Map();
2710
- const classifyDevPageRoute = (route) => {
2711
- const cached = devPageRouteDataKinds.get(route.filePath);
2712
- if (cached) return cached;
2713
- let dataKind = "none";
2714
- try {
2715
- const source = fs.readFileSync(route.filePath, "utf8");
2716
- dataKind = hasExportedName(source, "getStaticProps") ? "static" : hasExportedName(source, "getServerSideProps") ? "server" : "none";
2717
- } catch {}
2718
- devPageRouteDataKinds.set(route.filePath, dataKind);
2719
- return dataKind;
2720
- };
2721
- const pipelineResult = await runPagesRequest(webRequest, {
3162
+ const classifyDevPageRoute = (route) => classifyDevPageFile(route.filePath);
3163
+ const pipelineDeps = {
2722
3164
  basePath: bp,
2723
3165
  trailingSlash: nextConfig?.trailingSlash ?? false,
2724
3166
  i18nConfig: nextConfig?.i18n ?? null,
@@ -2738,12 +3180,15 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2738
3180
  configMatchPathname,
2739
3181
  runMiddleware: devRunMiddlewareAdapter,
2740
3182
  matchApiRoute: async (apiUrl) => {
2741
- const pagesMatch = matchRoute(apiUrl, await getDevApiRoutes());
3183
+ const devApiRoutes = await getDevApiRoutes();
3184
+ const pagesMatch = matchRoute(apiUrl, devApiRoutes);
2742
3185
  if (pagesMatch) return pagesMatch;
2743
- return matchAppRoute(apiUrl, await getDevAppRoutes());
3186
+ const devAppRoutes = await getDevAppRoutes();
3187
+ return matchAppRoute(apiUrl, devAppRoutes);
2744
3188
  },
2745
3189
  matchPageRoute: (resolvedPathname, request) => {
2746
- const m = matchRoute(nextConfig?.i18n ? resolvePagesI18nRequest(resolvedPathname, nextConfig.i18n, request.headers, getUrlHostname(request.url), bp, nextConfig.trailingSlash ?? false).url : resolvedPathname, devPageRoutes);
3190
+ const routeUrl = nextConfig?.i18n ? resolvePagesI18nRequest(resolvedPathname, nextConfig.i18n, request.headers, getUrlHostname(request.url), bp, nextConfig.trailingSlash ?? false).url : resolvedPathname;
3191
+ const m = matchRoute(routeUrl, devPageRoutes);
2747
3192
  return m ? { route: {
2748
3193
  dataKind: classifyDevPageRoute(m.route),
2749
3194
  isDynamic: m.route.isDynamic,
@@ -2762,11 +3207,14 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2762
3207
  externalInit.body = Readable.toWeb(req);
2763
3208
  externalInit.duplex = "half";
2764
3209
  }
2765
- return proxyExternalRequest(new Request(new URL(url, requestOrigin), externalInit), externalUrl);
3210
+ const reqWithBody = new Request(new URL(url, requestOrigin), externalInit);
3211
+ return proxyExternalRequest(reqWithBody, externalUrl);
2766
3212
  },
2767
3213
  serveFilesystemRoute: async (requestPathname, stagedHeaders, phase, resolvedUrl) => {
2768
3214
  if (isImageOptimizationPath(requestPathname)) {
2769
- const encodedLocation = resolveDevImageRedirect(new URL(resolvedUrl, requestOrigin), [...nextConfig.images?.deviceSizes ?? DEFAULT_DEVICE_SIZES, ...nextConfig.images?.imageSizes ?? DEFAULT_IMAGE_SIZES], nextConfig.images?.qualities);
3215
+ const imageRequestUrl = new URL(resolvedUrl, requestOrigin);
3216
+ const allowedWidths = [...nextConfig.images?.deviceSizes ?? DEFAULT_DEVICE_SIZES, ...nextConfig.images?.imageSizes ?? DEFAULT_IMAGE_SIZES];
3217
+ const encodedLocation = resolveDevImageRedirect(imageRequestUrl, allowedWidths, nextConfig.images?.qualities);
2770
3218
  return encodedLocation ? new Response(null, {
2771
3219
  status: 302,
2772
3220
  headers: { Location: encodedLocation }
@@ -2777,7 +3225,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2777
3225
  if (!isRetrievalMethod) return isExistingDevPublicFile(requestPathname) ? methodNotAllowedResponse("GET, HEAD") : false;
2778
3226
  return serveRewrittenViteFilesystemRoute(req, res, requestPathname, stagedHeaders);
2779
3227
  }
2780
- });
3228
+ };
3229
+ const pipelineResult = await runPagesRequest(webRequest, pipelineDeps);
2781
3230
  if (pipelineResult.type === "response") {
2782
3231
  await writeWebResponseToNodeRes(res, pipelineResult.response);
2783
3232
  return;
@@ -2841,12 +3290,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2841
3290
  const renderMatch = matchRoute(resolvedPathname, routes);
2842
3291
  if (hasAppDir && appDir) {
2843
3292
  if (!renderMatch) return next();
2844
- const appMatch = matchAppRoute(resolvedPathname, await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher));
3293
+ const appRoutes = await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher);
3294
+ const appMatch = matchAppRoute(resolvedPathname, appRoutes);
2845
3295
  if (appMatch && !pagesRouteHasPriorityOverAppRoute(renderMatch.route, appMatch.route)) return next();
2846
3296
  }
2847
3297
  if (!cachedSSRHandler || cachedSSRHandler.routes !== routes) cachedSSRHandler = {
2848
3298
  routes,
2849
- handler: createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false, middlewarePath !== null, (nextConfig?.rewrites.beforeFiles.length ?? 0) > 0 || (nextConfig?.rewrites.afterFiles.length ?? 0) > 0 || (nextConfig?.rewrites.fallback.length ?? 0) > 0, nextConfig?.clientTraceMetadata, nextConfig?.htmlLimitedBots, nextConfig?.reactStrictMode === true, nextConfig?.expireTime, nextConfig?.crossOrigin, devBuildId)
3299
+ handler: createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false, middlewarePath !== null, (nextConfig?.rewrites.beforeFiles.length ?? 0) > 0 || (nextConfig?.rewrites.afterFiles.length ?? 0) > 0 || (nextConfig?.rewrites.fallback.length ?? 0) > 0, nextConfig?.clientTraceMetadata, nextConfig?.htmlLimitedBots, nextConfig?.reactStrictMode === true, nextConfig?.expireTime, nextConfig?.crossOrigin, devBuildId, middlewarePath ? compileClientMiddlewareMatchers(extractMiddlewareMatcherConfig(middlewarePath)) : void 0, classifyDevPageRoute)
2850
3300
  };
2851
3301
  flushStagedHeaders();
2852
3302
  flushRequestHeaders();
@@ -2855,11 +3305,54 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2855
3305
  await cachedSSRHandler.handler(req, res, pipelineResult.resolvedUrl, req.__vinextMiddlewareStatus, pipelineResult.isDataReq, originalRequestUrl);
2856
3306
  }
2857
3307
  } catch (e) {
2858
- next(e);
3308
+ return next(e);
3309
+ }
3310
+ };
3311
+ handlePagesMiddleware = async (req, res, next) => {
3312
+ const url = req.url ?? "/";
3313
+ if (!hasPagesDir) return next();
3314
+ if (url.startsWith("/@") || url.startsWith("/__vite") || url.startsWith("/node_modules")) return next();
3315
+ if (url.split("?")[0].endsWith(".rsc")) return next();
3316
+ if (hasCloudflarePlugin) return next();
3317
+ await pagesInstrumentationReady;
3318
+ const traceHeaders = new Headers();
3319
+ for (const [name, value] of Object.entries(req.headers)) {
3320
+ if (value === void 0 || name.startsWith(":")) continue;
3321
+ traceHeaders.set(name, Array.isArray(value) ? value.join(", ") : value);
2859
3322
  }
3323
+ const continueRequest = (error) => new Promise((resolve, reject) => {
3324
+ const finish = () => {
3325
+ res.off("finish", finish);
3326
+ res.off("close", finish);
3327
+ res.off("error", fail);
3328
+ resolve();
3329
+ };
3330
+ const fail = (responseError) => {
3331
+ res.off("finish", finish);
3332
+ res.off("close", finish);
3333
+ res.off("error", fail);
3334
+ reject(responseError);
3335
+ };
3336
+ res.once("finish", finish);
3337
+ res.once("close", finish);
3338
+ res.once("error", fail);
3339
+ try {
3340
+ next(error);
3341
+ if (res.writableFinished || res.destroyed) finish();
3342
+ } catch (nextError) {
3343
+ fail(nextError);
3344
+ }
3345
+ });
3346
+ return traceFrameworkRequest({
3347
+ callback: () => handlePagesRequest(req, res, continueRequest),
3348
+ getStatus: () => res.statusCode,
3349
+ headers: traceHeaders,
3350
+ method: req.method ?? "GET",
3351
+ target: url
3352
+ });
2860
3353
  };
2861
3354
  server.middlewares.use((req, res, next) => {
2862
- handlePagesMiddleware(req, res, next);
3355
+ handlePagesMiddleware(req, res, next).catch(next);
2863
3356
  });
2864
3357
  };
2865
3358
  }
@@ -3000,8 +3493,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3000
3493
  const serverDefines = { ...nextConfig.compilerDefineServer };
3001
3494
  serverDefines["process.env.NEXT_RUNTIME"] = JSON.stringify("nodejs");
3002
3495
  serverDefines["process.env.NEXT_PHASE"] = "globalThis.__VINEXT_NEXT_PHASE";
3003
- const sharedRevalidateSecret = process.env.__VINEXT_SHARED_REVALIDATE_SECRET;
3004
- if (sharedRevalidateSecret) serverDefines["process.env.__VINEXT_REVALIDATE_SECRET"] = JSON.stringify(sharedRevalidateSecret);
3496
+ if (revalidateSecret) serverDefines["process.env.__VINEXT_REVALIDATE_SECRET"] = JSON.stringify(revalidateSecret);
3005
3497
  if (previewBuildCredentials) {
3006
3498
  serverDefines["process.env.__VINEXT_PREVIEW_MODE_ID"] = JSON.stringify(previewBuildCredentials.id);
3007
3499
  serverDefines["process.env.__VINEXT_PREVIEW_MODE_SIGNING_KEY"] = JSON.stringify(previewBuildCredentials.signingKey);
@@ -3176,7 +3668,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3176
3668
  sequential: true,
3177
3669
  order: "post",
3178
3670
  handler() {
3179
- if (buildIdWritten) return;
3671
+ if (buildIdWritten || !isServerEnvironment(this.environment)) return;
3180
3672
  buildIdWritten = true;
3181
3673
  const outDir = path.join(root, "dist", "server");
3182
3674
  fs.mkdirSync(outDir, { recursive: true });
@@ -3207,14 +3699,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3207
3699
  if (!environment || (hasAppDir ? environment.name !== "rsc" : !isServerEnvironment(environment))) return;
3208
3700
  const outDir = options.dir;
3209
3701
  if (!outDir) return;
3210
- const source = JSON.stringify({ prerenderSecret });
3702
+ const canonicalServerDir = path.join(root, "dist", "server");
3703
+ if (selectedMultiStageOutput) {
3704
+ if (readPrerenderSecret(canonicalServerDir) === prerenderSecret) for (const runtimeOutputDir of readServerRuntimeOutputDirs(canonicalServerDir, root)) serverRuntimeOutputDirs.add(runtimeOutputDir);
3705
+ serverRuntimeOutputDirs.add(path.resolve(outDir));
3706
+ }
3707
+ const manifest = {
3708
+ prerenderSecret,
3709
+ ...serverRuntimeOutputDirs.size === 0 ? {} : { runtimeOutputDirs: [...serverRuntimeOutputDirs].map((runtimeOutputDir) => path.relative(root, runtimeOutputDir) || ".").sort() }
3710
+ };
3711
+ const source = JSON.stringify(manifest);
3211
3712
  fs.writeFileSync(path.join(outDir, "vinext-server.json"), source);
3212
- if (!hasAppDir) {
3213
- const canonicalServerDir = path.join(root, "dist", "server");
3214
- if (path.resolve(outDir) !== canonicalServerDir) {
3215
- fs.mkdirSync(canonicalServerDir, { recursive: true });
3216
- fs.writeFileSync(path.join(canonicalServerDir, "vinext-server.json"), source);
3217
- }
3713
+ if (path.resolve(outDir) !== canonicalServerDir) {
3714
+ fs.mkdirSync(canonicalServerDir, { recursive: true });
3715
+ fs.writeFileSync(path.join(canonicalServerDir, "vinext-server.json"), source);
3218
3716
  }
3219
3717
  }
3220
3718
  }
@@ -3222,6 +3720,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3222
3720
  {
3223
3721
  name: "vinext:nitro-route-rules",
3224
3722
  nitro: { setup: async (nitro) => {
3723
+ nitroBuildDir = nitro.options.buildDir ? path.resolve(root, nitro.options.buildDir) : void 0;
3724
+ nitroHostRuntime = nitro.options.exportConditions?.includes("workerd") ? "worker" : "node";
3225
3725
  if (!nextConfig) return;
3226
3726
  if (!hasAppDir && !hasPagesDir) return;
3227
3727
  if (resolvedServerExternalPackages.length > 0) nitro.options.traceDeps = [.../* @__PURE__ */ new Set([...nitro.options.traceDeps ?? [], ...resolvedServerExternalPackages])];
@@ -3252,7 +3752,10 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3252
3752
  const ssrManifestPath = path.join(viteDir, "ssr-manifest.json");
3253
3753
  if (!fs.existsSync(ssrManifestPath)) return;
3254
3754
  try {
3255
- const augmentedManifest = augmentSsrManifestFromBundle(JSON.parse(fs.readFileSync(ssrManifestPath, "utf-8")), bundle, this.environment?.config.root ?? process.cwd(), this.environment?.config.base ?? "/");
3755
+ const ssrManifest = JSON.parse(fs.readFileSync(ssrManifestPath, "utf-8"));
3756
+ const buildRoot = this.environment?.config.root ?? process.cwd();
3757
+ const buildBase = this.environment?.config.base ?? "/";
3758
+ const augmentedManifest = augmentSsrManifestFromBundle(ssrManifest, bundle, buildRoot, buildBase);
3256
3759
  fs.writeFileSync(ssrManifestPath, JSON.stringify(augmentedManifest, null, 2));
3257
3760
  } catch (err) {
3258
3761
  console.warn("[vinext] Failed to augment SSR manifest:", err);
@@ -3372,17 +3875,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3372
3875
  clientEntry: runtimeMetadata.clientEntryFile ?? void 0,
3373
3876
  appBootstrapPreinitModules: runtimeMetadata.appBootstrapPreinitModules,
3374
3877
  ssrManifest,
3878
+ cssGraph: runtimeMetadata.cssGraph,
3375
3879
  lazyChunks: runtimeMetadata.lazyChunks ?? void 0,
3376
- dynamicPreloads: runtimeMetadata.dynamicPreloads ?? void 0
3880
+ dynamicPreloads: runtimeMetadata.dynamicPreloads ?? void 0,
3881
+ crossOrigin: nextConfig.crossOrigin ?? ""
3377
3882
  });
3378
- const buildSession = process.env.__VINEXT_PAGES_CLIENT_ASSETS_BUILD_SESSION;
3379
- if (hasAppDir && hasPagesDir && buildSession) setPagesClientAssetsBuildMetadata(buildSession, pagesClientAssetsModule);
3380
- }
3381
- if (pagesClientAssetsModule === null) {
3382
- if (pagesClientAssetsOutputDirs.size === 0) return;
3383
- const buildSession = process.env.__VINEXT_PAGES_CLIENT_ASSETS_BUILD_SESSION;
3384
- if (buildSession) pagesClientAssetsModule = takePagesClientAssetsBuildMetadata(buildSession);
3385
3883
  }
3884
+ if (pagesClientAssetsModule === null && pagesClientAssetsOutputDirs.size === 0) return;
3386
3885
  if (pagesClientAssetsModule === null) {
3387
3886
  const emptyModule = buildPagesClientAssetsModule({});
3388
3887
  for (const outputDir of pagesClientAssetsOutputDirs) writePagesClientAssetsModuleIfMissing(outputDir, emptyModule);
@@ -3416,7 +3915,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3416
3915
  const envConfig = this.environment?.config;
3417
3916
  if (!envConfig) return;
3418
3917
  const buildRoot = envConfig.root ?? process.cwd();
3419
- const manifest = collectInlineCssManifest(path.resolve(buildRoot, "dist", "client"), nextConfig.assetPrefix);
3918
+ const clientDir = path.resolve(buildRoot, "dist", "client");
3919
+ const manifest = collectInlineCssManifest(clientDir, nextConfig.assetPrefix);
3420
3920
  const rscOutDir = path.resolve(buildRoot, options.rscOutDir ?? path.join("dist", "server"));
3421
3921
  for (const entryFile of ["index.js", "index.mjs"]) if (injectInlineCssManifestGlobal(path.join(rscOutDir, entryFile), manifest)) break;
3422
3922
  }
@@ -3453,6 +3953,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3453
3953
  }
3454
3954
  },
3455
3955
  createWasmModuleImportPlugin(),
3956
+ createOgHarfbuzzPlugin(),
3456
3957
  {
3457
3958
  name: "vinext:og-font-patch",
3458
3959
  enforce: "pre",
@@ -3524,7 +4025,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3524
4025
  const buildRoot = config.root ?? process.cwd();
3525
4026
  const outDir = path.resolve(buildRoot, outputOptions.dir);
3526
4027
  const loadedEntries = serverEntryKindsByEnvironment.get(this.environment?.name ?? "");
3527
- const isPrimaryServerOutput = Boolean(loadedEntries?.has(RESOLVED_RSC_ENTRY) || loadedEntries?.has(RESOLVED_SERVER_ENTRY) && !loadedEntries.has(RESOLVED_APP_SSR_ENTRY));
4028
+ const isPrimaryServerOutput = Boolean(loadedEntries?.has(RESOLVED_RSC_ENTRY) || loadedEntries?.has(RESOLVED_APP_REQUEST_ENTRY) || loadedEntries?.has(RESOLVED_APP_RESPONSE_ENTRY) || loadedEntries?.has(RESOLVED_PAGES_REQUEST_ENTRY) || loadedEntries?.has(RESOLVED_PAGES_RESPONSE_ENTRY) || loadedEntries?.has(RESOLVED_SERVER_ENTRY) && !loadedEntries.has(RESOLVED_APP_SSR_ENTRY));
3528
4029
  for (const output of cacheAdapterBuildOutputs) {
3529
4030
  if (output.matchesBuild && !output.matchesBuild(build)) continue;
3530
4031
  await output.finalizeBuildOutput?.({
@@ -3553,6 +4054,27 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3553
4054
  plugins.push(createRscReferenceValidationNormalizerPlugin());
3554
4055
  plugins.push(createRscClientReferenceLoadersPlugin());
3555
4056
  } else if (manualUseCachePluginPromise) plugins.push(manualUseCachePluginPromise);
4057
+ plugins.push({
4058
+ name: "vinext:plain-pages-build-config",
4059
+ apply: "build",
4060
+ enforce: "post",
4061
+ config: {
4062
+ order: "post",
4063
+ handler(config) {
4064
+ if (!hasPlainPagesBuildEnvironments) return;
4065
+ if (config.build?.watch || config.build?.ssr || config.build?.lib || getBuildBundlerOptions(config.build)?.input !== void 0) {
4066
+ for (const name of ["client", "ssr"]) if (originalPlainPagesEnvironments?.[name]) config.environments[name] = originalPlainPagesEnvironments[name];
4067
+ else delete config.environments?.[name];
4068
+ return;
4069
+ }
4070
+ return { builder: {
4071
+ ...config.builder,
4072
+ sharedConfigBuild: true
4073
+ } };
4074
+ }
4075
+ }
4076
+ });
4077
+ plugins.push(buildLifecyclePlugins[1]);
3556
4078
  return plugins;
3557
4079
  }
3558
4080
  /**