vinext 1.2.1 → 1.3.1

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 (509) hide show
  1. package/README.md +12 -9
  2. package/dist/_virtual/_rolldown/runtime.js +1 -1
  3. package/dist/build/action-owner-manifest.d.ts +3 -2
  4. package/dist/build/action-owner-manifest.js +18 -2
  5. package/dist/build/app-page-static-eligibility.d.ts +17 -1
  6. package/dist/build/app-page-static-eligibility.js +80 -13
  7. package/dist/build/clean-output.d.ts +2 -1
  8. package/dist/build/client-build-config.d.ts +77 -6
  9. package/dist/build/client-build-config.js +176 -12
  10. package/dist/build/client-reference-async.d.ts +48 -0
  11. package/dist/build/client-reference-async.js +123 -0
  12. package/dist/build/client-reference-chunks.d.ts +32 -0
  13. package/dist/build/client-reference-chunks.js +111 -0
  14. package/dist/build/client-reference-groups.d.ts +171 -0
  15. package/dist/build/client-reference-groups.js +572 -0
  16. package/dist/build/css-url-assets.d.ts +2 -1
  17. package/dist/build/google-fonts/fallback-metrics.d.ts +2 -1
  18. package/dist/build/google-fonts/find-font-files-in-css.d.ts +1 -0
  19. package/dist/build/google-fonts/find-font-files-in-css.js +17 -4
  20. package/dist/build/google-fonts/font-metadata.d.ts +2 -1
  21. package/dist/build/google-fonts/validate.d.ts +2 -1
  22. package/dist/build/inline-css.d.ts +2 -1
  23. package/dist/build/layout-classification.d.ts +2 -1
  24. package/dist/build/module-dependency-cache.d.ts +33 -1
  25. package/dist/build/module-dependency-cache.js +51 -1
  26. package/dist/build/next-client-runtime-manifests.d.ts +12 -2
  27. package/dist/build/next-client-runtime-manifests.js +19 -4
  28. package/dist/build/nitro-public-files.d.ts +24 -0
  29. package/dist/build/nitro-public-files.js +60 -0
  30. package/dist/build/pages-client-assets-module.js +1 -1
  31. package/dist/build/precompress.d.ts +2 -1
  32. package/dist/build/precompress.js +1 -1
  33. package/dist/build/prerender-paths.d.ts +2 -1
  34. package/dist/build/prerender-paths.js +5 -2
  35. package/dist/build/prerender-phase.d.ts +2 -1
  36. package/dist/build/prerender-server-pool.js +1 -1
  37. package/dist/build/prerender.d.ts +3 -2
  38. package/dist/build/prerender.js +5 -4
  39. package/dist/build/report.d.ts +2 -1
  40. package/dist/build/route-classification-injector.d.ts +2 -1
  41. package/dist/build/route-classification-manifest.d.ts +2 -1
  42. package/dist/build/run-prerender.d.ts +2 -1
  43. package/dist/build/server-actions-encryption-key.d.ts +24 -0
  44. package/dist/build/server-actions-encryption-key.js +101 -0
  45. package/dist/build/ssr-manifest.d.ts +3 -0
  46. package/dist/build/ssr-manifest.js +34 -2
  47. package/dist/build/standalone.d.ts +2 -1
  48. package/dist/cache/cache-adapters-virtual.d.ts +2 -1
  49. package/dist/cache.js +1 -2
  50. package/dist/check.d.ts +2 -1
  51. package/dist/check.js +4 -0
  52. package/dist/cli-args.d.ts +2 -1
  53. package/dist/cli.js +2 -0
  54. package/dist/client/client-redirect-matcher.js +2 -1
  55. package/dist/client/client-redirects.d.ts +4 -3
  56. package/dist/client/client-redirects.js +2 -1
  57. package/dist/client/client-rewrite-params.d.ts +9 -0
  58. package/dist/client/client-rewrite-params.js +20 -0
  59. package/dist/client/client-rewrites.d.ts +2 -1
  60. package/dist/client/dev-error-overlay-store.d.ts +2 -1
  61. package/dist/client/dev-error-overlay.js +2 -1
  62. package/dist/client/index.js +1 -2
  63. package/dist/client/instrumentation-client-state.js +5 -5
  64. package/dist/client/navigation-runtime.d.ts +28 -3
  65. package/dist/client/navigation-runtime.js +42 -11
  66. package/dist/client/pages-router-link-navigation.d.ts +2 -1
  67. package/dist/client/vinext-next-data.d.ts +25 -2
  68. package/dist/client/window-next.d.ts +2 -1
  69. package/dist/config/config-matchers.d.ts +27 -41
  70. package/dist/config/config-matchers.js +293 -270
  71. package/dist/config/config-source.d.ts +34 -0
  72. package/dist/config/config-source.js +141 -0
  73. package/dist/config/dotenv.d.ts +2 -1
  74. package/dist/config/header-params.d.ts +29 -0
  75. package/dist/config/header-params.js +106 -0
  76. package/dist/config/next-config.d.ts +20 -6
  77. package/dist/config/next-config.js +149 -11
  78. package/dist/config/tsconfig-paths.d.ts +2 -1
  79. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/detector.js +23 -0
  80. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/index.js +2 -0
  81. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/lookup.js +25 -0
  82. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/bmp.js +11 -0
  83. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/cur.js +15 -0
  84. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/dds.js +11 -0
  85. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/gif.js +12 -0
  86. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/heif.js +55 -0
  87. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/icns.js +76 -0
  88. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ico.js +39 -0
  89. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/index.js +46 -0
  90. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/j2c.js +11 -0
  91. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jp2.js +21 -0
  92. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jpg.js +71 -0
  93. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl-stream.js +42 -0
  94. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl.js +46 -0
  95. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ktx.js +19 -0
  96. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/png.js +28 -0
  97. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/pnm.js +54 -0
  98. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/psd.js +11 -0
  99. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/svg.js +79 -0
  100. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tga.js +15 -0
  101. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tiff.js +96 -0
  102. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/utils.js +53 -0
  103. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/webp.js +45 -0
  104. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/utils/bit-reader.js +38 -0
  105. package/dist/deps/.pnpm/ua-parser-js@1.0.35/deps/ua-parser-js/src/ua-parser.js +2 -2
  106. package/dist/entries/app-browser-entry.d.ts +34 -6
  107. package/dist/entries/app-browser-entry.js +103 -40
  108. package/dist/entries/app-rsc-entry.d.ts +4 -1
  109. package/dist/entries/app-rsc-entry.js +131 -66
  110. package/dist/entries/app-rsc-manifest.d.ts +12 -1
  111. package/dist/entries/app-rsc-manifest.js +73 -1
  112. package/dist/entries/app-ssr-entry.d.ts +4 -1
  113. package/dist/entries/app-ssr-entry.js +9 -2
  114. package/dist/entries/pages-client-entry.d.ts +1 -0
  115. package/dist/entries/pages-client-entry.js +6 -6
  116. package/dist/entries/pages-entry-helpers.js +1 -2
  117. package/dist/entries/pages-server-entry.d.ts +2 -1
  118. package/dist/entries/pages-server-entry.js +18 -15
  119. package/dist/entries/runtime-entry-module.d.ts +1 -0
  120. package/dist/entries/runtime-entry-module.js +4 -1
  121. package/dist/image/image-adapters-virtual.d.ts +2 -1
  122. package/dist/index.d.ts +11 -0
  123. package/dist/index.js +340 -116
  124. package/dist/init.js +17 -0
  125. package/dist/plugins/client-compile-hints.d.ts +30 -0
  126. package/dist/plugins/client-compile-hints.js +88 -0
  127. package/dist/plugins/client-reference-dedup.d.ts +2 -1
  128. package/dist/plugins/cloudflare-dev-module-urls.d.ts +2 -1
  129. package/dist/plugins/dynamic-preload-metadata.d.ts +3 -1
  130. package/dist/plugins/dynamic-preload-metadata.js +1 -1
  131. package/dist/plugins/environment.d.ts +2 -1
  132. package/dist/plugins/fonts.js +9 -12
  133. package/dist/plugins/ignore-dynamic-requests.d.ts +2 -1
  134. package/dist/plugins/import-meta-url.d.ts +2 -1
  135. package/dist/plugins/og-assets.d.ts +2 -1
  136. package/dist/plugins/og-assets.js +2 -3
  137. package/dist/plugins/optimize-imports.d.ts +27 -3
  138. package/dist/plugins/optimize-imports.js +106 -20
  139. package/dist/plugins/pages-node-externals.d.ts +2 -1
  140. package/dist/plugins/remove-console.d.ts +2 -1
  141. package/dist/plugins/require-condition-resolution.d.ts +2 -1
  142. package/dist/plugins/rsc-client-reference-loaders.d.ts +53 -1
  143. package/dist/plugins/rsc-client-reference-loaders.js +447 -27
  144. package/dist/plugins/rsc-client-shim-excludes.js +2 -0
  145. package/dist/plugins/sass.d.ts +2 -1
  146. package/dist/plugins/strip-server-exports.d.ts +2 -1
  147. package/dist/plugins/styled-jsx.d.ts +2 -1
  148. package/dist/plugins/transform-result.d.ts +2 -1
  149. package/dist/plugins/typeof-window.d.ts +2 -1
  150. package/dist/plugins/use-cache-callable.d.ts +5 -0
  151. package/dist/plugins/use-cache-callable.js +30 -8
  152. package/dist/plugins/worker-image-imports.d.ts +1 -0
  153. package/dist/plugins/worker-image-imports.js +2 -2
  154. package/dist/plugins/worker-use-server.d.ts +2 -1
  155. package/dist/routing/app-route-graph.d.ts +41 -1
  156. package/dist/routing/app-route-graph.js +122 -50
  157. package/dist/routing/browser-route-manifest.d.ts +44 -0
  158. package/dist/routing/browser-route-manifest.js +195 -0
  159. package/dist/routing/hashed-route-patterns.d.ts +4 -0
  160. package/dist/routing/hashed-route-patterns.js +22 -0
  161. package/dist/routing/optimistic-route-trie.d.ts +28 -0
  162. package/dist/routing/optimistic-route-trie.js +102 -0
  163. package/dist/routing/route-matching.d.ts +2 -1
  164. package/dist/routing/route-pattern.d.ts +2 -1
  165. package/dist/routing/route-validation.d.ts +6 -1
  166. package/dist/routing/route-validation.js +26 -10
  167. package/dist/server/accept-encoding.d.ts +2 -1
  168. package/dist/server/app-action-forwarding.d.ts +10 -1
  169. package/dist/server/app-action-forwarding.js +15 -1
  170. package/dist/server/app-bfcache-identity.d.ts +2 -1
  171. package/dist/server/app-browser-action-result.d.ts +2 -1
  172. package/dist/server/app-browser-client-reuse-manifest.d.ts +2 -1
  173. package/dist/server/app-browser-entry.js +175 -64
  174. package/dist/server/app-browser-error.d.ts +5 -2
  175. package/dist/server/app-browser-error.js +7 -2
  176. package/dist/server/app-browser-history-controller.d.ts +2 -1
  177. package/dist/server/app-browser-hydration.d.ts +2 -1
  178. package/dist/server/app-browser-interception-context.d.ts +4 -3
  179. package/dist/server/app-browser-mpa-navigation.d.ts +1 -0
  180. package/dist/server/app-browser-mpa-navigation.js +6 -5
  181. package/dist/server/app-browser-navigation-controller.d.ts +17 -6
  182. package/dist/server/app-browser-navigation-controller.js +103 -36
  183. package/dist/server/app-browser-popstate.d.ts +2 -1
  184. package/dist/server/app-browser-rsc-redirect.d.ts +2 -1
  185. package/dist/server/app-browser-server-action-client.d.ts +2 -1
  186. package/dist/server/app-browser-state.d.ts +2 -2
  187. package/dist/server/app-browser-state.js +1 -1
  188. package/dist/server/app-browser-stream.d.ts +2 -1
  189. package/dist/server/app-browser-visible-commit.d.ts +6 -5
  190. package/dist/server/app-client-reference-manifest.d.ts +31 -0
  191. package/dist/server/app-client-reference-manifest.js +46 -0
  192. package/dist/server/app-client-reference-preloader.d.ts +45 -2
  193. package/dist/server/app-client-reference-preloader.js +48 -10
  194. package/dist/server/app-elements-wire.d.ts +2 -1
  195. package/dist/server/app-elements.d.ts +2 -0
  196. package/dist/server/app-elements.js +3 -1
  197. package/dist/server/app-fallback-renderer.d.ts +9 -2
  198. package/dist/server/app-fallback-renderer.js +6 -2
  199. package/dist/server/app-history-state.d.ts +2 -1
  200. package/dist/server/app-inline-css-client.d.ts +2 -1
  201. package/dist/server/app-layout-param-observation.d.ts +2 -1
  202. package/dist/server/app-metadata-tracing.d.ts +2 -1
  203. package/dist/server/app-middleware.d.ts +6 -0
  204. package/dist/server/app-middleware.js +8 -10
  205. package/dist/server/app-optimistic-routing.d.ts +26 -11
  206. package/dist/server/app-optimistic-routing.js +38 -96
  207. package/dist/server/app-page-boundary-render.d.ts +20 -2
  208. package/dist/server/app-page-boundary-render.js +229 -39
  209. package/dist/server/app-page-boundary.d.ts +34 -5
  210. package/dist/server/app-page-boundary.js +40 -7
  211. package/dist/server/app-page-cache-finalizer.d.ts +2 -1
  212. package/dist/server/app-page-cache-finalizer.js +1 -1
  213. package/dist/server/app-page-cache-render.d.ts +10 -2
  214. package/dist/server/app-page-cache-render.js +15 -2
  215. package/dist/server/app-page-cache.js +2 -2
  216. package/dist/server/app-page-dispatch.d.ts +34 -1
  217. package/dist/server/app-page-dispatch.js +165 -34
  218. package/dist/server/app-page-element-builder.d.ts +17 -1
  219. package/dist/server/app-page-element-builder.js +187 -66
  220. package/dist/server/app-page-execution.d.ts +28 -1
  221. package/dist/server/app-page-execution.js +114 -5
  222. package/dist/server/app-page-head.d.ts +95 -3
  223. package/dist/server/app-page-head.js +307 -152
  224. package/dist/server/app-page-http-access-fallback-metadata.d.ts +48 -2
  225. package/dist/server/app-page-http-access-fallback-metadata.js +76 -1
  226. package/dist/server/app-page-method.d.ts +2 -1
  227. package/dist/server/app-page-probe.d.ts +2 -1
  228. package/dist/server/app-page-render-identity.d.ts +2 -1
  229. package/dist/server/app-page-render.d.ts +7 -1
  230. package/dist/server/app-page-render.js +38 -11
  231. package/dist/server/app-page-request.d.ts +14 -1
  232. package/dist/server/app-page-request.js +1 -1
  233. package/dist/server/app-page-route-wiring.d.ts +52 -2
  234. package/dist/server/app-page-route-wiring.js +197 -47
  235. package/dist/server/app-page-rsc-render-status.d.ts +3 -1
  236. package/dist/server/app-page-rsc-render-status.js +1 -0
  237. package/dist/server/app-page-search-params-observation.d.ts +8 -6
  238. package/dist/server/app-page-search-params-observation.js +16 -11
  239. package/dist/server/app-page-segment-plan.d.ts +2 -1
  240. package/dist/server/app-page-stream.d.ts +38 -1
  241. package/dist/server/app-page-stream.js +24 -4
  242. package/dist/server/app-pages-bridge.d.ts +4 -2
  243. package/dist/server/app-pages-bridge.js +11 -7
  244. package/dist/server/app-ppr-fallback-shell-render.d.ts +2 -1
  245. package/dist/server/app-ppr-fallback-shell.d.ts +2 -1
  246. package/dist/server/app-prerender-endpoints.d.ts +2 -1
  247. package/dist/server/app-prerender-static-params.d.ts +2 -1
  248. package/dist/server/app-prerender-static-params.js +3 -2
  249. package/dist/server/app-render-dependency.d.ts +11 -1
  250. package/dist/server/app-render-dependency.js +65 -6
  251. package/dist/server/app-request-stage-independent-entry.d.ts +2 -1
  252. package/dist/server/app-request-stage-independent-entry.js +2 -2
  253. package/dist/server/app-response-stage-entry.d.ts +2 -1
  254. package/dist/server/app-response-stage-entry.js +3 -3
  255. package/dist/server/app-route-handler-cache.d.ts +2 -1
  256. package/dist/server/app-route-handler-dispatch.d.ts +2 -1
  257. package/dist/server/app-route-handler-dispatch.js +4 -2
  258. package/dist/server/app-route-handler-execution.d.ts +4 -1
  259. package/dist/server/app-route-handler-execution.js +9 -2
  260. package/dist/server/app-route-handler-middleware-context.d.ts +2 -1
  261. package/dist/server/app-route-handler-middleware-context.js +3 -3
  262. package/dist/server/app-route-handler-response.d.ts +4 -2
  263. package/dist/server/app-route-handler-response.js +2 -2
  264. package/dist/server/app-route-handler-runtime.d.ts +4 -1
  265. package/dist/server/app-route-handler-runtime.js +20 -3
  266. package/dist/server/app-route-module-loader.d.ts +18 -1
  267. package/dist/server/app-route-module-loader.js +15 -6
  268. package/dist/server/app-route-tree-prefetch.d.ts +2 -1
  269. package/dist/server/app-route-tree.d.ts +20 -0
  270. package/dist/server/app-route-tree.js +18 -0
  271. package/dist/server/app-router-entry.js +2 -2
  272. package/dist/server/app-rsc-combined-handler.js +8 -1
  273. package/dist/server/app-rsc-error-handler.d.ts +2 -1
  274. package/dist/server/app-rsc-errors.d.ts +9 -1
  275. package/dist/server/app-rsc-errors.js +9 -2
  276. package/dist/server/app-rsc-handler.d.ts +6 -2
  277. package/dist/server/app-rsc-handler.js +152 -140
  278. package/dist/server/app-rsc-response-finalizer.d.ts +7 -1
  279. package/dist/server/app-rsc-response-finalizer.js +4 -1
  280. package/dist/server/app-rsc-response-stage.js +3 -1
  281. package/dist/server/app-rsc-route-matching.d.ts +39 -1
  282. package/dist/server/app-rsc-route-matching.js +25 -1
  283. package/dist/server/app-segment-config.d.ts +2 -1
  284. package/dist/server/app-segment-config.js +1 -14
  285. package/dist/server/app-server-action-execution.d.ts +25 -7
  286. package/dist/server/app-server-action-execution.js +53 -59
  287. package/dist/server/app-ssr-entry.d.ts +12 -0
  288. package/dist/server/app-ssr-entry.js +104 -48
  289. package/dist/server/app-ssr-error-meta.d.ts +2 -1
  290. package/dist/server/app-ssr-search-params-gate.d.ts +2 -1
  291. package/dist/server/app-ssr-stream.d.ts +29 -10
  292. package/dist/server/app-ssr-stream.js +311 -67
  293. package/dist/server/app-static-generation.d.ts +2 -1
  294. package/dist/server/app-streamed-client-references.d.ts +39 -0
  295. package/dist/server/app-streamed-client-references.js +156 -0
  296. package/dist/server/app-visited-response-cache.d.ts +2 -1
  297. package/dist/server/app-worker-stages.d.ts +2 -1
  298. package/dist/server/artifact-compatibility.d.ts +2 -1
  299. package/dist/server/bfcache-identity.d.ts +2 -1
  300. package/dist/server/cache-headers.d.ts +2 -1
  301. package/dist/server/cacheability-request.d.ts +2 -1
  302. package/dist/server/client-reuse-manifest.d.ts +2 -1
  303. package/dist/server/config-headers.d.ts +2 -1
  304. package/dist/server/config-headers.js +12 -3
  305. package/dist/server/csp.d.ts +2 -1
  306. package/dist/server/default-global-not-found-module.d.ts +2 -1
  307. package/dist/server/default-http-access-fallback-modules.d.ts +33 -0
  308. package/dist/server/default-http-access-fallback-modules.js +31 -0
  309. package/dist/server/defer-until-stream-consumed.d.ts +34 -0
  310. package/dist/server/defer-until-stream-consumed.js +154 -21
  311. package/dist/server/dev-lockfile.d.ts +32 -2
  312. package/dist/server/dev-lockfile.js +46 -2
  313. package/dist/server/dev-module-runner.d.ts +2 -1
  314. package/dist/server/dev-server.js +10 -3
  315. package/dist/server/fetch-handler.js +1 -2
  316. package/dist/server/file-based-metadata.d.ts +2 -1
  317. package/dist/server/framework-tracer.d.ts +2 -1
  318. package/dist/server/html.d.ts +1 -0
  319. package/dist/server/html.js +19 -1
  320. package/dist/server/http-conditional.d.ts +2 -1
  321. package/dist/server/http-error-responses.d.ts +2 -1
  322. package/dist/server/implicit-tags.d.ts +2 -1
  323. package/dist/server/isolate-shared-promise.d.ts +10 -0
  324. package/dist/server/isolate-shared-promise.js +33 -0
  325. package/dist/server/isr-cache.js +3 -2
  326. package/dist/server/metadata-route-build-data.d.ts +2 -1
  327. package/dist/server/metadata-route-build-data.js +1 -1
  328. package/dist/server/metadata-route-response.d.ts +2 -1
  329. package/dist/server/metadata-route-response.js +1 -1
  330. package/dist/server/metadata-routes.d.ts +2 -1
  331. package/dist/server/middleware-matcher-pattern.d.ts +0 -1
  332. package/dist/server/middleware-matcher-pattern.js +11 -140
  333. package/dist/server/middleware-matcher.js +5 -6
  334. package/dist/server/middleware-response-headers.d.ts +31 -0
  335. package/dist/server/middleware-response-headers.js +57 -1
  336. package/dist/server/middleware-runtime.d.ts +2 -1
  337. package/dist/server/middleware-runtime.js +26 -13
  338. package/dist/server/navigation-planner.d.ts +2 -2
  339. package/dist/server/navigation-trace.d.ts +2 -1
  340. package/dist/server/next-error-digest.d.ts +2 -1
  341. package/dist/server/nitro-public-files-plugin.d.ts +39 -0
  342. package/dist/server/nitro-public-files-plugin.js +106 -0
  343. package/dist/server/nitro-public-files.d.ts +22 -0
  344. package/dist/server/nitro-public-files.js +39 -0
  345. package/dist/server/opentelemetry-api.d.ts +2 -1
  346. package/dist/server/operation-token.d.ts +2 -1
  347. package/dist/server/pages-api-route.d.ts +2 -1
  348. package/dist/server/pages-asset-tags.d.ts +7 -1
  349. package/dist/server/pages-asset-tags.js +9 -2
  350. package/dist/server/pages-body-parser-config.d.ts +2 -1
  351. package/dist/server/pages-client-assets.d.ts +8 -1
  352. package/dist/server/pages-data-route.d.ts +2 -1
  353. package/dist/server/pages-document-asset-props.d.ts +2 -1
  354. package/dist/server/pages-document-initial-props.d.ts +2 -1
  355. package/dist/server/pages-execution-tracing.d.ts +2 -1
  356. package/dist/server/pages-execution-tracing.js +1 -1
  357. package/dist/server/pages-get-initial-props.d.ts +2 -1
  358. package/dist/server/pages-i18n.d.ts +18 -0
  359. package/dist/server/pages-i18n.js +18 -2
  360. package/dist/server/pages-node-compat.d.ts +5 -3
  361. package/dist/server/pages-node-compat.js +35 -16
  362. package/dist/server/pages-page-data.d.ts +7 -1
  363. package/dist/server/pages-page-data.js +35 -12
  364. package/dist/server/pages-page-handler.d.ts +3 -2
  365. package/dist/server/pages-page-handler.js +16 -7
  366. package/dist/server/pages-page-method.d.ts +2 -1
  367. package/dist/server/pages-page-response.d.ts +2 -1
  368. package/dist/server/pages-preview.d.ts +2 -1
  369. package/dist/server/pages-readiness.d.ts +2 -1
  370. package/dist/server/pages-request-pipeline.d.ts +8 -2
  371. package/dist/server/pages-request-pipeline.js +35 -40
  372. package/dist/server/pages-request-stage-entry.d.ts +2 -1
  373. package/dist/server/pages-request-stage-entry.js +16 -6
  374. package/dist/server/pages-response-stage-entry.d.ts +2 -1
  375. package/dist/server/pages-response-stage-entry.js +1 -1
  376. package/dist/server/pages-revalidate.js +1 -0
  377. package/dist/server/pages-route-data-kind.d.ts +2 -1
  378. package/dist/server/pages-router-entry.js +1 -1
  379. package/dist/server/prerender-cache-life-header.d.ts +2 -1
  380. package/dist/server/prerender-route-params.d.ts +2 -1
  381. package/dist/server/prod-server.d.ts +2 -2
  382. package/dist/server/prod-server.js +80 -36
  383. package/dist/server/proxy-trust.d.ts +6 -0
  384. package/dist/server/proxy-trust.js +12 -6
  385. package/dist/server/request-log.d.ts +2 -1
  386. package/dist/server/request-pipeline.d.ts +5 -0
  387. package/dist/server/request-pipeline.js +12 -1
  388. package/dist/server/request-tracing.d.ts +2 -1
  389. package/dist/server/request-tracing.js +1 -1
  390. package/dist/server/response-start-tracing.js +7 -29
  391. package/dist/server/rsc-render-stream.d.ts +4 -0
  392. package/dist/server/rsc-render-stream.js +25 -0
  393. package/dist/server/seed-cache.d.ts +2 -1
  394. package/dist/server/seed-cache.js +1 -1
  395. package/dist/server/server-reference-loader.js +10 -1
  396. package/dist/server/static-file-cache.d.ts +2 -1
  397. package/dist/server/static-file-cache.js +16 -3
  398. package/dist/server/static-layout-client-reuse-proof.d.ts +2 -1
  399. package/dist/server/worker-revalidation-context.d.ts +2 -1
  400. package/dist/server/worker-stages.d.ts +2 -1
  401. package/dist/server/worker-utils.js +1 -1
  402. package/dist/shims/app.d.ts +2 -1
  403. package/dist/shims/cache-callable-runtime.d.ts +2 -1
  404. package/dist/shims/cache-handler.d.ts +8 -3
  405. package/dist/shims/cache-handler.js +32 -11
  406. package/dist/shims/cache-request-state.d.ts +40 -3
  407. package/dist/shims/cache-request-state.js +70 -5
  408. package/dist/shims/cache-runtime.js +47 -19
  409. package/dist/shims/cache.d.ts +2 -2
  410. package/dist/shims/cache.js +17 -8
  411. package/dist/shims/caught-not-found-boundaries.d.ts +15 -0
  412. package/dist/shims/caught-not-found-boundaries.js +48 -0
  413. package/dist/shims/cdn-purge-routes.d.ts +25 -0
  414. package/dist/shims/cdn-purge-routes.js +77 -0
  415. package/dist/shims/client-locale.js +2 -1
  416. package/dist/shims/client-page-root.d.ts +2 -1
  417. package/dist/shims/config.d.ts +2 -1
  418. package/dist/shims/default-forbidden.d.ts +4 -0
  419. package/dist/shims/default-forbidden.js +18 -0
  420. package/dist/shims/default-not-found.d.ts +0 -5
  421. package/dist/shims/default-not-found.js +5 -41
  422. package/dist/shims/default-unauthorized.d.ts +4 -0
  423. package/dist/shims/default-unauthorized.js +18 -0
  424. package/dist/shims/dynamic.js +17 -4
  425. package/dist/shims/error-boundary.d.ts +39 -3
  426. package/dist/shims/error-boundary.js +31 -16
  427. package/dist/shims/font-google.js +1 -2
  428. package/dist/shims/font-utils.d.ts +3 -2
  429. package/dist/shims/font-utils.js +5 -3
  430. package/dist/shims/form.js +9 -4
  431. package/dist/shims/http-access-error-fallback.d.ts +7 -0
  432. package/dist/shims/http-access-error-fallback.js +47 -0
  433. package/dist/shims/image-props.d.ts +93 -0
  434. package/dist/shims/image-props.js +323 -0
  435. package/dist/shims/image.d.ts +4 -39
  436. package/dist/shims/image.js +4 -319
  437. package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +22 -2
  438. package/dist/shims/internal/app-prefetch-fetch-queue.js +71 -18
  439. package/dist/shims/internal/app-route-prefetch-policy.d.ts +14 -3
  440. package/dist/shims/internal/app-route-prefetch-policy.js +29 -4
  441. package/dist/shims/internal/cache-context-accessor.d.ts +2 -1
  442. package/dist/shims/internal/client-reference-loader.d.ts +7 -0
  443. package/dist/shims/internal/client-reference-loader.js +91 -0
  444. package/dist/shims/internal/cookie-serialize.d.ts +2 -1
  445. package/dist/shims/internal/cookies.js +1 -2
  446. package/dist/shims/internal/headers-state.d.ts +9 -0
  447. package/dist/shims/internal/headers-state.js +19 -2
  448. package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +6 -2
  449. package/dist/shims/internal/hybrid-client-route-owner-direct.js +31 -14
  450. package/dist/shims/internal/hybrid-client-route-owner.js +8 -8
  451. package/dist/shims/internal/interpolate-as.d.ts +2 -1
  452. package/dist/shims/internal/pages-data-target.d.ts +2 -1
  453. package/dist/shims/internal/pages-data-url.d.ts +2 -1
  454. package/dist/shims/internal/thenable-well-known-properties.d.ts +2 -1
  455. package/dist/shims/link.js +198 -53
  456. package/dist/shims/metadata.d.ts +32 -11
  457. package/dist/shims/metadata.js +88 -26
  458. package/dist/shims/navigation-errors.d.ts +2 -1
  459. package/dist/shims/navigation.d.ts +23 -3
  460. package/dist/shims/navigation.js +91 -25
  461. package/dist/shims/og.js +35 -10
  462. package/dist/shims/pages-router-runtime.d.ts +2 -1
  463. package/dist/shims/ppr-fallback-shell.d.ts +2 -1
  464. package/dist/shims/request-context.d.ts +13 -0
  465. package/dist/shims/router.js +33 -43
  466. package/dist/shims/server.d.ts +31 -4
  467. package/dist/shims/server.js +58 -10
  468. package/dist/shims/thenable-params.d.ts +6 -1
  469. package/dist/shims/thenable-params.js +11 -2
  470. package/dist/shims/unified-request-context.d.ts +5 -0
  471. package/dist/shims/unified-request-context.js +5 -3
  472. package/dist/typegen.d.ts +2 -1
  473. package/dist/utils/asset-prefix.d.ts +7 -0
  474. package/dist/utils/asset-prefix.js +10 -1
  475. package/dist/utils/client-build-manifest.d.ts +4 -1
  476. package/dist/utils/client-build-manifest.js +20 -6
  477. package/dist/utils/client-entry-manifest.d.ts +13 -0
  478. package/dist/utils/client-entry-manifest.js +20 -1
  479. package/dist/utils/client-reference-chunks.d.ts +45 -0
  480. package/dist/utils/client-reference-chunks.js +30 -0
  481. package/dist/utils/client-runtime-metadata.d.ts +10 -1
  482. package/dist/utils/client-runtime-metadata.js +53 -9
  483. package/dist/utils/compare.d.ts +9 -0
  484. package/dist/utils/compare.js +15 -1
  485. package/dist/utils/lazy-chunks.d.ts +18 -0
  486. package/dist/utils/lazy-chunks.js +27 -1
  487. package/dist/utils/manifest-paths.d.ts +14 -0
  488. package/dist/utils/manifest-paths.js +22 -1
  489. package/dist/utils/middleware-request-headers.d.ts +2 -1
  490. package/dist/utils/path-to-regexp.d.ts +21 -0
  491. package/dist/{server/middleware-path-to-regexp.js → utils/path-to-regexp.js} +14 -11
  492. package/dist/utils/plugin-react-version.d.ts +15 -0
  493. package/dist/utils/plugin-react-version.js +64 -0
  494. package/dist/utils/project.d.ts +2 -1
  495. package/dist/utils/project.js +9 -1
  496. package/dist/utils/public-routes.d.ts +2 -0
  497. package/dist/utils/public-routes.js +18 -7
  498. package/dist/utils/query.d.ts +2 -1
  499. package/dist/utils/sorted-array.d.ts +2 -1
  500. package/dist/utils/vite-cli-invocation.d.ts +2 -1
  501. package/package.json +5 -5
  502. package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +0 -808
  503. package/dist/server/default-not-found-module.d.ts +0 -19
  504. package/dist/server/default-not-found-module.js +0 -18
  505. package/dist/server/middleware-path-to-regexp.d.ts +0 -13
  506. package/dist/server/rsc-stream-hints.d.ts +0 -21
  507. package/dist/server/rsc-stream-hints.js +0 -227
  508. package/dist/utils/regex-safety.d.ts +0 -17
  509. package/dist/utils/regex-safety.js +0 -789
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
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 { escapeRegExp } from "./utils/regex.js";
3
4
  import { buildViteResolveExtensions, createValidFileMatcher, findFileWithExts, normalizeViteResolveExtensions } from "./routing/file-matcher.js";
