vinext 1.0.0-beta.0 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/README.md +17 -1
  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 +6 -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 +0 -3
  22. package/dist/build/report.js +2 -4
  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 +12 -34
  33. package/dist/cli.js +58 -53
  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.js +2 -2
  37. package/dist/config/dotenv.js +1 -1
  38. package/dist/config/next-config.d.ts +4 -1
  39. package/dist/config/next-config.js +81 -14
  40. package/dist/config/prerender.d.ts +2 -2
  41. package/dist/config/prerender.js +7 -15
  42. package/dist/config/server-external-packages.js +1 -1
  43. package/dist/config/tsconfig-paths.js +2 -2
  44. 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
  45. package/dist/deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js +50 -0
  46. package/dist/entries/app-rsc-entry.js +12 -5
  47. package/dist/entries/app-rsc-manifest.js +4 -4
  48. package/dist/entries/pages-client-entry.js +6 -5
  49. package/dist/entries/pages-server-entry.js +15 -26
  50. package/dist/entries/runtime-entry-module.js +2 -2
  51. package/dist/index.js +255 -195
  52. package/dist/init-cloudflare.js +1 -1
  53. package/dist/init-platform.js +1 -1
  54. package/dist/init.js +5 -5
  55. package/dist/plugins/ast-utils.js +1 -1
  56. package/dist/plugins/dynamic-preload-metadata.js +7 -7
  57. package/dist/plugins/extensionless-dynamic-import.js +1 -1
  58. package/dist/plugins/fonts.js +3 -3
  59. package/dist/plugins/ignore-dynamic-requests.js +13 -8
  60. package/dist/plugins/import-meta-url.js +16 -17
  61. package/dist/plugins/middleware-export-validation.js +1 -1
  62. package/dist/plugins/middleware-server-only.js +2 -2
  63. package/dist/plugins/og-asset-ownership.js +7 -6
  64. package/dist/plugins/og-assets.js +4 -5
  65. package/dist/plugins/optimize-imports.js +12 -13
  66. package/dist/plugins/postcss.js +1 -1
  67. package/dist/plugins/remove-console.js +1 -1
  68. package/dist/plugins/require-context.js +1 -1
  69. package/dist/plugins/sass.js +2 -2
  70. package/dist/plugins/server-externals-manifest.js +1 -1
  71. package/dist/plugins/strip-server-exports.js +1 -1
  72. package/dist/plugins/styled-jsx.js +3 -2
  73. package/dist/plugins/typeof-window.js +1 -1
  74. package/dist/routing/app-route-graph.d.ts +3 -10
  75. package/dist/routing/app-route-graph.js +28 -76
  76. package/dist/routing/app-router.d.ts +0 -5
  77. package/dist/routing/app-router.js +0 -5
  78. package/dist/routing/file-matcher.d.ts +2 -6
  79. package/dist/routing/file-matcher.js +10 -11
  80. package/dist/routing/pages-router.js +3 -3
  81. package/dist/server/api-handler.js +41 -33
  82. package/dist/server/app-browser-entry.js +17 -11
  83. package/dist/server/app-browser-navigation-controller.js +5 -3
  84. package/dist/server/app-browser-server-action-client.js +1 -1
  85. package/dist/server/app-browser-state.js +1 -1
  86. package/dist/server/app-browser-visible-commit.js +1 -1
  87. package/dist/server/app-elements-wire.d.ts +2 -1
  88. package/dist/server/app-fallback-renderer.d.ts +8 -0
  89. package/dist/server/app-fallback-renderer.js +13 -1
  90. package/dist/server/app-page-boundary-render.d.ts +14 -1
  91. package/dist/server/app-page-boundary-render.js +107 -54
  92. package/dist/server/app-page-dispatch.d.ts +1 -0
  93. package/dist/server/app-page-dispatch.js +26 -37
  94. package/dist/server/app-page-element-builder.d.ts +2 -1
  95. package/dist/server/app-page-element-builder.js +3 -3
  96. package/dist/server/app-page-execution.d.ts +3 -1
  97. package/dist/server/app-page-execution.js +31 -39
  98. package/dist/server/app-page-request.js +1 -1
  99. package/dist/server/app-page-route-wiring.js +1 -1
  100. package/dist/server/app-route-handler-execution.js +1 -1
  101. package/dist/server/app-route-tree-prefetch.js +1 -1
  102. package/dist/server/app-rsc-cache-busting.js +1 -1
  103. package/dist/server/app-rsc-handler.js +3 -3
  104. package/dist/server/app-rsc-redirect-flight.d.ts +66 -0
  105. package/dist/server/app-rsc-redirect-flight.js +71 -0
  106. package/dist/server/app-segment-config.js +2 -2
  107. package/dist/server/app-server-action-execution.js +1 -1
  108. package/dist/server/app-ssr-entry.js +6 -3
  109. package/dist/server/app-ssr-stream.d.ts +2 -1
  110. package/dist/server/app-ssr-stream.js +4 -1
  111. package/dist/server/cache-proof.js +1 -1
  112. package/dist/server/default-global-error-module.d.ts +3 -1
  113. package/dist/server/default-not-found-module.d.ts +3 -1
  114. package/dist/server/dev-lockfile.js +2 -3
  115. package/dist/server/dev-route-files.js +1 -1
  116. package/dist/server/dev-server.js +253 -161
  117. package/dist/server/dev-stack-sourcemap.js +4 -3
  118. package/dist/server/headers.d.ts +3 -1
  119. package/dist/server/headers.js +3 -1
  120. package/dist/server/image-optimization.js +2 -2
  121. package/dist/server/implicit-tags.js +2 -1
  122. package/dist/server/instrumentation.js +2 -2
  123. package/dist/server/isr-cache.js +1 -1
  124. package/dist/server/metadata-routes.js +4 -4
  125. package/dist/server/middleware-response-headers.js +1 -1
  126. package/dist/server/middleware-runtime.js +1 -1
  127. package/dist/server/middleware.d.ts +1 -0
  128. package/dist/server/middleware.js +1 -1
  129. package/dist/server/navigation-planner.d.ts +2 -0
  130. package/dist/server/navigation-planner.js +8 -2
  131. package/dist/server/next-error-digest.d.ts +9 -24
  132. package/dist/server/next-error-digest.js +23 -15
  133. package/dist/server/operation-token.js +1 -1
  134. package/dist/server/pages-body-parser-config.js +2 -1
  135. package/dist/server/pages-dev-hydration.d.ts +14 -0
  136. package/dist/server/pages-dev-hydration.js +83 -0
  137. package/dist/server/pages-dev-module-url.js +2 -2
  138. package/dist/server/pages-node-compat.d.ts +13 -6
  139. package/dist/server/pages-node-compat.js +44 -45
  140. package/dist/server/pages-page-data.d.ts +1 -1
  141. package/dist/server/pages-page-data.js +4 -3
  142. package/dist/server/pages-page-handler.js +61 -29
  143. package/dist/server/pages-page-response.d.ts +2 -2
  144. package/dist/server/pages-preview.d.ts +26 -0
  145. package/dist/server/pages-preview.js +165 -0
  146. package/dist/server/pages-readiness.d.ts +2 -1
  147. package/dist/server/pages-readiness.js +4 -2
  148. package/dist/server/prod-server.js +9 -8
  149. package/dist/server/request-pipeline.js +1 -1
  150. package/dist/server/seed-cache.js +1 -1
  151. package/dist/server/socket-error-backstop.js +1 -1
  152. package/dist/server/static-file-cache.js +7 -8
  153. package/dist/server/worker-utils.js +1 -1
  154. package/dist/shims/cache.js +2 -1
  155. package/dist/shims/constants.js +1 -1
  156. package/dist/shims/error-boundary.d.ts +4 -4
  157. package/dist/shims/error.d.ts +21 -5
  158. package/dist/shims/error.js +52 -14
  159. package/dist/shims/fetch-cache.js +1 -1
  160. package/dist/shims/font-utils.js +1 -1
  161. package/dist/shims/form.d.ts +1 -1
  162. package/dist/shims/head.js +3 -3
  163. package/dist/shims/headers.js +6 -4
  164. package/dist/shims/internal/pages-data-fetch-dedup.js +5 -3
  165. package/dist/shims/layout-segment-context.d.ts +1 -1
  166. package/dist/shims/link.d.ts +3 -1
  167. package/dist/shims/link.js +6 -3
  168. package/dist/shims/navigation-errors.d.ts +2 -1
  169. package/dist/shims/navigation-errors.js +9 -13
  170. package/dist/shims/navigation.d.ts +1 -1
  171. package/dist/shims/navigation.js +5 -5
  172. package/dist/shims/navigation.react-server.js +1 -1
  173. package/dist/shims/router-state.d.ts +1 -0
  174. package/dist/shims/router.d.ts +2 -1
  175. package/dist/shims/router.js +18 -11
  176. package/dist/shims/script.js +1 -1
  177. package/dist/shims/server.js +2 -2
  178. package/dist/shims/slot.d.ts +1 -1
  179. package/dist/shims/thenable-params.js +1 -1
  180. package/dist/typegen.js +9 -11
  181. package/dist/utils/client-build-manifest.js +2 -2
  182. package/dist/utils/client-entry-manifest.js +1 -1
  183. package/dist/utils/client-runtime-metadata.js +1 -1
  184. package/dist/utils/commonjs-loader.js +3 -3
  185. package/dist/utils/mdx-scan.js +1 -1
  186. package/dist/utils/path.d.ts +1 -13
  187. package/dist/utils/path.js +1 -15
  188. package/dist/utils/plugin-options.d.ts +4 -0
  189. package/dist/utils/plugin-options.js +8 -0
  190. package/dist/utils/project.d.ts +0 -6
  191. package/dist/utils/project.js +2 -8
  192. package/dist/utils/public-routes.js +2 -2
  193. package/dist/utils/react-version.js +1 -1
  194. package/dist/utils/redirect-digest.d.ts +9 -0
  195. package/dist/utils/redirect-digest.js +25 -0
  196. package/dist/utils/vinext-root.js +1 -1
  197. package/dist/utils/vite-version.d.ts +5 -2
  198. package/dist/utils/vite-version.js +43 -17
  199. package/package.json +4 -3
  200. /package/dist/build/google-fonts/{fallback-metrics-data.js → fallback-metrics-data.json.js} +0 -0
  201. /package/dist/build/google-fonts/{font-data.js → font-data.json.js} +0 -0
  202. /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
