vinext 1.0.0-beta.0 → 1.0.0-beta.2

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 (305) hide show
  1. package/README.md +21 -2
  2. package/dist/build/assets-ignore.js +1 -1
  3. package/dist/build/clean-output.js +1 -1
  4. package/dist/build/client-build-config.js +7 -4
  5. package/dist/build/css-url-assets.js +3 -3
  6. package/dist/build/google-fonts/fallback-metrics.js +1 -1
  7. package/dist/build/google-fonts/font-metadata.js +1 -1
  8. package/dist/build/inject-pregenerated-paths.js +1 -1
  9. package/dist/build/inline-css.js +2 -5
  10. package/dist/build/module-dependency-cache.d.ts +4 -0
  11. package/dist/build/module-dependency-cache.js +13 -0
  12. package/dist/build/next-client-runtime-manifests.js +1 -1
  13. package/dist/build/pages-client-assets-module.js +1 -1
  14. package/dist/build/precompress.js +7 -7
  15. package/dist/build/prerender-paths.d.ts +2 -2
  16. package/dist/build/prerender-paths.js +10 -15
  17. package/dist/build/prerender-server-pool.js +2 -2
  18. package/dist/build/prerender.js +1 -1
  19. package/dist/build/preview-credentials.d.ts +11 -0
  20. package/dist/build/preview-credentials.js +19 -0
  21. package/dist/build/report.d.ts +8 -4
  22. package/dist/build/report.js +14 -6
  23. package/dist/build/run-prerender.d.ts +2 -11
  24. package/dist/build/run-prerender.js +2 -10
  25. package/dist/build/server-manifest.js +1 -1
  26. package/dist/build/ssr-manifest.d.ts +4 -0
  27. package/dist/build/ssr-manifest.js +10 -6
  28. package/dist/build/standalone.js +37 -37
  29. package/dist/cache/cache-adapters-virtual.d.ts +1 -17
  30. package/dist/cache/cache-adapters-virtual.js +20 -11
  31. package/dist/check.d.ts +0 -16
  32. package/dist/check.js +27 -36
  33. package/dist/cli.js +61 -55
  34. package/dist/client/instrumentation-client-inject.js +1 -1
  35. package/dist/client/pages-router-link-navigation.js +1 -1
  36. package/dist/config/config-matchers.d.ts +13 -37
  37. package/dist/config/config-matchers.js +33 -123
  38. package/dist/config/dotenv.js +1 -1
  39. package/dist/config/next-config.d.ts +7 -3
  40. package/dist/config/next-config.js +84 -15
  41. package/dist/config/prerender.d.ts +2 -2
  42. package/dist/config/prerender.js +7 -15
  43. package/dist/config/request-context.d.ts +14 -0
  44. package/dist/config/request-context.js +26 -0
  45. package/dist/config/server-external-packages.js +1 -1
  46. package/dist/config/tsconfig-paths.js +2 -2
  47. package/dist/{node_modules/.pnpm/am-i-vibing@0.5.0/node_modules → deps/.pnpm/am-i-vibing@0.5.0/deps}/am-i-vibing/dist/detector-1yx2Hoe0.js +2 -2
  48. package/dist/deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js +50 -0
  49. package/dist/entries/app-rsc-entry.js +39 -14
  50. package/dist/entries/app-rsc-manifest.js +21 -4
  51. package/dist/entries/pages-client-entry.js +6 -5
  52. package/dist/entries/pages-server-entry.js +18 -28
  53. package/dist/entries/runtime-entry-module.js +2 -2
  54. package/dist/index.js +314 -230
  55. package/dist/init-cloudflare.js +1 -1
  56. package/dist/init-platform.js +1 -1
  57. package/dist/init.d.ts +6 -4
  58. package/dist/init.js +25 -27
  59. package/dist/plugins/ast-utils.js +1 -1
  60. package/dist/plugins/dynamic-preload-metadata.js +7 -7
  61. package/dist/plugins/extensionless-dynamic-import.js +1 -1
  62. package/dist/plugins/fonts.js +3 -3
  63. package/dist/plugins/ignore-dynamic-requests.js +13 -8
  64. package/dist/plugins/import-meta-url.js +16 -17
  65. package/dist/plugins/middleware-export-validation.js +1 -1
  66. package/dist/plugins/middleware-server-only.js +2 -2
  67. package/dist/plugins/og-asset-ownership.js +7 -6
  68. package/dist/plugins/og-assets.js +5 -6
  69. package/dist/plugins/optimize-imports.js +12 -13
  70. package/dist/plugins/postcss.js +1 -1
  71. package/dist/plugins/remove-console.js +1 -1
  72. package/dist/plugins/require-context.js +1 -1
  73. package/dist/plugins/sass.js +2 -2
  74. package/dist/plugins/server-externals-manifest.js +1 -1
  75. package/dist/plugins/strip-server-exports.js +1 -1
  76. package/dist/plugins/styled-jsx.js +3 -2
  77. package/dist/plugins/typeof-window.js +1 -1
  78. package/dist/routing/app-route-graph.d.ts +16 -15
  79. package/dist/routing/app-route-graph.js +86 -88
  80. package/dist/routing/app-router.d.ts +0 -5
  81. package/dist/routing/app-router.js +12 -11
  82. package/dist/routing/file-matcher.d.ts +13 -28
  83. package/dist/routing/file-matcher.js +31 -44
  84. package/dist/routing/pages-router.js +26 -32
  85. package/dist/routing/route-matching.d.ts +14 -1
  86. package/dist/routing/route-matching.js +13 -1
  87. package/dist/routing/route-pattern.d.ts +2 -1
  88. package/dist/routing/route-pattern.js +7 -4
  89. package/dist/routing/route-trie.d.ts +5 -1
  90. package/dist/routing/route-trie.js +5 -2
  91. package/dist/server/api-handler.js +41 -33
  92. package/dist/server/app-browser-entry.js +18 -11
  93. package/dist/server/app-browser-history-controller.d.ts +1 -1
  94. package/dist/server/app-browser-history-controller.js +3 -3
  95. package/dist/server/app-browser-navigation-controller.js +4 -2
  96. package/dist/server/app-browser-server-action-client.js +1 -1
  97. package/dist/server/app-elements-wire.d.ts +2 -1
  98. package/dist/server/app-fallback-renderer.d.ts +11 -0
  99. package/dist/server/app-fallback-renderer.js +16 -2
  100. package/dist/server/app-middleware.js +2 -1
  101. package/dist/server/app-page-boundary-render.d.ts +26 -2
  102. package/dist/server/app-page-boundary-render.js +190 -55
  103. package/dist/server/app-page-cache-finalizer.d.ts +1 -1
  104. package/dist/server/app-page-cache.d.ts +1 -1
  105. package/dist/server/app-page-dispatch.d.ts +12 -2
  106. package/dist/server/app-page-dispatch.js +37 -51
  107. package/dist/server/app-page-element-builder.d.ts +8 -2
  108. package/dist/server/app-page-element-builder.js +112 -27
  109. package/dist/server/app-page-execution.d.ts +3 -1
  110. package/dist/server/app-page-execution.js +31 -39
  111. package/dist/server/app-page-head.d.ts +54 -2
  112. package/dist/server/app-page-head.js +164 -78
  113. package/dist/server/app-page-http-access-fallback-metadata.d.ts +29 -0
  114. package/dist/server/app-page-http-access-fallback-metadata.js +106 -0
  115. package/dist/server/app-page-render.d.ts +2 -2
  116. package/dist/server/app-page-render.js +1 -1
  117. package/dist/server/app-page-request.d.ts +12 -0
  118. package/dist/server/app-page-request.js +134 -14
  119. package/dist/server/app-page-route-wiring.d.ts +9 -0
  120. package/dist/server/app-page-route-wiring.js +44 -4
  121. package/dist/server/app-post-middleware-context.d.ts +1 -1
  122. package/dist/server/app-post-middleware-context.js +1 -1
  123. package/dist/server/app-route-handler-dispatch.js +31 -17
  124. package/dist/server/app-route-handler-execution.d.ts +6 -1
  125. package/dist/server/app-route-handler-execution.js +41 -15
  126. package/dist/server/app-route-handler-policy.d.ts +2 -0
  127. package/dist/server/app-route-handler-policy.js +3 -3
  128. package/dist/server/app-route-module-loader.d.ts +3 -1
  129. package/dist/server/app-route-module-loader.js +1 -0
  130. package/dist/server/app-route-tree-prefetch.js +1 -1
  131. package/dist/server/app-rsc-cache-busting.d.ts +1 -1
  132. package/dist/server/app-rsc-cache-busting.js +1 -1
  133. package/dist/server/app-rsc-errors.d.ts +1 -1
  134. package/dist/server/app-rsc-errors.js +12 -2
  135. package/dist/server/app-rsc-handler.d.ts +10 -5
  136. package/dist/server/app-rsc-handler.js +51 -23
  137. package/dist/server/app-rsc-redirect-flight.d.ts +66 -0
  138. package/dist/server/app-rsc-redirect-flight.js +71 -0
  139. package/dist/server/app-rsc-request-normalization.d.ts +3 -2
  140. package/dist/server/app-rsc-request-normalization.js +8 -2
  141. package/dist/server/app-rsc-response-finalizer.d.ts +2 -2
  142. package/dist/server/app-rsc-response-finalizer.js +5 -11
  143. package/dist/server/app-rsc-route-matching.d.ts +20 -0
  144. package/dist/server/app-rsc-route-matching.js +87 -11
  145. package/dist/server/app-segment-config.js +15 -5
  146. package/dist/server/app-server-action-execution.d.ts +3 -1
  147. package/dist/server/app-server-action-execution.js +8 -6
  148. package/dist/server/app-ssr-entry.js +4 -1
  149. package/dist/server/app-ssr-stream.d.ts +2 -7
  150. package/dist/server/app-ssr-stream.js +5 -10
  151. package/dist/server/cache-proof.js +1 -1
  152. package/dist/server/config-headers.d.ts +24 -0
  153. package/dist/server/config-headers.js +52 -0
  154. package/dist/server/default-global-error-module.d.ts +3 -1
  155. package/dist/server/default-not-found-module.d.ts +3 -1
  156. package/dist/server/dev-initial-server-error.d.ts +1 -1
  157. package/dist/server/dev-lockfile.js +2 -3
  158. package/dist/server/dev-route-files.js +1 -1
  159. package/dist/server/dev-server.js +281 -173
  160. package/dist/server/dev-stack-sourcemap.js +4 -3
  161. package/dist/server/headers.d.ts +3 -1
  162. package/dist/server/headers.js +3 -1
  163. package/dist/server/image-optimization.js +2 -2
  164. package/dist/server/implicit-tags.js +2 -1
  165. package/dist/server/instrumentation.js +2 -2
  166. package/dist/server/isr-cache.d.ts +1 -1
  167. package/dist/server/isr-cache.js +1 -1
  168. package/dist/server/metadata-routes.js +4 -4
  169. package/dist/server/middleware-matcher-pattern.d.ts +22 -0
  170. package/dist/server/middleware-matcher-pattern.js +219 -0
  171. package/dist/server/middleware-matcher.d.ts +2 -7
  172. package/dist/server/middleware-matcher.js +13 -60
  173. package/dist/server/middleware-path-to-regexp.d.ts +14 -0
  174. package/dist/server/middleware-path-to-regexp.js +228 -0
  175. package/dist/server/middleware-response-headers.js +1 -1
  176. package/dist/server/middleware-runtime.js +5 -4
  177. package/dist/server/middleware.d.ts +2 -1
  178. package/dist/server/middleware.js +3 -2
  179. package/dist/server/navigation-planner.d.ts +2 -0
  180. package/dist/server/navigation-planner.js +8 -2
  181. package/dist/server/next-error-digest.d.ts +9 -24
  182. package/dist/server/next-error-digest.js +23 -15
  183. package/dist/server/operation-token.js +1 -1
  184. package/dist/server/pages-body-parser-config.js +2 -1
  185. package/dist/server/pages-data-route.d.ts +11 -1
  186. package/dist/server/pages-data-route.js +16 -1
  187. package/dist/server/pages-dev-hydration.d.ts +14 -0
  188. package/dist/server/pages-dev-hydration.js +83 -0
  189. package/dist/server/pages-dev-module-url.js +2 -2
  190. package/dist/server/pages-get-initial-props.d.ts +15 -2
  191. package/dist/server/pages-get-initial-props.js +16 -6
  192. package/dist/server/pages-node-compat.d.ts +13 -6
  193. package/dist/server/pages-node-compat.js +44 -45
  194. package/dist/server/pages-page-data.d.ts +4 -2
  195. package/dist/server/pages-page-data.js +20 -10
  196. package/dist/server/pages-page-handler.d.ts +4 -2
  197. package/dist/server/pages-page-handler.js +74 -43
  198. package/dist/server/pages-page-response.d.ts +2 -2
  199. package/dist/server/pages-page-response.js +1 -1
  200. package/dist/server/pages-preview.d.ts +26 -0
  201. package/dist/server/pages-preview.js +165 -0
  202. package/dist/server/pages-readiness.d.ts +5 -4
  203. package/dist/server/pages-readiness.js +4 -2
  204. package/dist/server/pages-request-pipeline.d.ts +1 -0
  205. package/dist/server/pages-request-pipeline.js +25 -11
  206. package/dist/server/pages-router-entry.js +6 -0
  207. package/dist/server/prerender-route-params.js +2 -2
  208. package/dist/server/prod-server.d.ts +1 -4
  209. package/dist/server/prod-server.js +44 -30
  210. package/dist/server/request-pipeline.d.ts +15 -29
  211. package/dist/server/request-pipeline.js +25 -60
  212. package/dist/server/rsc-stream-hints.js +122 -18
  213. package/dist/server/seed-cache.js +1 -1
  214. package/dist/server/socket-error-backstop.js +1 -1
  215. package/dist/server/static-file-cache.js +7 -8
  216. package/dist/server/worker-utils.js +1 -1
  217. package/dist/shims/app.d.ts +1 -1
  218. package/dist/shims/cache-request-state.d.ts +27 -1
  219. package/dist/shims/cache-request-state.js +60 -1
  220. package/dist/shims/cache-runtime.d.ts +12 -1
  221. package/dist/shims/cache-runtime.js +22 -7
  222. package/dist/shims/cache.d.ts +5 -5
  223. package/dist/shims/cache.js +28 -11
  224. package/dist/shims/constants.js +1 -1
  225. package/dist/shims/document.d.ts +42 -83
  226. package/dist/shims/document.js +62 -53
  227. package/dist/shims/dynamic.d.ts +5 -25
  228. package/dist/shims/dynamic.js +29 -8
  229. package/dist/shims/error-boundary.d.ts +4 -4
  230. package/dist/shims/error.d.ts +22 -6
  231. package/dist/shims/error.js +53 -15
  232. package/dist/shims/fetch-cache.js +13 -4
  233. package/dist/shims/font-google-base.d.ts +11 -4
  234. package/dist/shims/font-local.d.ts +10 -3
  235. package/dist/shims/font-utils.js +1 -1
  236. package/dist/shims/form.d.ts +1 -1
  237. package/dist/shims/head.d.ts +13 -2
  238. package/dist/shims/head.js +6 -6
  239. package/dist/shims/headers.d.ts +28 -31
  240. package/dist/shims/headers.js +115 -53
  241. package/dist/shims/image.d.ts +27 -37
  242. package/dist/shims/image.js +21 -14
  243. package/dist/shims/internal/cookie-serialize.d.ts +3 -1
  244. package/dist/shims/internal/cookie-serialize.js +3 -1
  245. package/dist/shims/internal/hybrid-client-route-owner.js +3 -1
  246. package/dist/shims/internal/pages-data-fetch-dedup.js +5 -3
  247. package/dist/shims/internal/utils.d.ts +3 -3
  248. package/dist/shims/layout-segment-context.d.ts +1 -1
  249. package/dist/shims/legacy-image.d.ts +3 -37
  250. package/dist/shims/legacy-image.js +6 -16
  251. package/dist/shims/link.d.ts +16 -21
  252. package/dist/shims/link.js +25 -13
  253. package/dist/shims/navigation-context-state.d.ts +1 -1
  254. package/dist/shims/navigation-errors.d.ts +2 -1
  255. package/dist/shims/navigation-errors.js +9 -13
  256. package/dist/shims/navigation.d.ts +8 -4
  257. package/dist/shims/navigation.js +29 -18
  258. package/dist/shims/next-shims-augmentations.d.ts +1 -0
  259. package/dist/shims/next-shims-public.d.ts +1 -0
  260. package/dist/shims/public-shim-map.json.js +103 -0
  261. package/dist/shims/readonly-url-search-params.d.ts +3 -3
  262. package/dist/shims/readonly-url-search-params.js +3 -3
  263. package/dist/shims/request-state-types.d.ts +1 -1
  264. package/dist/shims/router-state.d.ts +1 -0
  265. package/dist/shims/router.d.ts +57 -22
  266. package/dist/shims/router.js +178 -46
  267. package/dist/shims/script.d.ts +6 -10
  268. package/dist/shims/script.js +7 -4
  269. package/dist/shims/server.d.ts +45 -22
  270. package/dist/shims/server.js +46 -7
  271. package/dist/shims/slot.d.ts +1 -1
  272. package/dist/shims/thenable-params.js +1 -1
  273. package/dist/shims/unified-request-context.d.ts +1 -1
  274. package/dist/shims/unified-request-context.js +2 -0
  275. package/dist/shims/url-safety.d.ts +1 -1
  276. package/dist/shims/url-safety.js +2 -2
  277. package/dist/typegen.d.ts +8 -2
  278. package/dist/typegen.js +84 -25
  279. package/dist/utils/client-build-manifest.js +2 -2
  280. package/dist/utils/client-entry-manifest.js +1 -1
  281. package/dist/utils/client-runtime-metadata.js +1 -1
  282. package/dist/utils/commonjs-loader.js +3 -3
  283. package/dist/utils/domain-locale.d.ts +2 -2
  284. package/dist/utils/external-url.d.ts +5 -0
  285. package/dist/utils/external-url.js +7 -0
  286. package/dist/utils/mdx-scan.js +1 -1
  287. package/dist/utils/path.d.ts +1 -13
  288. package/dist/utils/path.js +1 -15
  289. package/dist/utils/plugin-options.d.ts +4 -0
  290. package/dist/utils/plugin-options.js +8 -0
  291. package/dist/utils/project.d.ts +0 -6
  292. package/dist/utils/project.js +2 -8
  293. package/dist/utils/public-routes.js +2 -2
  294. package/dist/utils/react-version.js +1 -1
  295. package/dist/utils/redirect-digest.d.ts +9 -0
  296. package/dist/utils/redirect-digest.js +25 -0
  297. package/dist/utils/regex-safety.d.ts +8 -0
  298. package/dist/utils/regex-safety.js +737 -0
  299. package/dist/utils/vinext-root.js +1 -1
  300. package/dist/utils/vite-version.d.ts +5 -2
  301. package/dist/utils/vite-version.js +43 -17
  302. package/package.json +16 -4
  303. /package/dist/build/google-fonts/{fallback-metrics-data.js → fallback-metrics-data.json.js} +0 -0
  304. /package/dist/build/google-fonts/{font-data.js → font-data.json.js} +0 -0
  305. /package/dist/{node_modules/.pnpm/process-ancestry@0.1.0/node_modules → deps/.pnpm/process-ancestry@0.1.0/deps}/process-ancestry/dist/index.js +0 -0