4
5
  import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
5
6
  import { TRIVIA_PATTERN, hasImportAttributes, isTypeOnlyImport, parseModuleRecord, parseProgram } from "./plugins/ast-utils.js";
@@ -7,6 +8,7 @@ import { claimViteCliBuildInvocation, getViteCliInvocation, isViteCliConfigFile
7
8
  import { VINEXT_DEV_CLI_LIFECYCLE, applyDevServerDefaults, claimViteCliDevInvocation, createDevServerLifecyclePlugin, reserveViteCliDevInvocation } from "./cli-dev-config.js";
8
9
  import { isUnknownRecord } from "./utils/record.js";
9
10
  import { getReactUpgradeDeps, reactUpgradeRequiredMessage } from "./utils/react-version.js";
11
+ import { resolvePluginReactPath } from "./utils/plugin-react-version.js";
10
12
  import { loadDotenv } from "./config/dotenv.js";
11
13
  import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
12
14
  import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
@@ -28,14 +30,14 @@ import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./rout
28
30
  import { resolveRuntimeEntryModule } from "./entries/runtime-entry-module.js";
29
31
  import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
30
32
  import { validateMiddlewareMatcherPatterns } from "./server/middleware-matcher-pattern.js";
31
- import { resolvePagesI18nRequest, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
33
+ import { resolvePagesI18nRequest, shouldRestoreLocaleRootTrailingSlash, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
32
34
  import { encodeUrlParserIgnoredCharacters, isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname, shouldAddTrailingSlashToPagesDataPath, urlParserCreatesPagesDataPath } from "./server/pages-data-route.js";
33
35
  import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
34
36
  import { findMiddlewareFile, isProxyFile, runMiddleware } from "./server/middleware.js";
35
37
  import { extractMiddlewareMatcherConfig, extractMiddlewareMatcherConfigValue, hasExportedName } from "./build/report.js";
36
38
  import { generatePagesRequestEntry, generatePagesResponseEntry, generateServerEntry } from "./entries/pages-server-entry.js";
37
39
  import { compileClientMiddlewareMatchers, generateClientEntry } from "./entries/pages-client-entry.js";
38
- import { isPathInside, isPathInsideOrEqual, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
40
+ import { canonicalizeFilePath, isPathInside, isPathInsideOrEqual, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
39
41
  import { logRequest, now } from "./server/request-log.js";
40
42
  import { getPagesPreviewModeId } from "./server/pages-preview.js";
41
43
  import { createSSRHandler } from "./server/dev-server.js";
@@ -44,30 +46,34 @@ import { handleApiRoute } from "./server/api-handler.js";
44
46
  import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath, resolveDevImageRedirect } from "./server/image-optimization.js";
45
47
  import { CACHEABILITY_MANIFEST_MODULE, CACHEABILITY_REQUEST_PROJECTION_MODULE } from "./server/cacheability-manifest.js";
46
48
  import { PREGENERATED_CONCRETE_PATHS_MODULE } from "./server/pregenerated-concrete-paths.js";
49
+ import { isAppInterceptRenderedDynamically, isAppPageRouteRenderedDynamically } from "./build/app-page-static-eligibility.js";
47
50
  import { rewriteOutputRootExternals } from "./build/output-root-externals.js";
48
51
  import { installSocketErrorBackstop } from "./server/socket-error-backstop.js";
49
52
  import { invalidateMetadataFileCache, scanMetadataFiles } from "./server/metadata-routes.js";
50
53
  import { shouldInvalidateAppRouteFile } from "./server/dev-route-files.js";
51
54
  import { createDirectRunner } from "./server/dev-module-runner.js";
55
+ import { rootBoundaryFiles, rootBoundaryRouteFiles } from "./entries/app-rsc-manifest.js";
52
56
  import { validateDevRequest } from "./server/dev-origin-check.js";
53
57
  import { createActionOwnerManifestPlugin } from "./plugins/action-owner-manifest.js";
54
58
  import { generateAppRequestRscEntry, generateAppResponseRscEntry, generateRscEntry } from "./entries/app-rsc-entry.js";
55
59
  import { generateSsrEntry } from "./entries/app-ssr-entry.js";
56
60
  import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VIRTUAL_CACHE_ADAPTERS, VIRTUAL_CDN_CACHE_ADAPTER, generateCacheAdaptersModule, generateCdnCacheAdapterModule } from "./cache/cache-adapters-virtual.js";
57
61
  import { VIRTUAL_IMAGE_ADAPTERS, generateImageAdaptersModule } from "./image/image-adapters-virtual.js";
58
- import { generateBrowserEntry, toLinkPrefetchRoutes } from "./entries/app-browser-entry.js";
62
+ import { generateBrowserEntry, generateBrowserRouteManifestModule, toHashedRouteHandlerRoutes, toLinkPrefetchRoutes } from "./entries/app-browser-entry.js";
59
63
  import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
60
64
  import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
61
65
  import { createRscScanGlobImportsPlugin, isRscScanGlobImportsAffected } from "./plugins/rsc-scan-glob-imports.js";
66
+ import { loadOrGenerateServerActionsEncryptionKey } from "./build/server-actions-encryption-key.js";
62
67
  import { findOpenTelemetryPackages, mergeServerExternalPackages } from "./config/server-external-packages.js";
63
68
  import { precompressAssets } from "./build/precompress.js";
64
69
  import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY, normalizeVinextPrerenderConfig } from "./config/prerender.js";
65
- import { VINEXT_CLIENT_ENTRY_MANIFEST } from "./utils/client-entry-manifest.js";
70
+ import { VINEXT_CLIENT_ENTRY_MANIFEST, VINEXT_CLIENT_REFERENCE_SOURCES } from "./utils/client-entry-manifest.js";
66
71
  import { PAGES_CLIENT_ASSETS_MODULE, buildPagesClientAssetsModule, collectClientBuildFiles, writePagesClientAssetsModuleIfMissing } from "./build/pages-client-assets-module.js";
67
72
  import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
68
73
  import { VINEXT_BUILD_LIFECYCLE_CONFIG, createBuildLifecyclePlugins } from "./build/lifecycle.js";
69
74
  import { ensureAssetsIgnore } from "./build/assets-ignore.js";
70
- import { emitNextClientRuntimeManifests } from "./build/next-client-runtime-manifests.js";
75
+ import { registerNitroPublicFiles } from "./build/nitro-public-files.js";
76
+ import { emitNextClientRuntimeManifests, getPagesManifestPage } from "./build/next-client-runtime-manifests.js";
71
77
  import { collectInlineCssManifest, injectInlineCssManifestGlobal } from "./build/inline-css.js";
72
78
  import { readTrustedRevalidationHostname } from "./server/revalidation-host.js";
73
79
  import { sealForwardedMiddlewareContext } from "./server/forwarded-middleware-context.js";
@@ -80,10 +86,13 @@ import { VIRTUAL_MODULE_ID_RE } from "./utils/virtual-module.js";
80
86
  import { assertNoPublicDirAssetConflict, assertNoPublicNextRequestConflict } from "./build/public-dir-conflict.js";
81
87
  import { renderVinextBuiltUrl } from "./utils/built-asset-url.js";
82
88
  import { asyncHooksStubPlugin } from "./plugins/async-hooks-stub.js";
89
+ import { createClientCompileHintsPlugin } from "./plugins/client-compile-hints.js";
83
90
  import { clientReferenceDedupPlugin } from "./plugins/client-reference-dedup.js";
84
91
  import { dataUrlCssPlugin } from "./plugins/css-data-url.js";
85
92
  import { createCssModuleImportCompatibilityPlugin } from "./plugins/css-module-imports.js";
86
- import { createRscClientReferenceLoadersPlugin } from "./plugins/rsc-client-reference-loaders.js";
93
+ import { createWorkerImageImportsPlugin } from "./plugins/worker-image-imports.js";
94
+ import { assertClientOutDirIsSeparate, createClientAssetFileNames, createClientCodeSplittingConfig, createClientManualChunks, createClientOutputFileNameDefaults, createMultiStageChunkFileNames, createMultiStageCodeSplittingConfig, createRscFrameworkChunkOutputConfig, createWorkerFileNames, findUnsupportedClientOutputFileNames, getBuildBundlerOptions, getClientTreeshakeConfig, getOutputFileNames, withBuildBundlerOptions } from "./build/client-build-config.js";
95
+ import { createRouteClientReferencesFallbackPlugin, createRscClientReferenceLoadersPlugin } from "./plugins/rsc-client-reference-loaders.js";
87
96
  import { createRscReferenceValidationNormalizerPlugin } from "./plugins/rsc-reference-validation-normalizer.js";
88
97
  import { createScanBuildCssPlugin } from "./plugins/scan-build-css.js";
89
98
  import { createInstrumentationClientTransformPlugin, createInstrumentationServerTransformPlugin } from "./plugins/instrumentation-client.js";
@@ -107,14 +116,13 @@ import { createTransitiveExternalsPlugin } from "./plugins/transitive-externals.
107
116
  import public_shim_map_default from "./shims/public-shim-map.json.js";
108
117
  import { computeClientRuntimeMetadata } from "./utils/client-runtime-metadata.js";
109
118
  import { readPrerenderSecret, readServerRuntimeOutputDirs } from "./build/server-manifest.js";
110
- import { createModuleDependencyCache } from "./build/module-dependency-cache.js";
119
+ import { ModuleDependencyStore, createModuleDependencyCache } from "./build/module-dependency-cache.js";
111
120
  import { markCssUrlAssetReferences, restoreDedupedCssAssetReferences } from "./build/css-url-assets.js";
112
121
  import { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter, createSassTsconfigPathImporters } from "./plugins/sass.js";
113
- import { assertClientOutDirIsSeparate, createClientAssetFileNames, createClientCodeSplittingConfig, createClientFileNameConfig, createClientManualChunks, createMultiStageChunkFileNames, createMultiStageCodeSplittingConfig, createRscFrameworkChunkOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfig, withBuildBundlerOptions } from "./build/client-build-config.js";
122
+ import { collectClientReferenceChunks, collectClientReferenceSources } from "./build/client-reference-chunks.js";
114
123
  import { EXPORT_ALL_CANDIDATE_FILTER, hasExportAllCandidate, stripServerExports, validatePageExports } from "./plugins/strip-server-exports.js";
115
124
  import { removeConsoleCalls } from "./plugins/remove-console.js";
116
125
  import { createImportMetaUrlPlugin } from "./plugins/import-meta-url.js";
117
- import { createWorkerImageImportsPlugin } from "./plugins/worker-image-imports.js";
118
126
  import { SERVER_ONLY_SPECIFIER_RE, createWorkerServerOnlyImportsPlugin } from "./plugins/worker-server-only-imports.js";
119
127
  import { createWorkerUseServerPlugins } from "./plugins/worker-use-server.js";
120
128
  import { createRequireContextPlugin } from "./plugins/require-context.js";
@@ -126,7 +134,7 @@ import { createWasmModuleImportPlugin } from "./plugins/wasm-module-import.js";
126
134
  import { consumerEnvironmentConditionFilter, getTypeofWindowReplacement, mayFoldChangeScannedImports, replaceConsumerEnvironmentConditions } from "./plugins/typeof-window.js";
127
135
  import { hasMdxFiles, loadMdxEsmReader, pageExtensionsIncludeMdx } from "./utils/mdx-scan.js";
128
136
  import { publicFileRouteKey } from "./utils/public-file-path.js";
129
- import { scanPublicFileRoutes } from "./utils/public-routes.js";
137
+ import { scanPublicFileRoutes, scanPublicFiles } from "./utils/public-routes.js";
130
138
  import { createIgnoreDynamicRequestsPlugin } from "./plugins/ignore-dynamic-requests.js";
131
139
  import { assertPluginRscVersion, needsAppReactServerDom } from "./utils/plugin-rsc-version.js";
132
140
  import { assertSupportedViteVersion, getDepOptimizeNodeEnvOptions, serializeViteDefine } from "./utils/vite-version.js";
@@ -134,7 +142,7 @@ import { staticExportApp, staticExportPages } from "./build/static-export.js";
134
142
  import { createRequire } from "node:module";
135
143
  import fs from "node:fs";
136
144
  import { pathToFileURL } from "node:url";
137
- import { createIdResolver, createLogger, isRunnableDevEnvironment, transformWithOxc } from "vite";
145
+ import { createIdResolver, createLogger, esmExternalRequirePlugin, isRunnableDevEnvironment, transformWithOxc } from "vite";
138
146
  import { createHash, randomBytes } from "node:crypto";
139
147
  import MagicString from "magic-string";
140
148
  import commonjs from "vite-plugin-commonjs";
@@ -156,6 +164,11 @@ const APP_CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
156
164
  "use-sync-external-store/with-selector",
157
165
  "use-sync-external-store/with-selector.js"
158
166
  ]);