@@ -1,6 +1,8 @@
1
1
  import { PHASE_PRODUCTION_BUILD } from "../shims/constants.js";
2
+ import { PluginOption } from "vite";
2
3
 
3
4
  //#region src/config/next-config.d.ts
5
+ declare const VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY = "__vinextNextConfig";
4
6
  /**
5
7
  * Parse a body size limit value (string or number) into bytes.
6
8
  * Accepts Next.js-style strings like "1mb", "500kb", "10mb", bare number strings like "1048576" (bytes),
@@ -241,6 +243,7 @@ type NextConfigFactory = (phase: string, opts: {
241
243
  defaultConfig: NextConfig;
242
244
  }) => NextConfig | Promise<NextConfig>;
243
245
  type NextConfigInput = NextConfig | NextConfigFactory;
246
+ declare function findVinextNextConfigInPlugins(plugins: PluginOption[] | undefined): Promise<NextConfigInput | null>;
244
247
  /**
245
248
  * Resolved configuration with all async values awaited.
246
249
  */
@@ -564,4 +567,4 @@ declare function extractMdxOptions(config: NextConfig, root?: string): Promise<M
564
567
  */
565
568
  declare function detectNextIntlConfig(root: string, resolved: ResolvedNextConfig): void;
566
569
  //#endregion
567
- export { HasCondition, MdxOptions, NextConfig, NextConfigInput, NextHeader, NextI18nConfig, NextRedirect, NextRewrite, PHASE_PRODUCTION_BUILD, PrefetchInliningConfig, ResolvedNextConfig, createRscCompatibilityId, detectNextIntlConfig, extractMdxOptions, findNextConfigPath, lightningCssFeatureNamesToMask, loadNextConfig, normalizeAssetPrefix, parseBodySizeLimit, reassignsModuleExports, referencesCjsGlobals, resolveNextConfig, resolveNextConfigInput };
570
+ export { HasCondition, MdxOptions, NextConfig, NextConfigInput, NextHeader, NextI18nConfig, NextRedirect, NextRewrite, PHASE_PRODUCTION_BUILD, PrefetchInliningConfig, ResolvedNextConfig, VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, detectNextIntlConfig, extractMdxOptions, findNextConfigPath, findVinextNextConfigInPlugins, lightningCssFeatureNamesToMask, loadNextConfig, normalizeAssetPrefix, parseBodySizeLimit, reassignsModuleExports, referencesCjsGlobals, resolveNextConfig, resolveNextConfigInput };
@@ -1,13 +1,14 @@
1
+ import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { normalizePageExtensions } from "../routing/file-matcher.js";
2
3
  import { applyLocaleToRoutes, isExternalUrl } from "./config-matchers.js";
