vinext 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (529) hide show
  1. package/README.md +5 -2
  2. package/THIRD_PARTY_LICENSES.md +47 -0
  3. package/dist/_virtual/_rolldown/runtime.js +4 -3
  4. package/dist/build/action-owner-manifest.d.ts +3 -2
  5. package/dist/build/action-owner-manifest.js +18 -2
  6. package/dist/build/app-page-static-eligibility.d.ts +17 -1
  7. package/dist/build/app-page-static-eligibility.js +80 -13
  8. package/dist/build/clean-output.d.ts +2 -1
  9. package/dist/build/client-build-config.d.ts +13 -3
  10. package/dist/build/client-build-config.js +46 -9
  11. package/dist/build/client-reference-async.d.ts +48 -0
  12. package/dist/build/client-reference-async.js +123 -0
  13. package/dist/build/client-reference-chunks.d.ts +32 -0
  14. package/dist/build/client-reference-chunks.js +111 -0
  15. package/dist/build/client-reference-groups.d.ts +9 -1
  16. package/dist/build/client-reference-groups.js +40 -2
  17. package/dist/build/css-url-assets.d.ts +2 -1
  18. package/dist/build/google-fonts/fallback-metrics.d.ts +2 -1
  19. package/dist/build/google-fonts/find-font-files-in-css.d.ts +1 -0
  20. package/dist/build/google-fonts/find-font-files-in-css.js +17 -4
  21. package/dist/build/google-fonts/font-metadata.d.ts +2 -1
  22. package/dist/build/google-fonts/validate.d.ts +2 -1
  23. package/dist/build/inline-css.d.ts +2 -1
  24. package/dist/build/module-dependency-cache.d.ts +2 -1
  25. package/dist/build/next-client-runtime-manifests.d.ts +2 -1
  26. package/dist/build/precompress.d.ts +2 -1
  27. package/dist/build/precompress.js +1 -1
  28. package/dist/build/prerender-paths.d.ts +2 -1
  29. package/dist/build/prerender-phase.d.ts +2 -1
  30. package/dist/build/prerender-server-pool.js +1 -1
  31. package/dist/build/prerender.d.ts +3 -2
  32. package/dist/build/prerender.js +6 -5
  33. package/dist/build/report.d.ts +2 -15
  34. package/dist/build/report.js +1 -51
  35. package/dist/build/run-prerender.d.ts +2 -1
  36. package/dist/build/server-actions-encryption-key.d.ts +2 -1
  37. package/dist/build/ssr-manifest.js +25 -2
  38. package/dist/build/standalone.d.ts +2 -1
  39. package/dist/cache/cache-adapters-virtual.d.ts +2 -1
  40. package/dist/cache.js +1 -2
  41. package/dist/check.d.ts +2 -1
  42. package/dist/check.js +5 -1
  43. package/dist/cli-args.d.ts +2 -1
  44. package/dist/cli.js +5 -0
  45. package/dist/client/client-redirect-matcher.js +2 -1
  46. package/dist/client/client-redirects.d.ts +4 -3
  47. package/dist/client/client-redirects.js +2 -1
  48. package/dist/client/client-rewrites.d.ts +2 -1
  49. package/dist/client/dev-error-overlay-store.d.ts +2 -1
  50. package/dist/client/dev-error-overlay.js +1 -1
  51. package/dist/client/index.js +1 -2
  52. package/dist/client/instrumentation-client-state.js +5 -5
  53. package/dist/client/navigation-runtime.d.ts +16 -2
  54. package/dist/client/navigation-runtime.js +2 -2
  55. package/dist/client/pages-router-link-navigation.d.ts +2 -1
  56. package/dist/client/vinext-next-data.d.ts +25 -1
  57. package/dist/client/window-next.d.ts +2 -1
  58. package/dist/config/config-matchers.d.ts +12 -1
  59. package/dist/config/config-matchers.js +111 -16
  60. package/dist/config/dotenv.d.ts +2 -1
  61. package/dist/config/next-config.d.ts +32 -1
  62. package/dist/config/next-config.js +93 -5
  63. package/dist/config/tsconfig-paths.d.ts +2 -1
  64. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/dbcs-codec.js +327 -0
  65. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/dbcs-data.js +123 -0
  66. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/index.js +29 -0
  67. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/internal.js +134 -0
  68. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-codec.js +50 -0
  69. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-data-generated.js +455 -0
  70. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-data.js +147 -0
  71. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/big5-added.json.js +169 -0
  72. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp936.json.js +2584 -0
  73. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp949.json.js +2220 -0
  74. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp950.json.js +227 -0
  75. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/eucjp.json.js +425 -0
  76. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/gb18030-ranges.json.js +427 -0
  77. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/gbk-added.json.js +229 -0
  78. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/shiftjis.json.js +292 -0
  79. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/utf16.js +106 -0
  80. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/utf7.js +182 -0
  81. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/bom-handling.js +42 -0
  82. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/extend-node.js +147 -0
  83. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/index.js +94 -0
  84. package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/streams.js +95 -0
  85. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/detector.js +23 -0
  86. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/index.js +2 -0
  87. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/lookup.js +25 -0
  88. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/bmp.js +11 -0
  89. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/cur.js +15 -0
  90. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/dds.js +11 -0
  91. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/gif.js +12 -0
  92. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/heif.js +55 -0
  93. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/icns.js +76 -0
  94. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ico.js +39 -0
  95. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/index.js +46 -0
  96. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/j2c.js +11 -0
  97. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jp2.js +21 -0
  98. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jpg.js +71 -0
  99. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl-stream.js +42 -0
  100. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl.js +46 -0
  101. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ktx.js +19 -0
  102. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/png.js +28 -0
  103. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/pnm.js +54 -0
  104. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/psd.js +11 -0
  105. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/svg.js +79 -0
  106. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tga.js +15 -0
  107. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tiff.js +96 -0
  108. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/utils.js +53 -0
  109. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/webp.js +45 -0
  110. package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/utils/bit-reader.js +38 -0
  111. package/dist/deps/.pnpm/safer-buffer@2.1.2/deps/safer-buffer/safer.js +45 -0
  112. package/dist/deps/.pnpm/ua-parser-js@1.0.35/deps/ua-parser-js/src/ua-parser.js +2 -2
  113. package/dist/entries/app-browser-entry.d.ts +20 -5
  114. package/dist/entries/app-browser-entry.js +79 -6
  115. package/dist/entries/app-rsc-entry.d.ts +2 -1
  116. package/dist/entries/app-rsc-entry.js +59 -60
  117. package/dist/entries/app-rsc-manifest.d.ts +2 -1
  118. package/dist/entries/app-rsc-manifest.js +56 -4
  119. package/dist/entries/app-ssr-entry.js +1 -0
  120. package/dist/entries/pages-entry-helpers.js +1 -2
  121. package/dist/entries/pages-server-entry.d.ts +2 -1
  122. package/dist/entries/pages-server-entry.js +34 -9
  123. package/dist/entries/runtime-entry-module.d.ts +1 -0
  124. package/dist/entries/runtime-entry-module.js +4 -1
  125. package/dist/image/image-adapters-virtual.d.ts +2 -1
  126. package/dist/index.js +184 -103
  127. package/dist/init-cloudflare.d.ts +1 -3
  128. package/dist/init-cloudflare.js +10 -48
  129. package/dist/init-platform.d.ts +2 -0
  130. package/dist/init-platform.js +4 -0
  131. package/dist/plugins/client-compile-hints.d.ts +30 -0
  132. package/dist/plugins/client-compile-hints.js +88 -0
  133. package/dist/plugins/client-reference-dedup.d.ts +2 -1
  134. package/dist/plugins/cloudflare-dev-module-urls.d.ts +2 -1
  135. package/dist/plugins/dynamic-preload-metadata.d.ts +3 -1
  136. package/dist/plugins/dynamic-preload-metadata.js +1 -1
  137. package/dist/plugins/environment.d.ts +2 -1
  138. package/dist/plugins/extensionless-dynamic-import.js +6 -2
  139. package/dist/plugins/fonts.js +9 -12
  140. package/dist/plugins/ignore-dynamic-requests.d.ts +2 -1
  141. package/dist/plugins/import-meta-url.d.ts +2 -1
  142. package/dist/plugins/next-intl-catalog.d.ts +12 -0
  143. package/dist/plugins/next-intl-catalog.js +85 -0
  144. package/dist/plugins/og-assets.d.ts +2 -1
  145. package/dist/plugins/og-assets.js +2 -3
  146. package/dist/plugins/optimize-imports.d.ts +2 -1
  147. package/dist/plugins/pages-node-externals.d.ts +3 -1
  148. package/dist/plugins/pages-node-externals.js +1 -1
  149. package/dist/plugins/remove-console.d.ts +2 -1
  150. package/dist/plugins/require-condition-resolution.d.ts +2 -1
  151. package/dist/plugins/rsc-client-reference-loaders.d.ts +8 -0
  152. package/dist/plugins/rsc-client-reference-loaders.js +170 -68
  153. package/dist/plugins/rsc-client-shim-excludes.js +2 -0
  154. package/dist/plugins/sass.d.ts +2 -1
  155. package/dist/plugins/strip-server-exports.d.ts +2 -1
  156. package/dist/plugins/styled-jsx.d.ts +2 -1
  157. package/dist/plugins/transform-result.d.ts +2 -1
  158. package/dist/plugins/typeof-window.d.ts +2 -1
  159. package/dist/plugins/use-cache-callable.d.ts +1 -1
  160. package/dist/plugins/use-cache-callable.js +136 -94
  161. package/dist/plugins/worker-image-imports.js +1 -1
  162. package/dist/plugins/worker-use-server.d.ts +2 -1
  163. package/dist/routing/app-route-graph.d.ts +46 -0
  164. package/dist/routing/app-route-graph.js +131 -51
  165. package/dist/routing/browser-route-manifest.d.ts +2 -1
  166. package/dist/routing/optimistic-route-trie.d.ts +2 -1
  167. package/dist/routing/route-matching.d.ts +2 -1
  168. package/dist/routing/route-pattern.d.ts +2 -1
  169. package/dist/server/accept-encoding.d.ts +2 -1
  170. package/dist/server/api-handler.js +19 -4
  171. package/dist/server/app-action-forwarding.d.ts +2 -1
  172. package/dist/server/app-bfcache-identity.d.ts +2 -1
  173. package/dist/server/app-bfcache-identity.js +1 -1
  174. package/dist/server/app-browser-action-result.d.ts +2 -1
  175. package/dist/server/app-browser-entry.js +106 -66
  176. package/dist/server/app-browser-error.d.ts +2 -1
  177. package/dist/server/app-browser-history-controller.d.ts +7 -5
  178. package/dist/server/app-browser-history-controller.js +93 -15
  179. package/dist/server/app-browser-hydration.d.ts +2 -1
  180. package/dist/server/app-browser-interception-context.d.ts +2 -1
  181. package/dist/server/app-browser-navigation-controller.d.ts +2 -2
  182. package/dist/server/app-browser-navigation-controller.js +16 -12
  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-rsc-redirect.js +4 -4
  186. package/dist/server/app-browser-server-action-client.d.ts +4 -1
  187. package/dist/server/app-browser-server-action-client.js +4 -3
  188. package/dist/server/app-browser-state.d.ts +2 -4
  189. package/dist/server/app-browser-state.js +9 -4
  190. package/dist/server/app-browser-stream.d.ts +2 -1
  191. package/dist/server/app-browser-supplemental-refresh.js +16 -1
  192. package/dist/server/app-browser-visible-commit.d.ts +3 -2
  193. package/dist/server/app-browser-visible-commit.js +2 -12
  194. package/dist/server/app-client-reference-manifest.d.ts +31 -0
  195. package/dist/server/app-client-reference-manifest.js +46 -0
  196. package/dist/server/app-client-reference-preloader.d.ts +25 -5
  197. package/dist/server/app-client-reference-preloader.js +22 -7
  198. package/dist/server/app-elements-wire.d.ts +8 -39
  199. package/dist/server/app-elements-wire.js +4 -41
  200. package/dist/server/app-elements.d.ts +4 -2
  201. package/dist/server/app-elements.js +4 -2
  202. package/dist/server/app-fallback-renderer.d.ts +9 -2
  203. package/dist/server/app-fallback-renderer.js +4 -1
  204. package/dist/server/app-history-state.d.ts +4 -3
  205. package/dist/server/app-history-state.js +5 -2
  206. package/dist/server/app-inline-css-client.d.ts +2 -1
  207. package/dist/server/app-metadata-tracing.d.ts +2 -1
  208. package/dist/server/app-mounted-layouts.d.ts +21 -0
  209. package/dist/server/app-mounted-layouts.js +67 -0
  210. package/dist/server/app-optimistic-routing.d.ts +37 -2
  211. package/dist/server/app-optimistic-routing.js +75 -2
  212. package/dist/server/app-page-boundary-render.d.ts +20 -2
  213. package/dist/server/app-page-boundary-render.js +224 -40
  214. package/dist/server/app-page-boundary.d.ts +34 -5
  215. package/dist/server/app-page-boundary.js +41 -8
  216. package/dist/server/app-page-cache-finalizer.d.ts +14 -2
  217. package/dist/server/app-page-cache-finalizer.js +71 -30
  218. package/dist/server/app-page-cache-render.d.ts +10 -2
  219. package/dist/server/app-page-cache-render.js +14 -2
  220. package/dist/server/app-page-cache.d.ts +13 -1
  221. package/dist/server/app-page-cache.js +33 -11
  222. package/dist/server/app-page-dispatch.d.ts +39 -11
  223. package/dist/server/app-page-dispatch.js +236 -177
  224. package/dist/server/app-page-element-builder.d.ts +19 -3
  225. package/dist/server/app-page-element-builder.js +193 -71
  226. package/dist/server/app-page-execution.d.ts +43 -51
  227. package/dist/server/app-page-execution.js +205 -92
  228. package/dist/server/app-page-head.d.ts +108 -3
  229. package/dist/server/app-page-head.js +337 -154
  230. package/dist/server/app-page-http-access-fallback-metadata.d.ts +49 -2
  231. package/dist/server/app-page-http-access-fallback-metadata.js +77 -2
  232. package/dist/server/app-page-layout-gate.d.ts +35 -0
  233. package/dist/server/app-page-layout-gate.js +50 -0
  234. package/dist/server/app-page-method.d.ts +2 -1
  235. package/dist/server/app-page-params.d.ts +0 -1
  236. package/dist/server/app-page-params.js +1 -14
  237. package/dist/server/app-page-probe.d.ts +5 -22
  238. package/dist/server/app-page-probe.js +4 -37
  239. package/dist/server/app-page-render-identity.d.ts +2 -1
  240. package/dist/server/app-page-render.d.ts +9 -13
  241. package/dist/server/app-page-render.js +108 -214
  242. package/dist/server/app-page-request.d.ts +15 -4
  243. package/dist/server/app-page-request.js +2 -2
  244. package/dist/server/app-page-response.js +3 -3
  245. package/dist/server/app-page-route-wiring.d.ts +65 -8
  246. package/dist/server/app-page-route-wiring.js +259 -103
  247. package/dist/server/app-page-rsc-render-status.d.ts +29 -2
  248. package/dist/server/app-page-rsc-render-status.js +121 -13
  249. package/dist/server/app-page-search-params-observation.d.ts +7 -2
  250. package/dist/server/app-page-search-params-observation.js +8 -1
  251. package/dist/server/app-page-segment-plan.d.ts +2 -1
  252. package/dist/server/app-page-stream.d.ts +33 -1
  253. package/dist/server/app-page-stream.js +25 -6
  254. package/dist/server/app-pages-bridge.d.ts +6 -1
  255. package/dist/server/app-pages-bridge.js +7 -3
  256. package/dist/server/app-ppr-fallback-shell-render.d.ts +2 -1
  257. package/dist/server/app-ppr-fallback-shell.d.ts +2 -1
  258. package/dist/server/app-prerender-endpoints.d.ts +2 -1
  259. package/dist/server/app-prerender-static-params.d.ts +2 -1
  260. package/dist/server/app-render-dependency.d.ts +21 -4
  261. package/dist/server/app-render-dependency.js +100 -33
  262. package/dist/server/app-request-stage-dispatch.js +1 -1
  263. package/dist/server/app-request-stage-independent-entry.d.ts +2 -1
  264. package/dist/server/app-response-stage-entry.d.ts +2 -1
  265. package/dist/server/app-route-handler-cache.d.ts +2 -1
  266. package/dist/server/app-route-handler-cache.js +2 -2
  267. package/dist/server/app-route-handler-dispatch.d.ts +2 -1
  268. package/dist/server/app-route-handler-dispatch.js +15 -10
  269. package/dist/server/app-route-handler-execution.d.ts +2 -1
  270. package/dist/server/app-route-handler-execution.js +8 -3
  271. package/dist/server/app-route-handler-policy.d.ts +1 -1
  272. package/dist/server/app-route-handler-policy.js +3 -3
  273. package/dist/server/app-route-handler-response.d.ts +2 -1
  274. package/dist/server/app-route-handler-response.js +1 -1
  275. package/dist/server/app-route-handler-runtime.d.ts +2 -1
  276. package/dist/server/app-route-handler-runtime.js +17 -4
  277. package/dist/server/app-route-module-loader.d.ts +18 -1
  278. package/dist/server/app-route-module-loader.js +8 -0
  279. package/dist/server/app-route-tree-prefetch.d.ts +2 -1
  280. package/dist/server/app-rsc-cache-busting.d.ts +2 -2
  281. package/dist/server/app-rsc-cache-busting.js +4 -4
  282. package/dist/server/app-rsc-error-handler.d.ts +4 -2
  283. package/dist/server/app-rsc-error-handler.js +9 -1
  284. package/dist/server/app-rsc-errors.d.ts +10 -1
  285. package/dist/server/app-rsc-errors.js +8 -1
  286. package/dist/server/app-rsc-handler.d.ts +7 -6
  287. package/dist/server/app-rsc-handler.js +36 -34
  288. package/dist/server/app-rsc-request-normalization.d.ts +0 -4
  289. package/dist/server/app-rsc-request-normalization.js +1 -4
  290. package/dist/server/app-rsc-response-finalizer.d.ts +2 -1
  291. package/dist/server/app-rsc-response-finalizer.js +2 -2
  292. package/dist/server/app-rsc-response-stage.js +5 -3
  293. package/dist/server/app-rsc-route-matching.d.ts +38 -1
  294. package/dist/server/app-rsc-route-matching.js +24 -0
  295. package/dist/server/app-segment-config.d.ts +2 -1
  296. package/dist/server/app-segment-config.js +1 -14
  297. package/dist/server/app-server-action-execution.d.ts +5 -2
  298. package/dist/server/app-server-action-execution.js +10 -7
  299. package/dist/server/app-ssr-entry.d.ts +8 -0
  300. package/dist/server/app-ssr-entry.js +98 -50
  301. package/dist/server/app-ssr-error-meta.d.ts +2 -1
  302. package/dist/server/app-ssr-search-params-gate.d.ts +2 -1
  303. package/dist/server/app-ssr-stream.d.ts +22 -10
  304. package/dist/server/app-ssr-stream.js +300 -68
  305. package/dist/server/app-static-generation.d.ts +2 -1
  306. package/dist/server/app-streamed-client-references.d.ts +39 -0
  307. package/dist/server/app-streamed-client-references.js +156 -0
  308. package/dist/server/app-visited-response-cache.d.ts +38 -2
  309. package/dist/server/app-visited-response-cache.js +46 -5
  310. package/dist/server/app-worker-stages.d.ts +27 -4
  311. package/dist/server/app-worker-stages.js +45 -6
  312. package/dist/server/artifact-compatibility.d.ts +2 -2
  313. package/dist/server/artifact-compatibility.js +1 -10
  314. package/dist/server/bfcache-identity.d.ts +2 -1
  315. package/dist/server/cache-headers.d.ts +2 -1
  316. package/dist/server/cache-proof.d.ts +1 -115
  317. package/dist/server/cache-proof.js +1 -544
  318. package/dist/server/cacheability-request.d.ts +2 -1
  319. package/dist/server/cacheability-request.js +13 -8
  320. package/dist/server/config-headers.d.ts +2 -1
  321. package/dist/server/csp.d.ts +2 -1
  322. package/dist/server/default-global-not-found-module.d.ts +2 -1
  323. package/dist/server/default-http-access-fallback-modules.d.ts +33 -0
  324. package/dist/server/default-http-access-fallback-modules.js +31 -0
  325. package/dist/server/defer-until-stream-consumed.d.ts +34 -0
  326. package/dist/server/defer-until-stream-consumed.js +154 -21
  327. package/dist/server/dev-lockfile.d.ts +32 -2
  328. package/dist/server/dev-lockfile.js +46 -2
  329. package/dist/server/dev-module-runner.d.ts +2 -1
  330. package/dist/server/dev-server.js +14 -6
  331. package/dist/server/fetch-handler.js +1 -2
  332. package/dist/server/file-based-metadata.d.ts +2 -1
  333. package/dist/server/framework-tracer.d.ts +2 -1
  334. package/dist/server/headers.d.ts +6 -3
  335. package/dist/server/headers.js +9 -5
  336. package/dist/server/html.d.ts +1 -0
  337. package/dist/server/html.js +19 -1
  338. package/dist/server/http-conditional.d.ts +2 -1
  339. package/dist/server/http-error-responses.d.ts +2 -1
  340. package/dist/server/implicit-tags.d.ts +2 -1
  341. package/dist/server/isr-cache.d.ts +8 -2
  342. package/dist/server/isr-cache.js +26 -1
  343. package/dist/server/metadata-route-build-data.d.ts +2 -1
  344. package/dist/server/metadata-route-build-data.js +1 -1
  345. package/dist/server/metadata-route-response.d.ts +2 -1
  346. package/dist/server/metadata-route-response.js +32 -15
  347. package/dist/server/metadata-routes.d.ts +2 -1
  348. package/dist/server/middleware-runtime.d.ts +2 -1
  349. package/dist/server/multi-stage.d.ts +52 -11
  350. package/dist/server/multi-stage.js +13 -1
  351. package/dist/server/navigation-planner.js +1 -1
  352. package/dist/server/navigation-trace.d.ts +2 -1
  353. package/dist/server/next-error-digest.d.ts +2 -1
  354. package/dist/server/nitro-public-files-plugin.d.ts +2 -1
  355. package/dist/server/nitro-public-files.d.ts +2 -1
  356. package/dist/server/opentelemetry-api.d.ts +2 -1
  357. package/dist/server/operation-token.d.ts +2 -1
  358. package/dist/server/pages-api-route.d.ts +2 -1
  359. package/dist/server/pages-api-route.js +28 -19
  360. package/dist/server/pages-asset-tags.d.ts +2 -1
  361. package/dist/server/pages-body-parser-config.d.ts +2 -1
  362. package/dist/server/pages-client-assets.d.ts +4 -0
  363. package/dist/server/pages-data-route.d.ts +2 -1
  364. package/dist/server/pages-document-asset-props.d.ts +2 -1
  365. package/dist/server/pages-document-initial-props.d.ts +2 -1
  366. package/dist/server/pages-execution-tracing.d.ts +2 -1
  367. package/dist/server/pages-execution-tracing.js +1 -1
  368. package/dist/server/pages-get-initial-props.d.ts +2 -1
  369. package/dist/server/pages-media-type.d.ts +21 -1
  370. package/dist/server/pages-media-type.js +69 -5
  371. package/dist/server/pages-node-compat.js +52 -27
  372. package/dist/server/pages-page-data.d.ts +7 -1
  373. package/dist/server/pages-page-data.js +35 -12
  374. package/dist/server/pages-page-handler.d.ts +3 -2
  375. package/dist/server/pages-page-handler.js +27 -27
  376. package/dist/server/pages-page-method.d.ts +2 -1
  377. package/dist/server/pages-page-response.d.ts +2 -1
  378. package/dist/server/pages-preview.d.ts +2 -1
  379. package/dist/server/pages-readiness.d.ts +2 -1
  380. package/dist/server/pages-request-pipeline.d.ts +10 -1
  381. package/dist/server/pages-request-pipeline.js +6 -7
  382. package/dist/server/pages-request-stage-entry.d.ts +2 -1
  383. package/dist/server/pages-request-stage-entry.js +14 -12
  384. package/dist/server/pages-response-stage-entry.d.ts +2 -1
  385. package/dist/server/pages-response-stage-entry.js +9 -3
  386. package/dist/server/pages-route-data-kind.d.ts +2 -1
  387. package/dist/server/prerender-cache-life-header.d.ts +2 -1
  388. package/dist/server/prerender-route-params.d.ts +2 -1
  389. package/dist/server/prod-server.js +14 -4
  390. package/dist/server/request-log.d.ts +2 -1
  391. package/dist/server/request-pipeline.d.ts +6 -0
  392. package/dist/server/request-pipeline.js +21 -1
  393. package/dist/server/request-tracing.d.ts +2 -1
  394. package/dist/server/request-tracing.js +1 -1
  395. package/dist/server/response-start-tracing.js +7 -29
  396. package/dist/server/rsc-render-stream.d.ts +4 -0
  397. package/dist/server/rsc-render-stream.js +25 -0
  398. package/dist/server/seed-cache.d.ts +2 -1
  399. package/dist/server/seed-cache.js +1 -1
  400. package/dist/server/shared-cache-identity.d.ts +23 -0
  401. package/dist/server/shared-cache-identity.js +36 -0
  402. package/dist/server/static-file-cache.d.ts +2 -1
  403. package/dist/server/static-file-cache.js +1 -0
  404. package/dist/server/worker-revalidation-context.d.ts +2 -1
  405. package/dist/server/worker-stages.d.ts +18 -4
  406. package/dist/server/worker-stages.js +23 -4
  407. package/dist/shims/app.d.ts +2 -1
  408. package/dist/shims/cache-callable-runtime.d.ts +2 -1
  409. package/dist/shims/cache-handler.d.ts +8 -3
  410. package/dist/shims/cache-handler.js +31 -11
  411. package/dist/shims/cache-request-state.d.ts +17 -20
  412. package/dist/shims/cache-request-state.js +16 -21
  413. package/dist/shims/cache-runtime.js +27 -11
  414. package/dist/shims/cache.d.ts +8 -7
  415. package/dist/shims/cache.js +17 -19
  416. package/dist/shims/cacheability-classification.d.ts +2 -0
  417. package/dist/shims/caught-not-found-boundaries.d.ts +15 -0
  418. package/dist/shims/caught-not-found-boundaries.js +48 -0
  419. package/dist/shims/cdn-cache.d.ts +22 -5
  420. package/dist/shims/cdn-purge-routes.d.ts +2 -1
  421. package/dist/shims/client-locale.js +2 -1
  422. package/dist/shims/client-page-root.d.ts +2 -1
  423. package/dist/shims/client-page-root.js +2 -2
  424. package/dist/shims/config.d.ts +2 -1
  425. package/dist/shims/default-forbidden.d.ts +4 -0
  426. package/dist/shims/default-forbidden.js +18 -0
  427. package/dist/shims/default-not-found.d.ts +0 -5
  428. package/dist/shims/default-not-found.js +5 -41
  429. package/dist/shims/default-unauthorized.d.ts +4 -0
  430. package/dist/shims/default-unauthorized.js +18 -0
  431. package/dist/shims/dynamic.js +9 -6
  432. package/dist/shims/error-boundary.d.ts +39 -3
  433. package/dist/shims/error-boundary.js +33 -18
  434. package/dist/shims/fetch-cache-state.d.ts +5 -1
  435. package/dist/shims/fetch-cache-state.js +1 -3
  436. package/dist/shims/fetch-cache.d.ts +2 -1
  437. package/dist/shims/fetch-cache.js +34 -24
  438. package/dist/shims/font-google.js +1 -2
  439. package/dist/shims/font-utils.d.ts +3 -2
  440. package/dist/shims/font-utils.js +5 -3
  441. package/dist/shims/form.js +3 -3
  442. package/dist/shims/headers.d.ts +8 -23
  443. package/dist/shims/headers.js +17 -67
  444. package/dist/shims/http-access-error-fallback.d.ts +7 -0
  445. package/dist/shims/http-access-error-fallback.js +47 -0
  446. package/dist/shims/image.d.ts +1 -22
  447. package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +22 -2
  448. package/dist/shims/internal/app-prefetch-fetch-queue.js +71 -18
  449. package/dist/shims/internal/app-route-prefetch-policy.d.ts +14 -3
  450. package/dist/shims/internal/app-route-prefetch-policy.js +29 -4
  451. package/dist/shims/internal/cache-context-accessor.d.ts +2 -1
  452. package/dist/shims/internal/client-reference-loader.d.ts +7 -0
  453. package/dist/shims/internal/client-reference-loader.js +91 -0
  454. package/dist/shims/internal/cookie-serialize.d.ts +2 -1
  455. package/dist/shims/internal/cookies.js +1 -2
  456. package/dist/shims/internal/headers-state.d.ts +2 -0
  457. package/dist/shims/internal/headers-state.js +6 -1
  458. package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +2 -1
  459. package/dist/shims/internal/interpolate-as.d.ts +2 -1
  460. package/dist/shims/internal/navigation-untracked.js +1 -1
  461. package/dist/shims/internal/pages-data-target.d.ts +2 -1
  462. package/dist/shims/internal/pages-data-url.d.ts +2 -1
  463. package/dist/shims/internal/thenable-well-known-properties.d.ts +2 -1
  464. package/dist/shims/link.js +197 -52
  465. package/dist/shims/metadata.d.ts +52 -29
  466. package/dist/shims/metadata.js +142 -42
  467. package/dist/shims/navigation-errors.d.ts +2 -1
  468. package/dist/shims/navigation-server.js +1 -1
  469. package/dist/shims/navigation.d.ts +95 -8
  470. package/dist/shims/navigation.js +255 -47
  471. package/dist/shims/navigation.react-server.js +2 -2
  472. package/dist/shims/pages-router-runtime.d.ts +2 -1
  473. package/dist/shims/ppr-fallback-shell.d.ts +2 -1
  474. package/dist/shims/request-state-types.d.ts +2 -2
  475. package/dist/shims/router.js +14 -3
  476. package/dist/shims/slot.d.ts +12 -0
  477. package/dist/shims/slot.js +37 -9
  478. package/dist/shims/unified-request-context.d.ts +1 -1
  479. package/dist/shims/unified-request-context.js +5 -6
  480. package/dist/typegen.d.ts +2 -1
  481. package/dist/utils/cache-control-metadata.d.ts +5 -0
  482. package/dist/utils/cache-control-metadata.js +9 -1
  483. package/dist/utils/client-build-manifest.d.ts +4 -1
  484. package/dist/utils/client-build-manifest.js +9 -2
  485. package/dist/utils/client-entry-manifest.d.ts +13 -0
  486. package/dist/utils/client-entry-manifest.js +20 -1
  487. package/dist/utils/client-reference-chunks.d.ts +45 -0
  488. package/dist/utils/client-reference-chunks.js +30 -0
  489. package/dist/utils/client-runtime-metadata.d.ts +9 -1
  490. package/dist/utils/client-runtime-metadata.js +40 -9
  491. package/dist/utils/compare.d.ts +9 -0
  492. package/dist/utils/compare.js +15 -1
  493. package/dist/utils/lazy-chunks.d.ts +14 -0
  494. package/dist/utils/lazy-chunks.js +27 -1
  495. package/dist/utils/middleware-request-headers.d.ts +2 -1
  496. package/dist/utils/project.d.ts +4 -3
  497. package/dist/utils/project.js +12 -17
  498. package/dist/utils/query.d.ts +2 -1
  499. package/dist/utils/regex.d.ts +5 -0
  500. package/dist/utils/regex.js +11 -1
  501. package/dist/utils/text-stream.d.ts +10 -5
  502. package/dist/utils/text-stream.js +6 -6
  503. package/dist/utils/vite-cli-invocation.d.ts +2 -1
  504. package/package.json +6 -5
  505. package/dist/build/layout-classification-types.d.ts +0 -60
  506. package/dist/build/layout-classification-types.js +0 -1
  507. package/dist/build/layout-classification.d.ts +0 -61
  508. package/dist/build/layout-classification.js +0 -98
  509. package/dist/build/route-classification-injector.d.ts +0 -32
  510. package/dist/build/route-classification-injector.js +0 -59
  511. package/dist/build/route-classification-manifest.d.ts +0 -53
  512. package/dist/build/route-classification-manifest.js +0 -143
  513. package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +0 -808
  514. package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -10
  515. package/dist/server/app-browser-client-reuse-manifest.js +0 -101
  516. package/dist/server/app-layout-param-observation.d.ts +0 -41
  517. package/dist/server/app-layout-param-observation.js +0 -168
  518. package/dist/server/client-reuse-manifest.d.ts +0 -102
  519. package/dist/server/client-reuse-manifest.js +0 -209
  520. package/dist/server/default-not-found-module.d.ts +0 -19
  521. package/dist/server/default-not-found-module.js +0 -18
  522. package/dist/server/rsc-stream-hints.d.ts +0 -21
  523. package/dist/server/rsc-stream-hints.js +0 -227
  524. package/dist/server/skip-cache-proof.d.ts +0 -60
  525. package/dist/server/skip-cache-proof.js +0 -168
  526. package/dist/server/static-layout-client-reuse-proof.d.ts +0 -13
  527. package/dist/server/static-layout-client-reuse-proof.js +0 -33
  528. package/dist/utils/sorted-array.d.ts +0 -7
  529. package/dist/utils/sorted-array.js +0 -20