package/dist/index.js CHANGED
@@ -1,17 +1,18 @@
1
+ import path, { toSlash } from "./deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { detectPackageManager, formatMissingCloudflarePluginError, hasWranglerConfig } from "./utils/project.js";
2
- import { normalizePathSeparators, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
3
3
  import { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
4
- import { escapeRegExp } from "./utils/regex.js";
5
4
  import { buildViteResolveExtensions, createValidFileMatcher, findFileWithExts, normalizeViteResolveExtensions } from "./routing/file-matcher.js";
5
+ import { hasBasePath, stripBasePath } from "./utils/base-path.js";
6
6
  import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./routing/pages-router.js";
7
7
  import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
8
8
  import { INTERNAL_HEADERS, NEXTJS_DEPLOYMENT_ID_HEADER, VINEXT_INTERNAL_HEADERS, VINEXT_TIMING_HEADER } from "./server/headers.js";
9
9
  import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
10
10
  import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
11
+ import { validateMiddlewareMatcherPatterns } from "./server/middleware-matcher-pattern.js";
11
12
  import { isOpenRedirectShaped } from "./server/open-redirect.js";
12
- import { filterInternalHeaders, normalizeTrailingSlash } from "./server/request-pipeline.js";
13
+ import { canonicalizeRequestUrlPathname, filterInternalHeaders, normalizeTrailingSlash } from "./server/request-pipeline.js";
13
14
  import { findMiddlewareFile, isProxyFile, runMiddleware } from "./server/middleware.js";
14
- import { extractMiddlewareMatcherConfig, hasExportedName } from "./build/report.js";
15
+ import { extractMiddlewareMatcherConfig, extractMiddlewareMatcherConfigValue, hasExportedName } from "./build/report.js";
15
16
  import { generateServerEntry } from "./entries/pages-server-entry.js";
16
17
  import { generateClientEntry } from "./entries/pages-client-entry.js";
17
18
  import { appRouteGraph, appRouter, invalidateAppRouteCache, matchAppRoute } from "./routing/app-router.js";
@@ -19,8 +20,9 @@ import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentat
19
20
  import { isUnknownRecord } from "./utils/record.js";
20
21
  import { logRequest, now } from "./server/request-log.js";
21
22
  import { resolvePagesI18nRequest, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
22
- import { isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname } from "./server/pages-data-route.js";
23
+ import { encodeUrlParserIgnoredCharacters, isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname, urlParserCreatesPagesDataPath } from "./server/pages-data-route.js";
23
24
  import { resolveAssetsDir } from "./utils/asset-prefix.js";
25
+ import { getPagesPreviewModeId } from "./server/pages-preview.js";
24
26
  import { createSSRHandler } from "./server/dev-server.js";
25
27
  import { handleApiRoute } from "./server/api-handler.js";
26
28
  import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath, resolveDevImageRedirect } from "./server/image-optimization.js";
@@ -38,7 +40,7 @@ import { collectRouteClassificationManifest } from "./build/route-classification
38
40
  import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
39
41
  import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
40
42
  import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
41
- import { createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
43
+ import { VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
42
44
  import { mergeServerExternalPackages } from "./config/server-external-packages.js";
43
45
  import { precompressAssets } from "./build/precompress.js";
44
46
  import { ensureAssetsIgnore } from "./build/assets-ignore.js";
@@ -59,6 +61,7 @@ import { createInstrumentationClientTransformPlugin } from "./plugins/instrument
59
61
  import { createStyledJsxPlugin } from "./plugins/styled-jsx.js";
60
62
  import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
61
63
  import { createMiddlewareServerOnlyPlugin } from "./plugins/middleware-server-only.js";
64
+ import { stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
62
65
  import { validateMiddlewareModuleExports } from "./plugins/middleware-export-validation.js";
63
66
  import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
64
67
  import { augmentSsrManifestFromBundle, relativeWithinRoot, tryRealpathSync } from "./build/ssr-manifest.js";
@@ -67,9 +70,12 @@ import { createOgAssetsPlugin, createOgInlineFetchAssetsPlugin } from "./plugins
67
70
  import { generateRouteTypes } from "./typegen.js";
68
71
  import { SSR_EXTERNAL_REACT_ENTRIES, VINEXT_OPTIMIZE_DEPS_EXCLUDE, mergeOptimizeDepsExclude } from "./plugins/rsc-client-shim-excludes.js";
69
72
  import { createServerExternalsManifestPlugin } from "./plugins/server-externals-manifest.js";
73
+ import public_shim_map_default from "./shims/public-shim-map.json.js";
70
74
  import { VINEXT_CLIENT_ENTRY_MANIFEST } from "./utils/client-entry-manifest.js";
71
75
  import { computeClientRuntimeMetadata } from "./utils/client-runtime-metadata.js";
72
76
  import { PAGES_CLIENT_ASSETS_MODULE, buildPagesClientAssetsModule, setPagesClientAssetsBuildMetadata, takePagesClientAssetsBuildMetadata, writePagesClientAssetsModuleIfMissing } from "./build/pages-client-assets-module.js";
77
+ import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
78
+ import { createModuleDependencyCache } from "./build/module-dependency-cache.js";
73
79
  import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
74
80
  import { markCssUrlAssetReferences, restoreDedupedCssAssetReferences } from "./build/css-url-assets.js";
75
81
  import { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter } from "./plugins/sass.js";
@@ -89,10 +95,9 @@ import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGI
89
95
  import { staticExportApp, staticExportPages } from "./build/static-export.js";
90
96
  import { createRequire } from "node:module";
91
97
  import fs from "node:fs";
92
- import path from "node:path";
93
98
  import { createLogger, loadEnv, parseAst, transformWithOxc } from "vite";
94
99
  import { pathToFileURL } from "node:url";
95
- import { createHash, randomBytes, randomUUID } from "node:crypto";
100
+ import { createHash, randomBytes } from "node:crypto";
96
101
  import commonjs from "vite-plugin-commonjs";
97
102
  import MagicString from "magic-string";
98
103
  //#region src/index.ts
@@ -109,10 +114,6 @@ const OPTIONAL_OPTIMIZE_DEPS_WARNING_RE = /Failed to resolve dependency: .*use-s
109
114
  const VINEXT_FILTERED_OPTIMIZE_DEPS_WARN = Symbol.for("vinext.filteredOptimizeDepsWarn");
110
115
  const ANSI_ESCAPE_RE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
111
116
  installSocketErrorBackstop();
112
- function getCacheDirPrefix(cacheDir) {
113
- const normalizedCacheDir = normalizePathSeparators(cacheDir);
114
- return normalizedCacheDir.endsWith("/") ? normalizedCacheDir : `${normalizedCacheDir}/`;
115
- }
116
117
  function isInsideDirectory(dir, filePath) {
117
118
  const relativePath = path.relative(dir, filePath);
118
119
  return relativePath !== "" && !relativePath.startsWith("..") && !path.isAbsolute(relativePath);
@@ -165,21 +166,22 @@ function resolveShimModulePath(shimsDir, moduleName) {
165
166
  ".tsx",
166
167
  ".js"
167
168
  ]) {
168
- const candidate = path.posix.join(shimsDir, `${moduleName}${ext}`);
169
+ const candidate = path.join(shimsDir, `${moduleName}${ext}`);
169
170
  if (fs.existsSync(candidate)) return candidate;
170
171
  }
171
- return path.posix.join(shimsDir, `${moduleName}.js`);
172
+ return path.join(shimsDir, `${moduleName}.js`);
172
173
  }
173
174
  function isVercelOgImport(id) {
174
175
  return id === "@vercel/og" || id === "@vercel/og.js";
175
176
  }
176
177
  function isVinextOgShimImporter(importer) {
177
178
  if (!importer) return false;
178
- const normalizedImporter = (importer.startsWith("\0") ? importer.slice(1) : importer).split("?")[0].replace(/\\/g, "/");
179
+ const cleanImporter = (importer.startsWith("\0") ? importer.slice(1) : importer).split("?")[0];
180
+ const normalizedImporter = toSlash(cleanImporter);
179
181
  return normalizedImporter.endsWith("/shims/og.tsx") || normalizedImporter.endsWith("/shims/og.js") || normalizedImporter.endsWith("/dist/shims/og.js");
180
182
  }
181
183
  function toRelativeFileEntry(root, absPath) {
182
- return path.relative(root, absPath).split(path.sep).join("/");
184
+ return path.relative(root, absPath);
183
185
  }
184
186
  const DEV_PAGES_CLIENT_ENTRY = "/@id/__x00__virtual:vinext-client-entry";
185
187
  const STYLESHEET_IMPORT_RE = /\.(?:css|scss|sass)$/i;
@@ -243,7 +245,7 @@ function isScriptModuleId(id) {
243
245
  return SCRIPT_IMPORT_RE.test(stripViteModuleQuery(id).toLowerCase());
244
246
  }
245
247
  function skipCommonjsForLocalCjs(id) {
246
- const cleanId = normalizePathSeparators(stripViteModuleQuery(id));
248
+ const cleanId = toSlash(stripViteModuleQuery(id));
247
249
  return /\.c[jt]s$/i.test(cleanId) && !cleanId.includes("node_modules") ? false : void 0;
248
250
  }
249
251
  function hasOnlyTypeSpecifiers(statement) {
@@ -255,24 +257,37 @@ function resolvedStylesheetToDevManifestAsset(root, resolvedId) {
255
257
  const rootForRelative = tryRealpathSync(root) ?? root;
256
258
  const fileForRelative = tryRealpathSync(cleanId) ?? cleanId;
257
259
  const relativePath = path.relative(rootForRelative, fileForRelative);
258
- if (relativePath !== "" && !relativePath.startsWith("..") && !path.isAbsolute(relativePath)) return normalizePathSeparators(relativePath);
259
- return `@fs/${normalizePathSeparators(cleanId).replace(/^\/+/, "")}`;
260
+ if (relativePath !== "" && !relativePath.startsWith("..") && !path.isAbsolute(relativePath)) return relativePath;
261
+ return `@fs/${toSlash(cleanId).replace(/^\/+/, "")}`;
260
262
  }
261
- async function collectDevPagesAppStylesheetAssets(root, appFilePath, resolve) {
263
+ async function collectDevPagesAppStylesheetAssets(appFilePath, getModuleDependencies) {
262
264
  const stylesheetAssets = [];
263
265
  const seenAssets = /* @__PURE__ */ new Set();
264
266
  const seenModules = /* @__PURE__ */ new Set();
265
267
  async function visitModule(modulePath) {
268
+ if (seenModules.has(modulePath)) return;
269
+ seenModules.add(modulePath);
270
+ for (const dependency of await getModuleDependencies(modulePath)) if (dependency.type === "stylesheet") {
271
+ if (seenAssets.has(dependency.asset)) continue;
272
+ seenAssets.add(dependency.asset);
273
+ stylesheetAssets.push(dependency.asset);
274
+ } else await visitModule(dependency.id);
275
+ }
276
+ await visitModule(appFilePath);
277
+ return stylesheetAssets;
278
+ }
279
+ function createDevPagesModuleDependencyReader(root, resolve) {
280
+ return createModuleDependencyCache(collectModuleDependencies);
281
+ async function collectModuleDependencies(modulePath) {
266
282
  const cleanModulePath = stripViteModuleQuery(modulePath);
267
- if (!path.isAbsolute(cleanModulePath) || !fs.existsSync(cleanModulePath)) return;
268
- if (seenModules.has(cleanModulePath)) return;
269
- seenModules.add(cleanModulePath);
283
+ if (!path.isAbsolute(cleanModulePath) || !fs.existsSync(cleanModulePath)) return [];
270
284
  let ast;
271
285
  try {
272
286
  ast = parseAst(fs.readFileSync(cleanModulePath, "utf-8"), { lang: parserLanguageForScript(cleanModulePath) });
273
287
  } catch {
274
- return;
288
+ return [];
275
289
  }
290
+ const dependencies = [];
276
291
  for (const statement of ast.body) {
277
292
  if (statement.type !== "ImportDeclaration" && statement.type !== "ExportNamedDeclaration" && statement.type !== "ExportAllDeclaration") continue;
278
293
  if (statement.importKind === "type") continue;
@@ -285,17 +300,17 @@ async function collectDevPagesAppStylesheetAssets(root, appFilePath, resolve) {
285
300
  if (!resolved?.id) continue;
286
301
  if (isStylesheetSpecifier(specifier)) {
287
302
  const asset = resolvedStylesheetToDevManifestAsset(root, resolved.id);
288
- if (!asset || seenAssets.has(asset)) continue;
289
- seenAssets.add(asset);
290
- stylesheetAssets.push(asset);
291
- continue;
292
- }
293
- if (specifier.includes("?") || specifier.includes("#")) continue;
294
- if (isScriptModuleId(resolved.id)) await visitModule(resolved.id);
303
+ if (asset) dependencies.push({
304
+ type: "stylesheet",
305
+ asset
306
+ });
307
+ } else if (!specifier.includes("?") && !specifier.includes("#") && isScriptModuleId(resolved.id)) dependencies.push({
308
+ type: "script",
309
+ id: resolved.id
310
+ });
295
311
  }
312
+ return dependencies;
296
313
  }
297
- await visitModule(appFilePath);
298
- return stylesheetAssets;
299
314
  }
300
315
  const TSCONFIG_FILES = ["tsconfig.json", "jsconfig.json"];
301
316
  function resolveTsconfigPathCandidate(candidate) {
@@ -353,11 +368,11 @@ function materializeTsconfigPathAliases(pathsConfig, baseUrl, projectRoot) {
353
368
  return aliases;
354
369
  }
355
370
  function toViteAliasReplacement(absolutePath, projectRoot) {
356
- const normalizedPath = absolutePath.replace(/\\/g, "/");
357
- const rootCandidates = new Set([projectRoot]);
371
+ const normalizedPath = toSlash(absolutePath);
372
+ const rootCandidates = /* @__PURE__ */ new Set([projectRoot]);
358
373
  const realRoot = tryRealpathSync(projectRoot);
359
374
  if (realRoot) rootCandidates.add(realRoot);
360
- const pathCandidates = new Set([absolutePath]);
375
+ const pathCandidates = /* @__PURE__ */ new Set([absolutePath]);
361
376
  const realPath = tryRealpathSync(absolutePath);
362
377
  if (realPath) pathCandidates.add(realPath);
363
378
  for (const rootCandidate of rootCandidates) for (const pathCandidate of pathCandidates) {
@@ -378,7 +393,7 @@ function resolveSwcHelpersAlias(root) {
378
393
  resolvers.push(rootRequire, createRequire(import.meta.url));
379
394
  for (const resolver of resolvers) try {
380
395
  const packageJsonPath = resolver.resolve("@swc/helpers/package.json");
381
- return normalizePathSeparators(path.join(path.dirname(packageJsonPath), "_"));
396
+ return path.join(path.dirname(packageJsonPath), "_");
382
397
  } catch {}
383
398
  }
384
399
  function loadTsconfigPathAliases(configPath, projectRoot, seen = /* @__PURE__ */ new Set()) {
@@ -432,7 +447,7 @@ function getVinextVersion() {
432
447
  return _vinextVersionCache;
433
448
  }
434
449
  function mergeStringArrayValues(value, additions) {
435
- return [...new Set([...value === void 0 ? [] : Array.isArray(value) ? value : [value], ...additions])];
450
+ return [.../* @__PURE__ */ new Set([...value === void 0 ? [] : Array.isArray(value) ? value : [value], ...additions])];
436
451
  }
437
452
  function stripAnsi(value) {
438
453
  return value.replace(ANSI_ESCAPE_RE, "");
@@ -579,14 +594,14 @@ function createStaticImageAsset(imagePath) {
579
594
  };
580
595
  }
581
596
  /**
582
- * Absolute path to vinext's shims directory, with a trailing slash. Normalized
583
- * to forward slashes because it is prefix-matched against Vite module ids (which
584
- * Vite always normalizes to forward slashes) in the font plugins and
585
- * clientManualChunks a raw path.resolve value has backslashes on Windows and
586
- * the `id.startsWith(_shimsDir)` checks would never match.
597
+ * Absolute path to vinext's shims directory, with a trailing slash. Forward
598
+ * slashes are guaranteed by pathslash's `path.resolve`, matching the Vite
599
+ * module ids (always forward-slash) that the `id.startsWith(_shimsDir)`
600
+ * prefix checks in the font plugins and clientManualChunks compare against.
601
+ * The trailing "/" keeps those prefix checks directory-exact.
587
602
  */
588
- const _shimsDir = normalizePathSeparators(path.resolve(__dirname, "shims")) + "/";
589
- const _serverDir = normalizePathSeparators(path.resolve(__dirname, "server"));
603
+ const _shimsDir = path.resolve(__dirname, "shims") + "/";
604
+ const _serverDir = path.resolve(__dirname, "server");
590
605
  const _fontGoogleShimPath = resolveShimModulePath(_shimsDir, "font-google");
591
606
  const _appBrowserServerActionClientPath = resolveShimModulePath(_serverDir, "app-browser-server-action-client");
592
607
  const _appRscHandlerPath = resolveShimModulePath(_serverDir, "app-rsc-handler");
@@ -597,8 +612,8 @@ function isValidExportIdentifier(name) {
597
612
  }
598
613
  function isVirtualEntryFacade(id, virtualId) {
599
614
  if (!id) return false;
600
- const cleanId = id.startsWith("\0") ? id.slice(1) : id;
601
- return cleanId === virtualId || cleanId.endsWith("/" + virtualId) || cleanId.endsWith("\\" + virtualId);
615
+ const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
616
+ return cleanId === virtualId || cleanId.endsWith("/" + virtualId);
602
617
  }
603
618
  /**
604
619
  * Returns the leading React `"use client"` or `"use server"` directive after
@@ -655,27 +670,14 @@ function generateRootParamsModule(rootParamNames) {
655
670
  const exports = names.map((name) => `export function ${name}() { return getRootParam(${JSON.stringify(name)}); }`).join("\n");
656
671
  return `import { getRootParam } from ${JSON.stringify(rootParamsShimPath)};\n${exports}\n`;
657
672
  }
658
- /**
659
- * Shims with a `.react-server.ts` variant for the RSC environment.
660
- * Maps import specifier base shim name. In the RSC env, resolveId
661
- * appends `.react-server`; in other envs it resolves to the base.
662
- *
663
- * These MUST NOT appear in `nextShimMap` (resolve.alias) because Vite's
664
- * alias plugin runs before user `enforce:"pre"` plugins — aliases are
665
- * unoverridable. Keeping them out of the alias lets the resolveId hook
666
- * control resolution per-environment.
667
- *
668
- * To add a new react-server shim:
669
- * 1. Create `<name>.react-server.ts` in src/shims/
670
- * 2. Add entries here for each import specifier.
671
- */
672
- const _reactServerShims = new Map([
673
- ["next/navigation", "navigation"],
674
- ["next/navigation.js", "navigation"],
675
- ["next/dist/client/components/navigation", "navigation"],
676
- ["next/error", "error"],
677
- ["next/error.js", "error"]
678
- ]);
673
+ const _publicNextShimMap = public_shim_map_default;
674
+ const _reactServerShims = /* @__PURE__ */ new Map();
675
+ for (const [specifier, definition] of Object.entries(_publicNextShimMap)) {
676
+ if (!definition.reactServer) continue;
677
+ _reactServerShims.set(specifier, definition.shim);
678
+ _reactServerShims.set(`${specifier}.js`, definition.shim);
679
+ }
680
+ _reactServerShims.set("next/dist/client/components/navigation", "navigation");
679
681
  const clientCodeSplittingConfig = createClientCodeSplittingConfig(createClientManualChunks(_shimsDir));
680
682
  const appClientCodeSplittingConfig = createClientCodeSplittingConfig(createClientManualChunks(_shimsDir, true));
681
683
  function getClientOutputConfig(assetsDir, preserveAppRouteBoundaries = false) {
@@ -687,7 +689,7 @@ function getClientOutputConfig(assetsDir, preserveAppRouteBoundaries = false) {
687
689
  };
688
690
  }
689
691
  function vinext(options = {}) {
690
- assertSupportedViteVersion();
692
+ const { supportsNativeTypeofWindowFolding: useNativeTypeofWindowFolding } = assertSupportedViteVersion();
691
693
  const prerenderConfig = normalizeVinextPrerenderConfig(options.prerender);
692
694
  let root;
693
695
  let pagesDir;
@@ -706,17 +708,18 @@ function vinext(options = {}) {
706
708
  let hasCloudflarePlugin = false;
707
709
  let warnedInlineNextConfigOverride = false;
708
710
  let hasNitroPlugin = false;
711
+ let nitroTraceDepsFromServerExternals = [];
709
712
  let isServeCommand = false;
710
713
  let pagesOptimizeEntries = [];
711
714
  const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
712
715
  let pagesClientAssetsModule = null;
713
716
  let rscCompatibilityId;
714
- const draftModeSecret = randomUUID();
717
+ let draftModeSecret = getPagesPreviewModeId();
718
+ let previewBuildCredentials;
715
719
  const sassComposesLoader = createSassAwareFileSystemLoader();
716
- const typeofWindowIdFilter = { exclude: /(?!)/ };
717
720
  let rscClassificationManifest = null;
718
- const shimsDir = normalizePathSeparators(path.resolve(__dirname, "shims"));
719
- const canonicalize = (p) => normalizePathSeparators(tryRealpathSync(p) ?? p);
721
+ const shimsDir = path.resolve(__dirname, "shims");
722
+ const canonicalize = (p) => toSlash(tryRealpathSync(p) ?? p);
720
723
  const pageTransformCanonicalPaths = /* @__PURE__ */ new Map();
721
724
  const canonicalizePageTransformPath = (modulePath) => {
722
725
  const cached = pageTransformCanonicalPaths.get(modulePath);
@@ -761,10 +764,9 @@ function vinext(options = {}) {
761
764
  });
762
765
  }
763
766
  async function writeRouteTypes() {
764
- if (!hasAppDir) return;
765
767
  await generateRouteTypes({
766
768
  root,
767
- appDir,
769
+ appDir: hasAppDir ? appDir : null,
768
770
  pageExtensions: nextConfig.pageExtensions
769
771
  });
770
772
  }
@@ -801,11 +803,32 @@ function vinext(options = {}) {
801
803
  if (!pluginApi || pluginApi.manager.isScanBuild) return true;
802
804
  return Object.keys(pluginApi.manager.serverReferenceMetaMap).length > 0;
803
805
  }
804
- const reactOptions = options.react && options.react !== true ? options.react : void 0;
806
+ const configuredReactOptions = options.react && options.react !== true ? options.react : void 0;
807
+ const reactOptions = configuredReactOptions;
805
808
  let reactPluginPromise = null;
806
809
  if (options.react !== false) {
807
810
  if (!resolvedReactPath) throw new Error("vinext: @vitejs/plugin-react is not installed.\nRun: " + detectPackageManager(process.cwd()) + " @vitejs/plugin-react");
808
- reactPluginPromise = import(pathToFileURL(resolvedReactPath).href).then((mod) => mod.default(reactOptions)).catch((cause) => {
811
+ reactPluginPromise = import(pathToFileURL(resolvedReactPath).href).then((mod) => {
812
+ const react = mod.default;
813
+ const limitToCommand = (plugin, command) => {
814
+ const originalApply = plugin.apply;
815
+ return {
816
+ ...plugin,
817
+ apply(config, env) {
818
+ if (env.command !== command) return false;
819
+ if (!originalApply) return true;
820
+ if (typeof originalApply === "function") return originalApply(config, env);
821
+ return originalApply === env.command;
822
+ }
823
+ };
824
+ };
825
+ const buildPlugins = react(reactOptions).map((plugin) => limitToCommand(plugin, "build"));
826
+ const servePlugins = react(configuredReactOptions !== void 0 && Object.prototype.hasOwnProperty.call(configuredReactOptions, "include") ? reactOptions : {
827
+ ...reactOptions,
828
+ include: /\.(?:[tj]sx?|mdx)$/i
829
+ }).map((plugin) => limitToCommand(plugin, "serve"));
830
+ return [...buildPlugins, ...servePlugins];
831
+ }).catch((cause) => {
809
832
  throw new Error("vinext: Failed to load @vitejs/plugin-react.", { cause });
810
833
  });
811
834
  }
@@ -845,8 +868,36 @@ function vinext(options = {}) {
845
868
  })();
846
869
  return mdxDelegatePromise;
847
870
  }
871
+ const mdxProxyPlugin = {
872
+ name: "vinext:mdx",
873
+ enforce: "pre",
874
+ transform: {
875
+ filter: { id: {
876
+ include: /\.mdx$/i,
877
+ exclude: /\?/
878
+ } },
879
+ async handler(code, id, options) {
880
+ const delegate = mdxDelegate ?? await ensureMdxDelegate("on-demand");
881
+ if (delegate?.transform) {
882
+ const hook = delegate.transform;
883
+ return (typeof hook === "function" ? hook : hook.handler).call(this, code, id, options);
884
+ }
885
+ if (!hasUserMdxPlugin) throw new Error(`[vinext] Encountered MDX module ${id} but no MDX plugin is configured. Install @mdx-js/rollup or register an MDX plugin manually.`);
886
+ }
887
+ }
888
+ };
889
+ const mdxConfigProxyPlugin = {
890
+ name: "vinext:mdx-config",
891
+ enforce: "pre",
892
+ config(config, env) {
893
+ if (!mdxDelegate?.config) return;
894
+ const hook = mdxDelegate.config;
895
+ return (typeof hook === "function" ? hook : hook.handler).call(this, config, env);
896
+ }
897
+ };
848
898
  const plugins = [
849
899
  createStyledJsxPlugin(earlyBaseDir),
900
+ mdxProxyPlugin,
850
901
  reactPluginPromise,
851
902
  createIgnoreDynamicRequestsPlugin(() => nextConfig?.turbopackTranspilePackages ?? []),
852
903
  commonjs({ filter: skipCommonjsForLocalCjs }),
@@ -860,7 +911,7 @@ function vinext(options = {}) {
860
911
  code: /\.(?:css|scss|sass)['"]/
861
912
  },
862
913
  handler(code, id) {
863
- const cleanId = normalizePathSeparators(stripViteModuleQuery(id));
914
+ const cleanId = toSlash(stripViteModuleQuery(id));
864
915
  if (!globalNotFoundCssIsolationPath || canonicalize(cleanId) !== canonicalize(globalNotFoundCssIsolationPath)) return null;
865
916
  return isolateGlobalNotFoundStylesheetImports(code, cleanId);
866
917
  }
@@ -905,6 +956,7 @@ function vinext(options = {}) {
905
956
  name: "vinext:config",
906
957
  enforce: "pre",
907
958
  [VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY]: prerenderConfig,
959
+ [VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY]: options.nextConfig ?? null,
908
960
  [VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY]: {
909
961
  appDir: options.appDir,
910
962
  disableAppRouter: options.disableAppRouter,
@@ -914,7 +966,7 @@ function vinext(options = {}) {
914
966
  [VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY]: options.cache ?? null,
915
967
  async config(config, env) {
916
968
  isServeCommand = env.command === "serve";
917
- root = normalizePathSeparators(config.root ?? process.cwd());
969
+ root = toSlash(config.root ?? process.cwd());
918
970
  const shouldEnableNativeTsconfigPaths = config.resolve?.tsconfigPaths === void 0;
919
971
  const tsconfigPathAliases = resolveTsconfigAliases(root);
920
972
  const swcHelpersAlias = resolveSwcHelpersAlias(root);
@@ -926,23 +978,27 @@ function vinext(options = {}) {
926
978
  if (mode === "test") resolvedNodeEnv = "test";
927
979
  else if (env?.command === "build" || env?.isPreview === true) resolvedNodeEnv = "production";
928
980
  else resolvedNodeEnv = "development";
929
- if (process.env.NODE_ENV !== resolvedNodeEnv) process.env.NODE_ENV = resolvedNodeEnv;
981
+ if (process.env.NODE_ENV !== resolvedNodeEnv) Reflect.set(process.env, "NODE_ENV", resolvedNodeEnv);
982
+ if (env?.command === "build") previewBuildCredentials = getPreviewBuildCredentials() ?? createPreviewBuildCredentials();
983
+ draftModeSecret = previewBuildCredentials?.id ?? getPagesPreviewModeId();
930
984
  let baseDir;
931
- if (options.appDir) baseDir = normalizePathSeparators(path.isAbsolute(options.appDir) ? options.appDir : path.resolve(root, options.appDir));
985
+ if (options.appDir) baseDir = toSlash(path.isAbsolute(options.appDir) ? options.appDir : path.resolve(root, options.appDir));
932
986
  else {
933
- const hasRootApp = fs.existsSync(path.posix.join(root, "app"));
934
- const hasRootPages = fs.existsSync(path.posix.join(root, "pages"));
935
- const hasSrcApp = fs.existsSync(path.posix.join(root, "src", "app"));
936
- const hasSrcPages = fs.existsSync(path.posix.join(root, "src", "pages"));
987
+ const hasRootApp = fs.existsSync(path.join(root, "app"));
988
+ const hasRootPages = fs.existsSync(path.join(root, "pages"));
989
+ const hasSrcApp = fs.existsSync(path.join(root, "src", "app"));
990
+ const hasSrcPages = fs.existsSync(path.join(root, "src", "pages"));
937
991
  if (hasRootApp || hasRootPages) baseDir = root;
938
- else if (hasSrcApp || hasSrcPages) baseDir = path.posix.join(root, "src");
992
+ else if (hasSrcApp || hasSrcPages) baseDir = path.join(root, "src");
939
993
  else baseDir = root;
940
994
  }
941
- pagesDir = path.posix.join(baseDir, "pages");
995
+ pagesDir = path.join(baseDir, "pages");
942
996
  canonicalPagesDir = canonicalize(pagesDir);
943
- appDir = path.posix.join(baseDir, "app");
997
+ appDir = path.join(baseDir, "app");
944
998
  hasPagesDir = fs.existsSync(pagesDir);
945
999
  hasAppDir = !options.disableAppRouter && fs.existsSync(appDir);
1000
+ invalidateRouteCache(pagesDir);
1001
+ invalidateAppRouteCache();
946
1002
  if (!nextConfig) {
947
1003
  const phase = env?.command === "build" ? PHASE_PRODUCTION_BUILD : PHASE_DEVELOPMENT_SERVER;
948
1004
  let rawConfig;
@@ -969,8 +1025,12 @@ function vinext(options = {}) {
969
1025
  globalNotFoundCssIsolationPath = env?.command === "build" && nextConfig.globalNotFound ? findFileWithExts(appDir, "global-not-found", fileMatcher) : null;
970
1026
  instrumentationPath = findInstrumentationFile(root, fileMatcher);
971
1027
  instrumentationClientPath = findInstrumentationClientFile(root, fileMatcher);
972
- const middlewareConventionDir = canonicalize(baseDir) === canonicalize(path.posix.join(root, "src")) ? path.posix.join(root, "src") : root;
1028
+ const middlewareConventionDir = canonicalize(baseDir) === canonicalize(path.join(root, "src")) ? path.join(root, "src") : root;
973
1029
  middlewarePath = findMiddlewareFile(root, fileMatcher, middlewareConventionDir);
1030
+ if (middlewarePath) {
1031
+ const staticMatcher = extractMiddlewareMatcherConfigValue(middlewarePath);
1032
+ if (staticMatcher !== void 0) validateMiddlewareMatcherPatterns(staticMatcher);
1033
+ }
974
1034
  const instrumentationClientInjects = nextConfig.instrumentationClientInject.map((spec) => spec.startsWith("./") || spec.startsWith("../") ? path.resolve(root, spec) : spec);
975
1035
  clientInjectModule = instrumentationClientInjects.length ? generateInstrumentationClientInjectModule(instrumentationClientInjects, instrumentationClientPath, INSTRUMENTATION_CLIENT_EMPTY_MODULE) : null;
976
1036
  if (env?.command === "build") await writeRouteTypes();
@@ -985,6 +1045,10 @@ function vinext(options = {}) {
985
1045
  }
986
1046
  defines["process.env.__NEXT_ROUTER_BASEPATH"] = JSON.stringify(nextConfig.basePath);
987
1047
  defines["process.env.__VINEXT_HAS_PAGES_ROUTER"] = JSON.stringify(String(hasPagesDir));
1048
+ defines["process.env.__VINEXT_HAS_CLIENT_REWRITES"] = JSON.stringify(String(nextConfig.rewrites.beforeFiles.length > 0 || nextConfig.rewrites.afterFiles.length > 0 || nextConfig.rewrites.fallback.length > 0));
1049
+ defines["process.env.__VINEXT_HAS_CONFIG_HEADERS"] = JSON.stringify(String(nextConfig.headers.length > 0));
1050
+ defines["process.env.__VINEXT_HAS_CONFIG_REDIRECTS"] = JSON.stringify(String(nextConfig.redirects.length > 0));
1051
+ defines["process.env.__VINEXT_HAS_CONFIG_REWRITES"] = JSON.stringify(String(nextConfig.rewrites.beforeFiles.length > 0 || nextConfig.rewrites.afterFiles.length > 0 || nextConfig.rewrites.fallback.length > 0));
988
1052
  defines["process.env.__NEXT_CLIENT_ROUTER_DYNAMIC_STALETIME"] = JSON.stringify(String(nextConfig.staleTimes.dynamic));
989
1053
  defines["process.env.__NEXT_CLIENT_ROUTER_STATIC_STALETIME"] = JSON.stringify(String(nextConfig.staleTimes.static));
990
1054
  defines["process.env.__VINEXT_PREFETCH_INLINING"] = JSON.stringify(nextConfig.prefetchInlining ? "true" : "false");
@@ -1036,55 +1100,34 @@ function vinext(options = {}) {
1036
1100
  }
1037
1101
  for (const key of Object.keys(nextConfig.compilerDefineServer)) if (key in defines) throw new Error(`The \`compiler.defineServer\` option is configured to replace the \`${key}\` variable. This variable is either part of a built-in or is already configured.`);
1038
1102
  nextShimMap = Object.fromEntries(Object.entries({
1039
- "next/link": path.posix.join(shimsDir, "link"),
1040
- "next/head": path.posix.join(shimsDir, "head"),
1041
- "next/router": path.posix.join(shimsDir, "router"),
1042
- "next/compat/router": path.posix.join(shimsDir, "compat-router"),
1043
- "next/image": path.posix.join(shimsDir, "image"),
1044
- "next/legacy/image": path.posix.join(shimsDir, "legacy-image"),
1045
- "next/dynamic": path.posix.join(shimsDir, "dynamic"),
1046
- "next/app": path.posix.join(shimsDir, "app"),
1047
- "next/document": path.posix.join(shimsDir, "document"),
1048
- "next/config": path.posix.join(shimsDir, "config"),
1049
- "next/script": path.posix.join(shimsDir, "script"),
1050
- "next/server": path.posix.join(shimsDir, "server"),
1051
- "next/headers": path.posix.join(shimsDir, "headers"),
1052
- "next/font/google": path.posix.join(shimsDir, "font-google"),
1053
- "next/font/local": path.posix.join(shimsDir, "font-local"),
1054
- "next/cache": path.posix.join(shimsDir, "cache"),
1055
- "next/form": path.posix.join(shimsDir, "form"),
1056
- "next/og": path.posix.join(shimsDir, "og"),
1057
- "next/web-vitals": path.posix.join(shimsDir, "web-vitals"),
1058
- "next/amp": path.posix.join(shimsDir, "amp"),
1059
- "next/offline": path.posix.join(shimsDir, "offline"),
1060
- "next/constants": path.posix.join(shimsDir, "constants"),
1061
- "next/dist/shared/lib/app-router-context.shared-runtime": path.posix.join(shimsDir, "internal", "app-router-context"),
1062
- "next/dist/shared/lib/app-router-context": path.posix.join(shimsDir, "internal", "app-router-context"),
1063
- "next/dist/shared/lib/router-context.shared-runtime": path.posix.join(shimsDir, "internal", "router-context"),
1064
- "next/dist/shared/lib/utils": path.posix.join(shimsDir, "internal", "utils"),
1065
- "next/dist/server/api-utils": path.posix.join(shimsDir, "internal", "api-utils"),
1066
- "next/dist/server/web/spec-extension/cookies": path.posix.join(shimsDir, "internal", "cookies"),
1067
- "next/dist/compiled/@edge-runtime/cookies": path.posix.join(shimsDir, "internal", "cookies"),
1068
- "next/dist/server/app-render/work-unit-async-storage.external": path.posix.join(shimsDir, "internal", "work-unit-async-storage"),
1069
- "next/dist/client/components/work-unit-async-storage.external": path.posix.join(shimsDir, "internal", "work-unit-async-storage"),
1070
- "next/dist/client/components/request-async-storage.external": path.posix.join(shimsDir, "internal", "work-unit-async-storage"),
1071
- "next/dist/client/components/request-async-storage": path.posix.join(shimsDir, "internal", "work-unit-async-storage"),
1072
- "next/dist/server/request/root-params": path.posix.join(shimsDir, "root-params"),
1073
- "next/dist/server/config-shared": path.posix.join(shimsDir, "internal", "utils"),
1074
- "server-only": path.posix.join(shimsDir, "server-only"),
1075
- "client-only": path.posix.join(shimsDir, "client-only"),
1076
- "vinext/error-boundary": path.posix.join(shimsDir, "error-boundary"),
1077
- "vinext/layout-segment-context": path.posix.join(shimsDir, "layout-segment-context"),
1078
- "vinext/metadata": path.posix.join(shimsDir, "metadata"),
1079
- "vinext/fetch-cache": path.posix.join(shimsDir, "fetch-cache"),
1080
- "vinext/cache-runtime": path.posix.join(shimsDir, "cache-runtime"),
1081
- "vinext/navigation-state": path.posix.join(shimsDir, "navigation-state"),
1082
- "vinext/unified-request-context": path.posix.join(shimsDir, "unified-request-context"),
1083
- "vinext/pages-router-runtime": path.posix.join(shimsDir, "pages-router-runtime"),
1084
- "vinext/router-state": path.posix.join(shimsDir, "router-state"),
1085
- "vinext/head-state": path.posix.join(shimsDir, "head-state"),
1086
- "vinext/i18n-state": path.posix.join(shimsDir, "i18n-state"),
1087
- "vinext/i18n-context": path.posix.join(shimsDir, "i18n-context"),
1103
+ ...Object.fromEntries(Object.entries(_publicNextShimMap).filter(([, definition]) => !definition.reactServer).map(([specifier, definition]) => [specifier, path.join(shimsDir, definition.shim)])),
1104
+ "next/dist/shared/lib/app-router-context.shared-runtime": path.join(shimsDir, "internal", "app-router-context"),
1105
+ "next/dist/shared/lib/app-router-context": path.join(shimsDir, "internal", "app-router-context"),
1106
+ "next/dist/shared/lib/router-context.shared-runtime": path.join(shimsDir, "internal", "router-context"),
1107
+ "next/dist/shared/lib/utils": path.join(shimsDir, "internal", "utils"),
1108
+ "next/dist/server/api-utils": path.join(shimsDir, "internal", "api-utils"),
1109
+ "next/dist/server/web/spec-extension/cookies": path.join(shimsDir, "internal", "cookies"),
1110
+ "next/dist/compiled/@edge-runtime/cookies": path.join(shimsDir, "internal", "cookies"),
1111
+ "next/dist/server/app-render/work-unit-async-storage.external": path.join(shimsDir, "internal", "work-unit-async-storage"),
1112
+ "next/dist/client/components/work-unit-async-storage.external": path.join(shimsDir, "internal", "work-unit-async-storage"),
1113
+ "next/dist/client/components/request-async-storage.external": path.join(shimsDir, "internal", "work-unit-async-storage"),
1114
+ "next/dist/client/components/request-async-storage": path.join(shimsDir, "internal", "work-unit-async-storage"),
1115
+ "next/dist/server/request/root-params": path.join(shimsDir, "root-params"),
1116
+ "next/dist/server/config-shared": path.join(shimsDir, "internal", "utils"),
1117
+ "server-only": path.join(shimsDir, "server-only"),
1118
+ "client-only": path.join(shimsDir, "client-only"),
1119
+ "vinext/error-boundary": path.join(shimsDir, "error-boundary"),
1120
+ "vinext/layout-segment-context": path.join(shimsDir, "layout-segment-context"),
1121
+ "vinext/metadata": path.join(shimsDir, "metadata"),
1122
+ "vinext/fetch-cache": path.join(shimsDir, "fetch-cache"),
1123
+ "vinext/cache-runtime": path.join(shimsDir, "cache-runtime"),
1124
+ "vinext/navigation-state": path.join(shimsDir, "navigation-state"),
1125
+ "vinext/unified-request-context": path.join(shimsDir, "unified-request-context"),
1126
+ "vinext/pages-router-runtime": path.join(shimsDir, "pages-router-runtime"),
1127
+ "vinext/router-state": path.join(shimsDir, "router-state"),
1128
+ "vinext/head-state": path.join(shimsDir, "head-state"),
1129
+ "vinext/i18n-state": path.join(shimsDir, "i18n-state"),
1130
+ "vinext/i18n-context": path.join(shimsDir, "i18n-context"),
1088
1131
  "vinext/cache": path.resolve(__dirname, "cache"),
1089
1132
  "vinext/instrumentation": path.resolve(__dirname, "server", "instrumentation"),
1090
1133
  "vinext/instrumentation-client": path.resolve(__dirname, "client", "instrumentation-client"),
@@ -1108,6 +1151,7 @@ function vinext(options = {}) {
1108
1151
  const isSSR = !!config.build?.ssr;
1109
1152
  const serverTranspilePackages = [...nextConfig?.turbopackTranspilePackages ?? [], ...nextConfig?.optimizePackageImports ?? []];
1110
1153
  const nextServerExternal = mergeServerExternalPackages(nextConfig?.serverExternalPackages, serverTranspilePackages);
1154
+ nitroTraceDepsFromServerExternals = nextServerExternal;
1111
1155
  const isMultiEnv = hasAppDir || hasCloudflarePlugin || hasNitroPlugin;
1112
1156
  const hasBuildInput = getBuildBundlerOptions(config.build)?.input !== void 0;
1113
1157
  const shouldInjectPlainPagesEnvironments = !hasAppDir && !hasCloudflarePlugin && !isSSR && !hasBuildInput;
@@ -1245,7 +1289,7 @@ function vinext(options = {}) {
1245
1289
  if (hasAppDir) {
1246
1290
  const appEntries = [`${path.relative(root, appDir)}/**/*.{tsx,ts,jsx,js}`];
1247
1291
  const explicitInstrumentationEntries = [instrumentationPath, instrumentationClientPath].flatMap((entry) => entry ? [toRelativeFileEntry(root, entry)] : []);
1248
- const optimizeEntries = [...new Set([...appEntries, ...explicitInstrumentationEntries])];
1292
+ const optimizeEntries = [.../* @__PURE__ */ new Set([...appEntries, ...explicitInstrumentationEntries])];
1249
1293
  const appClientInput = { index: VIRTUAL_APP_BROWSER_ENTRY };
1250
1294
  if (hasPagesDir) appClientInput["vinext-client-entry"] = VIRTUAL_CLIENT_ENTRY;
1251
1295
  viteConfig.environments = {
@@ -1263,7 +1307,7 @@ function vinext(options = {}) {
1263
1307
  optimizeDeps: {
1264
1308
  exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE),
1265
1309
  entries: optimizeEntries,
1266
- include: [...new Set([...incomingInclude, "react-server-dom-webpack/static.edge"])],
1310
+ include: [.../* @__PURE__ */ new Set([...incomingInclude, "react-server-dom-webpack/static.edge"])],
1267
1311
  ...depOptimizeNodeEnvOptions
1268
1312
  },
1269
1313
  build: {
@@ -1298,7 +1342,7 @@ function vinext(options = {}) {
1298
1342
  optimizeDeps: {
1299
1343
  exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, nextServerExternal),
1300
1344
  entries: optimizeEntries,
1301
- include: [...new Set([
1345
+ include: [.../* @__PURE__ */ new Set([
1302
1346
  ...incomingInclude,
1303
1347
  "react",
1304
1348
  "react-dom",
@@ -1394,14 +1438,12 @@ function vinext(options = {}) {
1394
1438
  config.optimizeDeps.exclude = mergeOptimizeDepsExclude(config.optimizeDeps.exclude ?? [], VINEXT_OPTIMIZE_DEPS_EXCLUDE, PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_EXCLUDE);
1395
1439
  }
1396
1440
  const configuredExtensions = name === "client" ? nextConfig.resolveExtensions : nextConfig.serverResolveExtensions;
1397
- const extensions = configuredExtensions === null ? buildViteResolveExtensions(nextConfig.pageExtensions, config.resolve?.extensions) : normalizeViteResolveExtensions(configuredExtensions);
1441
+ const extensions = configuredExtensions === null ? buildViteResolveExtensions(config.resolve?.extensions) : normalizeViteResolveExtensions(configuredExtensions);
1398
1442
  config.resolve ??= {};
1399
1443
  config.resolve.extensions = extensions;
1400
1444
  return null;
1401
1445
  },
1402
1446
  async configResolved(config) {
1403
- const cacheDirPrefix = getCacheDirPrefix(config.cacheDir);
1404
- typeofWindowIdFilter.exclude = new RegExp(`^${escapeRegExp(cacheDirPrefix)}`);
1405
1447
  if (isServeCommand && hasCloudflarePlugin && hasPagesDir && !hasAppDir) suppressOptionalOptimizeDepsWarnings(config.logger);
1406
1448
  sassComposesLoader.setResolvedConfig(config);
1407
1449
  if (config.command === "build" && hasAppDir && hasPagesDir) {
@@ -1441,7 +1483,7 @@ function vinext(options = {}) {
1441
1483
  resolveId: {
1442
1484
  filter: { id: /(?:next\/|vinext\/(?:shims\/|server\/app-rsc-handler)|virtual:vinext-|@vercel\/og(?:\.js)?$)/ },
1443
1485
  handler(id, importer) {
1444
- const cleanId = normalizePathSeparators(id.startsWith("\0") ? id.slice(1) : id);
1486
+ const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
1445
1487
  if (cleanId === "vinext/server/app-rsc-handler") {
1446
1488
  if (_canExternalizeAppRscHandler && this.environment?.name === "rsc" && this.environment.config?.command === "serve") return {
1447
1489
  id: _appRscHandlerPath,
@@ -1473,7 +1515,10 @@ function vinext(options = {}) {
1473
1515
  return RESOLVED_VIRTUAL_GOOGLE_FONTS + cleanId.slice(queryIndex + VIRTUAL_GOOGLE_FONTS.length);
1474
1516
  }
1475
1517
  const reactServerShim = _reactServerShims.get(cleanId);
1476
- if (reactServerShim !== void 0) return resolveShimModulePath(_shimsDir, this.environment?.name === "rsc" ? `${reactServerShim}.react-server` : reactServerShim);
1518
+ if (reactServerShim !== void 0) {
1519
+ const shimName = this.environment?.name === "rsc" ? `${reactServerShim}.react-server` : reactServerShim;
1520
+ return resolveShimModulePath(_shimsDir, shimName);
1521
+ }
1477
1522
  }
1478
1523
  },
1479
1524
  load: {
@@ -1488,9 +1533,10 @@ function vinext(options = {}) {
1488
1533
  const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
1489
1534
  const pagesRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
1490
1535
  const moduleFilePaths = [...appFilePath ? [appFilePath] : [], ...pagesRoutes.map((route) => route.filePath)];
1536
+ const getModuleDependencies = createDevPagesModuleDependencyReader(root, this.resolve.bind(this));
1491
1537
  for (const moduleFilePath of moduleFilePaths) {
1492
- const stylesheetAssets = await collectDevPagesAppStylesheetAssets(root, moduleFilePath, this.resolve.bind(this));
1493
- if (stylesheetAssets.length > 0) ssrManifest[normalizePathSeparators(moduleFilePath)] = stylesheetAssets;
1538
+ const stylesheetAssets = await collectDevPagesAppStylesheetAssets(moduleFilePath, getModuleDependencies);
1539
+ if (stylesheetAssets.length > 0) ssrManifest[toSlash(moduleFilePath)] = stylesheetAssets;
1494
1540
  }
1495
1541
  if (Object.keys(ssrManifest).length > 0) metadata.ssrManifest = ssrManifest;
1496
1542
  return `export default ${JSON.stringify(metadata)};`;
@@ -1606,13 +1652,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1606
1652
  resolveId: {
1607
1653
  filter: { id: /virtual:vinext-pages-client-assets$/ },
1608
1654
  handler(id) {
1609
- const cleanId = normalizePathSeparators(id.startsWith("\0") ? id.slice(1) : id);
1655
+ const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
1610
1656
  if (cleanId !== VIRTUAL_PAGES_CLIENT_ASSETS && !cleanId.endsWith("/virtual:vinext-pages-client-assets")) return;
1611
1657
  if (this.environment?.config.command !== "build") return RESOLVED_PAGES_CLIENT_ASSETS;
1612
1658
  const buildRoot = this.environment.config.root ?? process.cwd();
1613
1659
  const environmentOutDir = path.resolve(buildRoot, this.environment.config.build.outDir);
1614
1660
  const sidecarDir = !hasAppDir && this.environment.name === "ssr" ? path.dirname(environmentOutDir) : environmentOutDir;
1615
- let externalId = normalizePathSeparators(path.relative(environmentOutDir, path.join(sidecarDir, PAGES_CLIENT_ASSETS_MODULE)));
1661
+ let externalId = path.relative(environmentOutDir, path.join(sidecarDir, PAGES_CLIENT_ASSETS_MODULE));
1616
1662
  if (!externalId.startsWith(".")) externalId = `./${externalId}`;
1617
1663
  pagesClientAssetsOutputDirs.add(sidecarDir);
1618
1664
  return {
@@ -1715,29 +1761,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1715
1761
  }
1716
1762
  },
1717
1763
  ...options.experimental?.clientReferenceDedup ? [clientReferenceDedupPlugin()] : [],
1718
- {
1719
- name: "vinext:mdx",
1720
- enforce: "pre",
1721
- config(config, env) {
1722
- if (!mdxDelegate?.config) return;
1723
- const hook = mdxDelegate.config;
1724
- return (typeof hook === "function" ? hook : hook.handler).call(this, config, env);
1725
- },
1726
- transform: {
1727
- filter: { id: {
1728
- include: /\.mdx$/i,
1729
- exclude: /\?/
1730
- } },
1731
- async handler(code, id, options) {
1732
- const delegate = mdxDelegate ?? await ensureMdxDelegate("on-demand");
1733
- if (delegate?.transform) {
1734
- const hook = delegate.transform;
1735
- return (typeof hook === "function" ? hook : hook.handler).call(this, code, id, options);
1736
- }
1737
- if (!hasUserMdxPlugin) throw new Error(`[vinext] Encountered MDX module ${id} but no MDX plugin is configured. Install @mdx-js/rollup or register an MDX plugin manually.`);
1738
- }
1739
- }
1740
- },
1764
+ mdxConfigProxyPlugin,
1741
1765
  createCssModuleImportCompatibilityPlugin({ compiledMdx: true }),
1742
1766
  {
1743
1767
  name: "vinext:react-canary",
@@ -1778,39 +1802,42 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1778
1802
  },
1779
1803
  {
1780
1804
  name: "vinext:pages-router",
1781
- hotUpdate(options) {
1782
- if (!hasPagesDir) return;
1783
- const isPagesAppFile = (filePath) => {
1784
- const relativePath = normalizePathSeparators(path.relative(pagesDir, filePath));
1785
- return !relativePath.includes("/") && relativePath.startsWith("_app.") && fileMatcher.extensionRegex.test(filePath);
1786
- };
1787
- const isPotentialPagesAssetGraphScript = (filePath) => {
1788
- const cleanPath = stripViteModuleQuery(filePath);
1789
- if (!path.isAbsolute(cleanPath)) return false;
1790
- if (!isScriptModuleId(cleanPath) || cleanPath.endsWith(".d.ts")) return false;
1791
- const relativeRootPath = normalizePathSeparators(path.relative(root, cleanPath));
1792
- if (relativeRootPath.startsWith("..") || path.isAbsolute(relativeRootPath)) return false;
1793
- if (relativeRootPath.includes("/node_modules/") || relativeRootPath.startsWith("node_modules/")) return false;
1794
- const relativeAppPath = normalizePathSeparators(path.relative(appDir, cleanPath));
1795
- return relativeAppPath.startsWith("..") || path.isAbsolute(relativeAppPath);
1796
- };
1797
- const pagesAppChanged = isPagesAppFile(options.file);
1798
- const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(options.file);
1799
- if (pagesAppChanged || STYLESHEET_FILE_RE.test(options.file) || pagesAssetGraphScriptChanged) for (const env of Object.values(options.server.environments)) {
1800
- const mod = env.moduleGraph.getModuleById(RESOLVED_PAGES_CLIENT_ASSETS);
1801
- if (mod) env.moduleGraph.invalidateModule(mod);
1802
- }
1803
- if (pagesAppChanged || !hasAppDir && pagesAssetGraphScriptChanged) {
1804
- options.server.ws.send({ type: "full-reload" });
1805
- return [];
1806
- }
1807
- if (hasAppDir) return;
1808
- if (options.file.startsWith(pagesDir) && fileMatcher.extensionRegex.test(options.file)) {
1809
- options.server.environments.client.hot.send({ type: "full-reload" });
1810
- return [];
1805
+ // @vitejs/plugin-react to handle normal module updates. Next.js preserves
1806
+ hotUpdate: {
1807
+ order: "post",
1808
+ handler(options) {
1809
+ if (!hasPagesDir) return;
1810
+ const isPagesAppFile = (filePath) => {
1811
+ const relativePath = path.relative(pagesDir, filePath);
1812
+ return !relativePath.includes("/") && relativePath.startsWith("_app.") && fileMatcher.extensionRegex.test(filePath);
1813
+ };
1814
+ const isPotentialPagesAssetGraphScript = (filePath) => {
1815
+ const cleanPath = stripViteModuleQuery(filePath);
1816
+ if (!path.isAbsolute(cleanPath)) return false;
1817
+ if (!isScriptModuleId(cleanPath) || cleanPath.endsWith(".d.ts")) return false;
1818
+ const relativeRootPath = path.relative(root, cleanPath);
1819
+ if (relativeRootPath.startsWith("..") || path.isAbsolute(relativeRootPath)) return false;
1820
+ if (relativeRootPath.includes("/node_modules/") || relativeRootPath.startsWith("node_modules/")) return false;
1821
+ const relativeAppPath = path.relative(appDir, cleanPath);
1822
+ return relativeAppPath.startsWith("..") || path.isAbsolute(relativeAppPath);
1823
+ };
1824
+ const pagesAppChanged = isPagesAppFile(options.file);
1825
+ const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(options.file);
1826
+ if (pagesAppChanged || STYLESHEET_FILE_RE.test(options.file) || pagesAssetGraphScriptChanged) for (const env of Object.values(options.server.environments)) {
1827
+ const mod = env.moduleGraph.getModuleById(RESOLVED_PAGES_CLIENT_ASSETS);
1828
+ if (mod) env.moduleGraph.invalidateModule(mod);
1829
+ }
1830
+ if (this.environment?.name === "ssr" && pagesAssetGraphScriptChanged) {
1831
+ for (const mod of options.modules) this.environment.moduleGraph.invalidateModule(mod, /* @__PURE__ */ new Set(), options.timestamp, true);
1832
+ return [];
1833
+ }
1811
1834
  }
1812
1835
  },
1813
1836
  configureServer(server) {
1837
+ server.middlewares.use((req, _res, next) => {
1838
+ req.__vinextOriginalEncodedUrl ??= req.url;
1839
+ next();
1840
+ });
1814
1841
  const pageExtensions = fileMatcher.extensionRegex;
1815
1842
  let pagesRunner = null;
1816
1843
  let cachedSSRHandler = null;
@@ -1857,13 +1884,12 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1857
1884
  }
1858
1885
  pagesRunner?.clearCache();
1859
1886
  }
1860
- function invalidatePagesClientAssetsModule(reloadDocument = false) {
1887
+ function invalidatePagesClientAssetsModule() {
1861
1888
  for (const env of Object.values(server.environments)) {
1862
1889
  const mod = env.moduleGraph.getModuleById(RESOLVED_PAGES_CLIENT_ASSETS);
1863
1890
  if (mod) env.moduleGraph.invalidateModule(mod);
1864
1891
  }
1865
1892
  pagesRunner?.clearCache();
1866
- if (reloadDocument) server.ws.send({ type: "full-reload" });
1867
1893
  }
1868
1894
  function invalidateAppRoutingModules() {
1869
1895
  invalidateAppRouteCache();
@@ -1913,17 +1939,17 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1913
1939
  let appRouteTypeGeneration = null;
1914
1940
  let appRouteTypeGenerationPending = false;
1915
1941
  function isPagesAppFile(filePath) {
1916
- const relativePath = normalizePathSeparators(path.relative(pagesDir, filePath));
1942
+ const relativePath = path.relative(pagesDir, filePath);
1917
1943
  return !relativePath.includes("/") && relativePath.startsWith("_app.") && fileMatcher.extensionRegex.test(filePath);
1918
1944
  }
1919
1945
  function isPotentialPagesAssetGraphScript(filePath) {
1920
1946
  const cleanPath = stripViteModuleQuery(filePath);
1921
1947
  if (!path.isAbsolute(cleanPath)) return false;
1922
1948
  if (!isScriptModuleId(cleanPath) || cleanPath.endsWith(".d.ts")) return false;
1923
- const relativeRootPath = normalizePathSeparators(path.relative(root, cleanPath));
1949
+ const relativeRootPath = path.relative(root, cleanPath);
1924
1950
  if (relativeRootPath.startsWith("..") || path.isAbsolute(relativeRootPath)) return false;
1925
1951
  if (relativeRootPath.includes("/node_modules/") || relativeRootPath.startsWith("node_modules/")) return false;
1926
- const relativeAppPath = normalizePathSeparators(path.relative(appDir, cleanPath));
1952
+ const relativeAppPath = path.relative(appDir, cleanPath);
1927
1953
  return relativeAppPath.startsWith("..") || path.isAbsolute(relativeAppPath);
1928
1954
  }
1929
1955
  function warnRouteTypeGenerationFailure(error) {
@@ -1956,8 +1982,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1956
1982
  let routeChanged = false;
1957
1983
  const pagesAppChanged = isPagesAppFile(filePath);
1958
1984
  const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
1959
- if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule(pagesAppChanged || !hasAppDir && pagesAssetGraphScriptChanged);
1960
- if (hasPagesDir && filePath.startsWith(pagesDir) && pageExtensions.test(filePath)) {
1985
+ if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
1986
+ if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
1961
1987
  invalidateRouteCache(pagesDir);
1962
1988
  routeChanged = true;
1963
1989
  }
@@ -1968,6 +1994,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1968
1994
  }
1969
1995
  if (routeChanged) {
1970
1996
  invalidatePagesServerEntry();
1997
+ if (!hasAppDir) server.ws.send({ type: "full-reload" });
1971
1998
  invalidateHybridClientEntries();
1972
1999
  revalidateHybridRoutes();
1973
2000
  }
@@ -1975,14 +2002,14 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1975
2002
  server.watcher.on("change", (filePath) => {
1976
2003
  const pagesAppChanged = isPagesAppFile(filePath);
1977
2004
  const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
1978
- if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule(pagesAppChanged || !hasAppDir && pagesAssetGraphScriptChanged);
2005
+ if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
1979
2006
  });
1980
2007
  server.watcher.on("unlink", (filePath) => {
1981
2008
  let routeChanged = false;
1982
2009
  const pagesAppChanged = isPagesAppFile(filePath);
1983
2010
  const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
1984
- if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule(pagesAppChanged || !hasAppDir && pagesAssetGraphScriptChanged);
1985
- if (hasPagesDir && filePath.startsWith(pagesDir) && pageExtensions.test(filePath)) {
2011
+ if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
2012
+ if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
1986
2013
  invalidateRouteCache(pagesDir);
1987
2014
  routeChanged = true;
1988
2015
  }
@@ -1993,6 +2020,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1993
2020
  }
1994
2021
  if (routeChanged) {
1995
2022
  invalidatePagesServerEntry();
2023
+ if (!hasAppDir) server.ws.send({ type: "full-reload" });
1996
2024
  invalidateHybridClientEntries();
1997
2025
  revalidateHybridRoutes();
1998
2026
  }
@@ -2147,9 +2175,25 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2147
2175
  res.end();
2148
2176
  return;
2149
2177
  }
2178
+ const originalEncodedUrl = req.__vinextOriginalEncodedUrl ?? url;
2179
+ const originalEncodedPathname = originalEncodedUrl.split("?")[0];
2180
+ if (isOpenRedirectShaped(originalEncodedPathname)) {
2181
+ res.writeHead(404);
2182
+ res.end("This page could not be found");
2183
+ return;
2184
+ }
2185
+ const canonicalOriginalUrl = canonicalizeRequestUrlPathname(originalEncodedUrl);
2186
+ url = canonicalizeRequestUrlPathname(url);
2150
2187
  const rawPathname = url.split("?")[0];
2151
2188
  if (rawPathname.endsWith("/index.html")) url = url.replace("/index.html", "/");
2152
2189
  else if (rawPathname.endsWith(".html")) url = url.replace(/\.html(?=\?|$)/, "");
2190
+ let middlewareUrl = canonicalOriginalUrl;
2191
+ let routeUrl = middlewareUrl;
2192
+ {
2193
+ const routePathname = routeUrl.split("?")[0];
2194
+ if (routePathname.endsWith("/index.html")) routeUrl = routeUrl.replace("/index.html", "/");
2195
+ else if (routePathname.endsWith(".html")) routeUrl = routeUrl.replace(/\.html(?=\?|$)/, "");
2196
+ }
2153
2197
  let pathname = url.split("?")[0];
2154
2198
  if (isOpenRedirectShaped(pathname)) {
2155
2199
  res.writeHead(404);
@@ -2164,20 +2208,42 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2164
2208
  res.end("Bad Request");
2165
2209
  return;
2166
2210
  }
2211
+ if (urlParserCreatesPagesDataPath(pathname)) {
2212
+ res.writeHead(404);
2213
+ res.end("This page could not be found");
2214
+ return;
2215
+ }
2216
+ pathname = encodeUrlParserIgnoredCharacters(pathname);
2167
2217
  {
2168
2218
  const qs = url.includes("?") ? url.slice(url.indexOf("?")) : "";
2169
2219
  url = pathname + qs;
2170
2220
  }
2171
2221
  const capturedMiddlewarePath = middlewarePath;
2172
2222
  const bp = nextConfig?.basePath ?? "";
2173
- if (bp && pathname.startsWith(bp)) {
2174
- const stripped = pathname.slice(bp.length) || "/";
2175
- url = stripped + (url.includes("?") ? url.slice(url.indexOf("?")) : "");
2176
- pathname = stripped;
2223
+ const viteBase = server.config.base;
2224
+ const viteBasePath = viteBase.startsWith("/") && viteBase !== "/" ? viteBase.replace(/\/+$/, "") : "";
2225
+ const routingBasePath = bp || viteBasePath;
2226
+ if (routingBasePath) {
2227
+ if (hasBasePath(pathname, routingBasePath)) {
2228
+ const stripped = stripBasePath(pathname, routingBasePath);
2229
+ url = stripped + (url.includes("?") ? url.slice(url.indexOf("?")) : "");
2230
+ pathname = stripped;
2231
+ }
2232
+ const middlewarePathname = middlewareUrl.split("?")[0];
2233
+ if (hasBasePath(middlewarePathname, routingBasePath)) {
2234
+ const middlewareQs = middlewareUrl.includes("?") ? middlewareUrl.slice(middlewareUrl.indexOf("?")) : "";
2235
+ middlewareUrl = stripBasePath(middlewarePathname, routingBasePath) + middlewareQs;
2236
+ }
2237
+ const routePathname = routeUrl.split("?")[0];
2238
+ if (hasBasePath(routePathname, routingBasePath)) {
2239
+ const routeQs = routeUrl.includes("?") ? routeUrl.slice(routeUrl.indexOf("?")) : "";
2240
+ routeUrl = stripBasePath(routePathname, routingBasePath) + routeQs;
2241
+ }
2177
2242
  }
2243
+ let configMatchPathname = stripBasePath(middlewareUrl.split("?")[0], routingBasePath);
2178
2244
  if (nextConfig) {
2179
2245
  const qs = url.includes("?") ? url.slice(url.indexOf("?")) : "";
2180
- const trailingSlashRedirect = normalizeTrailingSlash(pathname, bp, nextConfig.trailingSlash, qs);
2246
+ const trailingSlashRedirect = normalizeTrailingSlash(routeUrl.split("?")[0], bp, nextConfig.trailingSlash, qs);
2181
2247
  if (trailingSlashRedirect) {
2182
2248
  const location = trailingSlashRedirect.headers.get("Location");
2183
2249
  res.writeHead(trailingSlashRedirect.status, location ? { Location: location } : void 0);
@@ -2195,7 +2261,10 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2195
2261
  const qs = url.includes("?") ? url.slice(url.indexOf("?")) : "";
2196
2262
  const pagePathname = normalizeNextDataPagePathname(dataMatch.pagePathname, capturedMiddlewarePath !== null && nextConfig?.trailingSlash === true);
2197
2263
  url = pagePathname + qs;
2264
+ middlewareUrl = url;
2265
+ routeUrl = url;
2198
2266
  pathname = pagePathname;
2267
+ configMatchPathname = pagePathname;
2199
2268
  req.url = url;
2200
2269
  } else {
2201
2270
  const deploymentId = process.env.__VINEXT_DEPLOYMENT_ID || process.env.NEXT_DEPLOYMENT_ID;
@@ -2230,7 +2299,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2230
2299
  for (const header of INTERNAL_HEADERS) delete req.headers[header];
2231
2300
  for (const header of VINEXT_INTERNAL_HEADERS) delete req.headers[header];
2232
2301
  const method = req.method ?? "GET";
2233
- const webRequest = new Request(new URL(url, requestOrigin), {
2302
+ const webRequest = new Request(new URL(routeUrl, requestOrigin), {
2234
2303
  method,
2235
2304
  headers: nodeRequestHeaders
2236
2305
  });
@@ -2241,11 +2310,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2241
2310
  const devRunMiddlewareAdapter = capturedMiddlewarePath ? async (_request, _ctx, opts) => {
2242
2311
  const rawProto = process.env.VINEXT_TRUST_PROXY === "1" || (process.env.VINEXT_TRUSTED_HOSTS ?? "").split(",").some((h) => h.trim()) ? String(req.headers["x-forwarded-proto"] || "").split(",")[0].trim() : "";
2243
2312
  const mwOrigin = `${rawProto === "https" || rawProto === "http" ? rawProto : "http"}://${requestHost}`;
2244
- const middlewareRequest = new Request(new URL(url, mwOrigin), {
2313
+ const middlewareRequest = new Request(new URL(middlewareUrl, mwOrigin), {
2245
2314
  method: req.method,
2246
2315
  headers: nodeRequestHeaders
2247
2316
  });
2248
- const result = await runMiddleware(getPagesRunner(), capturedMiddlewarePath, middlewareRequest, nextConfig?.i18n, nextConfig?.basePath, nextConfig?.trailingSlash, opts.isDataRequest);
2317
+ const result = await runMiddleware(getPagesRunner(), capturedMiddlewarePath, middlewareRequest, nextConfig?.i18n, nextConfig?.basePath, nextConfig?.trailingSlash, opts.isDataRequest, pathname);
2249
2318
  if (hasAppDir && result.continue) {
2250
2319
  const mwCtxEntries = [];
2251
2320
  if (result.responseHeaders) {
@@ -2289,6 +2358,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2289
2358
  isDataRequest,
2290
2359
  hasMiddleware: capturedMiddlewarePath !== null,
2291
2360
  rawSearch: url.includes("?") ? url.slice(url.indexOf("?")) : "",
2361
+ configMatchPathname,
2292
2362
  runMiddleware: devRunMiddlewareAdapter,
2293
2363
  matchPageRoute: (resolvedPathname, request) => {
2294
2364
  const m = matchRoute(nextConfig?.i18n ? resolvePagesI18nRequest(resolvedPathname, nextConfig.i18n, request.headers, getUrlHostname(request.url), bp, nextConfig.trailingSlash ?? false).url : resolvedPathname, devPageRoutes);
@@ -2474,15 +2544,23 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2474
2544
  },
2475
2545
  {
2476
2546
  name: "vinext:typeof-window",
2547
+ configEnvironment(_name, environment) {
2548
+ if (!useNativeTypeofWindowFolding) return null;
2549
+ return { define: { "typeof window": environment.consumer === "client" ? "\"object\"" : "\"undefined\"" } };
2550
+ }
2551
+ },
2552
+ {
2553
+ name: "vinext:typeof-window-scan",
2554
+ apply(_config, environment) {
2555
+ return !useNativeTypeofWindowFolding || environment.command === "build";
2556
+ },
2477
2557
  enforce: "post",
2478
2558
  transform: {
2479
- filter: {
2480
- id: typeofWindowIdFilter,
2481
- code: /typeof\s+window/
2482
- },
2559
+ filter: { code: /\btypeof\s+window\b/ },
2483
2560
  handler(code, id) {
2484
- const cacheDirPrefix = getCacheDirPrefix(this.environment.config.cacheDir);
2485
- if (normalizePathSeparators(id).startsWith(cacheDirPrefix)) return null;
2561
+ if (useNativeTypeofWindowFolding && this.environment.config.build.write !== false) return null;
2562
+ const cacheDir = `${toSlash(this.environment.config.cacheDir).replace(/\/$/, "")}/`;
2563
+ if (toSlash(id).startsWith(cacheDir)) return null;
2486
2564
  return replaceTypeofWindow(code, getTypeofWindowReplacement(this.environment), id);
2487
2565
  }
2488
2566
  }
@@ -2495,6 +2573,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2495
2573
  serverDefines["process.env.NEXT_RUNTIME"] = JSON.stringify("nodejs");
2496
2574
  const sharedRevalidateSecret = process.env.__VINEXT_SHARED_REVALIDATE_SECRET;
2497
2575
  if (sharedRevalidateSecret) serverDefines["process.env.__VINEXT_REVALIDATE_SECRET"] = JSON.stringify(sharedRevalidateSecret);
2576
+ if (previewBuildCredentials) {
2577
+ serverDefines["process.env.__VINEXT_PREVIEW_MODE_ID"] = JSON.stringify(previewBuildCredentials.id);
2578
+ serverDefines["process.env.__VINEXT_PREVIEW_MODE_SIGNING_KEY"] = JSON.stringify(previewBuildCredentials.signingKey);
2579
+ serverDefines["process.env.__VINEXT_PREVIEW_MODE_ENCRYPTION_KEY"] = JSON.stringify(previewBuildCredentials.encryptionKey);
2580
+ }
2498
2581
  return { define: serverDefines };
2499
2582
  }
2500
2583
  },
@@ -2519,7 +2602,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2519
2602
  staticImageAssets.clear();
2520
2603
  },
2521
2604
  watchChange(id) {
2522
- const key = normalizePathSeparators(id);
2605
+ const key = toSlash(id);
2523
2606
  imageImportDimCache.delete(key);
2524
2607
  staticImageAssets.delete(key);
2525
2608
  staticImageImportsByModule.delete(key);
@@ -2597,7 +2680,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2597
2680
  const dir = path.dirname(id);
2598
2681
  const resolvedImage = importPath.startsWith(".") ? path.resolve(dir, importPath) : (await this.resolve(importPath, id, { skipSelf: true }))?.id;
2599
2682
  if (!resolvedImage) continue;
2600
- const absImagePath = normalizePathSeparators(resolvedImage.split("?", 1)[0]);
2683
+ const absImagePath = toSlash(resolvedImage.split("?", 1)[0]);
2601
2684
  if (!fs.existsSync(absImagePath)) continue;
2602
2685
  imageImports.add(absImagePath);
2603
2686
  const urlVar = `__vinext_img_url_${varName}`;
@@ -2800,9 +2883,10 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2800
2883
  {
2801
2884
  name: "vinext:nitro-route-rules",
2802
2885
  nitro: { setup: async (nitro) => {
2803
- if (nitro.options.dev) return;
2804
2886
  if (!nextConfig) return;
2805
2887
  if (!hasAppDir && !hasPagesDir) return;
2888
+ if (nitroTraceDepsFromServerExternals.length > 0) nitro.options.traceDeps = [.../* @__PURE__ */ new Set([...nitro.options.traceDeps ?? [], ...nitroTraceDepsFromServerExternals])];
2889
+ if (nitro.options.dev) return;
2806
2890
  const { collectNitroRouteRules, mergeNitroRouteRules } = await import("./build/nitro-route-rules.js");
2807
2891
  const generatedRouteRules = await collectNitroRouteRules({
2808
2892
  appDir: hasAppDir ? appDir : null,