vinext 1.0.0-beta.3 → 1.0.0-beta.5

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 (436) hide show
  1. package/README.md +44 -3
  2. package/dist/build/client-build-config.d.ts +0 -1
  3. package/dist/build/css-url-assets.d.ts +0 -1
  4. package/dist/build/google-fonts/build-url.d.ts +5 -2
  5. package/dist/build/google-fonts/font-metadata.d.ts +7 -3
  6. package/dist/build/google-fonts/get-axes.d.ts +0 -1
  7. package/dist/build/layout-classification.d.ts +7 -4
  8. package/dist/build/next-client-runtime-manifests.d.ts +0 -1
  9. package/dist/build/next-client-runtime-manifests.js +2 -19
  10. package/dist/build/nitro-route-rules.d.ts +0 -1
  11. package/dist/build/pages-client-assets-module.d.ts +0 -1
  12. package/dist/build/precompress.d.ts +7 -2
  13. package/dist/build/precompress.js +42 -8
  14. package/dist/build/prerender-paths.d.ts +2 -2
  15. package/dist/build/prerender-server-entry.d.ts +1 -1
  16. package/dist/build/prerender-server-pool.d.ts +4 -2
  17. package/dist/build/prerender.d.ts +36 -32
  18. package/dist/build/prerender.js +18 -3
  19. package/dist/build/public-dir-conflict.d.ts +14 -0
  20. package/dist/build/public-dir-conflict.js +25 -0
  21. package/dist/build/report.d.ts +2 -2
  22. package/dist/build/route-classification-injector.d.ts +0 -1
  23. package/dist/build/route-classification-manifest.d.ts +5 -3
  24. package/dist/build/run-prerender.d.ts +3 -2
  25. package/dist/build/static-export.d.ts +23 -12
  26. package/dist/cache/cache-adapters-virtual.d.ts +5 -2
  27. package/dist/check.js +4 -4
  28. package/dist/cli-args.d.ts +2 -1
  29. package/dist/cli-args.js +10 -0
  30. package/dist/cli-dev-config.d.ts +0 -1
  31. package/dist/cli.d.ts +1 -1
  32. package/dist/cli.js +14 -8
  33. package/dist/client/client-rewrite-matcher.d.ts +12 -0
  34. package/dist/client/client-rewrite-matcher.js +20 -0
  35. package/dist/client/client-rewrites.d.ts +31 -0
  36. package/dist/client/client-rewrites.js +41 -0
  37. package/dist/client/dev-error-overlay.d.ts +0 -1
  38. package/dist/client/empty-module.d.ts +1 -1
  39. package/dist/client/index.d.ts +2 -0
  40. package/dist/client/index.js +2 -0
  41. package/dist/client/instrumentation-client-state.d.ts +0 -1
  42. package/dist/client/navigation-runtime.d.ts +12 -1
  43. package/dist/client/navigation-runtime.js +6 -2
  44. package/dist/client/pages-router-link-navigation.d.ts +3 -21
  45. package/dist/client/react-instance-bootstrap.d.ts +1 -0
  46. package/dist/client/react-instance-bootstrap.js +7 -0
  47. package/dist/client/react-instance.d.ts +13 -0
  48. package/dist/client/react-instance.js +20 -0
  49. package/dist/client/vinext-next-data.d.ts +11 -6
  50. package/dist/client/window-next.d.ts +5 -2
  51. package/dist/config/config-matchers.d.ts +3 -5
  52. package/dist/config/config-matchers.js +7 -6
  53. package/dist/config/dotenv.d.ts +4 -9
  54. package/dist/config/dotenv.js +30 -22
  55. package/dist/config/next-config.d.ts +113 -52
  56. package/dist/config/next-config.js +6 -0
  57. package/dist/config/prerender.d.ts +0 -1
  58. package/dist/entries/app-browser-entry.d.ts +0 -1
  59. package/dist/entries/app-browser-entry.js +7 -3
  60. package/dist/entries/app-rsc-entry.d.ts +30 -16
  61. package/dist/entries/app-rsc-entry.js +40 -12
  62. package/dist/entries/app-rsc-manifest.d.ts +0 -1
  63. package/dist/entries/app-rsc-manifest.js +1 -0
  64. package/dist/entries/pages-client-entry.d.ts +0 -1
  65. package/dist/entries/pages-client-entry.js +7 -2
  66. package/dist/entries/pages-server-entry.d.ts +1 -2
  67. package/dist/entries/pages-server-entry.js +25 -6
  68. package/dist/image/image-adapters-virtual.d.ts +4 -2
  69. package/dist/index.d.ts +0 -1
  70. package/dist/index.js +257 -75
  71. package/dist/init-cloudflare.d.ts +0 -1
  72. package/dist/init-platform.d.ts +0 -1
  73. package/dist/init.d.ts +40 -20
  74. package/dist/plugins/ast-scope.d.ts +0 -1
  75. package/dist/plugins/async-hooks-stub.d.ts +0 -1
  76. package/dist/plugins/client-reference-dedup.d.ts +0 -1
  77. package/dist/plugins/client-reference-dedup.js +7 -5
  78. package/dist/plugins/css-data-url.d.ts +0 -1
  79. package/dist/plugins/css-module-imports.d.ts +0 -1
  80. package/dist/plugins/dynamic-preload-metadata.d.ts +0 -1
  81. package/dist/plugins/extensionless-dynamic-import.d.ts +0 -1
  82. package/dist/plugins/extensionless-dynamic-import.js +352 -13
  83. package/dist/plugins/fonts.d.ts +0 -1
  84. package/dist/plugins/ignore-dynamic-requests.d.ts +0 -1
  85. package/dist/plugins/ignore-dynamic-requests.js +28 -4
  86. package/dist/plugins/import-meta-url.d.ts +0 -1
  87. package/dist/plugins/instrumentation-client.d.ts +0 -1
  88. package/dist/plugins/middleware-server-only.d.ts +0 -1
  89. package/dist/plugins/og-asset-ownership.d.ts +0 -1
  90. package/dist/plugins/og-assets.d.ts +0 -1
  91. package/dist/plugins/optimize-imports.d.ts +0 -1
  92. package/dist/plugins/remove-console.d.ts +0 -1
  93. package/dist/plugins/require-context.d.ts +0 -1
  94. package/dist/plugins/require-context.js +143 -26
  95. package/dist/plugins/rsc-client-reference-loaders.d.ts +0 -1
  96. package/dist/plugins/rsc-reference-validation-normalizer.d.ts +0 -1
  97. package/dist/plugins/sass.d.ts +30 -2
  98. package/dist/plugins/sass.js +67 -5
  99. package/dist/plugins/server-externals-manifest.d.ts +0 -1
  100. package/dist/plugins/strip-server-exports.d.ts +0 -1
  101. package/dist/plugins/styled-jsx.d.ts +0 -1
  102. package/dist/plugins/wasm-module-import.d.ts +0 -1
  103. package/dist/routing/app-route-graph.d.ts +115 -56
  104. package/dist/routing/app-route-graph.js +2 -1
  105. package/dist/routing/app-router.d.ts +0 -1
  106. package/dist/routing/pages-router.d.ts +9 -5
  107. package/dist/routing/route-matching.d.ts +0 -1
  108. package/dist/routing/utils.d.ts +1 -23
  109. package/dist/routing/utils.js +1 -30
  110. package/dist/server/accept-encoding.d.ts +0 -1
  111. package/dist/server/api-handler.d.ts +0 -1
  112. package/dist/server/api-handler.js +4 -3
  113. package/dist/server/app-bfcache-identity.d.ts +9 -10
  114. package/dist/server/app-bfcache-identity.js +27 -102
  115. package/dist/server/app-browser-action-result.d.ts +0 -1
  116. package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -1
  117. package/dist/server/app-browser-entry.d.ts +1 -1
  118. package/dist/server/app-browser-entry.js +106 -66
  119. package/dist/server/app-browser-history-controller.d.ts +8 -5
  120. package/dist/server/app-browser-hydration.d.ts +0 -1
  121. package/dist/server/app-browser-interception-context.d.ts +0 -1
  122. package/dist/server/app-browser-mpa-navigation.d.ts +0 -1
  123. package/dist/server/app-browser-navigation-controller.d.ts +3 -6
  124. package/dist/server/app-browser-navigation-controller.js +29 -4
  125. package/dist/server/app-browser-popstate.d.ts +0 -1
  126. package/dist/server/app-browser-prefetch-response.d.ts +25 -0
  127. package/dist/server/app-browser-prefetch-response.js +54 -0
  128. package/dist/server/app-browser-server-action-client.d.ts +1 -1
  129. package/dist/server/app-browser-server-action-client.js +3 -2
  130. package/dist/server/app-browser-server-action-navigation.d.ts +0 -1
  131. package/dist/server/app-browser-state.d.ts +11 -5
  132. package/dist/server/app-browser-state.js +10 -6
  133. package/dist/server/app-browser-stream.d.ts +0 -1
  134. package/dist/server/app-browser-visible-commit.d.ts +1 -1
  135. package/dist/server/app-browser-visible-commit.js +6 -2
  136. package/dist/server/app-elements-wire.d.ts +16 -13
  137. package/dist/server/app-elements-wire.js +37 -10
  138. package/dist/server/app-elements.d.ts +2 -3
  139. package/dist/server/app-elements.js +2 -2
  140. package/dist/server/app-fallback-renderer.d.ts +8 -4
  141. package/dist/server/app-fallback-renderer.js +2 -1
  142. package/dist/server/app-history-state.d.ts +2 -2
  143. package/dist/server/app-history-state.js +1 -1
  144. package/dist/server/app-hook-warning-suppression.d.ts +0 -1
  145. package/dist/server/app-layout-param-observation.d.ts +0 -1
  146. package/dist/server/app-layout-param-observation.js +1 -1
  147. package/dist/server/app-middleware.d.ts +5 -1
  148. package/dist/server/app-middleware.js +96 -31
  149. package/dist/server/app-optimistic-routing.d.ts +1 -0
  150. package/dist/server/app-page-boundary-render.d.ts +8 -4
  151. package/dist/server/app-page-cache-finalizer.d.ts +2 -3
  152. package/dist/server/app-page-cache-finalizer.js +47 -17
  153. package/dist/server/app-page-cache-render.d.ts +2 -2
  154. package/dist/server/app-page-cache-render.js +2 -1
  155. package/dist/server/app-page-cache.d.ts +1 -3
  156. package/dist/server/app-page-cache.js +22 -11
  157. package/dist/server/app-page-dispatch.d.ts +12 -6
  158. package/dist/server/app-page-dispatch.js +14 -6
  159. package/dist/server/app-page-element-builder.d.ts +63 -20
  160. package/dist/server/app-page-element-builder.js +114 -43
  161. package/dist/server/app-page-execution.d.ts +12 -5
  162. package/dist/server/app-page-execution.js +1 -1
  163. package/dist/server/app-page-head.d.ts +2 -2
  164. package/dist/server/app-page-http-access-fallback-metadata.d.ts +2 -2
  165. package/dist/server/app-page-params.d.ts +0 -1
  166. package/dist/server/app-page-ppr-runtime.d.ts +0 -1
  167. package/dist/server/app-page-probe.d.ts +4 -3
  168. package/dist/server/app-page-probe.js +1 -1
  169. package/dist/server/app-page-render-identity.d.ts +1 -0
  170. package/dist/server/app-page-render-observation.d.ts +0 -1
  171. package/dist/server/app-page-render.d.ts +7 -5
  172. package/dist/server/app-page-render.js +59 -24
  173. package/dist/server/app-page-request.d.ts +3 -2
  174. package/dist/server/app-page-request.js +6 -46
  175. package/dist/server/app-page-response.d.ts +15 -3
  176. package/dist/server/app-page-response.js +21 -3
  177. package/dist/server/app-page-route-wiring.d.ts +30 -7
  178. package/dist/server/app-page-route-wiring.js +163 -63
  179. package/dist/server/app-page-search-params-observation.d.ts +0 -1
  180. package/dist/server/app-page-segment-plan.d.ts +56 -0
  181. package/dist/server/app-page-segment-plan.js +177 -0
  182. package/dist/server/app-page-segment-state.d.ts +18 -2
  183. package/dist/server/app-page-segment-state.js +23 -4
  184. package/dist/server/app-page-stream.d.ts +19 -10
  185. package/dist/server/app-pages-bridge.d.ts +2 -2
  186. package/dist/server/app-pages-bridge.js +14 -2
  187. package/dist/server/app-post-middleware-context.d.ts +0 -1
  188. package/dist/server/app-ppr-fallback-shell-render.d.ts +0 -1
  189. package/dist/server/app-prerender-endpoints.d.ts +0 -1
  190. package/dist/server/app-prerender-static-params.d.ts +0 -1
  191. package/dist/server/app-render-dependency.d.ts +11 -4
  192. package/dist/server/app-render-dependency.js +59 -9
  193. package/dist/server/app-request-context.d.ts +1 -0
  194. package/dist/server/app-route-handler-cache.d.ts +2 -2
  195. package/dist/server/app-route-handler-cache.js +5 -1
  196. package/dist/server/app-route-handler-dispatch.d.ts +0 -1
  197. package/dist/server/app-route-handler-execution.d.ts +2 -2
  198. package/dist/server/app-route-handler-execution.js +5 -1
  199. package/dist/server/app-route-handler-policy.d.ts +0 -1
  200. package/dist/server/app-route-handler-response.d.ts +0 -1
  201. package/dist/server/app-route-handler-runtime.d.ts +0 -1
  202. package/dist/server/app-route-handler-runtime.js +1 -2
  203. package/dist/server/app-route-module-loader.d.ts +32 -6
  204. package/dist/server/app-route-module-loader.js +73 -3
  205. package/dist/server/app-router-entry.d.ts +0 -1
  206. package/dist/server/app-router-entry.js +2 -2
  207. package/dist/server/app-rsc-cache-busting.d.ts +7 -1
  208. package/dist/server/app-rsc-cache-busting.js +6 -0
  209. package/dist/server/app-rsc-handler.d.ts +9 -2
  210. package/dist/server/app-rsc-handler.js +173 -41
  211. package/dist/server/app-rsc-redirect-flight.d.ts +0 -1
  212. package/dist/server/app-rsc-render-mode.d.ts +3 -2
  213. package/dist/server/app-rsc-render-mode.js +4 -1
  214. package/dist/server/app-rsc-request-normalization.d.ts +19 -10
  215. package/dist/server/app-rsc-request-normalization.js +65 -4
  216. package/dist/server/app-rsc-response-finalizer.d.ts +5 -2
  217. package/dist/server/app-rsc-response-finalizer.js +31 -18
  218. package/dist/server/app-rsc-route-matching.d.ts +6 -1
  219. package/dist/server/app-rsc-route-matching.js +47 -2
  220. package/dist/server/app-segment-config.d.ts +0 -1
  221. package/dist/server/app-server-action-execution.d.ts +42 -9
  222. package/dist/server/app-server-action-execution.js +189 -111
  223. package/dist/server/app-ssr-entry.d.ts +5 -3
  224. package/dist/server/app-ssr-entry.js +4 -5
  225. package/dist/server/app-ssr-router-instance.d.ts +0 -1
  226. package/dist/server/app-ssr-stream.d.ts +7 -1
  227. package/dist/server/app-ssr-stream.js +2 -1
  228. package/dist/server/app-static-generation.d.ts +0 -1
  229. package/dist/server/app-visited-response-cache.d.ts +7 -2
  230. package/dist/server/app-visited-response-cache.js +49 -1
  231. package/dist/server/before-interactive-head.d.ts +0 -1
  232. package/dist/server/before-interactive-head.js +2 -0
  233. package/dist/server/bfcache-identity.d.ts +45 -0
  234. package/dist/server/bfcache-identity.js +52 -0
  235. package/dist/server/cache-control.d.ts +3 -3
  236. package/dist/server/cache-control.js +3 -2
  237. package/dist/server/cache-proof.d.ts +0 -1
  238. package/dist/server/client-reuse-manifest.d.ts +0 -1
  239. package/dist/server/config-headers.d.ts +2 -2
  240. package/dist/server/csp.d.ts +0 -1
  241. package/dist/server/default-global-error-module.d.ts +0 -1
  242. package/dist/server/default-global-not-found-module.d.ts +0 -1
  243. package/dist/server/default-not-found-module.d.ts +0 -1
  244. package/dist/server/dev-lockfile.d.ts +21 -9
  245. package/dist/server/dev-module-runner.d.ts +0 -1
  246. package/dist/server/dev-route-files.d.ts +0 -1
  247. package/dist/server/dev-server.d.ts +4 -8
  248. package/dist/server/dev-server.js +86 -131
  249. package/dist/server/dev-stack-sourcemap.d.ts +0 -1
  250. package/dist/server/document-initial-head.d.ts +12 -2
  251. package/dist/server/document-initial-head.js +17 -2
  252. package/dist/server/edge-api-runtime.d.ts +10 -1
  253. package/dist/server/edge-api-runtime.js +29 -1
  254. package/dist/server/file-based-metadata.d.ts +0 -1
  255. package/dist/server/headers.d.ts +17 -2
  256. package/dist/server/headers.js +17 -1
  257. package/dist/server/http-conditional.d.ts +22 -0
  258. package/dist/server/http-conditional.js +117 -0
  259. package/dist/server/http-date.d.ts +5 -0
  260. package/dist/server/http-date.js +73 -0
  261. package/dist/server/http-error-responses.d.ts +2 -1
  262. package/dist/server/http-error-responses.js +14 -2
  263. package/dist/server/http-range.d.ts +25 -0
  264. package/dist/server/http-range.js +67 -0
  265. package/dist/server/image-optimization.d.ts +14 -6
  266. package/dist/server/image-optimization.js +0 -1
  267. package/dist/server/instrumentation.d.ts +7 -4
  268. package/dist/server/isr-cache.d.ts +28 -6
  269. package/dist/server/isr-cache.js +19 -13
  270. package/dist/server/isr-decision.d.ts +6 -4
  271. package/dist/server/metadata-route-build-data.d.ts +0 -1
  272. package/dist/server/metadata-route-response.d.ts +0 -1
  273. package/dist/server/metadata-route-response.js +7 -6
  274. package/dist/server/metadata-routes.d.ts +34 -16
  275. package/dist/server/middleware-matcher-pattern.d.ts +0 -1
  276. package/dist/server/middleware-matcher.d.ts +8 -3
  277. package/dist/server/middleware-matcher.js +23 -18
  278. package/dist/server/middleware-runtime.d.ts +6 -1
  279. package/dist/server/middleware-runtime.js +91 -28
  280. package/dist/server/middleware.d.ts +0 -1
  281. package/dist/server/navigation-planner.d.ts +1 -1
  282. package/dist/server/next-error-digest.d.ts +0 -1
  283. package/dist/server/pages-api-route.d.ts +2 -1
  284. package/dist/server/pages-api-route.js +32 -7
  285. package/dist/server/pages-asset-tags.d.ts +3 -1
  286. package/dist/server/pages-asset-tags.js +6 -4
  287. package/dist/server/pages-data-route.d.ts +14 -6
  288. package/dist/server/pages-data-route.js +19 -10
  289. package/dist/server/pages-dev-hydration.js +3 -0
  290. package/dist/server/pages-dev-stylesheets.d.ts +10 -0
  291. package/dist/server/pages-dev-stylesheets.js +150 -0
  292. package/dist/server/pages-document-asset-props.d.ts +26 -0
  293. package/dist/server/pages-document-asset-props.js +69 -0
  294. package/dist/server/pages-document-initial-props.d.ts +10 -6
  295. package/dist/server/pages-get-initial-props.d.ts +2 -2
  296. package/dist/server/pages-i18n.d.ts +1 -7
  297. package/dist/server/pages-node-compat.d.ts +11 -2
  298. package/dist/server/pages-node-compat.js +52 -5
  299. package/dist/server/pages-page-data.d.ts +21 -9
  300. package/dist/server/pages-page-data.js +109 -30
  301. package/dist/server/pages-page-handler.d.ts +70 -32
  302. package/dist/server/pages-page-handler.js +25 -6
  303. package/dist/server/pages-page-response.d.ts +9 -13
  304. package/dist/server/pages-page-response.js +25 -26
  305. package/dist/server/pages-readiness.d.ts +0 -1
  306. package/dist/server/pages-request-pipeline.d.ts +20 -6
  307. package/dist/server/pages-request-pipeline.js +40 -20
  308. package/dist/server/pages-revalidate.d.ts +0 -1
  309. package/dist/server/pages-revalidate.js +1 -1
  310. package/dist/server/pages-router-entry.js +14 -10
  311. package/dist/server/prerender-manifest.d.ts +7 -0
  312. package/dist/server/prod-server.d.ts +13 -7
  313. package/dist/server/prod-server.js +276 -83
  314. package/dist/server/proxy-trust.d.ts +0 -1
  315. package/dist/server/request-log.d.ts +7 -11
  316. package/dist/server/request-pipeline.d.ts +13 -4
  317. package/dist/server/request-pipeline.js +28 -20
  318. package/dist/server/revalidation-host.d.ts +0 -1
  319. package/dist/server/revalidation-host.js +1 -1
  320. package/dist/server/rsc-completion-metadata.d.ts +15 -0
  321. package/dist/server/rsc-completion-metadata.js +183 -0
  322. package/dist/server/seed-cache.d.ts +2 -1
  323. package/dist/server/seed-cache.js +8 -5
  324. package/dist/server/skip-cache-proof.d.ts +0 -1
  325. package/dist/server/static-file-cache.d.ts +23 -9
  326. package/dist/server/static-file-cache.js +47 -23
  327. package/dist/server/static-layout-client-reuse-proof.d.ts +0 -1
  328. package/dist/server/worker-revalidation-context.d.ts +0 -1
  329. package/dist/server/worker-revalidation-context.js +1 -0
  330. package/dist/server/worker-utils.d.ts +3 -1
  331. package/dist/server/worker-utils.js +11 -2
  332. package/dist/shims/app-router-scroll-state.d.ts +2 -1
  333. package/dist/shims/app-router-scroll-state.js +7 -2
  334. package/dist/shims/app-router-scroll.d.ts +2 -8
  335. package/dist/shims/app.d.ts +1 -5
  336. package/dist/shims/before-interactive-context.d.ts +5 -3
  337. package/dist/shims/cache-handler.d.ts +6 -1
  338. package/dist/shims/cache-handler.js +4 -2
  339. package/dist/shims/cache-request-state.d.ts +12 -1
  340. package/dist/shims/cache-request-state.js +22 -1
  341. package/dist/shims/cache-runtime.d.ts +9 -5
  342. package/dist/shims/cache-runtime.js +16 -6
  343. package/dist/shims/cache.d.ts +2 -3
  344. package/dist/shims/cache.js +2 -2
  345. package/dist/shims/cdn-cache.d.ts +0 -1
  346. package/dist/shims/client-locale.d.ts +1 -6
  347. package/dist/shims/client-only.d.ts +1 -1
  348. package/dist/shims/compat-router.d.ts +0 -1
  349. package/dist/shims/constants.d.ts +1 -1
  350. package/dist/shims/default-global-error.d.ts +1 -4
  351. package/dist/shims/default-not-found.d.ts +0 -1
  352. package/dist/shims/document.d.ts +0 -1
  353. package/dist/shims/document.js +17 -3
  354. package/dist/shims/dynamic-preload-chunks.d.ts +0 -1
  355. package/dist/shims/dynamic.d.ts +0 -1
  356. package/dist/shims/error-boundary-navigation.d.ts +0 -1
  357. package/dist/shims/error-boundary.d.ts +7 -32
  358. package/dist/shims/error.d.ts +1 -6
  359. package/dist/shims/fetch-cache.js +112 -63
  360. package/dist/shims/font-google-base.d.ts +0 -1
  361. package/dist/shims/font-local.d.ts +0 -1
  362. package/dist/shims/form.d.ts +5 -3
  363. package/dist/shims/hash-scroll.d.ts +1 -1
  364. package/dist/shims/hash-scroll.js +2 -1
  365. package/dist/shims/head-state.d.ts +0 -1
  366. package/dist/shims/head.d.ts +1 -4
  367. package/dist/shims/headers.d.ts +2 -2
  368. package/dist/shims/headers.js +1 -1
  369. package/dist/shims/i18n-context.d.ts +0 -1
  370. package/dist/shims/i18n-state.d.ts +0 -1
  371. package/dist/shims/image.d.ts +0 -1
  372. package/dist/shims/image.js +1 -2
  373. package/dist/shims/internal/als-registry.d.ts +31 -2
  374. package/dist/shims/internal/als-registry.js +50 -2
  375. package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +17 -2
  376. package/dist/shims/internal/app-prefetch-fetch-queue.js +69 -7
  377. package/dist/shims/internal/app-route-detection.d.ts +0 -1
  378. package/dist/shims/internal/app-route-prefetch-policy.d.ts +31 -0
  379. package/dist/shims/internal/app-route-prefetch-policy.js +57 -0
  380. package/dist/shims/internal/app-router-context.d.ts +0 -1
  381. package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +1 -5
  382. package/dist/shims/internal/hybrid-client-route-owner.d.ts +0 -1
  383. package/dist/shims/internal/hybrid-client-route-owner.js +6 -8
  384. package/dist/shims/internal/interpolate-as.d.ts +3 -2
  385. package/dist/shims/internal/pages-data-target.d.ts +21 -10
  386. package/dist/shims/internal/pages-data-target.js +1 -1
  387. package/dist/shims/internal/pages-data-url.d.ts +3 -1
  388. package/dist/shims/internal/router-context.d.ts +0 -1
  389. package/dist/shims/internal/work-unit-async-storage.d.ts +4 -3
  390. package/dist/shims/internal/work-unit-async-storage.js +2 -0
  391. package/dist/shims/layout-segment-context.d.ts +2 -6
  392. package/dist/shims/legacy-image.d.ts +0 -1
  393. package/dist/shims/link.d.ts +29 -21
  394. package/dist/shims/link.js +52 -97
  395. package/dist/shims/metadata.d.ts +11 -25
  396. package/dist/shims/metadata.js +24 -32
  397. package/dist/shims/navigation-context-state.d.ts +0 -1
  398. package/dist/shims/navigation-state.d.ts +1 -0
  399. package/dist/shims/navigation.d.ts +54 -6
  400. package/dist/shims/navigation.js +325 -73
  401. package/dist/shims/navigation.react-server.d.ts +1 -0
  402. package/dist/shims/og.d.ts +0 -1
  403. package/dist/shims/request-context.d.ts +8 -3
  404. package/dist/shims/request-state-types.d.ts +1 -0
  405. package/dist/shims/router.d.ts +44 -23
  406. package/dist/shims/router.js +8 -7
  407. package/dist/shims/script-nonce-context.d.ts +0 -1
  408. package/dist/shims/script.d.ts +25 -13
  409. package/dist/shims/server-only.d.ts +1 -1
  410. package/dist/shims/server.d.ts +1 -3
  411. package/dist/shims/server.js +5 -6
  412. package/dist/shims/slot.d.ts +23 -11
  413. package/dist/shims/slot.js +103 -19
  414. package/dist/shims/streamed-icons.d.ts +7 -0
  415. package/dist/shims/streamed-icons.js +33 -0
  416. package/dist/shims/unified-request-context.d.ts +44 -4
  417. package/dist/shims/unified-request-context.js +56 -2
  418. package/dist/shims/use-merged-ref.d.ts +0 -1
  419. package/dist/shims/web-vitals.d.ts +0 -1
  420. package/dist/typegen.d.ts +1 -2
  421. package/dist/typegen.js +1 -1
  422. package/dist/utils/cache-control-metadata.d.ts +13 -1
  423. package/dist/utils/cache-control-metadata.js +17 -1
  424. package/dist/utils/client-build-manifest.d.ts +0 -1
  425. package/dist/utils/domain-locale.d.ts +1 -5
  426. package/dist/utils/html-limited-bots.js +1 -1
  427. package/dist/utils/middleware-request-headers.d.ts +17 -5
  428. package/dist/utils/middleware-request-headers.js +32 -23
  429. package/dist/utils/precompressed-variant.d.ts +9 -0
  430. package/dist/utils/precompressed-variant.js +15 -0
  431. package/dist/utils/project.d.ts +12 -7
  432. package/dist/utils/public-file-path.d.ts +5 -0
  433. package/dist/utils/public-file-path.js +12 -0
  434. package/dist/utils/public-routes.d.ts +1 -1
  435. package/dist/utils/public-routes.js +6 -5
  436. package/package.json +7 -3