@@ -8,7 +8,6 @@ export type CloudflareProjectInfo = {
8
8
  hasMDX: boolean;
9
9
  /** The effective Next.js config sets `output: "export"`. */
10
10
  isStaticExport?: boolean;
11
- nativeModulesToStub: string[];
12
11
  };
13
12
  export type CloudflarePlatformSetupContext = {
14
13
  root: string;
@@ -46,14 +45,13 @@ export declare function cssModulesConfigSource(indent?: string): string;
46
45
  /** Generate vite.config.ts for App Router */
47
46
  export declare function generateAppRouterViteConfig(info?: CloudflareProjectInfo, options?: CloudflareInitOptions, imagesBinding?: string, versionMetadataBinding?: string, serviceBinding?: boolean, assetsBinding?: string, assetsDirectory?: string, hasCssModules?: boolean): string;
48
47
  /** Generate vite.config.ts for Pages Router */
49
- export declare function generatePagesRouterViteConfig(info?: CloudflareProjectInfo, options?: CloudflareInitOptions, imagesBinding?: string, versionMetadataBinding?: string, serviceBinding?: boolean, hasCssModules?: boolean, assetsBinding?: string, assetsDirectory?: string): string;
48
+ export declare function generatePagesRouterViteConfig(options?: CloudflareInitOptions, imagesBinding?: string, versionMetadataBinding?: string, serviceBinding?: boolean, hasCssModules?: boolean, assetsBinding?: string, assetsDirectory?: string): string;
50
49
  export declare function updateViteConfigForCssModules(filePath: string, code: string): {
51
50
  code: string;
52
51
  preservedExistingGenerateScopedName: boolean;
53
52
  };
54
53
  export declare function updateViteConfigForCloudflare(filePath: string, code: string, options: {
55
54
  isAppRouter: boolean;
56
- nativeModulesToStub: string[];
57
55
  cache?: CloudflareInitOptions;
58
56
  assetsBinding?: string;
59
57
  assetsDirectory?: string;
@@ -32,14 +32,15 @@ const CACHE_METADATA_EXPORT = {
32
32
  const CTX_EXPORTS_DEFAULT_DATE = "2025-11-17";
33
33
  function validateCloudflarePlatformSetup(context, cloudflare) {
34
34
  if (cloudflare.name !== void 0) validateWorkerName(cloudflare.name);
35
+ if (cloudflare.legacyWrangler && cloudflare.ignoreWranglerConfig) throw new Error("--ignore-wrangler-config cannot be combined with --legacy-wrangler-cloudflare-init.");
35
36
  if (!cloudflare.legacyWrangler) {
36
- const existingWrangler = [
37
+ const existingWrangler = cloudflare.ignoreWranglerConfig ? void 0 : [
37
38
  "wrangler.toml",
38
39
  "wrangler.json",
39
40
  "wrangler.jsonc",
40
41
  RESPONSE_STORE_WRANGLER_CONFIG
41
42
  ].find((name) => fs.existsSync(path.join(context.root, name)));
42
- if (existingWrangler) throw new Error(`Cloudflare init cannot replace an existing Wrangler config (${existingWrangler}). Migrate its bindings to cloudflare.config.ts first, or use --legacy-wrangler-cloudflare-init to keep the Wrangler setup.`);
43
+ if (existingWrangler) throw new Error(`Cloudflare init cannot replace an existing Wrangler config (${existingWrangler}). Migrate its bindings to cloudflare.config.ts first, use --ignore-wrangler-config if it belongs to another Worker, or use --legacy-wrangler-cloudflare-init to keep the Wrangler setup.`);
43
44
  const typedConfigPath = path.join(context.root, "cloudflare.config.ts");
44
45
  if (cloudflare.cdnCache === "static-assets" && fs.existsSync(typedConfigPath)) throw new Error("Static Assets cache setup for an existing cloudflare.config.ts must be configured manually. Keep its assets binding aligned with staticAssetsAdapter({ binding }) and include \"/_vinext/static-cache/*\" in assets.runWorkerFirst to protect private cache files.");
45
46
  if (cloudflare.cdnCache === "response-store" && (cloudflare.responseStoreMode ?? "service-binding") === "service-binding" && fs.existsSync(typedConfigPath) && !fs.readFileSync(typedConfigPath, "utf-8").includes("export const responseStoreServiceBinding")) throw new Error("The existing cloudflare.config.ts must export responseStoreServiceBinding for the Response Store auxiliary Worker. Configure it before rerunning init.");
@@ -47,7 +48,6 @@ function validateCloudflarePlatformSetup(context, cloudflare) {
47
48
  if (context.existingViteConfigPath) {
48
49
  const updatedConfig = updateViteConfigForCloudflare(context.existingViteConfigPath, fs.readFileSync(context.existingViteConfigPath, "utf-8"), {
49
50
  isAppRouter: context.isAppRouter,
50
- nativeModulesToStub: detectProject(context.root).nativeModulesToStub,
51
51
  cache: cloudflare
52
52
  });
53
53
  if (context.hasCssModules) updateViteConfigForCssModules(context.existingViteConfigPath, updatedConfig);
@@ -56,7 +56,6 @@ function validateCloudflarePlatformSetup(context, cloudflare) {
56
56
  }
57
57
  const tomlPath = path.join(context.root, "wrangler.toml");
58
58
  if (fs.existsSync(tomlPath)) throw new Error("wrangler.toml is not supported by vinext init. Convert it to wrangler.jsonc and rerun.");
59
- const projectInfo = detectProject(context.root);
60
59
  const wranglerPath = ["wrangler.jsonc", "wrangler.json"].map((fileName) => path.join(context.root, fileName)).find((candidate) => fs.existsSync(candidate));
61
60
  const wranglerCode = wranglerPath ? fs.readFileSync(wranglerPath, "utf-8") : void 0;
62
61
  if (!wranglerCode && cloudflare.cdnCache === "response-store" && (cloudflare.responseStoreMode ?? "service-binding") === "service-binding" && fs.existsSync(path.join(context.root, RESPONSE_STORE_WRANGLER_CONFIG))) readResponseStoreServiceName(context.root, {});
@@ -71,7 +70,6 @@ function validateCloudflarePlatformSetup(context, cloudflare) {
71
70
  if (context.existingViteConfigPath) {
72
71
  const updatedConfig = updateViteConfigForCloudflare(context.existingViteConfigPath, fs.readFileSync(context.existingViteConfigPath, "utf-8"), {
73
72
  isAppRouter: context.isAppRouter,
74
- nativeModulesToStub: projectInfo.nativeModulesToStub,
75
73
  cache: cloudflare,
76
74
  assetsBinding,
77
75
  assetsDirectory,
@@ -101,7 +99,6 @@ function setupCloudflarePlatform(context, cloudflare) {
101
99
  const currentConfig = fs.readFileSync(context.existingViteConfigPath, "utf-8");
102
100
  let updatedConfig = updateViteConfigForCloudflare(context.existingViteConfigPath, currentConfig, {
103
101
  isAppRouter: context.isAppRouter,
104
- nativeModulesToStub: projectInfo.nativeModulesToStub,
105
102
  cache: cloudflare,
106
103
  assetsBinding,
107
104
  assetsDirectory,
@@ -118,7 +115,7 @@ function setupCloudflarePlatform(context, cloudflare) {
118
115
  generatedViteConfig = true;
119
116
  } else skippedViteConfig = true;
120
117
  } else {
121
- const configContent = context.isAppRouter ? generateAppRouterViteConfig(projectInfo, cloudflare, imagesBinding, versionMetadataBinding, false, assetsBinding, assetsDirectory, context.hasCssModules) : generatePagesRouterViteConfig(projectInfo, cloudflare, imagesBinding, versionMetadataBinding, false, context.hasCssModules, assetsBinding, assetsDirectory);
118
+ const configContent = context.isAppRouter ? generateAppRouterViteConfig(projectInfo, cloudflare, imagesBinding, versionMetadataBinding, false, assetsBinding, assetsDirectory, context.hasCssModules) : generatePagesRouterViteConfig(cloudflare, imagesBinding, versionMetadataBinding, false, context.hasCssModules, assetsBinding, assetsDirectory);
122
119
  fs.writeFileSync(path.join(context.root, "vite.config.ts"), configContent, "utf-8");
123
120
  generatedViteConfig = true;
124
121
  }
@@ -178,7 +175,6 @@ function setupCfPlatform(context, cloudflare) {
178
175
  const current = fs.readFileSync(context.existingViteConfigPath, "utf-8");
179
176
  let updated = updateViteConfigForCloudflare(context.existingViteConfigPath, current, {
180
177
  isAppRouter: context.isAppRouter,
181
- nativeModulesToStub: projectInfo.nativeModulesToStub,
182
178
  cache: cloudflare
183
179
  });
184
180
  if (context.hasCssModules) {
@@ -191,7 +187,7 @@ function setupCfPlatform(context, cloudflare) {
191
187
  generatedViteConfig = true;
192
188
  }
193
189
  } else {
194
- const viteConfig = context.isAppRouter ? generateAppRouterViteConfig(projectInfo, cloudflare, "IMAGES", DEFAULT_VERSION_METADATA_BINDING, serviceBinding, "ASSETS", "dist/client", context.hasCssModules) : generatePagesRouterViteConfig(projectInfo, cloudflare, "IMAGES", DEFAULT_VERSION_METADATA_BINDING, serviceBinding, context.hasCssModules);
190
+ const viteConfig = context.isAppRouter ? generateAppRouterViteConfig(projectInfo, cloudflare, "IMAGES", DEFAULT_VERSION_METADATA_BINDING, serviceBinding, "ASSETS", "dist/client", context.hasCssModules) : generatePagesRouterViteConfig(cloudflare, "IMAGES", DEFAULT_VERSION_METADATA_BINDING, serviceBinding, context.hasCssModules);
195
191
  fs.writeFileSync(path.join(context.root, "vite.config.ts"), viteConfig, "utf-8");
196
192
  generatedViteConfig = true;
197
193
  }
@@ -849,7 +845,7 @@ function generateAppRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_OPT
849
845
  ...cacheImports(options),
850
846
  ...hasCssModules ? ["import { createHash } from \"node:crypto\";", "import { patchCssModules } from \"vite-css-modules\";"] : []
851
847
  ];
852
- if (hasCssModules || info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) imports.push(`import path from "node:path";`);
848
+ if (hasCssModules) imports.push(`import path from "node:path";`);
853
849
  const plugins = [];
854
850
  if (hasCssModules) plugins.push(" patchCssModules({ exportMode: \"default\" }),");
855
851
  if (info?.hasMDX) plugins.push(` // vinext auto-injects @mdx-js/rollup with plugins from next.config`);
@@ -860,21 +856,17 @@ function generateAppRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_OPT
860
856
  childEnvironments: ["ssr"],
861
857
  },
862
858
  }),`);
863
- let resolveBlock = "";
864
- const aliases = [];
865
- if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) for (const mod of info.nativeModulesToStub) aliases.push(` "${mod}": path.resolve(__dirname, "empty-stub.js"),`);
866
- if (aliases.length > 0) resolveBlock = `\n resolve: {\n alias: {\n${aliases.join("\n")}\n },\n },`;
867
859
  return `${imports.join("\n")}
868
860
 
869
861
  export default defineConfig({
870
862
  plugins: [
871
863
  ${plugins.join("\n")}
872
- ],${resolveBlock}${hasCssModules ? cssModulesConfigSource() : ""}
864
+ ],${hasCssModules ? cssModulesConfigSource() : ""}
873
865
  });
874
866
  `;
875
867
  }
876
868
  /** Generate vite.config.ts for Pages Router */
877
- function generatePagesRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_OPTIONS, imagesBinding = "IMAGES", versionMetadataBinding = DEFAULT_VERSION_METADATA_BINDING, serviceBinding = false, hasCssModules = false, assetsBinding = "ASSETS", assetsDirectory = "dist/client") {
869
+ function generatePagesRouterViteConfig(options = DEFAULT_CLOUDFLARE_INIT_OPTIONS, imagesBinding = "IMAGES", versionMetadataBinding = DEFAULT_VERSION_METADATA_BINDING, serviceBinding = false, hasCssModules = false, assetsBinding = "ASSETS", assetsDirectory = "dist/client") {
878
870
  const legacyStaticAssets = options.legacyWrangler && options.cdnCache === "static-assets";
879
871
  const imports = [
880
872
  `import { defineConfig } from "vite";`,
@@ -884,18 +876,14 @@ function generatePagesRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_O
884
876
  ...cacheImports(options),
885
877
  ...hasCssModules ? ["import { createHash } from \"node:crypto\";", "import { patchCssModules } from \"vite-css-modules\";"] : []
886
878
  ];
887
- if (hasCssModules || info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) imports.push(`import path from "node:path";`);
888
- let resolveBlock = "";
889
- const aliases = [];
890
- if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) for (const mod of info.nativeModulesToStub) aliases.push(` "${mod}": path.resolve(__dirname, "empty-stub.js"),`);
891
- if (aliases.length > 0) resolveBlock = `\n resolve: {\n alias: {\n${aliases.join("\n")}\n },\n },`;
879
+ if (hasCssModules) imports.push(`import path from "node:path";`);
892
880
  return `${imports.join("\n")}
893
881
 
894
882
  export default defineConfig({
895
883
  ${legacyStaticAssets ? ` environments: { client: { build: { outDir: ${JSON.stringify(assetsDirectory)} } }, ssr: { build: { outDir: "dist/server" } } },\n` : ""} plugins: [
896
884
  ${hasCssModules ? " patchCssModules({ exportMode: \"default\" }),\n" : ""} ${vinextExpression(options, "vinext", "imagesOptimizer", imagesBinding, versionMetadataBinding, "responseStoreAdapter", assetsBinding, assetsDirectory).replace(/\n/g, "\n ")},
897
885
  cloudflare(${legacyStaticAssets ? "{ viteEnvironment: { name: \"ssr\" } }" : serviceBinding ? "{ auxiliaryWorkers: [{ config: responseStoreServiceBinding }] }" : ""}),
898
- ],${resolveBlock}${hasCssModules ? cssModulesConfigSource() : ""}
886
+ ],${hasCssModules ? cssModulesConfigSource() : ""}
899
887
  });
900
888
  `;
901
889
  }
@@ -1447,27 +1435,6 @@ function updateViteConfigForCssModules(filePath, code) {
1447
1435
  preservedExistingGenerateScopedName: Boolean(existingName)
1448
1436
  };
1449
1437
  }
1450
- function ensureNativeAliases(output, config, modules, pathBinding, code) {
1451
- if (modules.length === 0) return;
1452
- const resolve = findProperty(config, "resolve");
1453
- if (resolve && resolve.value.type !== "ObjectExpression") throw new Error("The Vite config's resolve option must be an object for vinext init to update it.");
1454
- const resolveObject = resolve?.value;
1455
- const alias = resolveObject ? findProperty(resolveObject, "alias") : void 0;
1456
- if (alias && alias.value.type !== "ObjectExpression") throw new Error("The Vite config's resolve.alias option must be an object for vinext init to update it.");
1457
- const aliasLines = modules.map((moduleName) => ` ${JSON.stringify(moduleName)}: ${pathBinding}.resolve(__dirname, "empty-stub.js"),`);
1458
- if (!resolveObject) {
1459
- insertObjectProperty(output, config, ` resolve: {\n alias: {\n${aliasLines.join("\n")}\n },\n },`, code);
1460
- return;
1461
- }
1462
- if (!alias) {
1463
- insertObjectProperty(output, resolveObject, ` alias: {\n${aliasLines.join("\n")}\n },`, code);
1464
- return;
1465
- }
1466
- const aliasObject = alias.value;
1467
- const existingAliases = new Set(aliasObject.properties.flatMap((property) => property.type === "Property" && propertyName(property) ? [propertyName(property)] : []));
1468
- const missingLines = aliasLines.filter((_, index) => !existingAliases.has(modules[index]));
1469
- if (missingLines.length > 0) insertObjectProperty(output, aliasObject, missingLines.join("\n"), code);
1470
- }
1471
1438
  function updateViteConfigForCloudflare(filePath, code, options) {
1472
1439
  const program = parseViteConfig(filePath, code);
1473
1440
  const cacheOptions = options.cache ?? DEFAULT_CLOUDFLARE_INIT_OPTIONS;
@@ -1604,11 +1571,6 @@ function updateViteConfigForCloudflare(filePath, code, options) {
1604
1571
  if (cacheOptions.cdnCache === "static-assets" || cacheOptions.prerender) ensureVinextPrerenderOptions(output, config, vinextBinding, cacheOptions.cdnCache === "static-assets" ? options.assetsDirectory ?? "dist/client" : void 0, code);
1605
1572
  }
1606
1573
  }
1607
- if (options.nativeModulesToStub.length > 0) {
1608
- const pathLocal = (commonJs ? findRequiredBinding(program, "node:path", "default") : program.body.filter((statement) => statement.type === "ImportDeclaration").find((statement) => statement.source.value === "node:path")?.specifiers.find((specifier) => specifier.type === "ImportDefaultSpecifier")?.local.name) ?? allocateBinding(bindings, "path");
1609
- const pathBinding = commonJs ? ensureDefaultRequire(program, output, "node:path", pathLocal) : ensureDefaultImport(program, output, "node:path", pathLocal);
1610
- ensureNativeAliases(output, config, options.nativeModulesToStub, pathBinding, code);
1611
- }
1612
1574
  return formatInlineConfig(filePath, output.toString(), code);
1613
1575
  }
1614
1576
  function usesCommonJsViteConfig(filePath, code) {
@@ -12,6 +12,8 @@ export type CloudflareInitOptions = {
12
12
  responseStoreMode?: InitResponseStoreMode;
13
13
  warmCdnCache?: boolean;
14
14
  legacyWrangler?: boolean;
15
+ /** Proceed even though the root Wrangler config belongs to another Worker. */
16
+ ignoreWranglerConfig?: boolean;
15
17
  prerender?: boolean;
16
18
  /** Worker name for generated config, instead of one derived from package.json. */
17
19
  name?: string;
@@ -137,11 +137,14 @@ async function resolveInitPlatform(args, options = {}) {
137
137
  }
138
138
  async function resolveInitOptions(args, options = {}) {
139
139
  const legacyWrangler = parseBooleanArg(args, "--legacy-wrangler-cloudflare-init", void 0, "--legacy-wrangler-cloudflare-init expects true or false when using the \"--legacy-wrangler-cloudflare-init=value\" form.");
140
+ const ignoreWranglerConfig = parseBooleanArg(args, "--ignore-wrangler-config", void 0, "--ignore-wrangler-config expects true or false when using the \"--ignore-wrangler-config=value\" form.");
140
141
  const name = parseNameArg(args);
141
142
  const platform = legacyWrangler && !parsePlatformArg(args) ? "cloudflare" : await resolveInitPlatform(args, options);
142
143
  const platformOptions = await INIT_PLATFORMS[platform].options(args, options);
143
144
  const explicitWarmCdnCache = parseWarmCdnCacheArg(args);
144
145
  if (legacyWrangler && platform !== "cloudflare") throw new Error("--legacy-wrangler-cloudflare-init requires --platform=cloudflare.");
146
+ if (ignoreWranglerConfig && platform !== "cloudflare") throw new Error("--ignore-wrangler-config requires --platform=cloudflare.");
147
+ if (ignoreWranglerConfig && legacyWrangler) throw new Error("--ignore-wrangler-config cannot be combined with --legacy-wrangler-cloudflare-init.");
145
148
  if (name && platform !== "cloudflare") throw new Error("--name requires --platform=cloudflare.");
146
149
  const explicitPrerender = parsePrerenderArg(args);
147
150
  if (platform === "cloudflare" && platformOptions?.cdnCache === "static-assets" && explicitPrerender === false) throw new Error("--no-prerender cannot be used with --cdn-cache=static-assets, which requires build-time prerendering.");
@@ -158,6 +161,7 @@ async function resolveInitOptions(args, options = {}) {
158
161
  ...platformOptions,
159
162
  warmCdnCache,
160
163
  ...legacyWrangler ? { legacyWrangler } : {},
164
+ ...ignoreWranglerConfig ? { ignoreWranglerConfig } : {},
161
165
  ...prerender ? { prerender: true } : {},
162
166
  ...name ? { name } : {}
163
167
  } : void 0
@@ -0,0 +1,30 @@
1
+ import { Plugin } from "vite";
2
+ //#region src/plugins/client-compile-hints.d.ts
3
+ /**
4
+ * V8's file-level explicit compile hint (Chrome 136+). V8 compiles every
5
+ * function in a file that starts with this comment eagerly, on the background
6
+ * thread that streams the script, instead of lazily on the main thread the
7
+ * first time each function runs. Other engines ignore it.
8
+ * https://v8.dev/blog/explicit-compile-hints
9
+ */
10
+ export declare const CLIENT_COMPILE_HINT = "//# allFunctionsCalledOnLoad";
11
+ /**
12
+ * Marks the client chunks every page load runs with V8's compile hint.
13
+ *
14
+ * Those are the browser entry chunks and the chunks they import statically:
15
+ * React, React DOM, the Flight client and the vinext runtime. Hydration calls
16
+ * most of their functions on load, so lazy compilation only moves that work
17
+ * onto the main thread. Chunks reached through dynamic imports (route code,
18
+ * lazy client references, navigation-only modules) keep lazy compilation,
19
+ * since eagerly compiling code a page may never call costs time and memory.
20
+ *
21
+ * The hint has to be the first line of the file, so it is added in the last
22
+ * generateBundle pass, after minification and after Vite's import analysis
23
+ * prepends its `__vite__mapDeps` preload helper. That pass runs after Rolldown
24
+ * hashes file names, so `augmentChunkHash` salts the hash of every chunk that
25
+ * gets the hint: a hinted file never reuses the URL of an unhinted one, which
26
+ * browsers may hold as immutable. Its sourcemap keeps following the chunk's
27
+ * name, so builds that name sourcemaps themselves are left alone.
28
+ */
29
+ export declare function createClientCompileHintsPlugin(isBrowserEntry: (id: string) => boolean): Plugin;
30
+ //#endregion
@@ -0,0 +1,88 @@
1
+ //#region src/plugins/client-compile-hints.ts
2
+ /**
3
+ * V8's file-level explicit compile hint (Chrome 136+). V8 compiles every
4
+ * function in a file that starts with this comment eagerly, on the background
5
+ * thread that streams the script, instead of lazily on the main thread the
6
+ * first time each function runs. Other engines ignore it.
7
+ * https://v8.dev/blog/explicit-compile-hints
8
+ */
9
+ const CLIENT_COMPILE_HINT = "//# allFunctionsCalledOnLoad";
10
+ /** Shifts a sourcemap down one generated line, for a line added at the top. */
11
+ function shiftSourceMapSource(source) {
12
+ const text = typeof source === "string" ? source : new TextDecoder().decode(source);
13
+ const map = JSON.parse(text);
14
+ map.mappings = ";" + map.mappings;
15
+ return JSON.stringify(map);
16
+ }
17
+ /**
18
+ * Marks the client chunks every page load runs with V8's compile hint.
19
+ *
20
+ * Those are the browser entry chunks and the chunks they import statically:
21
+ * React, React DOM, the Flight client and the vinext runtime. Hydration calls
22
+ * most of their functions on load, so lazy compilation only moves that work
23
+ * onto the main thread. Chunks reached through dynamic imports (route code,
24
+ * lazy client references, navigation-only modules) keep lazy compilation,
25
+ * since eagerly compiling code a page may never call costs time and memory.
26
+ *
27
+ * The hint has to be the first line of the file, so it is added in the last
28
+ * generateBundle pass, after minification and after Vite's import analysis
29
+ * prepends its `__vite__mapDeps` preload helper. That pass runs after Rolldown
30
+ * hashes file names, so `augmentChunkHash` salts the hash of every chunk that
31
+ * gets the hint: a hinted file never reuses the URL of an unhinted one, which
32
+ * browsers may hold as immutable. Its sourcemap keeps following the chunk's
33
+ * name, so builds that name sourcemaps themselves are left alone.
34
+ */
35
+ function createClientCompileHintsPlugin(isBrowserEntry) {
36
+ const startupByEnvironment = /* @__PURE__ */ new WeakMap();
37
+ const startupChunks = (environment) => (environment && startupByEnvironment.get(environment)?.chunks) ?? void 0;
38
+ return {
39
+ name: "vinext:client-compile-hints",
40
+ apply: "build",
41
+ enforce: "post",
42
+ renderStart(outputOptions) {
43
+ const environment = this.environment;
44
+ if (environment?.name !== "client") return;
45
+ const { codeSplitting, sourcemap, sourcemapFileNames } = outputOptions;
46
+ if (!codeSplitting || sourcemap === "inline" || sourcemap && sourcemapFileNames !== void 0) {
47
+ startupByEnvironment.delete(environment);
48
+ return;
49
+ }
50
+ startupByEnvironment.set(environment, { chunks: null });
51
+ },
52
+ renderChunk(_code, _chunk, _options, meta) {
53
+ const state = this.environment && startupByEnvironment.get(this.environment);
54
+ if (!state || state.chunks) return null;
55
+ const startup = /* @__PURE__ */ new Set();
56
+ const pending = [];
57
+ for (const chunk of Object.values(meta.chunks)) if (chunk.isEntry && chunk.facadeModuleId !== null && isBrowserEntry(chunk.facadeModuleId)) pending.push(chunk.fileName);
58
+ for (let fileName = pending.pop(); fileName !== void 0; fileName = pending.pop()) {
59
+ const chunk = meta.chunks[fileName];
60
+ if (startup.has(fileName) || !chunk) continue;
61
+ startup.add(fileName);
62
+ pending.push(...chunk.imports);
63
+ }
64
+ state.chunks = startup;
65
+ return null;
66
+ },
67
+ augmentChunkHash(chunk) {
68
+ if (startupChunks(this.environment)?.has(chunk.fileName)) return CLIENT_COMPILE_HINT;
69
+ },
70
+ generateBundle: {
71
+ order: "post",
72
+ handler(options, bundle) {
73
+ const startup = startupChunks(this.environment);
74
+ if (!startup) return;
75
+ for (const chunk of Object.values(bundle)) {
76
+ if (chunk.type !== "chunk" || !startup.has(chunk.preliminaryFileName)) continue;
77
+ chunk.code = `${CLIENT_COMPILE_HINT}\n${chunk.code}`;
78
+ if (!options.sourcemap) continue;
79
+ if (chunk.map) chunk.map.mappings = ";" + chunk.map.mappings;
80
+ const mapAsset = chunk.sourcemapFileName ? bundle[chunk.sourcemapFileName] : void 0;
81
+ if (mapAsset?.type === "asset") mapAsset.source = shiftSourceMapSource(mapAsset.source);
82
+ }
83
+ }
84
+ }
85
+ };
86
+ }
87
+ //#endregion
88
+ export { CLIENT_COMPILE_HINT, createClientCompileHintsPlugin };
@@ -30,4 +30,5 @@ export declare function extractPackageImportSpecifier(absolutePath: string, read
30
30
  * Dev-only — production builds use the SSR manifest which handles this correctly.
31
31
  */
32
32
  export declare function clientReferenceDedupPlugin(options?: ClientReferenceDedupOptions): Plugin;
33
- //#endregion
33
+ //#endregion
34
+ export {};
@@ -38,4 +38,5 @@ type CloudflareDevModuleUrlsOptions = {
38
38
  * @returns The Vite plugin
39
39
  */
40
40
  export declare function createCloudflareDevModuleUrlsPlugin(options: CloudflareDevModuleUrlsOptions): Plugin;
41
- //#endregion
41
+ //#endregion
42
+ export {};
@@ -6,6 +6,8 @@ type TransformResult = {
6
6
  map: ReturnType<MagicString["generateMap"]>;
7
7
  };
8
8
  type ResolveDynamicImport = (specifier: string, importer: string) => Promise<string | null>;
9
+ export declare function toManifestModuleId(root: string, resolvedId: string): string | null;
9
10
  export declare function transformNextDynamicPreloadMetadata(code: string, id: string, root: string, resolveDynamicImport: ResolveDynamicImport): Promise<TransformResult | null>;
10
11
  export declare function createDynamicPreloadMetadataPlugin(getTranspiledPackages: () => readonly string[]): Plugin;
11
- //#endregion
12
+ //#endregion
13
+ export {};
@@ -290,4 +290,4 @@ function createDynamicPreloadMetadataPlugin(getTranspiledPackages) {
290
290
  };
291
291
  }
292
292
  //#endregion
293
- export { createDynamicPreloadMetadataPlugin, transformNextDynamicPreloadMetadata };
293
+ export { createDynamicPreloadMetadataPlugin, toManifestModuleId, transformNextDynamicPreloadMetadata };
@@ -7,4 +7,5 @@ type PluginEnvironment = {
7
7
  };
8
8
  /** Whether a Vite environment produces server-consumed output. */
9
9
  export declare function isServerEnvironment(environment: PluginEnvironment): boolean;
10
- //#endregion
10
+ //#endregion
11
+ export {};
@@ -1,5 +1,5 @@
1
1
  import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
- import { escapeRegExp } from "../utils/regex.js";
2
+ import { escapeRegExp, exactRegExpLiteral } from "../utils/regex.js";
3
3
  import { DYNAMIC_IMPORT_PRESCAN, SCRIPT_MODULE_ID_RE, parseProgram, scriptParserLanguage, walkAst } from "./ast-utils.js";
4
4
  import { isUnknownRecord } from "../utils/record.js";
5
5
  import { magicStringTransformResult } from "./transform-result.js";
@@ -219,7 +219,11 @@ function aliasesMayMatch(aliases, requestPattern) {
219
219
  const requestPrefix = requestPattern.slice(0, requestPattern.indexOf("*"));
220
220
  return aliases.some((alias) => {
221
221
  const { find } = alias;
222
- if (find instanceof RegExp) return !isViteInternalAlias(alias);
222
+ if (find instanceof RegExp) {
223
+ const literal = exactRegExpLiteral(find);
224
+ if (literal !== null) return matchesTemplatePattern(requestPattern, literal);
225
+ return !isViteInternalAlias(alias);
226
+ }
223
227
  if (matchesTemplatePattern(requestPattern, find)) return true;
224
228
  const aliasPrefix = `${find}/`;
225
229
  return requestPrefix.startsWith(aliasPrefix) || aliasPrefix.startsWith(requestPrefix);
@@ -74,10 +74,12 @@ const CACHED_FONT_DIR_TOKEN = "__VINEXT_FONT_CACHE_DIR__";
74
74
  * Cached stylesheet whose `url()` references use `CACHED_FONT_DIR_TOKEN`.
75
75
  * The suffix ties the cache to that format: a `style.css` written by an
76
76
  * earlier vinext holds the writing checkout's absolute paths, which would
77
- * 404 once embedded, so it is never read and the font is fetched again.
78
- * Change the suffix whenever the cached CSS format changes.
77
+ * 404 once embedded, and a `style-q7f3kd.css` names extensionless Google
78
+ * font URLs `.ttf` whatever their format, so neither is read and the font
79
+ * is fetched again. Change the suffix whenever the cached CSS format
80
+ * changes.
79
81
  */
80
- const CACHED_FONT_CSS_FILE = "style-q7f3kd.css";
82
+ const CACHED_FONT_CSS_FILE = "style-h8r2vn.css";
81
83
  function formatGoogleFontsErrorBody(body) {
82
84
  const trimmed = body.trim();
83
85
  if (!trimmed) return "(empty response body)";
@@ -330,16 +332,11 @@ async function downloadGoogleFont(cssUrl, family, fontDir, fontDirName) {
330
332
  }
331
333
  let css = await cssResponse.text();
332
334
  if (!css.trim()) throw new Error(`Google Fonts returned an empty stylesheet: ${cssUrl}`);
333
- const urlRe = /url\((https:\/\/fonts\.gstatic\.com\/[^)]+)\)/g;
334
335
  const urls = /* @__PURE__ */ new Map();
335
- let urlMatch;
336
- while ((urlMatch = urlRe.exec(css)) !== null) {
337
- const fontUrl = urlMatch[1];
338
- if (!urls.has(fontUrl)) {
339
- const ext = fontUrl.includes(".woff2") ? ".woff2" : fontUrl.includes(".woff") ? ".woff" : ".ttf";
340
- const fileHash = createHash("md5").update(fontUrl).digest("hex").slice(0, 8);
341
- urls.set(fontUrl, `${family.toLowerCase().replace(/\s+/g, "-")}-${fileHash}${ext}`);
342
- }
336
+ for (const { googleFontFileUrl: fontUrl, ext } of findFontFilesInCss(css)) {
337
+ if (!fontUrl.startsWith("https://fonts.gstatic.com/")) continue;
338
+ const fileHash = createHash("md5").update(fontUrl).digest("hex").slice(0, 8);
339
+ urls.set(fontUrl, `${family.toLowerCase().replace(/\s+/g, "-")}-${fileHash}.${ext}`);
343
340
  }
344
341
  fs.mkdirSync(fontDir, { recursive: true });
345
342
  for (const [fontUrl, filename] of urls) {
@@ -15,4 +15,5 @@ declare function transformVeryDynamicRequests(code: string, id: string): MagicSt
15
15
  export declare function createIgnoreDynamicRequestsPlugin(getTranspiledPackages?: () => readonly string[]): Plugin;
16
16
  export declare const _transformVeryDynamicRequests: typeof transformVeryDynamicRequests;
17
17
  export declare const _mayContainVeryDynamicRequest: typeof mayContainVeryDynamicRequest;
18
- //#endregion
18
+ //#endregion
19
+ export {};
@@ -17,4 +17,5 @@ export declare function createImportMetaUrlPlugin(options: {
17
17
  }): ImportMetaUrlCapability;
18
18
  export declare function rewriteImportMetaUrl(code: string, id: string, root: string, environment: ImportMetaUrlEnvironment): MagicStringTransformResult | null;
19
19
  export declare function rewriteServerCjsGlobals(code: string, id: string, root: string): MagicStringTransformResult | null;
20
- //#endregion
20
+ //#endregion
21
+ export {};
@@ -0,0 +1,12 @@
1
+ import { NextIntlCatalogLoader } from "../config/next-config.js";
2
+ import { Plugin } from "vite";
3
+ //#region src/plugins/next-intl-catalog.d.ts
4
+ /**
5
+ * Runs next-intl's catalog loader on its `experimental.messages` catalogs, as
6
+ * Next.js does through the webpack/Turbopack rule `createNextIntlPlugin` adds.
7
+ * With `precompile: true` the plugin also aliases use-intl's formatter to one
8
+ * that only formats precompiled messages, so raw catalogs would render their
9
+ * ICU placeholders literally.
10
+ */
11
+ export declare function createNextIntlCatalogPlugin(getRoot: () => string, getCatalogLoader: () => NextIntlCatalogLoader | null): Plugin;
12
+ //#endregion
@@ -0,0 +1,85 @@
1
+ import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
+ import { escapeRegExp } from "../utils/regex.js";
3
+ import { canonicalizeFilePath, stripViteModuleQuery } from "../utils/path.js";
4
+ import { createRequire } from "node:module";
5
+ import fsp from "node:fs/promises";
6
+ import { pathToFileURL } from "node:url";
7
+ //#region src/plugins/next-intl-catalog.ts
8
+ const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
9
+ /**
10
+ * Runs next-intl's catalog loader on its `experimental.messages` catalogs, as
11
+ * Next.js does through the webpack/Turbopack rule `createNextIntlPlugin` adds.
12
+ * With `precompile: true` the plugin also aliases use-intl's formatter to one
13
+ * that only formats precompiled messages, so raw catalogs would render their
14
+ * ICU placeholders literally.
15
+ */
16
+ function createNextIntlCatalogPlugin(getRoot, getCatalogLoader) {
17
+ return {
18
+ name: "vinext:next-intl-catalog",
19
+ enforce: "pre",
20
+ applyToEnvironment() {
21
+ const catalogLoader = getCatalogLoader();
22
+ if (!catalogLoader) return false;
23
+ return createCatalogLoadPlugin(getRoot(), catalogLoader);
24
+ }
25
+ };
26
+ }
27
+ function createCatalogLoadPlugin(root, catalogLoader) {
28
+ const catalogDirs = [...new Set(catalogLoader.include.flatMap((dir) => [toSlash(dir), canonicalizeFilePath(dir)]))].map((dir) => `${escapeRegExp(dir)}/`);
29
+ let loaderPromise;
30
+ return {
31
+ name: "vinext:next-intl-catalog",
32
+ load: {
33
+ filter: { id: new RegExp(`^(?:${catalogDirs.join("|")})`) },
34
+ async handler(id) {
35
+ if (SPECIAL_QUERY_RE.test(id)) return null;
36
+ const file = stripViteModuleQuery(id);
37
+ catalogLoader.test.lastIndex = 0;
38
+ if (!catalogLoader.test.test(file)) return null;
39
+ loaderPromise ??= importCatalogLoader(root, catalogLoader.options);
40
+ return {
41
+ code: await runLoader(await loaderPromise, await fsp.readFile(file, "utf8"), {
42
+ resourcePath: file,
43
+ rootContext: root,
44
+ options: catalogLoader.options
45
+ }),
46
+ moduleType: "js"
47
+ };
48
+ }
49
+ }
50
+ };
51
+ }
52
+ async function importCatalogLoader(root, options) {
53
+ const loaderPath = createRequire(path.join(root, "package.json")).resolve("next-intl/extractor/catalogLoader");
54
+ const url = pathToFileURL(loaderPath);
55
+ url.searchParams.set("vinext-config", JSON.stringify([root, options]));
56
+ const loaderModule = await import(url.href);
57
+ if (typeof loaderModule.default !== "function") throw new Error(`[vinext] ${loaderPath} does not export a webpack loader`);
58
+ return loaderModule.default;
59
+ }
60
+ function runLoader(loader, source, context) {
61
+ return new Promise((resolve, reject) => {
62
+ let isAsync = false;
63
+ const callback = (error, result) => {
64
+ if (error) reject(error);
65
+ else resolve(String(result));
66
+ };
67
+ try {
68
+ const result = loader.call({
69
+ resourcePath: context.resourcePath,
70
+ rootContext: context.rootContext,
71
+ getOptions: () => context.options,
72
+ async: () => {
73
+ isAsync = true;
74
+ return callback;
75
+ },
76
+ callback
77
+ }, source);
78
+ if (!isAsync) callback(null, result);
79
+ } catch (error) {
80
+ reject(error);
81
+ }
82
+ });
83
+ }
84
+ //#endregion
85
+ export { createNextIntlCatalogPlugin };
@@ -63,4 +63,5 @@ export declare function copyMissingOgWasm(opts: {
63
63
  * target — so it helps Node/self-hosted builds as well as Cloudflare Workers.
64
64
  */
65
65
  export declare function createOgAssetsPlugin(): Plugin;
66
- //#endregion
66
+ //#endregion
67
+ export {};
@@ -37,9 +37,8 @@ function createOgInlineFetchAssetsPlugin() {
37
37
  ...options,
38
38
  skipSelf: true
39
39
  });
40
- if (resolved === null || resolved.external) return null;
41
- await ownership.recordResolvedImport(source, resolved.id);
42
- return null;
40
+ if (resolved !== null && !resolved.external) await ownership.recordResolvedImport(source, resolved.id);
41
+ return options.kind === "require-call" ? null : resolved;
43
42
  },
44
43
  transform: {
45
44
  filter: { code: "import.meta.url" },
@@ -61,4 +61,5 @@ export declare function buildBarrelExportMap(entryPath: string | null, readFile:
61
61
  * @param getRoot - Returns the current project root (set by the vinext:config hook).
62
62
  */
63
63
  export declare function createOptimizeImportsPlugin(getNextConfig: () => ResolvedNextConfig | undefined, getRoot: () => string): Plugin;
64
- //#endregion
64
+ //#endregion
65
+ export {};
@@ -5,6 +5,7 @@ type PagesNodeExternalsOptions = {
5
5
  getPagesDir: () => string | null;
6
6
  getAliases: () => Readonly<Record<string, string>>;
7
7
  getTsconfigAliases: () => Readonly<Record<string, string>>;
8
+ getTsconfigExactAliases: () => Readonly<Record<string, string>>;
8
9
  getBundledPackages: () => ReadonlySet<string>;
9
10
  isEnabled: () => boolean;
10
11
  };
@@ -19,4 +20,5 @@ type PagesNodeExternalsOptions = {
19
20
  * selected `import` export just like Turbopack.
20
21
  */
21
22
  export declare function createPagesNodeExternalsPlugin(options: PagesNodeExternalsOptions): Plugin;
22
- //#endregion
23
+ //#endregion
24
+ export {};
@@ -141,7 +141,7 @@ function createPagesNodeExternalsPlugin(options) {
141
141
  }
142
142
  const packageName = packageNameFromSpecifier(id);
143
143
  if (!packageName || FRAMEWORK_PACKAGES.has(packageName) || id === "next" || id.startsWith("next/") || id.startsWith("vinext/") || id.startsWith("@vinext/") || options.getBundledPackages().has(packageName)) return null;
144
- if (matchesAlias(id, options.getAliases()) || matchesAlias(id, options.getTsconfigAliases())) {
144
+ if (matchesAlias(id, options.getAliases()) || matchesAlias(id, options.getTsconfigAliases()) || Object.hasOwn(options.getTsconfigExactAliases(), id)) {
145
145
  const aliased = await this.resolve(id, importer, { skipSelf: true });
146
146
  if (aliased && !aliased.external) {
147
147
  const aliasedFile = canonicalFile(aliased.id);
@@ -16,4 +16,5 @@ type RemoveConsoleResult = {
16
16
  * Returns `null` if no console calls are removed.
17
17
  */
18
18
  export declare function removeConsoleCalls(code: string, config: RemoveConsoleConfig): RemoveConsoleResult | null;
19
- //#endregion
19
+ //#endregion
20
+ export {};
@@ -12,4 +12,5 @@ export declare function isConditionalRequireScriptModuleId(id: string): boolean;
12
12
  type IdResolverFactory = typeof createIdResolver;
13
13
  type CommonJsTransformFilter = (id: string) => boolean | undefined;
14
14
  export declare function createRequireConditionResolutionPlugin(createResolver?: IdResolverFactory, commonjsTransformFilter?: CommonJsTransformFilter): Plugin;
15
- //#endregion
15
+ //#endregion
16
+ export {};