167
+ const CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
168
+ "vinext > @unpic/react",
169
+ "vinext > ipaddr.js",
170
+ "vinext > web-vitals"
171
+ ]);
159
172
  const ANSI_ESCAPE_RE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
160
173
  const RSC_ENVIRONMENTS = /* @__PURE__ */ new Set([
161
174
  "rsc",
@@ -185,13 +198,17 @@ function scopeRscPlugin(plugin) {
185
198
  };
186
199
  }
187
200
  const earlyViteCliInvocation = getViteCliInvocation();
201
+ let earlyDotenv;
188
202
  const viteCliBuildConfigNodeEnv = earlyViteCliInvocation?.command === "build" && process.env.NODE_ENV === "test" ? "test" : void 0;
189
203
  if (earlyViteCliInvocation) {
190
204
  if (!process.env.NODE_ENV) Reflect.set(process.env, "NODE_ENV", earlyViteCliInvocation.command === "build" ? viteCliBuildConfigNodeEnv ?? "production" : earlyViteCliInvocation.mode === "test" ? "test" : "development");
191
- loadDotenv({
192
- root: earlyViteCliInvocation.root,
193
- mode: earlyViteCliInvocation.mode
194
- });
205
+ earlyDotenv = {
206
+ dir: path.resolve(earlyViteCliInvocation.root),
207
+ env: loadDotenv({
208
+ root: earlyViteCliInvocation.root,
209
+ mode: earlyViteCliInvocation.mode
210
+ }).loadedEnv
211
+ };
195
212
  }
196
213
  installSocketErrorBackstop();
197
214
  const INVALID_SERVER_ONLY_ID_PREFIX = "\0vinext:invalid-server-only:";
@@ -391,23 +408,35 @@ async function collectDevPagesAppStylesheetAssets(appFilePath, getModuleDependen
391
408
  await visitModule(appFilePath);
392
409
  return stylesheetAssets;
393
410
  }
394
- function createDevPagesModuleDependencyReader(root, resolve) {
395
- return createModuleDependencyCache(collectModuleDependencies);
411
+ function createDevPagesModuleDependencyReader(root, resolve, store) {
412
+ return createModuleDependencyCache((modulePath) => store.read(modulePath, collectModuleDependencies));
396
413
  async function collectModuleDependencies(modulePath) {
414
+ const dependencies = [];
415
+ const entry = {
416
+ dependencies,
417
+ resolvedFiles: [],
418
+ cacheable: true
419
+ };
397
420
  const cleanModulePath = stripViteModuleQuery(modulePath);
398
- if (!path.isAbsolute(cleanModulePath) || !fs.existsSync(cleanModulePath)) return [];
421
+ if (!path.isAbsolute(cleanModulePath) || !fs.existsSync(cleanModulePath)) return entry;
399
422
  let code;
400
423
  try {
401
424
  code = fs.readFileSync(cleanModulePath, "utf-8");
402
425
  } catch {
403
- return [];
426
+ return {
427
+ ...entry,
428
+ cacheable: false
429
+ };
404
430
  }
405
431
  const record = parseModuleRecord(code, parserLanguageForScript(cleanModulePath));
406
- if (!record) return [];
407
- const dependencies = [];
432
+ if (!record) return entry;
408
433
  for (const specifier of runtimeStaticDependencySpecifiers(code, record, parserLanguageForScript(cleanModulePath))) {
409
434
  const resolved = await resolve(specifier, cleanModulePath, { skipSelf: false });
410
- if (!resolved?.id) continue;
435
+ if (!resolved?.id) {
436
+ entry.cacheable = false;
437
+ continue;
438
+ }
439
+ entry.resolvedFiles.push(stripViteModuleQuery(resolved.id));
411
440
  if (isStylesheetSpecifier(specifier) || isStylesheetSpecifier(resolved.id)) {
412
441
  const asset = resolvedStylesheetToDevManifestAsset(root, resolved.id);
413
442
  if (asset) dependencies.push({
@@ -419,7 +448,7 @@ function createDevPagesModuleDependencyReader(root, resolve) {
419
448
  id: resolved.id
420
449
  });
421
450
  }
422
- return dependencies;
451
+ return entry;
423
452
  }
424
453
  }
425
454
  const TSCONFIG_FILES = ["tsconfig.json", "jsconfig.json"];
@@ -762,13 +791,18 @@ const VIRTUAL_APP_SSR_ENTRY = "virtual:vinext-app-ssr-entry";
762
791
  const RESOLVED_APP_SSR_ENTRY = "\0" + VIRTUAL_APP_SSR_ENTRY;
763
792
  const VIRTUAL_APP_BROWSER_ENTRY = "virtual:vinext-app-browser-entry";
764
793
  const RESOLVED_APP_BROWSER_ENTRY = "\0" + VIRTUAL_APP_BROWSER_ENTRY;
794
+ const VIRTUAL_APP_ROUTE_MANIFEST = "virtual:vinext-app-route-manifest";
795
+ const RESOLVED_APP_ROUTE_MANIFEST = "\0" + VIRTUAL_APP_ROUTE_MANIFEST;
765
796
  const VIRTUAL_APP_CAPABILITIES = "virtual:vinext-app-capabilities";
766
797
  const RESOLVED_APP_CAPABILITIES = "\0" + VIRTUAL_APP_CAPABILITIES;
767
798
  const RESOLVED_ROOT_PARAMS = "\0virtual:vinext-root-params";
799
+ const RESOLVED_NEXT_IMAGE_RSC = "\0virtual:vinext-next-image-rsc";
768
800
  const APP_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("app-request-stage-independent-entry");
769
801
  const APP_RESPONSE_STAGE_ENTRY = resolveRuntimeEntryModule("app-response-stage-entry");
770
802
  const PAGES_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("pages-request-stage-entry");
771
803
  const PAGES_RESPONSE_STAGE_ENTRY = resolveRuntimeEntryModule("pages-response-stage-entry");
804
+ const NITRO_PUBLIC_FILES_ENTRY = resolveRuntimeEntryModule("nitro-public-files");
805
+ const NITRO_PUBLIC_FILES_PLUGIN = resolveRuntimeEntryModule("nitro-public-files-plugin");
772
806
  const WORKER_ROUTER_ENTRIES = /* @__PURE__ */ new Set([resolveRuntimeEntryModule("app-router-entry"), resolveRuntimeEntryModule("pages-router-entry")]);
773
807
  /** Virtual module that registers config-driven cache adapters (see VinextOptions.cache). */
774
808
  const RESOLVED_CACHE_ADAPTERS = "\0" + VIRTUAL_CACHE_ADAPTERS;
@@ -883,13 +917,8 @@ const clientManualChunks = createClientManualChunks(_shimsDir);
883
917
  const clientCodeSplittingConfig = createClientCodeSplittingConfig(clientManualChunks);
884
918
  const appClientManualChunks = createClientManualChunks(_shimsDir, true);
885
919
  const appClientCodeSplittingConfig = createClientCodeSplittingConfig(appClientManualChunks);
886
- function getClientOutputConfig(assetsDir, preserveAppRouteBoundaries = false) {
887
- const codeSplitting = preserveAppRouteBoundaries ? appClientCodeSplittingConfig : clientCodeSplittingConfig;
888
- return {
889
- ...createClientFileNameConfig(assetsDir),
890
- assetFileNames: createClientAssetFileNames(assetsDir),
891
- codeSplitting
892
- };
920
+ function getClientOutputConfig(preserveAppRouteBoundaries = false) {
921
+ return { codeSplitting: preserveAppRouteBoundaries ? appClientCodeSplittingConfig : clientCodeSplittingConfig };
893
922
  }
894
923
  function createServerEnvironmentFileNameResolver(config, outputRoot) {
895
924
  const resolvedOutputRoot = path.resolve(config.root, outputRoot);
@@ -928,6 +957,10 @@ function vinext(options = {}) {
928
957
  let clientInjectModule = null;
929
958
  let globalNotFoundCssIsolationPath = null;
930
959
  let clientAssetsInlineLimit = 0;
960
+ let clientOutputFileNamesAssetsDir = null;
961
+ let plainPagesSsrFileNamesAssetsDir = null;
962
+ let topLevelFileNames = {};
963
+ let environmentFileNames = {};
931
964
  let hasCloudflarePlugin = false;
932
965
  let matchedMultiStageOutput;
933
966
  let selectedMultiStageOutput;
@@ -935,6 +968,8 @@ function vinext(options = {}) {
935
968
  let warnedInlineNextConfigOverride = false;
936
969
  let hasNitroPlugin = false;
937
970
  let nitroHostRuntime = "node";
971
+ let nitroPublicFiles = false;
972
+ let nitroPublicDir = "public";
938
973
  let resolvedServerExternalPackages = [];
939
974
  let registerNodeOpenTelemetryLoader = false;
940
975
  let pagesTsconfigAliases = {};
@@ -956,6 +991,7 @@ function vinext(options = {}) {
956
991
  });
957
992
  const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
958
993
  const pagesClientAssetsExternalTargets = /* @__PURE__ */ new Map();
994
+ const devPagesModuleDependencyStores = /* @__PURE__ */ new Map();
959
995
  const resolvePagesClientAssetsOutputDir = (environmentName, outputDir) => !selectedMultiStageOutput && !hasAppDir && !hasCloudflarePlugin && environmentName === "ssr" ? path.dirname(outputDir) : outputDir;
960
996
  let pagesClientAssetsModule = internalOptions.__pagesClientAssetsModule ?? null;
961
997
  let clientBuildFiles = [];
@@ -973,6 +1009,10 @@ function vinext(options = {}) {
973
1009
  const rscClassificationManifests = /* @__PURE__ */ new Map();
974
1010
  let rscActionOwnerRoutes = null;
975
1011
  let rscActionOwnerSharedRoots = [];
1012
+ let clientReferenceRoutes = null;
1013
+ let clientReferenceModules = null;
1014
+ let clientReferenceAlwaysRenderedFiles = [];
1015
+ let clientReferenceRoutelessFiles = [];
976
1016
  const serverEntryKindsByEnvironment = /* @__PURE__ */ new Map();
977
1017
  const serverRuntimeOutputDirs = /* @__PURE__ */ new Set();
978
1018
  function recordServerEntryLoad(environmentName, id) {
@@ -985,6 +1025,8 @@ function vinext(options = {}) {
985
1025
  entries.add(id);
986
1026
  }
987
1027
  const shimsDir = path.resolve(__dirname, "shims");
1028
+ const nextImageAliasTarget = toSlash(path.join(shimsDir, "image"));
1029
+ const nextImageAliasTargetRE = new RegExp(`^${nextImageAliasTarget.split("/").map(escapeRegExp).join("[\\\\/]")}$`);
988
1030
  const canonicalize = (p) => toSlash(tryRealpathSync(p) ?? p);
989
1031
  const pageTransformCanonicalPaths = /* @__PURE__ */ new Map();
990
1032
  const canonicalizePageTransformPath = (modulePath) => {
@@ -1005,6 +1047,8 @@ function vinext(options = {}) {
1005
1047
  resolveShimModulePath(shimsDir, "cache")
1006
1048
  ].map(canonicalize));
1007
1049
  let nextShimMap = {};
1050
+ let shimOptimizeDepsExclude = VINEXT_OPTIMIZE_DEPS_EXCLUDE;
1051
+ const createShimRequirePlugin = () => esmExternalRequirePlugin({ external: [...shimOptimizeDepsExclude] });
1008
1052
  /**
1009
1053
  * Generate the virtual SSR server entry module.
1010
1054
  * This is the entry point for `vite build --ssr`.
@@ -1032,9 +1076,10 @@ function vinext(options = {}) {
1032
1076
  * __NEXT_DATA__ to determine which page to hydrate.
1033
1077
  */
1034
1078
  async function generateClientEntry$1() {
1035
- const appPrefetchRoutes = hasAppDir ? toLinkPrefetchRoutes(await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher)) : [];
1079
+ const appRoutes = hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : [];
1036
1080
  return generateClientEntry(pagesDir, nextConfig, fileMatcher, {
1037
- appPrefetchRoutes,
1081
+ appPrefetchRoutes: toLinkPrefetchRoutes(appRoutes),
1082
+ appRouteHandlers: toHashedRouteHandlerRoutes(appRoutes),
1038
1083
  instrumentationClientPath,
1039
1084
  middlewareMatcher: middlewarePath ? extractMiddlewareMatcherConfig(middlewarePath) : void 0,
1040
1085
  reactPreamble: options.react !== false
@@ -1051,28 +1096,29 @@ function vinext(options = {}) {
1051
1096
  const earlyRoot = earlyViteCliInvocation?.root ?? process.cwd();
1052
1097
  const earlyBaseDir = path.resolve(earlyRoot, options.appDir ?? ".");
1053
1098
  const earlyAppDirExists = !options.disableAppRouter && (fs.existsSync(path.join(earlyBaseDir, "app")) || fs.existsSync(path.join(earlyBaseDir, "src", "app")));
1054
- let resolvedReactPath = null;
1055
1099
  let resolvedRscPath = null;
1056
1100
  let rscPluginModulePromise = null;
1057
- resolvedReactPath = resolveOptionalDependency(earlyBaseDir, "@vitejs/plugin-react");
1058
1101
  resolvedRscPath = resolveOptionalDependency(earlyBaseDir, "@vitejs/plugin-rsc");
1059
1102
  const rscVersion = earlyAppDirExists && resolvedRscPath ? assertPluginRscVersion(resolvedRscPath) : null;
1060
1103
  let rscPluginPromise = null;
1061
1104
  let manualUseCachePluginPromise = null;
1105
+ const rscPluginOptions = { entries: {
1106
+ rsc: VIRTUAL_RSC_ENTRY,
1107
+ ssr: VIRTUAL_APP_SSR_ENTRY,
1108
+ client: VIRTUAL_APP_BROWSER_ENTRY
1109
+ } };
1110
+ let serverActionsEncryptionKey;
1062
1111
  if (earlyAppDirExists && autoRsc) {
1063
1112
  if (!resolvedRscPath) throw new Error("vinext: App Router detected but @vitejs/plugin-rsc is not installed.\nRun: " + detectPackageManager(process.cwd()) + " @vitejs/plugin-rsc");
1064
1113
  const rscImport = import(pathToFileURL(resolvedRscPath).href);
1065
1114
  rscPluginModulePromise = rscImport;
1066
1115
  rscPluginPromise = rscImport.then(async (mod) => {
1067
1116
  const rsc = mod.default;
1068
- const plugins = rsc({ entries: {
1069
- rsc: VIRTUAL_RSC_ENTRY,
1070
- ssr: VIRTUAL_APP_SSR_ENTRY,
1071
- client: VIRTUAL_APP_BROWSER_ENTRY
1072
- } });
1117
+ const plugins = rsc(rscPluginOptions);
1073
1118
  const useCachePlugin = await createUseCacheCallablePlugin({
1074
1119
  projectRoot: earlyBaseDir,
1075
- cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href
1120
+ cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href,
1121
+ getEncryptionKey: () => serverActionsEncryptionKey
1076
1122
  });
1077
1123
  const useServerIndex = plugins.findIndex((plugin) => plugin.name === "rsc:use-server");
1078
1124
  if (useServerIndex === -1) throw new Error("vinext: Failed to locate @vitejs/plugin-rsc use-server plugin.");
@@ -1101,6 +1147,7 @@ function vinext(options = {}) {
1101
1147
  let reactPluginPromise = null;
1102
1148
  let reactCompilerPluginPromise = null;
1103
1149
  if (options.react !== false) {
1150
+ const resolvedReactPath = resolvePluginReactPath(earlyBaseDir);
1104
1151
  if (!resolvedReactPath) throw new Error("vinext: @vitejs/plugin-react is not installed.\nRun: " + detectPackageManager(process.cwd()) + " @vitejs/plugin-react");
1105
1152
  const allReactPlugins = import(pathToFileURL(resolvedReactPath).href).catch((cause) => {
1106
1153
  throw new Error("vinext: Failed to load @vitejs/plugin-react.", { cause });
@@ -1378,6 +1425,7 @@ function vinext(options = {}) {
1378
1425
  originalPlainPagesEnvironments = void 0;
1379
1426
  buildEmptyOutDir = typeof config.build?.emptyOutDir === "boolean" ? config.build.emptyOutDir : void 0;
1380
1427
  isServeCommand = env.command === "serve";
1428
+ const ipaddrSsrExternal = env.command === "serve" ? ["ipaddr.js"] : [];
1381
1429
  root = path.resolve(toSlash(process.cwd()), config.root ?? ".");
1382
1430
  if (env.command === "build") assertClientOutDirIsSeparate(root, options);
1383
1431
  const devCliLifecycleEnabled = env.command === "serve" && env.isPreview !== true && claimViteCliDevInvocation(root, config["__vinextDevRestart"] === true, reservedDevCliInvocation && config.configFile === false);
@@ -1388,13 +1436,15 @@ function vinext(options = {}) {
1388
1436
  let sassTsconfigPathAliases = [];
1389
1437
  const swcHelpersAlias = resolveSwcHelpersAlias(root);
1390
1438
  const mode = env?.mode ?? "development";
1391
- if (config.envDir !== false) {
1392
- const envDir = config.envDir ?? root;
1393
- loadDotenv({
1394
- root: envDir,
1395
- mode
1396
- });
1439
+ const envDir = config.envDir === false ? void 0 : config.envDir ? path.resolve(root, config.envDir) : root;
1440
+ if (earlyDotenv && envDir !== earlyDotenv.dir) {
1441
+ for (const [key, value] of Object.entries(earlyDotenv.env)) if (process.env[key] === value) Reflect.deleteProperty(process.env, key);
1442
+ earlyDotenv = void 0;
1397
1443
  }
1444
+ if (envDir) loadDotenv({
1445
+ root: envDir,
1446
+ mode
1447
+ });
1398
1448
  let resolvedNodeEnv;
1399
1449
  if (env?.command === "build" || env?.isPreview === true) resolvedNodeEnv = "production";
1400
1450
  else if (mode === "test") resolvedNodeEnv = "test";
@@ -1443,6 +1493,13 @@ function vinext(options = {}) {
1443
1493
  buildId: sharedBuildId
1444
1494
  };
1445
1495
  }
1496
+ if (rscPluginPromise) {
1497
+ serverActionsEncryptionKey = loadOrGenerateServerActionsEncryptionKey({
1498
+ root,
1499
+ isBuild: env.command === "build"
1500
+ });
1501
+ rscPluginOptions.defineEncryptionKey = `process.env.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY || ${JSON.stringify(serverActionsEncryptionKey)}`;
1502
+ }
1446
1503
  if (env?.command === "build" && earlyViteCliInvocation?.command === "build") Reflect.set(process.env, "NODE_ENV", "production");
1447
1504
  const configuredTsconfigPath = isUnknownRecord(nextConfig.typescript) ? typeof nextConfig.typescript.tsconfigPath === "string" ? nextConfig.typescript.tsconfigPath : void 0 : void 0;
1448
1505
  const resolvedTsconfigAliases = resolveTsconfigAliases(root, configuredTsconfigPath);
@@ -1520,9 +1577,9 @@ function vinext(options = {}) {
1520
1577
  defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_SVG"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowSVG ?? false));
1521
1578
  defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_LOCAL_IP"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowLocalIP ?? false));
1522
1579
  defines["process.env.__VINEXT_IMAGE_UNOPTIMIZED"] = JSON.stringify(String(nextConfig.images?.unoptimized === true));
1523
- defines["process.env.__VINEXT_BUILD_ID"] = JSON.stringify(nextConfig.buildId);
1524
- defines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify(rscCompatibilityId);
1525
- defines["process.env.__VINEXT_RSC_BUILD_IDENTITY"] = JSON.stringify(rscBuildIdentity ?? "");
1580
+ defines["process.env.__VINEXT_BUILD_ID"] = "undefined";
1581
+ defines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify("");
1582
+ defines["process.env.__VINEXT_RSC_BUILD_IDENTITY"] = JSON.stringify("");
1526
1583
  defines["process.env.__VINEXT_DEPLOYMENT_ID"] = JSON.stringify(nextConfig.deploymentId ?? "");
1527
1584
  defines["process.env.NEXT_DEPLOYMENT_ID"] = nextConfig.deploymentId ? JSON.stringify(nextConfig.deploymentId) : "false";
1528
1585
  defines["process.env.NEXT_RUNTIME"] = "\"\"";
@@ -1572,6 +1629,7 @@ function vinext(options = {}) {
1572
1629
  "vinext/html": path.resolve(__dirname, "server", "html"),
1573
1630
  ...clientInjectModule === null ? { "private-next-instrumentation-client": instrumentationClientPath ?? INSTRUMENTATION_CLIENT_EMPTY_MODULE } : {}
1574
1631
  }).flatMap(([k, v]) => k.startsWith("next/") ? [[k, v], [`${k}.js`, v]] : [[k, v]]));
1632
+ shimOptimizeDepsExclude = mergeOptimizeDepsExclude(VINEXT_OPTIMIZE_DEPS_EXCLUDE, Object.keys(nextShimMap), [..._reactServerShims.keys()]);
1575
1633
  const pluginsFlat = [];
1576
1634
  function flattenPlugins(arr) {
1577
1635
  for (const p of arr) if (Array.isArray(p)) flattenPlugins(p);
@@ -1608,6 +1666,10 @@ function vinext(options = {}) {
1608
1666
  const hasClientBuildEnvironment = hasAppDir || hasCloudflarePlugin || hasNitroPlugin || shouldInjectPlainPagesEnvironments;
1609
1667
  const clientAssetsDir = resolveAssetsDir(nextConfig.assetPrefix ?? "");
1610
1668
  clientAssetsInlineLimit = config.build?.assetsInlineLimit ?? 0;
1669
+ clientOutputFileNamesAssetsDir = !isSSR && !isMultiEnv || hasAppDir || hasCloudflarePlugin || shouldInjectPlainPagesEnvironments ? clientAssetsDir : null;
1670
+ plainPagesSsrFileNamesAssetsDir = !isMultiEnv && shouldInjectPlainPagesEnvironments ? clientAssetsDir : null;
1671
+ topLevelFileNames = getOutputFileNames(getBuildBundlerOptions(config.build)?.output);
1672
+ environmentFileNames = Object.fromEntries(Object.entries(config.environments ?? {}).map(([environmentName, environment]) => [environmentName, getOutputFileNames(getBuildBundlerOptions(environment?.build)?.output)]));
1611
1673
  const devHmrConfig = config.server?.hmr === false ? false : {
1612
1674
  ...typeof config.server?.hmr === "object" ? config.server.hmr : {},
1613
1675
  overlay: false
@@ -1652,7 +1714,7 @@ function vinext(options = {}) {
1652
1714
  };
1653
1715
  })(),
1654
1716
  ...!isSSR && !isMultiEnv ? { treeshake: getClientTreeshakeConfig() } : {},
1655
- ...!isSSR && !isMultiEnv ? { output: getClientOutputConfig(clientAssetsDir) } : {}
1717
+ ...!isSSR && !isMultiEnv ? { output: getClientOutputConfig() } : {}
1656
1718
  })
1657
1719
  },
1658
1720
  worker: { plugins: () => [
@@ -1682,7 +1744,7 @@ function vinext(options = {}) {
1682
1744
  "react",
1683
1745
  "react-dom",
1684
1746
  "react-dom/server",
1685
- "ipaddr.js",
1747
+ ...ipaddrSsrExternal,
1686
1748
  ...Array.isArray(config.ssr?.external) ? config.ssr.external : [],
1687
1749
  ...nextServerExternal
1688
1750
  ],
@@ -1765,12 +1827,12 @@ function vinext(options = {}) {
1765
1827
  };
1766
1828
  const depOptimizeNodeEnvOptions = getDepOptimizeNodeEnvOptions(nodeEnvDefine);
1767
1829
  viteConfig.optimizeDeps = {
1768
- exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["@tailwindcss/oxide"]),
1830
+ exclude: mergeOptimizeDepsExclude(incomingExclude, hasAppDir ? shimOptimizeDepsExclude : VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["@tailwindcss/oxide"]),
1769
1831
  ...incomingInclude.length > 0 ? { include: incomingInclude } : {},
1770
1832
  ...depOptimizeNodeEnvOptions,
1771
1833
  rolldownOptions: {
1772
1834
  ...depOptimizeNodeEnvOptions.rolldownOptions,
1773
- plugins: [depOptimizeAliasPlugin, commonJsEsmFacadeOptimizeDepsPlugin]
1835
+ plugins: hasAppDir ? [commonJsEsmFacadeOptimizeDepsPlugin] : [depOptimizeAliasPlugin, commonJsEsmFacadeOptimizeDepsPlugin]
1774
1836
  }
1775
1837
  };
1776
1838
  pagesOptimizeEntries = !hasAppDir ? [...hasPagesDir ? [toRelativeFileEntry(root, pagesDir) + "/**/*.{tsx,ts,jsx,js}"] : [], ...[instrumentationPath, instrumentationClientPath].flatMap((entry) => entry ? [toRelativeFileEntry(root, entry)] : [])] : [];
@@ -1825,7 +1887,6 @@ function vinext(options = {}) {
1825
1887
  additionalClientOptimizeIncludes.push(include);
1826
1888
  } catch {}
1827
1889
  }
1828
- if (!excluded.includes("next") && !excluded.includes("next/link")) additionalClientOptimizeIncludes.push("next/link");
1829
1890
  } catch {}
1830
1891
  }
1831
1892
  const appClientInput = { index: VIRTUAL_APP_BROWSER_ENTRY };
@@ -1845,13 +1906,9 @@ function vinext(options = {}) {
1845
1906
  noExternal: userSsrExternal === true ? [...PATCHED_SERVER_PACKAGES] : true
1846
1907
  } },
1847
1908
  optimizeDeps: {
1848
- exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE),
1909
+ exclude: mergeOptimizeDepsExclude(incomingExclude, shimOptimizeDepsExclude),
1849
1910
  entries: optimizeEntries,
1850
- include: [.../* @__PURE__ */ new Set([
1851
- ...incomingInclude,
1852
- ...additionalRscOptimizeIncludes,
1853
- "react-server-dom-webpack/static.edge"
1854
- ])],
1911
+ include: [.../* @__PURE__ */ new Set([...incomingInclude, ...additionalRscOptimizeIncludes])],
1855
1912
  ...depOptimizeNodeEnvOptions
1856
1913
  },
1857
1914
  build: {
@@ -1867,13 +1924,14 @@ function vinext(options = {}) {
1867
1924
  ...hasCloudflarePlugin || hasNitroPlugin ? {} : { resolve: {
1868
1925
  external: userSsrExternal === true ? true : [
1869
1926
  ...userSsrExternal,
1870
- "ipaddr.js",
1927
+ ...ipaddrSsrExternal,
1871
1928
  ...externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []
1872
1929
  ],
1873
1930
  noExternal: userSsrExternal === true ? [...PATCHED_SERVER_PACKAGES] : true
1874
1931
  } },
1875
1932
  optimizeDeps: {
1876
- exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], userSsrExternal === true || externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []),
1933
+ exclude: mergeOptimizeDepsExclude(incomingExclude, shimOptimizeDepsExclude, ["ipaddr.js"], userSsrExternal === true || externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []),
1934
+ ...userSsrExternal === true || externalizeSsrReactInDev || hasCloudflarePlugin ? {} : { include: ["react-dom/server", "react-dom/static"] },
1877
1935
  entries: optimizeEntries,
1878
1936
  ...depOptimizeNodeEnvOptions
1879
1937
  },
@@ -1885,7 +1943,7 @@ function vinext(options = {}) {
1885
1943
  client: {
1886
1944
  consumer: "client",
1887
1945
  optimizeDeps: {
1888
- exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, nextServerExternal),
1946
+ exclude: mergeOptimizeDepsExclude(incomingExclude, shimOptimizeDepsExclude, nextServerExternal),
1889
1947
  entries: optimizeEntries,
1890
1948
  include: [.../* @__PURE__ */ new Set([
1891
1949
  ...incomingInclude,
@@ -1905,7 +1963,7 @@ function vinext(options = {}) {
1905
1963
  assetsInlineLimit: clientAssetsInlineLimit,
1906
1964
  ...withBuildBundlerOptions({
1907
1965
  input: appClientInput,
1908
- output: getClientOutputConfig(clientAssetsDir, true),
1966
+ output: getClientOutputConfig(true),
1909
1967
  treeshake: getClientTreeshakeConfig()
1910
1968
  })
1911
1969
  }
@@ -1925,7 +1983,7 @@ function vinext(options = {}) {
1925
1983
  assetsInlineLimit: clientAssetsInlineLimit,
1926
1984
  ...withBuildBundlerOptions({
1927
1985
  input: { index: VIRTUAL_CLIENT_ENTRY },
1928
- output: getClientOutputConfig(clientAssetsDir),
1986
+ output: getClientOutputConfig(),
1929
1987
  treeshake: getClientTreeshakeConfig()
1930
1988
  })
1931
1989
  }
@@ -1946,7 +2004,7 @@ function vinext(options = {}) {
1946
2004
  assetsInlineLimit: clientAssetsInlineLimit,
1947
2005
  ...withBuildBundlerOptions({
1948
2006
  input: { index: VIRTUAL_CLIENT_ENTRY },
1949
- output: getClientOutputConfig(clientAssetsDir),
2007
+ output: getClientOutputConfig(),
1950
2008
  treeshake: getClientTreeshakeConfig()
1951
2009
  })
1952
2010
  }
@@ -1957,13 +2015,13 @@ function vinext(options = {}) {
1957
2015
  "react",
1958
2016
  "react-dom",
1959
2017
  "react-dom/server",
1960
- "ipaddr.js",
2018
+ ...ipaddrSsrExternal,
1961
2019
  ...nextServerExternal
1962
2020
  ],
1963
2021
  noExternal: true
1964
2022
  },
1965
2023
  optimizeDeps: {
1966
- exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], Object.keys(nextShimMap)),
2024
+ exclude: mergeOptimizeDepsExclude(incomingExclude, shimOptimizeDepsExclude, ["ipaddr.js"]),
1967
2025
  ...depOptimizeNodeEnvOptions
1968
2026
  },
1969
2027
  build: {
@@ -1991,17 +2049,27 @@ function vinext(options = {}) {
1991
2049
  copyPublicDirIntoStaticExportBasePath = config.build.copyPublicDir !== false;
1992
2050
  config.build.copyPublicDir = false;
1993
2051
  }
1994
- if (name !== "client" && config.consumer !== "client") {
2052
+ const isClientConsumer = name === "client" || config.consumer === "client";
2053
+ if (isClientConsumer && hasAppDir) {
2054
+ config.optimizeDeps ??= {};
2055
+ config.optimizeDeps.exclude = mergeOptimizeDepsExclude(config.optimizeDeps.exclude ?? [], shimOptimizeDepsExclude);
2056
+ }
2057
+ if (!isClientConsumer) {
1995
2058
  config.optimizeDeps ??= {};
1996
2059
  config.optimizeDeps.rolldownOptions ??= {};
1997
2060
  const configuredPlugins = config.optimizeDeps.rolldownOptions.plugins;
1998
- config.optimizeDeps.rolldownOptions.plugins = [...Array.isArray(configuredPlugins) ? configuredPlugins : configuredPlugins ? [configuredPlugins] : [], importMetaUrlCapability.optimizeDepsPlugin];
2061
+ config.optimizeDeps.rolldownOptions.plugins = [
2062
+ ...Array.isArray(configuredPlugins) ? configuredPlugins : configuredPlugins ? [configuredPlugins] : [],
2063
+ importMetaUrlCapability.optimizeDepsPlugin,
2064
+ createShimRequirePlugin()
2065
+ ];
2066
+ config.optimizeDeps.exclude = mergeOptimizeDepsExclude(config.optimizeDeps.exclude ?? [], shimOptimizeDepsExclude);
1999
2067
  }
2000
2068
  if (isServeCommand && hasCloudflarePlugin && hasPagesDir && !hasAppDir && name !== "client") {
2001
2069
  config.optimizeDeps ??= {};
2002
2070
  config.optimizeDeps.entries = mergeStringArrayValues(config.optimizeDeps.entries, pagesOptimizeEntries);
2003
2071
  config.optimizeDeps.include = mergeStringArrayValues(config.optimizeDeps.include, PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE);
2004
- config.optimizeDeps.exclude = mergeOptimizeDepsExclude(config.optimizeDeps.exclude ?? [], VINEXT_OPTIMIZE_DEPS_EXCLUDE, PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_EXCLUDE);
2072
+ config.optimizeDeps.exclude = mergeOptimizeDepsExclude(config.optimizeDeps.exclude ?? [], PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_EXCLUDE);
2005
2073
  }
2006
2074
  const configuredExtensions = name === "client" ? nextConfig.resolveExtensions : nextConfig.serverResolveExtensions;
2007
2075
  const extensions = configuredExtensions === null ? buildViteResolveExtensions(config.resolve?.extensions) : normalizeViteResolveExtensions(configuredExtensions);
@@ -2016,11 +2084,21 @@ function vinext(options = {}) {
2016
2084
  if (!config.server.middlewareMode) applyDevServerDefaults(config.server, {});
2017
2085
  }
2018
2086
  }
2019
- if (isServeCommand && (hasAppDir || hasCloudflarePlugin && hasPagesDir)) {
2087
+ if (isServeCommand) {
2020
2088
  const optionalWarnings = /* @__PURE__ */ new Set();
2089
+ const isExcludedShim = (depId) => shimOptimizeDepsExclude.some((excluded) => {
2090
+ if (depId === excluded || depId.startsWith(`${excluded}/`)) return true;
2091
+ if (!/[*?[\]{}()!]/.test(depId)) return false;
2092
+ const pkgName = depId.split("/").slice(0, depId.startsWith("@") ? 2 : 1).join("/");
2093
+ if (excluded !== pkgName && !excluded.startsWith(`${pkgName}/`)) return false;
2094
+ return typeof path.matchesGlob !== "function" || path.matchesGlob(excluded, depId);
2095
+ });
2021
2096
  for (const [name, environment] of Object.entries(config.environments)) {
2022
2097
  const optimizer = environment.optimizeDeps;
2023
- const optionalIncludes = hasAppDir ? name === "client" && !optimizer.noDiscovery ? APP_CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE : [] : name !== "client" ? PAGES_CLOUDFLARE_WORKER_OPTIONAL_OPTIMIZE_DEPS_INCLUDE : [];
2098
+ const isClient = (environment.consumer ?? name) === "client";
2099
+ const optimizerActive = !optimizer.noDiscovery || !!optimizer.include?.length;
2100
+ if (optimizer.include && (!isClient || hasAppDir)) optimizer.include = optimizer.include.filter((id) => !isExcludedShim(id.slice(id.lastIndexOf(">") + 1).trim()));
2101
+ const optionalIncludes = isClient ? hasAppDir && optimizerActive ? [...optimizer.noDiscovery ? [] : APP_CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE, ...CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE] : [] : !hasAppDir && hasCloudflarePlugin && hasPagesDir ? PAGES_CLOUDFLARE_WORKER_OPTIONAL_OPTIMIZE_DEPS_INCLUDE : [];
2024
2102
  for (const id of optionalIncludes) {
2025
2103
  const depId = id.slice(id.lastIndexOf(">") + 1).trim();
2026
2104
  if (optimizer.include?.includes(id) || optimizer.include?.includes(depId) || optimizer.exclude?.some((excluded) => depId === excluded || depId.startsWith(`${excluded}/`))) continue;
@@ -2031,16 +2109,14 @@ function vinext(options = {}) {
2031
2109
  Object.assign(config, { logger: createOptionalOptimizeDepsLogger(config.logger, optionalWarnings) });
2032
2110
  }
2033
2111
  if (config.worker?.rolldownOptions) {
2034
- const workerFileNames = `${resolveAssetsDir(nextConfig.assetPrefix ?? "")}/workers/[name]-[hash].js`;
2112
+ const workerFileNames = createWorkerFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? ""), config.root);
2035
2113
  const workerOutputs = config.worker.rolldownOptions.output;
2036
2114
  config.worker.rolldownOptions.output = Array.isArray(workerOutputs) ? (workerOutputs.length > 0 ? workerOutputs : [{}]).map((output) => ({
2037
2115
  ...output,
2038
- entryFileNames: workerFileNames,
2039
- chunkFileNames: workerFileNames
2116
+ ...workerFileNames
2040
2117
  })) : {
2041
2118
  ...workerOutputs,
2042
- entryFileNames: workerFileNames,
2043
- chunkFileNames: workerFileNames
2119
+ ...workerFileNames
2044
2120
  };
2045
2121
  }
2046
2122
  sassComposesLoader.setResolvedConfig(config);
@@ -2114,8 +2190,9 @@ function vinext(options = {}) {
2114
2190
  }
2115
2191
  },
2116
2192
  resolveId: {
2117
- filter: { id: /(?:next\/|vinext\/(?:shims\/|server\/(?:app-rsc-(?:combined-)?handler|app-router-entry|pages-router-entry))|virtual:vinext-|@vercel\/og(?:\.js)?$)/ },
2193
+ filter: { id: new RegExp(`${/(?:next\/|vinext\/(?:shims\/|server\/(?:app-rsc-(?:combined-)?handler|app-router-entry|pages-router-entry))|virtual:vinext-|@vercel\/og(?:\.js)?$)/.source}|${nextImageAliasTargetRE.source}`) },
2118
2194
  handler(id, importer) {
2195
+ if (nextImageAliasTargetRE.test(id)) return this.environment?.name === "rsc" ? RESOLVED_NEXT_IMAGE_RSC : void 0;
2119
2196
  const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
2120
2197
  if (cleanId === "vinext/server/app-rsc-combined-handler") {
2121
2198
  if (_canExternalizeAppRscHandler && this.environment?.name === "rsc" && this.environment.config?.command === "serve") return {
@@ -2132,6 +2209,7 @@ function vinext(options = {}) {
2132
2209
  return _appRscHandlerPath;
2133
2210
  }
2134
2211
  if (isVercelOgImport(cleanId) && !isVinextOgShimImporter(importer)) return resolveShimModulePath(_shimsDir, "og");
2212
+ if (cleanId === "vinext/shims/image" && this.environment?.name !== "rsc") return this.resolve("next/image", importer, { skipSelf: true });
2135
2213
  if (cleanId.startsWith("vinext/shims/")) return resolveShimModulePath(_shimsDir, stripJsExtension(stripViteModuleQuery(cleanId.slice(13))));
2136
2214
  if (cleanId === VIRTUAL_WORKER_ENTRY) return RESOLVED_WORKER_ENTRY;
2137
2215
  if (selectedMultiStageOutput && (cleanId === "vinext/server/app-router-entry" || cleanId === "vinext/server/pages-router-entry")) return RESOLVED_WORKER_ENTRY;
@@ -2174,6 +2252,7 @@ function vinext(options = {}) {
2174
2252
  if (cleanId === VIRTUAL_APP_RESPONSE_ENTRY) return RESOLVED_APP_RESPONSE_ENTRY;
2175
2253
  if (cleanId === VIRTUAL_APP_SSR_ENTRY) return RESOLVED_APP_SSR_ENTRY;
2176
2254
  if (cleanId === VIRTUAL_APP_BROWSER_ENTRY) return RESOLVED_APP_BROWSER_ENTRY;
2255
+ if (cleanId === VIRTUAL_APP_ROUTE_MANIFEST) return RESOLVED_APP_ROUTE_MANIFEST;
2177
2256
  if (cleanId === VIRTUAL_APP_CAPABILITIES) return RESOLVED_APP_CAPABILITIES;
2178
2257
  if (cleanId === "next/root-params" || cleanId === "next/root-params.js") return RESOLVED_ROOT_PARAMS;
2179
2258
  if (cleanId === "virtual:vinext-cache-adapters" || cleanId.endsWith("/virtual:vinext-cache-adapters")) return RESOLVED_CACHE_ADAPTERS;
@@ -2207,7 +2286,8 @@ function vinext(options = {}) {
2207
2286
  ].join("\n");
2208
2287
  const entry = hasAppDir ? "vinext/server/app-router-entry" : "vinext/server/pages-router-entry";
2209
2288
  if (!hasAppDir && hasNitroPlugin) return [
2210
- `import worker from ${JSON.stringify(entry)};`,
2289
+ `import pagesWorker from ${JSON.stringify(entry)};`,
2290
+ ...nitroPublicFiles ? [`import { withNitroPagesPublicFiles } from ${JSON.stringify(NITRO_PUBLIC_FILES_ENTRY)};`, "const worker = withNitroPagesPublicFiles(pagesWorker);"] : ["const worker = pagesWorker;"],
2211
2291
  "export default { fetch(request, env, ctx) {",
2212
2292
  ` return worker.fetch(request, env, { ...ctx, hostRuntime: ${JSON.stringify(nitroHostRuntime)} });`,
2213
2293
  "} };"
@@ -2238,7 +2318,12 @@ function vinext(options = {}) {
2238
2318
  const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
2239
2319
  const pagesRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
2240
2320
  const moduleFilePaths = [...appFilePath ? [appFilePath] : [], ...pagesRoutes.map((route) => route.filePath)];
2241
- const getModuleDependencies = createDevPagesModuleDependencyReader(root, this.resolve.bind(this));
2321
+ let dependencyStore = devPagesModuleDependencyStores.get(this.environment.name);
2322
+ if (!dependencyStore) {
2323
+ dependencyStore = new ModuleDependencyStore();
2324
+ devPagesModuleDependencyStores.set(this.environment.name, dependencyStore);
2325
+ }
2326
+ const getModuleDependencies = createDevPagesModuleDependencyReader(root, this.resolve.bind(this), dependencyStore);
2242
2327
  for (const moduleFilePath of moduleFilePaths) {
2243
2328
  const stylesheetAssets = await collectDevPagesAppStylesheetAssets(moduleFilePath, getModuleDependencies);
2244
2329
  if (stylesheetAssets.length > 0) ssrManifest[toSlash(moduleFilePath)] = stylesheetAssets;
@@ -2259,6 +2344,9 @@ function vinext(options = {}) {
2259
2344
  rscClassificationManifests.set(id, collectRouteClassificationManifest(routes));
2260
2345
  rscActionOwnerRoutes = this.environment.config.command === "build" && hasServerActions ? routes : null;
2261
2346
  rscActionOwnerSharedRoots = [globalErrorPath, globalNotFoundPath].filter((path) => path !== null);
2347
+ clientReferenceRoutes = this.environment.config.command === "build" ? routes : null;
2348
+ clientReferenceAlwaysRenderedFiles = [...globalErrorPath ? [globalErrorPath] : [], ...rootBoundaryFiles(routes)];
2349
+ clientReferenceRoutelessFiles = [...rootBoundaryRouteFiles(routes), ...globalNotFoundPath ? [globalNotFoundPath] : []];
2262
2350
  }
2263
2351
  return (id === RESOLVED_APP_REQUEST_ENTRY ? generateAppRequestRscEntry : id === RESOLVED_APP_RESPONSE_ENTRY ? generateAppResponseRscEntry : generateRscEntry)(appDir, routes, middlewarePath, metaRoutes, globalErrorPath, nextConfig?.basePath, nextConfig?.trailingSlash, {
2264
2352
  redirects: nextConfig?.redirects,
@@ -2273,6 +2361,7 @@ function vinext(options = {}) {
2273
2361
  nodeOpenTelemetryLoader: registerNodeOpenTelemetryLoader,
2274
2362
  assetPrefix: nextConfig?.assetPrefix,
2275
2363
  crossOrigin: nextConfig?.crossOrigin,
2364
+ skipProxyUrlNormalize: nextConfig?.skipProxyUrlNormalize,
2276
2365
  skipTrailingSlashRedirect: nextConfig?.skipTrailingSlashRedirect,
2277
2366
  expireTime: nextConfig?.expireTime,
2278
2367
  reactMaxHeadersLength: nextConfig?.reactMaxHeadersLength,
@@ -2302,27 +2391,36 @@ function vinext(options = {}) {
2302
2391
  devForwardedMiddlewareContextKey: isServeCommand && this.environment.config.consumer === "server" ? devForwardedMiddlewareContextKey : void 0
2303
2392
  }, instrumentationPath);
2304
2393
  }
2394
+ if (id === RESOLVED_NEXT_IMAGE_RSC) return [
2395
+ `export { getImageProps, imageOptimizationUrl } from "vinext/shims/image-props";`,
2396
+ `export { default } from "vinext/shims/image";`,
2397
+ ""
2398
+ ].join("\n");
2305
2399
  if (id === RESOLVED_ROOT_PARAMS) return generateRootParamsModule((hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : []).flatMap((route) => route.rootParamNames ?? []));
2306
2400
  if (id === RESOLVED_CACHE_ADAPTERS) return generateCacheAdaptersModule(options.cache);
2307
2401
  if (id === RESOLVED_CDN_CACHE_ADAPTER) return generateCdnCacheAdapterModule(options.cache);
2308
2402
  if (id === RESOLVED_IMAGE_ADAPTERS) return generateImageAdaptersModule(options.images);
2309
2403
  if (id === RESOLVED_APP_SSR_ENTRY && hasAppDir) {
2310
2404
  recordServerEntryLoad(this.environment?.name, id);
2311
- return generateSsrEntry(hasPagesDir);
2405
+ return generateSsrEntry(hasPagesDir, nitroPublicFiles ? NITRO_PUBLIC_FILES_ENTRY : null);
2312
2406
  }
2313
2407
  if (id === RESOLVED_APP_BROWSER_ENTRY && hasAppDir) {
2314
2408
  const graph = await appRouteGraph(appDir, nextConfig?.pageExtensions, fileMatcher);
2315
- const pagesPrefetchRoutes = hasPagesDir ? [...(await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher)).map((route) => ({
2316
- canPrefetchLoadingShell: false,
2317
- isDynamic: route.isDynamic,
2318
- patternParts: [...route.patternParts]
2319
- })), ...(await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher)).map((route) => ({
2409
+ const pagesPrefetchRoutes = hasPagesDir ? (await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher)).map((route) => ({
2320
2410
  canPrefetchLoadingShell: false,
2321
- documentOnly: true,
2322
2411
  isDynamic: route.isDynamic,
2323
2412
  patternParts: [...route.patternParts]
2324
- }))] : [];
2325
- return generateBrowserEntry(graph.routes, graph.routeManifest, pagesPrefetchRoutes, nextConfig.rewrites, nextConfig.i18n?.locales);
2413
+ })) : [];
2414
+ const classifyDynamicRoutes = this.environment.config.command === "build" && !nextConfig?.cacheComponents;
2415
+ const readMdxEsm = classifyDynamicRoutes && pageExtensionsIncludeMdx(nextConfig?.pageExtensions ?? []) ? await loadMdxEsmReader(root) : null;
2416
+ return generateBrowserEntry(graph.routes, pagesPrefetchRoutes, nextConfig.rewrites, nextConfig.i18n?.locales, classifyDynamicRoutes ? {
2417
+ route: (route) => isAppPageRouteRenderedDynamically(route, readMdxEsm),
2418
+ intercept: (intercept, layoutPaths) => isAppInterceptRenderedDynamically(intercept, layoutPaths, readMdxEsm)
2419
+ } : void 0);
2420
+ }
2421
+ if (id === RESOLVED_APP_ROUTE_MANIFEST && hasAppDir) {
2422
+ const graph = await appRouteGraph(appDir, nextConfig?.pageExtensions, fileMatcher);
2423
+ return generateBrowserRouteManifestModule(graph.routeManifest);
2326
2424
  }
2327
2425
  if (id === RESOLVED_APP_CAPABILITIES && hasAppDir) {
2328
2426
  const hasServerActions = await resolveHasServerActions(this.environment.config);
@@ -2374,6 +2472,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2374
2472
  }
2375
2473
  }
2376
2474
  },
2475
+ {
2476
+ name: "vinext:cloudflare-react-dom-edge",
2477
+ enforce: "pre",
2478
+ resolveId: {
2479
+ filter: { id: /^react-dom\/(?:server|static)$/ },
2480
+ handler(id, importer, options) {
2481
+ if (!hasCloudflarePlugin || this.environment?.config.consumer !== "server" || this.environment.name === "rsc") return;
2482
+ return this.resolve(`${id}.edge`, importer, {
2483
+ ...options,
2484
+ skipSelf: true
2485
+ });
2486
+ }
2487
+ }
2488
+ },
2377
2489
  {
2378
2490
  name: "vinext:cloudflare-framework-tracing",
2379
2491
  transform: {
@@ -2488,12 +2600,36 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2488
2600
  name: "vinext:css-url-assets-defaults",
2489
2601
  apply: "build",
2490
2602
  configEnvironment(name, config) {
2491
- if (name === "client") return { build: { assetsInlineLimit: clientAssetsInlineLimit } };
2492
- if (!hasAppDir || name !== "rsc" && name !== "ssr") return null;
2603
+ if (name === "client") {
2604
+ const output = getBuildBundlerOptions(config.build)?.output;
2605
+ const fileNameDefaults = clientOutputFileNamesAssetsDir ? createClientOutputFileNameDefaults(output, clientOutputFileNamesAssetsDir) : null;
2606
+ if (clientOutputFileNamesAssetsDir) {
2607
+ const unsupported = findUnsupportedClientOutputFileNames(output, clientOutputFileNamesAssetsDir);
2608
+ if (unsupported.length > 0) console.warn(`[vinext] Client output file names should stay under "${clientOutputFileNamesAssetsDir}/", include [hash], emit ".js" chunks and start asset basenames with "[name]." or "[name]-" and end them with [extname] so asset URLs, immutable caching, content types, CSS url() assets and script tags keep working: ` + unsupported.join("; "));
2609
+ }
2610
+ return { build: {
2611
+ assetsInlineLimit: clientAssetsInlineLimit,
2612
+ ...fileNameDefaults && Object.keys(fileNameDefaults).length > 0 ? withBuildBundlerOptions({ output: fileNameDefaults }) : {}
2613
+ } };
2614
+ }
2615
+ const plainPagesSsrAssetsDir = name === "ssr" ? plainPagesSsrFileNamesAssetsDir : null;
2616
+ const isCloudflarePagesServer = hasCloudflarePlugin && !hasAppDir;
2617
+ if (!(hasAppDir && (name === "rsc" || name === "ssr")) && !plainPagesSsrAssetsDir && !isCloudflarePagesServer) return null;
2493
2618
  const output = getBuildBundlerOptions(config.build)?.output;
2494
- if (Array.isArray(output) || output?.assetFileNames !== void 0) return null;
2495
- const assetFileNames = createClientAssetFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? ""));
2496
- return { build: { ...withBuildBundlerOptions({ output: { assetFileNames } }) } };
2619
+ if (Array.isArray(output)) return null;
2620
+ const ownFileNames = environmentFileNames[name] ?? {};
2621
+ const inheritsTopLevel = (key) => ownFileNames[key] === void 0 && topLevelFileNames[key] !== void 0 && output?.[key] === topLevelFileNames[key];
2622
+ const clientAssetFileNames = environmentFileNames.client?.assetFileNames;
2623
+ const serverAssetFileNames = ownFileNames.assetFileNames === void 0 && clientAssetFileNames !== void 0 ? clientAssetFileNames : output?.assetFileNames === void 0 ? createClientAssetFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? "")) : void 0;
2624
+ if (isCloudflarePagesServer) return serverAssetFileNames === void 0 ? null : { build: withBuildBundlerOptions({ output: { assetFileNames: serverAssetFileNames } }) };
2625
+ const serverChunkFileNames = output?.chunkFileNames === void 0 || inheritsTopLevel("chunkFileNames") ? plainPagesSsrAssetsDir ? `${plainPagesSsrAssetsDir}/chunks/[name]-[hash].js` : output?.chunkFileNames === void 0 ? void 0 : `${config.build?.assetsDir ?? "assets"}/[name]-[hash].js` : void 0;
2626
+ const serverFileNameDefaults = {
2627
+ ...serverAssetFileNames !== void 0 ? { assetFileNames: serverAssetFileNames } : {},
2628
+ ...serverChunkFileNames !== void 0 ? { chunkFileNames: serverChunkFileNames } : {},
2629
+ ...inheritsTopLevel("entryFileNames") ? { entryFileNames: "[name].js" } : {}
2630
+ };
2631
+ if (Object.keys(serverFileNameDefaults).length === 0) return null;
2632
+ return { build: { ...withBuildBundlerOptions({ output: serverFileNameDefaults }) } };
2497
2633
  }
2498
2634
  },
2499
2635
  {
@@ -2560,22 +2696,38 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2560
2696
  {
2561
2697
  name: "vinext:client-entry-manifest",
2562
2698
  apply: "build",
2563
- generateBundle(_options, bundle) {
2564
- if (this.environment?.name !== "client") return;
2565
- const manifest = {};
2566
- for (const chunk of Object.values(bundle)) {
2567
- if (chunk.type !== "chunk" || !chunk.isEntry) continue;
2568
- if (isVirtualEntryFacade(chunk.facadeModuleId, VIRTUAL_CLIENT_ENTRY)) manifest.pagesClientEntry = chunk.fileName;
2569
- else if (isVirtualEntryFacade(chunk.facadeModuleId, VIRTUAL_APP_BROWSER_ENTRY)) manifest.appBrowserEntry = chunk.fileName;
2699
+ generateBundle: {
2700
+ order: "post",
2701
+ handler(_options, bundle) {
2702
+ if (this.environment?.name !== "client") return;
2703
+ const manifest = {};
2704
+ for (const chunk of Object.values(bundle)) {
2705
+ if (chunk.type !== "chunk") continue;
2706
+ if (chunk.isDynamicEntry && isVirtualEntryFacade(chunk.facadeModuleId, VIRTUAL_APP_ROUTE_MANIFEST)) manifest.appRouteManifest = chunk.fileName;
2707
+ if (!chunk.isEntry) continue;
2708
+ if (isVirtualEntryFacade(chunk.facadeModuleId, VIRTUAL_CLIENT_ENTRY)) manifest.pagesClientEntry = chunk.fileName;
2709
+ else if (isVirtualEntryFacade(chunk.facadeModuleId, VIRTUAL_APP_BROWSER_ENTRY)) manifest.appBrowserEntry = chunk.fileName;
2710
+ }
2711
+ if (clientReferenceModules) {
2712
+ const appBrowserEntry = manifest.appBrowserEntry ? bundle[manifest.appBrowserEntry] : void 0;
2713
+ manifest.appClientReferenceChunks = collectClientReferenceChunks(bundle, clientReferenceModules, appBrowserEntry?.type === "chunk" ? appBrowserEntry : void 0, this.environment.config.build.modulePreload);
2714
+ const sources = collectClientReferenceSources(bundle, (moduleId) => this.getModuleInfo(moduleId)?.importedIds, this.environment.config.root);
2715
+ if (sources) this.emitFile({
2716
+ type: "asset",
2717
+ fileName: VINEXT_CLIENT_REFERENCE_SOURCES,
2718
+ source: JSON.stringify(sources, null, 2) + "\n"
2719
+ });
2720
+ }
2721
+ if (!manifest.pagesClientEntry && !manifest.appBrowserEntry) return;
2722
+ this.emitFile({
2723
+ type: "asset",
2724
+ fileName: VINEXT_CLIENT_ENTRY_MANIFEST,
2725
+ source: JSON.stringify(manifest, null, 2) + "\n"
2726
+ });
2570
2727
  }
2571
- if (!manifest.pagesClientEntry && !manifest.appBrowserEntry) return;
2572
- this.emitFile({
2573
- type: "asset",
2574
- fileName: VINEXT_CLIENT_ENTRY_MANIFEST,
2575
- source: JSON.stringify(manifest, null, 2) + "\n"
2576
- });
2577
2728
  }
2578
2729
  },
2730
+ createClientCompileHintsPlugin((id) => isVirtualEntryFacade(id, VIRTUAL_APP_BROWSER_ENTRY) || isVirtualEntryFacade(id, VIRTUAL_CLIENT_ENTRY)),
2579
2731
  asyncHooksStubPlugin,
2580
2732
  createInstrumentationClientTransformPlugin(() => instrumentationClientPath, () => nextConfig.instrumentationClientRouteManifest),
2581
2733
  createInstrumentationServerTransformPlugin(() => instrumentationPath, () => nextConfig.instrumentationServerValueInjections),
@@ -2672,6 +2824,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2672
2824
  },
2673
2825
  configureServer(server) {
2674
2826
  installSocketErrorBackstop({ runningServer: true });
2827
+ devPagesModuleDependencyStores.clear();
2675
2828
  const devBuildId = nextConfig?.buildId ?? process.env.__VINEXT_BUILD_ID ?? "development";
2676
2829
  server.middlewares.use((req, _res, next) => {
2677
2830
  req.__vinextOriginalEncodedUrl ??= req.url;
@@ -2747,6 +2900,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2747
2900
  }
2748
2901
  pagesRunner?.clearCache();
2749
2902
  }
2903
+ function invalidatePagesModuleDependencies(filePath, event) {
2904
+ if (devPagesModuleDependencyStores.size === 0) return;
2905
+ if (path.basename(filePath) === "tsconfig.json") {
2906
+ devPagesModuleDependencyStores.clear();
2907
+ return;
2908
+ }
2909
+ const files = /* @__PURE__ */ new Set([
2910
+ toSlash(filePath),
2911
+ canonicalizeFilePath(filePath),
2912
+ path.join(canonicalizeFilePath(path.dirname(filePath)), path.basename(filePath))
2913
+ ]);
2914
+ const unmappedDelete = event === "delete" && (isScriptModuleId(filePath) || isStylesheetSpecifier(filePath));
2915
+ for (const store of devPagesModuleDependencyStores.values()) if (!store.invalidate([...files], event) && unmappedDelete) store.clear();
2916
+ }
2750
2917
  function invalidatePagesClientAssetsModule() {
2751
2918
  for (const env of Object.values(server.environments)) {
2752
2919
  const mod = env.moduleGraph.getModuleById(RESOLVED_PAGES_CLIENT_ASSETS);
@@ -2759,11 +2926,18 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2759
2926
  if (!graph) return;
2760
2927
  for (const mod of graph.idToModuleMap.values()) if (mod.id?.includes("?html-proxy&index=")) graph.invalidateModule(mod);
2761
2928
  }
2929
+ function invalidateAppRouteManifestModule() {
2930
+ for (const env of Object.values(server.environments)) {
2931
+ const mod = env.moduleGraph.getModuleById(RESOLVED_APP_ROUTE_MANIFEST);
2932
+ if (mod) env.moduleGraph.invalidateModule(mod);
2933
+ }
2934
+ }
2762
2935
  function invalidateAppRoutingModules() {
2763
2936
  invalidateAppRouteCache();
2764
2937
  invalidateMetadataFileCache();
2765
2938
  invalidateRscEntryModule();
2766
2939
  invalidateRootParamsModule();
2940
+ invalidateAppRouteManifestModule();
2767
2941
  }
2768
2942
  let hybridRouteValidation = Promise.resolve();
2769
2943
  let hybridRouteValidationError = null;
@@ -2876,6 +3050,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2876
3050
  server.ws.send({ type: "full-reload" });
2877
3051
  }
2878
3052
  server.watcher.on("add", (filePath) => {
3053
+ invalidatePagesModuleDependencies(filePath, "create");
2879
3054
  invalidatePagesMiddlewareMatcher(filePath);
2880
3055
  updatePublicFileRoute(filePath, true);
2881
3056
  let routeChanged = false;
@@ -2901,6 +3076,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2901
3076
  }
2902
3077
  });
2903
3078
  server.watcher.on("change", (filePath) => {
3079
+ invalidatePagesModuleDependencies(filePath, "update");
2904
3080
  invalidatePagesMiddlewareMatcher(filePath);
2905
3081
  if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
2906
3082
  const pageFile = toSlash(filePath);
@@ -2917,6 +3093,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2917
3093
  if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
2918
3094
  });
2919
3095
  server.watcher.on("unlink", (filePath) => {
3096
+ invalidatePagesModuleDependencies(filePath, "delete");
2920
3097
  invalidatePagesMiddlewareMatcher(filePath);
2921
3098
  updatePublicFileRoute(filePath, false);
2922
3099
  let routeChanged = false;
@@ -3329,6 +3506,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3329
3506
  dataNotFoundResponse,
3330
3507
  rawSearch: url.includes("?") ? url.slice(url.indexOf("?")) : "",
3331
3508
  configMatchPathname,
3509
+ restoreLocaleRootTrailingSlash: shouldRestoreLocaleRootTrailingSlash(canonicalOriginalUrl.split("?")[0], nextConfig ?? {}),
3332
3510
  runMiddleware: devRunMiddlewareAdapter,
3333
3511
  matchApiRoute: async (apiUrl) => {
3334
3512
  const devApiRoutes = await getDevApiRoutes();
@@ -3373,7 +3551,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3373
3551
  }) : new Response("Invalid image optimization parameters", { status: 400 });
3374
3552
  }
3375
3553
  const isRetrievalMethod = req.method === "GET" || req.method === "HEAD";
3376
- if (phase === "direct" && isRetrievalMethod || requestPathname === "/" || requestPathname === "/api" || requestPathname.startsWith("/api/")) return false;
3554
+ if (!resolvedPathnameHasBasePath || phase === "direct" && isRetrievalMethod || requestPathname === "/" || requestPathname === "/api" || requestPathname.startsWith("/api/")) return false;
3377
3555
  if (!isRetrievalMethod) return isExistingDevPublicFile(normalizePathnameForRouteMatch(requestPathname)) ? methodNotAllowedResponse("GET, HEAD") : false;
3378
3556
  return serveRewrittenViteFilesystemRoute(req, res, requestPathname, stagedHeaders);
3379
3557
  }
@@ -3673,12 +3851,15 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3673
3851
  },
3674
3852
  {
3675
3853
  name: "vinext:compiler-define-server",
3676
- configEnvironment(name) {
3677
- if (name === "client") return null;
3854
+ configEnvironment(name, config) {
3855
+ if (name === "client" || config.consumer === "client") return null;
3678
3856
  const serverDefines = { ...nextConfig.compilerDefineServer };
3679
3857
  serverDefines["process.env.NEXT_RUNTIME"] = JSON.stringify("nodejs");
3680
3858
  serverDefines["process.env.NEXT_PHASE"] = "globalThis.__VINEXT_NEXT_PHASE";
3681
3859
  if (revalidateSecret) serverDefines["process.env.__VINEXT_REVALIDATE_SECRET"] = JSON.stringify(revalidateSecret);
3860
+ serverDefines["process.env.__VINEXT_BUILD_ID"] = JSON.stringify(nextConfig.buildId);
3861
+ if (rscCompatibilityId) serverDefines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify(rscCompatibilityId);
3862
+ if (rscBuildIdentity) serverDefines["process.env.__VINEXT_RSC_BUILD_IDENTITY"] = JSON.stringify(rscBuildIdentity);
3682
3863
  if (previewBuildCredentials) {
3683
3864
  serverDefines["process.env.__VINEXT_PREVIEW_MODE_ID"] = JSON.stringify(previewBuildCredentials.id);
3684
3865
  serverDefines["process.env.__VINEXT_PREVIEW_MODE_SIGNING_KEY"] = JSON.stringify(previewBuildCredentials.signingKey);
@@ -3737,7 +3918,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3737
3918
  const cache = imageImportDimCache;
3738
3919
  let dims = cache.get(imagePath);
3739
3920
  if (!dims) try {
3740
- const { imageSize } = await import("./deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js");
3921
+ const { imageSize } = await import("./deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/index.js");
3741
3922
  const result = imageSize(fs.readFileSync(imagePath));
3742
3923
  dims = {
3743
3924
  width: result.width ?? 0,
@@ -3896,11 +4077,25 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3896
4077
  },
3897
4078
  {
3898
4079
  name: "vinext:nitro-setup",
4080
+ configResolved(config) {
4081
+ nitroPublicDir = config.publicDir;
4082
+ },
4083
+ buildStart() {
4084
+ if (this.environment?.name !== "nitro" || this.environment.mode !== "build") return;
4085
+ const config = this.environment.getTopLevelConfig();
4086
+ const clientOutDir = config.environments.client?.build.outDir;
4087
+ if (!clientOutDir) return;
4088
+ fs.rmSync(path.resolve(config.root, clientOutDir, ".vite"), {
4089
+ recursive: true,
4090
+ force: true
4091
+ });
4092
+ },
3899
4093
  nitro: { setup: (nitro) => {
3900
4094
  nitroBuildDir = nitro.options.buildDir ? path.resolve(root, nitro.options.buildDir) : void 0;
3901
4095
  nitroHostRuntime = nitro.options.exportConditions?.includes("workerd") ? "worker" : "node";
3902
4096
  if (!nextConfig) return;
3903
4097
  if (!hasAppDir && !hasPagesDir) return;
4098
+ nitroPublicFiles = registerNitroPublicFiles(nitro.options, NITRO_PUBLIC_FILES_PLUGIN, () => scanPublicFiles(root, nitroPublicDir));
3904
4099
  if (resolvedServerExternalPackages.length > 0) nitro.options.traceDeps = [.../* @__PURE__ */ new Set([...nitro.options.traceDeps ?? [], ...resolvedServerExternalPackages])];
3905
4100
  } }
3906
4101
  },
@@ -3936,15 +4131,17 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3936
4131
  writeBundle: {
3937
4132
  sequential: true,
3938
4133
  order: "post",
3939
- handler(outputOptions) {
4134
+ async handler(outputOptions) {
3940
4135
  const clientDir = outputOptions.dir;
3941
4136
  if (!clientDir) return;
3942
4137
  if (!(this.environment?.name === "client")) return;
4138
+ const pageRoutes = hasPagesDir ? (await Promise.all([pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher), apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher)])).flat() : [];
3943
4139
  emitNextClientRuntimeManifests({
3944
4140
  clientDir,
3945
4141
  assetsSubdir: resolveAssetsDir(nextConfig.assetPrefix),
3946
4142
  buildId: nextConfig.buildId,
3947
- rewrites: nextConfig.rewrites
4143
+ rewrites: nextConfig.rewrites,
4144
+ pages: pageRoutes.map((route) => getPagesManifestPage(pagesDir, route.filePath, fileMatcher))
3948
4145
  });
3949
4146
  }
3950
4147
  }
@@ -4044,8 +4241,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
4044
4241
  pagesClientAssetsModule = buildPagesClientAssetsModule({
4045
4242
  clientEntry: runtimeMetadata.clientEntryFile ?? void 0,
4046
4243
  appBootstrapPreinitModules: runtimeMetadata.appBootstrapPreinitModules,
4244
+ appRouteManifestModule: runtimeMetadata.appRouteManifestModule,
4245
+ appClientReferenceChunks: runtimeMetadata.appClientReferenceChunks,
4047
4246
  ssrManifest,
4048
4247
  cssGraph: runtimeMetadata.cssGraph,
4248
+ sharedChunks: runtimeMetadata.sharedChunks,
4049
4249
  lazyChunks: runtimeMetadata.lazyChunks ?? void 0,
4050
4250
  dynamicPreloads: runtimeMetadata.dynamicPreloads ?? void 0,
4051
4251
  crossOrigin: nextConfig.crossOrigin ?? "",
@@ -4247,14 +4447,38 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
4247
4447
  onComplete() {
4248
4448
  rscActionOwnerRoutes = null;
4249
4449
  rscActionOwnerSharedRoots = [];
4450
+ clientReferenceRoutes = null;
4451
+ clientReferenceAlwaysRenderedFiles = [];
4452
+ clientReferenceRoutelessFiles = [];
4250
4453
  }
4251
4454
  }));
4252
4455
  plugins.push(createScanBuildCssPlugin());
4253
4456
  }
4254
4457
  if (rscPluginPromise) {
4255
4458
  plugins.push(createRscReferenceValidationNormalizerPlugin());
4256
- plugins.push(createRscClientReferenceLoadersPlugin());
4257
- } else if (manualUseCachePluginPromise) plugins.push(manualUseCachePluginPromise);
4459
+ plugins.push(createRscClientReferenceLoadersPlugin({
4460
+ onClientReferenceModules(modules) {
4461
+ clientReferenceModules = modules;
4462
+ },
4463
+ routes: {
4464
+ canonicalizeModuleId: canonicalize,
4465
+ getAlwaysRenderedFiles: () => clientReferenceAlwaysRenderedFiles,
4466
+ getRoutelessFiles: () => clientReferenceRoutelessFiles,
4467
+ getRoutes: () => clientReferenceRoutes,
4468
+ getSharedRoots: () => rscActionOwnerSharedRoots
4469
+ },
4470
+ grouping: options.disableNextLikeChunking ? void 0 : {
4471
+ isAlwaysLoadedClientModule(id) {
4472
+ const chunkName = appClientManualChunks(id);
4473
+ return chunkName === "framework" || chunkName === "vinext";
4474
+ },
4475
+ ownClientChunkGroups: /* @__PURE__ */ new Set([...appClientCodeSplittingConfig.groups, ...clientCodeSplittingConfig.groups])
4476
+ }
4477
+ }));
4478
+ } else {
4479
+ plugins.push(createRouteClientReferencesFallbackPlugin());
4480
+ if (manualUseCachePluginPromise) plugins.push(manualUseCachePluginPromise);
4481
+ }
4258
4482
  plugins.push({
4259
4483
  name: "vinext:plain-pages-build-config",
4260
4484
  apply: "build",