@@ -43,6 +43,21 @@ function stringValue(node) {
43
43
  if ((node.type === "Literal" || node.type === "StringLiteral") && typeof node.value === "string") return node.value;
44
44
  return null;
45
45
  }
46
+ function stringFromCharCodeValue(value, scope) {
47
+ const node = unwrapExpression(value);
48
+ if (node?.type !== "CallExpression") return null;
49
+ const callee = unwrapExpression(node.callee);
50
+ const object = callee?.type === "MemberExpression" ? unwrapExpression(callee.object) : null;
51
+ const property = callee?.type === "MemberExpression" ? unwrapExpression(callee.property) : null;
52
+ if (callee?.type !== "MemberExpression" || callee.computed === true || !isIdentifierNamed(object, "String") || hasAstBinding(scope, "String") || !isIdentifierNamed(property, "fromCharCode")) return null;
53
+ let resolved = "";
54
+ for (const argument of nodeArray(node.arguments)) {
55
+ const argumentNode = unwrapExpression(argument);
56
+ if (argumentNode?.type !== "Literal" || typeof argumentNode.value !== "number" || !Number.isInteger(argumentNode.value) || argumentNode.value < 0 || argumentNode.value > 65535) return null;
57
+ resolved += String.fromCharCode(argumentNode.value);
58
+ }
59
+ return resolved;
60
+ }
46
61
  function isUnboundNumericGlobal(node, scope) {
47
62
  return node.type === "Identifier" && typeof node.name === "string" && !hasAstBinding(scope, node.name) && (isIdentifierNamed(node, "NaN") || isIdentifierNamed(node, "Infinity"));
48
63
  }