3
4
  import { isUnknownRecord } from "../utils/record.js";
4
5
  import { getHtmlLimitedBotRegex } from "../utils/html-limited-bots.js";
6
+ import { flattenPluginOptions } from "../utils/plugin-options.js";
5
7
  import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "../shims/constants.js";
6
8
  import { loadTsconfigResolutionForRoot } from "./tsconfig-paths.js";
7
9
  import { loadCommonJsModule, shouldRetryAsCommonJs } from "../utils/commonjs-loader.js";
8
10
  import { createRequire } from "node:module";
9
11
  import fs from "node:fs";
10
- import path from "node:path";
11
12
  import { fileURLToPath } from "node:url";
12
13
  import { randomUUID } from "node:crypto";
13
14
  import commonjs from "vite-plugin-commonjs";
@@ -18,6 +19,7 @@ import commonjs from "vite-plugin-commonjs";
18
19
  * Loads the Next.js config file (if present) and extracts supported options.
19
20
  * Unsupported options are logged as warnings.
20
21
  */
22
+ const VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY = "__vinextNextConfig";
21
23
  /**
22
24
  * Parse a body size limit value (string or number) into bytes.
23
25
  * Accepts Next.js-style strings like "1mb", "500kb", "10mb", bare number strings like "1048576" (bytes),
@@ -63,6 +65,15 @@ function parseBodySizeLimit(value) {
63
65
  if (bytes < 1) throw new Error(`Body size limit must be a positive number, got ${bytes}`);
64
66
  return bytes;
65
67
  }
68
+ async function findVinextNextConfigInPlugins(plugins) {
69
+ const flattened = await flattenPluginOptions(plugins);
70
+ for (const plugin of flattened) {
71
+ if (!isUnknownRecord(plugin)) continue;
72
+ const nextConfig = plugin[VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY];
73
+ if (nextConfig) return nextConfig;
74
+ }
75
+ return null;
76
+ }
66
77
  const CONFIG_FILES = [
67
78
  "next.config.ts",
68
79
  "next.config.mts",
@@ -150,10 +161,12 @@ async function unwrapConfig(mod, phase = PHASE_DEVELOPMENT_SERVER) {
150
161
  /**
151
162
  * Resolve a path through filesystem symlinks, falling back to the original
152
163
  * path when the file does not exist (e.g. virtual ids, query-suffixed ids).
164
+ * Output is forward-slashed so it compares consistently with pathslash
165
+ * results (fs.realpathSync returns backslashes on Windows).
153
166
  */