@@ -482,10 +497,19 @@ function transformVeryDynamicRequests(code, id) {
482
497
  if (node.type === "CallExpression" && hasRange(node)) {
483
498
  const callee = unwrapExpression(node.callee);
484
499
  const argumentsList = nodeArray(node.arguments);
485
- if (isIdentifierNamed(callee, "require") && !hasAstBinding(scope, "require") && argumentsList.length === 1 && astNode(argumentsList[0])?.type !== "SpreadElement" && !hasDynamicRequestIgnoreDirective(code, node, argumentsList[0]) && !requestHasStaticPart(argumentsList[0], scope)) {
486
- output.overwrite(node.start, node.end, dynamicRequireReplacement());
487
- changed = true;
488
- return;
500
+ if (isIdentifierNamed(callee, "require") && !hasAstBinding(scope, "require") && argumentsList.length === 1 && astNode(argumentsList[0])?.type !== "SpreadElement" && !hasDynamicRequestIgnoreDirective(code, node, argumentsList[0])) {
501
+ const resolvedRequest = stringFromCharCodeValue(argumentsList[0], scope);
502
+ const argument = astNode(argumentsList[0]);
503
+ if (resolvedRequest !== null && resolvedRequest.replaceAll("\\", "/") !== "/" && argument && hasRange(argument)) {
504
+ output.overwrite(argument.start, argument.end, JSON.stringify(resolvedRequest));
505
+ changed = true;
506
+ return;
507
+ }
508
+ if (!requestHasStaticPart(argumentsList[0], scope)) {
509
+ output.overwrite(node.start, node.end, dynamicRequireReplacement());
510
+ changed = true;
511
+ return;
512
+ }
489
513
  }
490
514
  }
491
515
  if (node.type === "ImportExpression" && hasRange(node) && !hasDynamicRequestIgnoreDirective(code, node, node.source) && !requestHasStaticPart(node.source, scope)) {
@@ -1,6 +1,5 @@
1
1
  import { Plugin } from "vite";
2
2
  import MagicString from "magic-string";
3
-
4
3
  //#region src/plugins/import-meta-url.d.ts
5
4
  type ImportMetaUrlEnvironment = "client" | "server";
6
5
  type RewriteResult = {
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/instrumentation-client.d.ts
4
3
  declare function createInstrumentationClientTransformPlugin(getInstrumentationClientPath: () => string | null): Plugin;
5
4
  //#endregion
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/middleware-server-only.d.ts
4
3
  /**
5
4
  * Allow `import 'server-only'` from neutral server targets (and any module
@@ -1,5 +1,4 @@
1
1
  import { Alias } from "vite";
2
-
3
2
  //#region src/plugins/og-asset-ownership.d.ts
4
3
  type OgAssetModuleBoundary = {
5
4
  assetRoot: string;
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/og-assets.d.ts
4
3
  /**
5
4
  * Create the `vinext:og-inline-fetch-assets` Vite plugin.
@@ -1,6 +1,5 @@
1
1
  import { ResolvedNextConfig } from "../config/next-config.js";
2
2
  import { Plugin } from "vite";
3
-
4
3
  //#region src/plugins/optimize-imports.d.ts
5
4
  type BarrelExportEntry = {
6
5
  source: string;
@@ -1,5 +1,4 @@
1
1
  import MagicString from "magic-string";
2
-
3
2
  //#region src/plugins/remove-console.d.ts
4
3
  type RemoveConsoleConfig = boolean | {
5
4
  exclude: string[];
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/require-context.d.ts
4
3
  declare function createRequireContextPlugin(): Plugin;
5
4
  //#endregion
@@ -1,6 +1,7 @@
1
+ import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { forEachAstChild, hasRange, isAstRecord, nodeArray } from "./ast-utils.js";
2
- import { createTransformCache } from "./transform-cache.js";
3
3
  import { parseAst } from "vite";
4
+ import { readdir, realpath, stat } from "node:fs/promises";
4
5
  import MagicString from "magic-string";
5
6
  //#region src/plugins/require-context.ts
6
7
  const TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
@@ -14,7 +15,7 @@ const TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
14
15
  ".cts"
15
16
  ]);
16
17
  function createRequireContextPlugin() {
17
- const cached = createTransformCache();
18
+ const watchedContexts = /* @__PURE__ */ new WeakMap();
18
19
  return {
19
20
  name: "vinext:require-context",
20
21
  enforce: "pre",
@@ -23,13 +24,42 @@ function createRequireContextPlugin() {
23
24
  id: /\.(?:[cm]?[jt]s|[jt]sx)(?:\?.*)?$/i,
24
25
  code: /\brequire\b[\s\S]*\.context/
25
26
  },
26
- handler(code, id) {
27
- return cached(id, code, void 0, () => transformRequireContext(code, id));
27
+ async handler(code, id) {
28
+ const transformed = await transformRequireContext(code, id);
29
+ const contextsForEnvironment = watchedContexts.get(this.environment) ?? /* @__PURE__ */ new Map();
30
+ watchedContexts.set(this.environment, contextsForEnvironment);
31
+ if (!transformed) {
32
+ contextsForEnvironment.delete(id);
33
+ return null;
34
+ }
35
+ contextsForEnvironment.set(id, transformed.contexts);
36
+ for (const context of transformed.contexts) this.addWatchFile(context.directory);
37
+ return {
38
+ code: transformed.code,
39
+ map: transformed.map
40
+ };
28
41
  }
42
+ },
43
+ hotUpdate({ type, file, modules }) {
44
+ const contextsForEnvironment = watchedContexts.get(this.environment);
45
+ if (!contextsForEnvironment) return;
46
+ for (const module of modules) if (module.id != null) contextsForEnvironment.delete(module.id);
47
+ if (type === "update") return;
48
+ const normalizedFile = toSlash(file);
49
+ const affectedModules = new Set(modules);
50
+ let addedImporter = false;
51
+ for (const [id, contexts] of contextsForEnvironment) {
52
+ if (!contexts.some((context) => matchesWatchedContext(normalizedFile, context))) continue;
53
+ const module = this.environment.moduleGraph.getModuleById(id);
54
+ if (!module || affectedModules.has(module)) continue;
55
+ affectedModules.add(module);
56
+ addedImporter = true;
57
+ }
58
+ return addedImporter ? [...affectedModules] : void 0;
29
59
  }
30
60
  };
31
61
  }
32
- function transformRequireContext(code, id) {
62
+ async function transformRequireContext(code, id) {
33
63
  const lang = langForId(id);
34
64
  let ast;
35
65
  try {
@@ -40,10 +70,25 @@ function transformRequireContext(code, id) {
40
70
  const calls = collectRequireContextCalls(ast);
41
71
  if (calls.length === 0) return null;
42
72
  const output = new MagicString(code);
43
- for (const call of calls) output.overwrite(call.range.start, call.range.end, buildReplacement(call));
73
+ const importOffset = findImportInsertionOffset(ast);
74
+ const imports = [];
75
+ const contexts = [];
76
+ let bindingPrefix = "__vinext_require_context";
77
+ while (code.includes(bindingPrefix)) bindingPrefix += "_";
78
+ for (const [callIndex, call] of calls.entries()) {
79
+ const resolved = await resolveContextModules(id, call, bindingPrefix, callIndex);
80
+ contexts.push(resolved.context);
81
+ for (const module of resolved.modules) imports.push(`import * as ${module.binding} from ${JSON.stringify(module.specifier)};`);
82
+ output.overwrite(call.range.start, call.range.end, buildReplacement(call, resolved.modules));
83
+ }
84
+ if (imports.length > 0) {
85
+ const importBlock = `${importOffset > 0 ? "\n" : ""}${imports.join("\n")}\n`;
86
+ output.appendLeft(importOffset, importBlock);
87
+ }
44
88
  return {
45
89
  code: output.toString(),
46
- map: output.generateMap({ hires: "boundary" })
90
+ map: output.generateMap({ hires: "boundary" }),
91
+ contexts
47
92
  };
48
93
  }
49
94
  function langForId(id) {
@@ -75,6 +120,16 @@ function collectRequireContextCalls(ast) {
75
120
  visit(ast);
76
121
  return calls;
77
122
  }
123
+ function findImportInsertionOffset(ast) {
124
+ if (!isAstRecord(ast) || ast.type !== "Program") return 0;
125
+ let offset = 0;
126
+ if (isAstRecord(ast.hashbang) && hasRange(ast.hashbang)) offset = ast.hashbang.end;
127
+ for (const statement of nodeArray(ast.body)) {
128
+ if (!isAstRecord(statement) || statement.type !== "ExpressionStatement" || typeof statement.directive !== "string" || !hasRange(statement)) break;
129
+ offset = statement.end;
130
+ }
131
+ return offset;
132
+ }
78
133
  function parseRequireContextCall(node) {
79
134
  if (node.type !== "CallExpression" || !hasRange(node)) return null;
80
135
  const callee = node.callee;
@@ -146,26 +201,14 @@ function regexLiteralValue(value) {
146
201
  };
147
202
  return null;
148
203
  }
149
- function buildReplacement(call) {
150
- const globPattern = globPatternFor(call.dir, call.recursive);
151
- const glob = `import.meta.glob(${JSON.stringify(globPattern)}, { eager: true })`;
204
+ function buildReplacement(call, modules) {
152
205
  const base = JSON.stringify(stripTrailingSlash(call.dir));
153
- const filterFlags = call.flags.replace(/[gy]/g, "");
154
- const regexArgs = `${JSON.stringify(call.pattern)}, ${JSON.stringify(filterFlags)}`;
206
+ const entries = modules.map((module) => `${JSON.stringify(module.key)}: ${module.binding}`);
155
207
  return [
156
208
  "(() => {",
157
- ` const __modules = ${glob};`,
158
209
  ` const __base = ${base};`,
159
- ` const __re = ${call.pattern ? `new RegExp(${regexArgs})` : "null"};`,
160
- " const __prefix = __base.endsWith('/') ? __base : __base + '/';",
161
- " const __map = Object.create(null);",
162
- " for (const __abs in __modules) {",
163
- " if (!__abs.startsWith(__prefix)) continue;",
164
- " const __key = './' + __abs.slice(__prefix.length);",
165
- " if (__re && !__re.test(__key)) continue;",
166
- " __map[__key] = __modules[__abs];",
167
- " }",
168
- " const __keys = Object.keys(__map).sort();",
210
+ ` const __map = Object.assign(Object.create(null), {${entries.join(",")}});`,
211
+ ` const __keys = ${JSON.stringify(modules.map((module) => module.key))};`,
169
212
  " const __ctx = (__key) => {",
170
213
  " if (__key in __map) return __map[__key];",
171
214
  " const __err = new Error('Cannot find module \\'' + __key + '\\'');",
@@ -179,9 +222,83 @@ function buildReplacement(call) {
179
222
  "})()"
180
223
  ].join("\n");
181
224
  }
182
- function globPatternFor(dir, recursive) {
183
- const base = stripTrailingSlash(dir);
184
- return recursive ? `${base}/**/*` : `${base}/*`;
225
+ async function resolveContextModules(id, call, bindingPrefix, callIndex) {
226
+ const importer = toSlash(id.split("?", 1)[0]);
227
+ const directory = path.resolve(path.dirname(importer), call.dir);
228
+ const context = {
229
+ directory,
230
+ recursive: call.recursive,
231
+ pattern: call.pattern,
232
+ flags: filterFlags(call.flags)
233
+ };
234
+ const regexp = call.pattern ? new RegExp(call.pattern, context.flags) : null;
235
+ const accepted = [];
236
+ for (const candidate of await listContextFiles(directory, call.recursive)) {
237
+ const key = `./${candidate}`;
238
+ if (regexp && !regexp.test(key)) continue;
239
+ accepted.push({
240
+ key,
241
+ specifier: `${stripTrailingSlash(call.dir)}/${candidate}`
242
+ });
243
+ }
244
+ accepted.sort((left, right) => left.key < right.key ? -1 : left.key > right.key ? 1 : 0);
245
+ return {
246
+ context,
247
+ modules: accepted.map((entry, index) => ({
248
+ ...entry,
249
+ binding: `${bindingPrefix}_${callIndex}_${index}`
250
+ }))
251
+ };
252
+ }
253
+ async function listContextFiles(directory, recursive) {
254
+ const files = [];
255
+ const ancestorRealPaths = /* @__PURE__ */ new Set();
256
+ async function walk(currentDirectory, prefix) {
257
+ let realDirectory;
258
+ let entries;
259
+ try {
260
+ realDirectory = await realpath(currentDirectory);
261
+ entries = await readdir(currentDirectory, { withFileTypes: true });
262
+ } catch (error) {
263
+ const code = error.code;
264
+ if (code === "ENOENT" || code === "ENOTDIR") return;
265
+ throw error;
266
+ }
267
+ if (ancestorRealPaths.has(realDirectory)) return;
268
+ ancestorRealPaths.add(realDirectory);
269
+ try {
270
+ for (const entry of entries) {
271
+ if (entry.name.startsWith(".")) continue;
272
+ const entryPath = path.join(currentDirectory, entry.name);
273
+ let isFile = entry.isFile();
274
+ let isDirectory = entry.isDirectory();
275
+ if (!isFile && !isDirectory) try {
276
+ const stats = await stat(entryPath);
277
+ isFile = stats.isFile();
278
+ isDirectory = stats.isDirectory();
279
+ } catch (error) {
280
+ const code = error.code;
281
+ if (code === "ENOENT" || code === "ELOOP") continue;
282
+ throw error;
283
+ }
284
+ if (isFile) files.push(`${prefix}${entry.name}`);
285
+ else if (isDirectory && recursive) await walk(entryPath, `${prefix}${entry.name}/`);
286
+ }
287
+ } finally {
288
+ ancestorRealPaths.delete(realDirectory);
289
+ }
290
+ }
291
+ await walk(directory, "");
292
+ return files;
293
+ }
294
+ function matchesWatchedContext(file, context) {
295
+ const candidate = path.relative(context.directory, file);
296
+ if (candidate.length === 0 || candidate === ".." || candidate.startsWith("../") || candidate.split("/").some((segment) => segment.startsWith(".")) || !context.recursive && candidate.includes("/")) return false;
297
+ if (context.recursive) return true;
298
+ return context.pattern === "" || new RegExp(context.pattern, context.flags).test(`./${candidate}`);
299
+ }
300
+ function filterFlags(flags) {
301
+ return flags.replace(/[gy]/g, "");
185
302
  }
186
303
  function stripTrailingSlash(value) {
187
304
  return value.endsWith("/") ? value.slice(0, -1) : value;
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/rsc-client-reference-loaders.d.ts
4
3
  declare function createRscClientReferenceLoadersPlugin(): Plugin;
5
4
  //#endregion
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/rsc-reference-validation-normalizer.d.ts
4
3
  /**
5
4
  * @vitejs/plugin-rsc stores dev virtual client-reference keys in Vite's encoded
@@ -1,5 +1,4 @@
1
1
  import { ResolvedConfig } from "vite";
2
-
3
2
  //#region src/plugins/sass.d.ts
4
3
  type AdditionalData = string | ((source: string, filename: string) => string | Promise<string>);
5
4
  type VitePreprocessorOptions = {
@@ -7,6 +6,35 @@ type VitePreprocessorOptions = {
7
6
  loadPaths?: string[];
8
7
  [key: string]: any;
9
8
  };
9
+ type SassTsconfigPathAlias = {
10
+ find: string;
11
+ replacements: readonly string[];
12
+ };
13
+ type SassFileImporterContext = {
14
+ containingUrl?: URL | null;
15
+ };
16
+ type SassFileImporter = {
17
+ findFileUrl(url: string, context?: SassFileImporterContext): URL | null;
18
+ };
19
+ /**
20
+ * Create Sass `FileImporter`s for paths materialized from tsconfig.
21
+ *
22
+ * Vite does not apply tsconfig path aliases while resolving Sass loads. Vinext
23
+ * deliberately extends that behavior for migration compatibility: application
24
+ * stylesheets may use the same exact and single-wildcard mappings as source
25
+ * modules. This is a vinext capability, not Next.js parity; current Next.js
26
+ * webpack builds do not resolve tsconfig `paths` from Sass.
27
+ *
28
+ * One importer is emitted per ordered replacement slot. When Sass cannot find
29
+ * a file for the first target it advances to the next importer, preserving the
30
+ * fallback order from `paths`. All importers select the same best pattern, so a
31
+ * failed specific mapping never falls through to a less-specific mapping.
32
+ *
33
+ * Aliases stay scoped to application stylesheets. Loads originating in
34
+ * `node_modules`, plus absolute, relative, protocol-relative, and scheme URLs,
35
+ * are left to user and Vite importers.
36
+ */
37
+ declare function createSassTsconfigPathImporters(aliases: readonly SassTsconfigPathAlias[]): SassFileImporter[];
10
38
  /**
11
39
  * Create a Sass `FileImporter` that resolves webpack-style tilde (`~`) imports.
12
40
  *
@@ -75,4 +103,4 @@ declare function createSassAwareFileSystemLoader(): {
75
103
  setResolvedConfig: (config: ResolvedConfig) => void;
76
104
  };
77
105
  //#endregion
78
- export { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter };
106
+ export { SassTsconfigPathAlias, buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter, createSassTsconfigPathImporters };
@@ -3,7 +3,7 @@ import { markCssUrlAssetReferences, rebaseCssUrlAssetReferences } from "../build
3
3
  import { createRequire } from "node:module";
4
4
  import fs from "node:fs";
5
5
  import { preprocessCSS } from "vite";
6
- import { pathToFileURL } from "node:url";
6
+ import { fileURLToPath, pathToFileURL } from "node:url";
7
7
  //#region src/plugins/sass.ts
8
8
  /**
9
9
  * Map a Next.js `sassOptions` object onto Vite's
@@ -28,6 +28,69 @@ import { pathToFileURL } from "node:url";
28
28
  *
29
29
  * @see https://vite.dev/config/shared-options.html#css-preprocessoroptions
30
30
  */
31
+ const URL_SCHEME_RE = /^[A-Za-z][A-Za-z\d+.-]*:/;
32
+ const NODE_MODULES_PATH_RE = /(?:^|\/)node_modules(?:\/|$)/;
33
+ function matchSassTsconfigPathAlias(aliases, url) {
34
+ for (const alias of aliases) if (!alias.find.includes("*") && alias.find === url) return {
35
+ alias,
36
+ matchedStar: null
37
+ };
38
+ let bestMatch = null;
39
+ let bestPrefixLength = -1;
40
+ for (const alias of aliases) {
41
+ const starIndex = alias.find.indexOf("*");
42
+ if (starIndex < 0) continue;
43
+ const prefix = alias.find.slice(0, starIndex);
44
+ const suffix = alias.find.slice(starIndex + 1);
45
+ if (url.length < prefix.length + suffix.length || !url.startsWith(prefix) || !url.endsWith(suffix) || prefix.length <= bestPrefixLength) continue;
46
+ bestPrefixLength = prefix.length;
47
+ bestMatch = {
48
+ alias,
49
+ matchedStar: url.slice(prefix.length, url.length - suffix.length)
50
+ };
51
+ }
52
+ return bestMatch;
53
+ }
54
+ function isSassAliasEligibleUrl(url, context) {
55
+ if (URL_SCHEME_RE.test(url) || url.startsWith("//") || url.startsWith("/") || url.startsWith("./") || url.startsWith("../") || url.startsWith("~")) return false;
56
+ const containingUrl = context?.containingUrl;
57
+ if (containingUrl?.protocol === "file:") {
58
+ const containingPath = toSlash(fileURLToPath(containingUrl));
59
+ if (NODE_MODULES_PATH_RE.test(containingPath)) return false;
60
+ }
61
+ return true;
62
+ }
63
+ /**
64
+ * Create Sass `FileImporter`s for paths materialized from tsconfig.
65
+ *
66
+ * Vite does not apply tsconfig path aliases while resolving Sass loads. Vinext
67
+ * deliberately extends that behavior for migration compatibility: application
68
+ * stylesheets may use the same exact and single-wildcard mappings as source
69
+ * modules. This is a vinext capability, not Next.js parity; current Next.js
70
+ * webpack builds do not resolve tsconfig `paths` from Sass.
71
+ *
72
+ * One importer is emitted per ordered replacement slot. When Sass cannot find
73
+ * a file for the first target it advances to the next importer, preserving the
74
+ * fallback order from `paths`. All importers select the same best pattern, so a
75
+ * failed specific mapping never falls through to a less-specific mapping.
76
+ *
77
+ * Aliases stay scoped to application stylesheets. Loads originating in
78
+ * `node_modules`, plus absolute, relative, protocol-relative, and scheme URLs,
79
+ * are left to user and Vite importers.
80
+ */
81
+ function createSassTsconfigPathImporters(aliases) {
82
+ const entries = aliases.filter(({ find, replacements }) => find.length > 0 && replacements.length > 0);
83
+ const replacementSlots = Math.max(0, ...entries.map((alias) => alias.replacements.length));
84
+ return Array.from({ length: replacementSlots }, (_, replacementIndex) => ({ findFileUrl(url, context) {
85
+ if (!isSassAliasEligibleUrl(url, context)) return null;
86
+ const match = matchSassTsconfigPathAlias(entries, url);
87
+ if (!match) return null;
88
+ const replacement = match.alias.replacements[replacementIndex];
89
+ if (!replacement) return null;
90
+ const matchedStar = match.matchedStar;
91
+ return pathToFileURL(matchedStar === null ? replacement : replacement.replaceAll("*", () => matchedStar));
92
+ } }));
93
+ }
31
94
  /**
32
95
  * Create a Sass `FileImporter` that resolves webpack-style tilde (`~`) imports.
33
96
  *
@@ -130,8 +193,7 @@ function createSassCssUrlAssetImporter() {
130
193
  if (!fs.statSync(candidate, { throwIfNoEntry: false })?.isFile()) continue;
131
194
  const prepared = prepareStylesheet(candidate, entryDirectory);
132
195
  if (prepared === null) return match;
133
- const canonicalUrl = pathToFileURL(candidate);
134
- markedStylesheets.set(canonicalUrl.href, prepared);
196
+ markedStylesheets.set(candidate, prepared);
135
197
  const namespace = rule === "use" && !/\bas\s+(?:\*|[-\w]+)/.test(suffix) ? ` as ${deriveSassNamespace(importUrl)}` : "";
136
198
  return `${prefix}${quote}${importUrlPrefix}${encodeURIComponent(candidate)}${quote}${namespace}${suffix}`;
137
199
  }
@@ -143,7 +205,7 @@ function createSassCssUrlAssetImporter() {
143
205
  return pathToFileURL(decodeURIComponent(url.slice(21)));
144
206
  },
145
207
  load(canonicalUrl) {
146
- return markedStylesheets.get(canonicalUrl.href) ?? null;
208
+ return markedStylesheets.get(toSlash(fileURLToPath(canonicalUrl))) ?? null;
147
209
  },
148
210
  rewriteImports
149
211
  };
@@ -338,4 +400,4 @@ function createSassAwareFileSystemLoader() {
338
400
  };
339
401
  }
340
402
  //#endregion
341
- export { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter };
403
+ export { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter, createSassTsconfigPathImporters };
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/server-externals-manifest.d.ts
4
3
  /**
5
4
  * vinext:server-externals-manifest
@@ -1,5 +1,4 @@
1
1
  import MagicString from "magic-string";
2
-
3
2
  //#region src/plugins/strip-server-exports.d.ts
4
3
  declare function hasServerExportCandidate(code: string): boolean;
5
4
  declare function hasExportAllCandidate(code: string): boolean;
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/styled-jsx.d.ts
4
3
  type NextSwcModule = {
5
4
  loadBindings(): Promise<unknown>;
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
-
3
2
  //#region src/plugins/wasm-module-import.d.ts
4
3
  /**
5
4
  * vinext:wasm-module-import — handle `import x from '*.wasm?module'`.