154
167
  function safeRealpath(p) {
155
168
  try {
156
- return fs.realpathSync(p);
169
+ return toSlash(fs.realpathSync(p));
157
170
  } catch {
158
171
  return p;
159
172
  }
@@ -439,8 +452,8 @@ function createRscCompatibilityId(nextConfig) {
439
452
  * @returns A filesystem path suitable for path operations
440
453
  */
441
454
  function resolveCacheHandlerPathToFilesystem(filePath) {
442
- if (filePath.startsWith("file://")) return fileURLToPath(filePath);
443
- return filePath;
455
+ if (filePath.startsWith("file://")) return toSlash(fileURLToPath(filePath));
456
+ return toSlash(filePath);
444
457
  }
445
458
  function resolveHtmlLimitedBots(value) {
446
459
  const source = value instanceof RegExp ? value.source : typeof value === "string" ? value : void 0;
@@ -571,11 +584,71 @@ function normalizePrefetchInliningConfig(value) {
571
584
  maxSize: Number.isFinite(normalizedMaxSize) ? normalizedMaxSize : Number.MAX_SAFE_INTEGER
572
585
  };
573
586
  }
587
+ function normalizeI18nConfig(value) {
588
+ if (!value) return null;
589
+ const i18nType = typeof value;
590
+ if (i18nType !== "object") throw new Error(`Specified i18n should be an object received ${i18nType}.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`);
591
+ const i18n = value;
592
+ if (!Array.isArray(i18n.locales)) throw new Error(`Specified i18n.locales should be an Array received ${typeof i18n.locales}.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`);
593
+ if (i18n.locales.length > 100) console.warn(`Received ${i18n.locales.length} i18n.locales items which exceeds the recommended max of 100.\nSee more info here: https://nextjs.org/docs/advanced-features/i18n-routing#how-does-this-work-with-static-generation`);
594
+ if (!i18n.defaultLocale || typeof i18n.defaultLocale !== "string") throw new Error("Specified i18n.defaultLocale should be a string.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config");
595
+ if (i18n.domains !== void 0 && !Array.isArray(i18n.domains)) throw new Error(`Specified i18n.domains must be an array of domain objects e.g. [ { domain: 'example.fr', defaultLocale: 'fr', locales: ['fr'] } ] received ${typeof i18n.domains}.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`);
596
+ if (i18n.domains) {
597
+ const invalidDomainItems = i18n.domains.filter((item) => {
598
+ if (!isUnknownRecord(item) || !item.defaultLocale) return true;
599
+ if (!item.domain || typeof item.domain !== "string") return true;
600
+ if (item.domain.includes(":")) {
601
+ console.warn(`i18n domain: "${item.domain}" is invalid it should be a valid domain without protocol (https://) or port (:3000) e.g. example.vercel.sh`);
602
+ return true;
603
+ }
604
+ const defaultLocaleDuplicate = i18n.domains.find((other) => isUnknownRecord(other) && other.defaultLocale === item.defaultLocale && other.domain !== item.domain);
605
+ if (defaultLocaleDuplicate && isUnknownRecord(defaultLocaleDuplicate)) {
606
+ console.warn(`Both ${item.domain} and ${String(defaultLocaleDuplicate.domain)} configured the defaultLocale ${item.defaultLocale} but only one can. Change one item's default locale to continue`);
607
+ return true;
608
+ }
609
+ let hasInvalidLocale = false;
610
+ if (Array.isArray(item.locales)) for (const locale of item.locales) {
611
+ if (typeof locale !== "string") hasInvalidLocale = true;
612
+ for (const domainItem of i18n.domains) {
613
+ if (domainItem === item || !isUnknownRecord(domainItem)) continue;
614
+ const domainLocales = domainItem.locales;
615
+ if (domainLocales && domainLocales.includes(locale)) {
616
+ console.warn(`Both ${item.domain} and ${String(domainItem.domain)} configured the locale (${String(locale)}) but only one can. Remove it from one i18n.domains config to continue`);
617
+ hasInvalidLocale = true;
618
+ break;
619
+ }
620
+ }
621
+ }
622
+ return hasInvalidLocale;
623
+ });
624
+ if (invalidDomainItems.length > 0) throw new Error(`Invalid i18n.domains values:\n${invalidDomainItems.map((item) => JSON.stringify(item)).join("\n")}\n\ndomains value must follow format { domain: 'example.fr', defaultLocale: 'fr', locales: ['fr'] }.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`);
625
+ }
626
+ const invalidLocales = i18n.locales.filter((locale) => typeof locale !== "string");
627
+ if (invalidLocales.length > 0) throw new Error(`Specified i18n.locales contains invalid values (${invalidLocales.map(String).join(", ")}), locales must be valid locale tags provided as strings e.g. "en-US".\nSee here for list of valid language sub-tags: http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry`);
628
+ const locales = i18n.locales;
629
+ if (!locales.includes(i18n.defaultLocale)) throw new Error("Specified i18n.defaultLocale should be included in i18n.locales.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config");
630
+ const normalizedLocales = /* @__PURE__ */ new Set();
631
+ const duplicateLocales = /* @__PURE__ */ new Set();
632
+ for (const locale of locales) {
633
+ const localeLower = locale.toLowerCase();
634
+ if (normalizedLocales.has(localeLower)) duplicateLocales.add(locale);
635
+ normalizedLocales.add(localeLower);
636
+ }
637
+ if (duplicateLocales.size > 0) throw new Error(`Specified i18n.locales contains the following duplicate locales:\n${[...duplicateLocales].join(", ")}\nEach locale should be listed only once.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`);
638
+ const localeDetectionType = typeof i18n.localeDetection;
639
+ if (localeDetectionType !== "boolean" && localeDetectionType !== "undefined") throw new Error(`Specified i18n.localeDetection should be undefined or a boolean received ${localeDetectionType}.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`);
640
+ return {
641
+ locales: [i18n.defaultLocale, ...locales.filter((locale) => locale !== i18n.defaultLocale)],
642
+ defaultLocale: i18n.defaultLocale,
643
+ localeDetection: i18n.localeDetection ?? true,
644
+ domains: i18n.domains
645
+ };
646
+ }
574
647
  /**
575
648
  * Resolve a NextConfig into a fully-resolved ResolvedNextConfig.
576
649
  * Awaits async functions for redirects/rewrites/headers.
577
650
  */
578
- async function resolveNextConfig(config, root = process.cwd(), options = {}) {
651
+ async function resolveNextConfig(config, root = toSlash(process.cwd()), options = {}) {
579
652
  if (!config) {
580
653
  const buildId = await resolveBuildId(void 0);
581
654
  const deploymentId = resolveDeploymentId(void 0);
@@ -643,6 +716,7 @@ async function resolveNextConfig(config, root = process.cwd(), options = {}) {
643
716
  return resolved;
644
717
  }
645
718
  warnDeprecatedConfigOptions(config, root);
719
+ const i18n = normalizeI18nConfig(config.i18n);
646
720
  let redirects = [];
647
721
  if (config.redirects) {
648
722
  const result = await config.redirects();
@@ -729,13 +803,6 @@ async function resolveNextConfig(config, root = process.cwd(), options = {}) {
729
803
  const experimentalTurbo = readOptionalRecord(experimental?.turbo);
730
804
  const turbopack = readOptionalRecord(config.turbopack);
731
805
  const resolveExtensions = Array.isArray(turbopack?.resolveExtensions) ? readStringArray(turbopack.resolveExtensions) : Array.isArray(experimentalTurbo?.resolveExtensions) ? readStringArray(experimentalTurbo.resolveExtensions) : null;
732
- let i18n = null;
733
- if (config.i18n) i18n = {
734
- locales: config.i18n.locales,
735
- defaultLocale: config.i18n.defaultLocale,
736
- localeDetection: config.i18n.localeDetection ?? true,
737
- domains: config.i18n.domains
738
- };
739
806
  const buildId = await resolveBuildId(config.generateBuildId);
740
807
  const deploymentId = resolveDeploymentId(config.deploymentId);
741
808
  const cacheHandler = typeof config.cacheHandler === "string" ? resolveCacheHandlerPathToFilesystem(config.cacheHandler) : void 0;
@@ -996,7 +1063,7 @@ function invokeLoaderSideEffects(rules, root) {
996
1063
  * loader rule. The remark/rehype plugins are captured in that closure.
997
1064
  * We probe the webpack function with a mock config to extract them.
998
1065
  */
999
- async function extractMdxOptions(config, root = process.cwd()) {
1066
+ async function extractMdxOptions(config, root = toSlash(process.cwd())) {
1000
1067
  return (await probeWebpackConfig(config, root, false)).mdx;
1001
1068
  }
1002
1069
  /**
@@ -1090,4 +1157,4 @@ function extractPluginsFromOptions(opts) {
1090
1157
  return null;
1091
1158
  }
1092
1159
  //#endregion
1093
- export { PHASE_PRODUCTION_BUILD, createRscCompatibilityId, detectNextIntlConfig, extractMdxOptions, findNextConfigPath, lightningCssFeatureNamesToMask, loadNextConfig, normalizeAssetPrefix, parseBodySizeLimit, reassignsModuleExports, referencesCjsGlobals, resolveNextConfig, resolveNextConfigInput };
1160
+ export { PHASE_PRODUCTION_BUILD, VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, detectNextIntlConfig, extractMdxOptions, findNextConfigPath, findVinextNextConfigInPlugins, lightningCssFeatureNamesToMask, loadNextConfig, normalizeAssetPrefix, parseBodySizeLimit, reassignsModuleExports, referencesCjsGlobals, resolveNextConfig, resolveNextConfigInput };
@@ -30,8 +30,8 @@ type ViteConfigLoader = {
30
30
  loadConfigFromFile: typeof import("vite").loadConfigFromFile;
31
31
  };
32
32
  declare function normalizeVinextPrerenderConfig(config: VinextPrerenderConfig | undefined): ResolvedVinextPrerenderConfig | null;
33
- declare function findVinextPrerenderConfigInPlugins(plugins: PluginOption[] | undefined): ResolvedVinextPrerenderConfig | null;
34
- declare function findVinextRouteRootConfigInPlugins(plugins: PluginOption[] | undefined): VinextRouteRootConfig | null;
33
+ declare function findVinextPrerenderConfigInPlugins(plugins: PluginOption[] | undefined): Promise<ResolvedVinextPrerenderConfig | null>;
34
+ declare function findVinextRouteRootConfigInPlugins(plugins: PluginOption[] | undefined): Promise<VinextRouteRootConfig | null>;
35
35
  declare function loadVinextPrerenderConfigFromViteConfig(vite: ViteConfigLoader, root: string): Promise<ResolvedVinextPrerenderConfig | null>;
36
36
  declare function loadVinextRouteRootConfigFromViteConfig(vite: ViteConfigLoader, root: string): Promise<VinextRouteRootConfig | null>;
37
37
  declare function resolveVinextPrerenderDecision(options: {
@@ -1,4 +1,5 @@
1
1
  import { isUnknownRecord } from "../utils/record.js";
2
+ import { flattenPluginOptions } from "../utils/plugin-options.js";
2
3
  import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, findVinextCacheConfigInPlugins, loadVinextCacheConfigFromViteConfig } from "../cache/cache-adapters-virtual.js";
3
4
  //#region src/config/prerender.ts
4
5
  const VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY = "__vinextPrerenderConfig";
@@ -10,16 +11,8 @@ function normalizeVinextPrerenderConfig(config) {
10
11
  if (config.routes === "*") return { routes: "*" };
11
12
  throw new Error("[vinext] Unsupported `prerender.routes` config. Currently only `routes: \"*\"` is supported.");
12
13
  }
13
- function flattenPluginOptions(value, target) {
14
- if (Array.isArray(value)) {
15
- for (const item of value) flattenPluginOptions(item, target);
16
- return;
17
- }
18
- if (value) target.push(value);
19
- }
20
- function findVinextPrerenderConfigInPlugins(plugins) {
21
- const flattened = [];
22
- flattenPluginOptions(plugins, flattened);
14
+ async function findVinextPrerenderConfigInPlugins(plugins) {
15
+ const flattened = await flattenPluginOptions(plugins);
23
16
  for (const plugin of flattened) {
24
17
  if (!isUnknownRecord(plugin)) continue;
25
18
  const prerenderConfig = plugin[VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY];
@@ -27,9 +20,8 @@ function findVinextPrerenderConfigInPlugins(plugins) {
27
20
  }
28
21
  return null;
29
22
  }
30
- function findVinextRouteRootConfigInPlugins(plugins) {
31
- const flattened = [];
32
- flattenPluginOptions(plugins, flattened);
23
+ async function findVinextRouteRootConfigInPlugins(plugins) {
24
+ const flattened = await flattenPluginOptions(plugins);
33
25
  for (const plugin of flattened) {
34
26
  if (!isUnknownRecord(plugin)) continue;
35
27
  const routeRootConfig = plugin[VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY];
@@ -38,13 +30,13 @@ function findVinextRouteRootConfigInPlugins(plugins) {
38
30
  return null;
39
31
  }
40
32
  async function loadVinextPrerenderConfigFromViteConfig(vite, root) {
41
- return findVinextPrerenderConfigInPlugins((await vite.loadConfigFromFile({
33
+ return await findVinextPrerenderConfigInPlugins((await vite.loadConfigFromFile({
42
34
  command: "build",
43
35
  mode: "production"
44
36
  }, void 0, root))?.config.plugins);
45
37
  }
46
38
  async function loadVinextRouteRootConfigFromViteConfig(vite, root) {
47
- return findVinextRouteRootConfigInPlugins((await vite.loadConfigFromFile({
39
+ return await findVinextRouteRootConfigInPlugins((await vite.loadConfigFromFile({
48
40
  command: "build",
49
41
  mode: "production"
50
42
  }, void 0, root))?.config.plugins);
@@ -85,7 +85,7 @@ function mergeServerExternalPackages(userPackages = [], transpilePackages = [])
85
85
  const conflicts = userPackages.filter((name) => transpiled.has(name));
86
86
  if (conflicts.length > 0) throw new Error(`The packages specified in the 'transpilePackages' conflict with the 'serverExternalPackages': ${conflicts.join(", ")}`);
87
87
  const defaults = DEFAULT_SERVER_EXTERNAL_PACKAGES.filter((name) => !transpiled.has(name));
88
- return [...new Set([...defaults, ...userPackages])];
88
+ return [.../* @__PURE__ */ new Set([...defaults, ...userPackages])];
89
89
  }
90
90
  //#endregion
91
91
  export { mergeServerExternalPackages };
@@ -1,8 +1,8 @@
1
+ import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { isUnknownRecord } from "../utils/record.js";
2
3
  import { parseStaticObjectLiteral } from "../plugins/fonts.js";
3
4
  import { createRequire } from "node:module";
4
5
  import fs from "node:fs";
5
- import path from "node:path";
6
6
  //#region src/config/tsconfig-paths.ts
7
7
  /**
8
8
  * tsconfig.json `compilerOptions.paths` loader.
@@ -61,7 +61,7 @@ function resolveTsconfigExtends(configPath, specifier) {
61
61
  path.join(specifier, "tsconfig.json")
62
62
  ];
63
63
  for (const item of candidates) try {
64
- return requireFromConfig.resolve(item);
64
+ return toSlash(requireFromConfig.resolve(item));
65
65
  } catch {}
66
66
  return null;
67
67
  }
@@ -1,4 +1,4 @@
1
- import { getProcessAncestry } from "../../../../process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js";
1
+ import { getProcessAncestry } from "../../../../process-ancestry@0.1.0/deps/process-ancestry/dist/index.js";
2
2
  //#region ../../node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.mjs
3
3
  /**
4
4
  * Provider configurations for major AI coding tools
@@ -291,4 +291,4 @@ function isAgent(envOrOptions, legacyAncestry) {
291
291
  return result.type === "agent" || result.type === "hybrid";
292
292
  }
293
293
  //#endregion
294
- export { isAgent };
294
+ export { providers as c, isAgent as n, detectAgenticEnvironment as t };
@@ -0,0 +1,50 @@
1
+ import nodePath from "node:path";
2
+ //#region ../../node_modules/.pnpm/pathslash@0.1.0/node_modules/pathslash/dist/index.mjs
3
+ const BACKSLASH_RE = /\\/g;
4
+ const isWindows = process.platform === "win32";
5
+ /**
6
+ * Flip backslashes to forward slashes, used to slash-ify `node:path.win32`
7
+ * output. `\\?\` (extended-length) paths are left untouched: there a forward
8
+ * slash is a literal character, not a separator.
9
+ */
10
+ const toForwardSlash = (path) => path.startsWith("\\\\?\\") ? path : path.replace(BACKSLASH_RE, "/");
11
+ /**
12
+ * Normalize separators to `/`, safely. On Windows it converts `\` to `/`. On
13
+ * POSIX it does nothing, because there a backslash is a legal filename character
14
+ * and rewriting it would corrupt the path.
15
+ */
16
+ function toSlash(path) {
17
+ return isWindows ? toForwardSlash(path) : path;
18
+ }
19
+ const w = nodePath.win32;
20
+ function slashed(fn) {
21
+ return (...args) => toForwardSlash(fn(...args));
22
+ }
23
+ const win32 = {
24
+ resolve: slashed(w.resolve),
25
+ normalize: slashed(w.normalize),
26
+ join: slashed(w.join),
27
+ relative: slashed(w.relative),
28
+ dirname: slashed(w.dirname),
29
+ format: slashed(w.format),
30
+ parse: (path) => {
31
+ const parsed = w.parse(path);
32
+ parsed.root = toForwardSlash(parsed.root);
33
+ parsed.dir = toForwardSlash(parsed.dir);
34
+ return parsed;
35
+ },
36
+ basename: w.basename,
37
+ extname: w.extname,
38
+ isAbsolute: w.isAbsolute,
39
+ matchesGlob: w.matchesGlob,
40
+ toNamespacedPath: w.toNamespacedPath,
41
+ delimiter: w.delimiter,
42
+ sep: "/"
43
+ };
44
+ const posix = { ...nodePath.posix };
45
+ posix.posix = win32.posix = posix;
46
+ posix.win32 = win32.win32 = win32;
47
+ const path = isWindows ? win32 : posix;
48
+ const { basename, delimiter, dirname, extname, format, isAbsolute, join, matchesGlob, normalize, parse, relative, resolve, sep, toNamespacedPath } = path;
49
+ //#endregion
50
+ export { path as default, posix, toSlash, win32 };
@@ -1,4 +1,4 @@
1
- import { normalizePathSeparators } from "../utils/path.js";
1
+ import { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
2
  import { resolveEntryPath } from "./runtime-entry-module.js";
3
3
  import { isProxyFile } from "../server/middleware.js";
4
4
  import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES } from "../server/image-optimization.js";
@@ -127,9 +127,9 @@ import { getNavigationContext as _getNavigationContext } from "next/navigation";
127
127
  import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "vinext/shims/cache-handler";
128
128
  import { headersContextFromRequest, getDraftModeCookieHeader, getAndClearPendingCookies, consumeDynamicUsage, consumeInvalidDynamicUsageError, setHeadersAccessPhase } from "next/headers";
129
129
  import { mergeMetadata, resolveModuleMetadata, mergeViewport, resolveModuleViewport } from "vinext/metadata";
130
- ${middlewarePath ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};
130
+ ${middlewarePath ? `import * as middlewareModule from ${JSON.stringify(toSlash(middlewarePath))};
131
131
  import { applyAppMiddleware as __applyAppMiddleware } from ${JSON.stringify(appMiddlewarePath)};` : ""}
132
- ${instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(normalizePathSeparators(instrumentationPath))};
132
+ ${instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(toSlash(instrumentationPath))};
133
133
  import { ensureInstrumentationRegistered as __ensureInstrumentationRegistered } from ${JSON.stringify(instrumentationRuntimePath)};` : ""}
134
134
  import { createAppRscHandler } from "vinext/server/app-rsc-handler";
135
135
  import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
@@ -333,6 +333,11 @@ export const __basePath = ${JSON.stringify(bp)};
333
333
  // thread the configured trailingSlash flag through canonical URL rendering.
334
334
  const __trailingSlash = ${JSON.stringify(ts)};
335
335
 
336
+ // Hoisted above __createAppFallbackRenderer (which runs at module init) so the
337
+ // fallback renderer can decide streaming-vs-blocking metadata redirects per
338
+ // request user-agent. The later per-request references still read this const.
339
+ const __htmlLimitedBots = ${JSON.stringify(htmlLimitedBots)};
340
+
336
341
  const rootNotFoundModule = ${rootNotFoundVar ? rootNotFoundVar : "null"};
337
342
  const rootForbiddenModule = ${rootForbiddenVar ? rootForbiddenVar : "null"};
338
343
  const rootUnauthorizedModule = ${rootUnauthorizedVar ? rootUnauthorizedVar : "null"};
@@ -358,6 +363,7 @@ const __fallbackRenderer = __createAppFallbackRenderer({
358
363
  ${(metadataRoutes?.length ?? 0) > 0 ? "applyFileBasedMetadata: __applyFileBasedMetadata," : ""}
359
364
  basePath: __basePath,
360
365
  trailingSlash: __trailingSlash,
366
+ htmlLimitedBots: __htmlLimitedBots,
361
367
  rootBoundaries: {
362
368
  rootForbiddenModule,
363
369
  rootLayouts,
@@ -380,6 +386,7 @@ const __fallbackRenderer = __createAppFallbackRenderer({
380
386
  makeThenableParams,
381
387
  sanitizer: __sanitizeErrorForClient,
382
388
  rscRenderer: renderToReadableStream,
389
+ getAndClearPendingCookies,
383
390
  getNavigationContext: _getNavigationContext,
384
391
  resolveChildSegments: __resolveAppPageChildSegments,
385
392
  clearRequestContext() {
@@ -432,7 +439,6 @@ const __runtimeImageConfig = ${JSON.stringify(config?.imageConfig)};
432
439
  const __publicFiles = new Set(${JSON.stringify(publicFiles)});
433
440
  const __allowedOrigins = ${JSON.stringify(allowedOrigins)};
434
441
  const __expireTime = ${JSON.stringify(expireTime)};
435
- const __htmlLimitedBots = ${JSON.stringify(htmlLimitedBots)};
436
442
  const __clientTraceMetadata = ${JSON.stringify(clientTraceMetadata)};
437
443
  const __reactMaxHeadersLength = ${JSON.stringify(reactMaxHeadersLength)};
438
444
  // Re-exported for the App Router prod-server to consume at startup —
@@ -582,6 +588,7 @@ export default createAppRscHandler({
582
588
  renderMode,
583
589
  observeMetadataSearchParamsAccess: buildOptions?.observeMetadataSearchParamsAccess === true,
584
590
  observePageSearchParamsAccess: buildOptions?.observePageSearchParamsAccess === true,
591
+ serveStreamingMetadata: buildOptions?.serveStreamingMetadata,
585
592
  }, layoutParamAccess, displayPathname);
586
593
  },
587
594
  clientReuseManifest,
@@ -962,7 +969,7 @@ export default createAppRscHandler({
962
969
  cleanPathname,
963
970
  context,
964
971
  hadBasePath,
965
- filePath: ${JSON.stringify(middlewarePath ? normalizePathSeparators(middlewarePath) : "")},
972
+ filePath: ${JSON.stringify(middlewarePath ? toSlash(middlewarePath) : "")},
966
973
  i18nConfig: __i18nConfig,
967
974
  isDataRequest,
968
975
  isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
@@ -1,4 +1,4 @@
1
- import { normalizePathSeparators } from "../utils/path.js";
1
+ import { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
2
  import { computeAppRouteStaticSiblings, convertSegmentsToRouteParts } from "../routing/app-route-graph.js";
3
3
  import "../routing/app-router.js";
4
4
  import { createMetadataRouteEntriesSource } from "../server/metadata-route-build-data.js";
@@ -30,7 +30,7 @@ function createImportAllocator() {
30
30
  const existing = importMap.get(filePath);
31
31
  if (existing) return existing;
32
32
  const varName = `mod_${importIdx++}`;
33
- const absPath = normalizePathSeparators(filePath);
33
+ const absPath = toSlash(filePath);
34
34
  imports.push(`import * as ${varName} from ${JSON.stringify(absPath)};`);
35
35
  importMap.set(filePath, varName);
36
36
  return varName;
@@ -39,7 +39,7 @@ function createImportAllocator() {
39
39
  const existing = lazyMap.get(filePath);
40
40
  if (existing) return existing;
41
41
  const varName = `load_${lazyIdx++}`;
42
- const absPath = normalizePathSeparators(filePath);
42
+ const absPath = toSlash(filePath);
43
43
  imports.push(`const ${varName} = () => import(${JSON.stringify(absPath)});`);
44
44
  lazyMap.set(filePath, varName);
45
45
  return varName;
@@ -282,7 +282,7 @@ function buildAppRscManifestCode(options) {
282
282
  const rootUnauthorizedVar = rootUnauthorizedPath ? imports.getImportVar(rootUnauthorizedPath) : null;
283
283
  const rootLayoutVars = rootRouteLayoutPaths(rootRoute).map((layoutPath) => imports.getImportVar(layoutPath));
284
284
  const globalErrorVar = options.globalErrorPath ? imports.getImportVar(options.globalErrorPath) : null;
285
- const globalNotFoundImportSpecifier = options.globalNotFoundPath ? JSON.stringify(normalizePathSeparators(options.globalNotFoundPath)) : null;
285
+ const globalNotFoundImportSpecifier = options.globalNotFoundPath ? JSON.stringify(toSlash(options.globalNotFoundPath)) : null;
286
286
  const dynamicMetadataRoutes = metadataRoutes.filter((r) => r.isDynamic);
287
287
  for (const route of dynamicMetadataRoutes) imports.getImportVar(route.filePath);
288
288
  const namesByPattern = buildRootParamNamesByPattern(options.routes);
@@ -1,8 +1,7 @@
1
- import { normalizePathSeparators } from "../utils/path.js";
1
+ import { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
2
  import { findFileWithExts } from "../routing/file-matcher.js";
3
3
  import { patternToNextFormat } from "../routing/route-validation.js";
4
4
  import { apiRouter, pagesRouter } from "../routing/pages-router.js";
5
- import "./pages-entry-helpers.js";
6
5
  import { hasExportedName } from "../build/report.js";
7
6
  import { readFile } from "node:fs/promises";
8
7
  //#region src/entries/pages-client-entry.ts
@@ -42,6 +41,7 @@ async function generateClientEntry(pagesDir, nextConfig, fileMatcher, options =
42
41
  const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
43
42
  const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
44
43
  const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
44
+ const errorFilePath = findFileWithExts(pagesDir, "_error", fileMatcher);
45
45
  const hasApp = appFilePath !== null;
46
46
  const appPrefetchRoutes = options.appPrefetchRoutes ?? [];
47
47
  const pagesPrefetchRoutes = [...pageRoutes.map(toPagesLinkPrefetchRoute), ...apiRoutes.map((route) => ({
@@ -52,12 +52,13 @@ async function generateClientEntry(pagesDir, nextConfig, fileMatcher, options =
52
52
  const pagesSspPatterns = (await Promise.all(pageRoutes.map(async (route) => await hasGetServerSidePropsExport(route.filePath) ? patternToNextFormat(route.pattern) : null))).filter((pattern) => pattern !== null);
53
53
  const instrumentationClientPath = options.instrumentationClientPath ?? null;
54
54
  const loaderEntries = pageRoutes.map((r) => {
55
- const absPath = normalizePathSeparators(r.filePath);
55
+ const absPath = r.filePath;
56
56
  const nextFormatPattern = patternToNextFormat(r.pattern);
57
57
  return ` ${JSON.stringify(nextFormatPattern)}: () => import(${JSON.stringify(absPath)})`;
58
58
  });
59
- const appFileBase = appFilePath ? normalizePathSeparators(appFilePath) : void 0;
60
- const userInstrumentationImport = instrumentationClientPath ? `import ${JSON.stringify(normalizePathSeparators(instrumentationClientPath))};\n` : "";
59
+ loaderEntries.push(errorFilePath !== null ? ` "/_error": () => import(${JSON.stringify(errorFilePath)})` : " \"/_error\": () => import(\"next/error\")");
60
+ const appFileBase = appFilePath ?? void 0;
61
+ const userInstrumentationImport = instrumentationClientPath ? `import ${JSON.stringify(toSlash(instrumentationClientPath))};\n` : "";
61
62
  const reactPreambleImport = options.reactPreamble === false ? "" : "import \"@vitejs/plugin-react/preamble\";\n";
62
63
  const reactStrictModeEnabled = nextConfig.reactStrictMode === true;
63
64
  return `${userInstrumentationImport}${reactPreambleImport}
@@ -1,9 +1,7 @@
1
- import { normalizePathSeparators } from "../utils/path.js";
2
1
  import { findFileWithExts } from "../routing/file-matcher.js";
3
2
  import { apiRouter, pagesRouter } from "../routing/pages-router.js";
4
3
  import { resolveEntryPath } from "./runtime-entry-module.js";
5
4
  import { isProxyFile } from "../server/middleware.js";
6
- import "./pages-entry-helpers.js";
7
5
  import { hasExportedName } from "../build/report.js";
8
6
  import { readFile } from "node:fs/promises";
9
7
  //#region src/entries/pages-server-entry.ts
@@ -39,18 +37,11 @@ async function getPagesDataKind(filePath) {
39
37
  async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath) {
40
38
  const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
41
39
  const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
42
- const pageImports = pageRoutes.map((r, i) => {
43
- const absPath = normalizePathSeparators(r.filePath);
44
- return `import * as page_${i} from ${JSON.stringify(absPath)};`;
45
- });
46
- const apiImports = apiRoutes.map((r, i) => {
47
- const absPath = normalizePathSeparators(r.filePath);
48
- return `import * as api_${i} from ${JSON.stringify(absPath)};`;
49
- });
40
+ const pageImports = pageRoutes.map((r, i) => `import * as page_${i} from ${JSON.stringify(r.filePath)};`);
41
+ const apiImports = apiRoutes.map((r, i) => `import * as api_${i} from ${JSON.stringify(r.filePath)};`);
50
42
  const pageRouteEntries = await Promise.all(pageRoutes.map(async (r, i) => {
51
- const absPath = normalizePathSeparators(r.filePath);
52
43
  const dataKind = await getPagesDataKind(r.filePath);
53
- return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(absPath)}, dataKind: ${JSON.stringify(dataKind)} }`;
44
+ return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(r.filePath)}, dataKind: ${JSON.stringify(dataKind)} }`;
54
45
  }));
55
46
  const apiRouteEntries = apiRoutes.map((r, i) => ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`);
56
47
  const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
@@ -60,7 +51,7 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
60
51
  const appImportCode = appFilePath !== null ? `import { default as AppComponent } from ${JSON.stringify(appFilePath)};` : `const AppComponent = null;`;
61
52
  const docImportCode = docFilePath !== null ? `import { default as DocumentComponent } from ${JSON.stringify(docFilePath)};` : `const DocumentComponent = null;`;
62
53
  const errorAssetPathJson = errorFilePath !== null ? JSON.stringify(errorFilePath) : "null";
63
- const errorImportCode = errorFilePath !== null ? `import * as ErrorPageModule from ${JSON.stringify(errorFilePath)};` : `const ErrorPageModule = null;`;
54
+ const errorImportCode = errorFilePath !== null ? `import * as ErrorPageModule from ${JSON.stringify(errorFilePath)};` : `import * as ErrorPageModule from "next/error";`;
64
55
  const i18nConfigJson = nextConfig?.i18n ? JSON.stringify({
65
56
  locales: nextConfig.i18n.locales,
66
57
  defaultLocale: nextConfig.i18n.defaultLocale,
@@ -95,7 +86,7 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
95
86
  contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy
96
87
  }
97
88
  });
98
- const instrumentationImportCode = instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(normalizePathSeparators(instrumentationPath))};` : "";
89
+ const instrumentationImportCode = instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(instrumentationPath)};` : "";
99
90
  const instrumentationInitCode = instrumentationPath ? `// Run instrumentation register() once at module evaluation time — before any
100
91
  // requests are handled. Matches Next.js semantics: register() is called once
101
92
  // on startup in the process that handles requests.
@@ -107,13 +98,13 @@ if (typeof _instrumentation.register === "function") {
107
98
  if (typeof _instrumentation.onRequestError === "function") {
108
99
  globalThis.__VINEXT_onRequestErrorHandler__ = _instrumentation.onRequestError;
109
100
  }` : "";
110
- const middlewareImportCode = middlewarePath ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};` : "";
101
+ const middlewareImportCode = middlewarePath ? `import * as middlewareModule from ${JSON.stringify(middlewarePath)};` : "";
111
102
  const middlewareExportCode = middlewarePath ? `
112
103
  export async function runMiddleware(request, ctx, options) {
113
104
  return __runGeneratedMiddleware({
114
105
  basePath: vinextConfig.basePath,
115
106
  ctx,
116
- filePath: ${JSON.stringify(normalizePathSeparators(middlewarePath))},
107
+ filePath: ${JSON.stringify(middlewarePath)},
117
108
  i18nConfig,
118
109
  isDataRequest: options?.isDataRequest === true,
119
110
  isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
@@ -228,16 +219,14 @@ export const pageRoutes = [
228
219
  ${pageRouteEntries.join(",\n")}
229
220
  ];
230
221
  const _pageRouteTrie = _buildRouteTrie(pageRoutes);
231
- const _errorPageRoute = ErrorPageModule
232
- ? {
233
- pattern: "/_error",
234
- patternParts: ["_error"],
235
- isDynamic: false,
236
- params: [],
237
- module: ErrorPageModule,
238
- filePath: ${errorAssetPathJson},
239
- }
240
- : null;
222
+ const _errorPageRoute = {
223
+ pattern: "/_error",
224
+ patternParts: ["_error"],
225
+ isDynamic: false,
226
+ params: [],
227
+ module: ErrorPageModule,
228
+ filePath: ${errorAssetPathJson},
229
+ };
241
230
 
242
231
  const apiRoutes = [
243
232
  ${apiRouteEntries.join(",\n")}
@@ -1,4 +1,4 @@
1
- import { normalizePathSeparators } from "../utils/path.js";
1
+ import { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
2
  import fs from "node:fs";
3
3
  import { fileURLToPath } from "node:url";
4
4
  //#region src/entries/runtime-entry-module.ts
@@ -14,7 +14,7 @@ import { fileURLToPath } from "node:url";
14
14
  * @param base - The caller's `import.meta.url`
15
15
  */
16
16
  function resolveEntryPath(rel, base) {
17
- return normalizePathSeparators(fileURLToPath(new URL(rel, base)));
17
+ return toSlash(fileURLToPath(new URL(rel, base)));
18
18
  }
19
19
  /**
20
20
  * Resolve a real runtime module for a virtual entry generator.