vinext 0.2.1 → 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 (236) hide show
  1. package/README.md +67 -30
  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.d.ts +13 -92
  5. package/dist/build/client-build-config.js +23 -99
  6. package/dist/build/css-url-assets.js +3 -3
  7. package/dist/build/google-fonts/fallback-metrics.js +1 -1
  8. package/dist/build/google-fonts/font-metadata.js +1 -1
  9. package/dist/build/inject-pregenerated-paths.js +1 -1
  10. package/dist/build/inline-css.js +2 -5
  11. package/dist/build/module-dependency-cache.d.ts +4 -0
  12. package/dist/build/module-dependency-cache.js +13 -0
  13. package/dist/build/next-client-runtime-manifests.js +1 -1
  14. package/dist/build/pages-client-assets-module.js +1 -1
  15. package/dist/build/precompress.js +7 -7
  16. package/dist/build/prerender-paths.d.ts +23 -0
  17. package/dist/build/prerender-paths.js +291 -0
  18. package/dist/build/prerender-server-pool.js +2 -2
  19. package/dist/build/prerender.d.ts +12 -1
  20. package/dist/build/prerender.js +2 -2
  21. package/dist/build/preview-credentials.d.ts +11 -0
  22. package/dist/build/preview-credentials.js +19 -0
  23. package/dist/build/report.d.ts +0 -3
  24. package/dist/build/report.js +2 -4
  25. package/dist/build/run-prerender.d.ts +2 -11
  26. package/dist/build/run-prerender.js +2 -10
  27. package/dist/build/server-manifest.js +1 -1
  28. package/dist/build/ssr-manifest.d.ts +4 -0
  29. package/dist/build/ssr-manifest.js +10 -6
  30. package/dist/build/standalone.js +37 -37
  31. package/dist/cache/cache-adapters-virtual.d.ts +7 -17
  32. package/dist/cache/cache-adapters-virtual.js +35 -2
  33. package/dist/check.d.ts +0 -16
  34. package/dist/check.js +17 -34
  35. package/dist/cli.js +86 -101
  36. package/dist/client/instrumentation-client-inject.js +1 -1
  37. package/dist/client/pages-router-link-navigation.js +1 -1
  38. package/dist/config/config-matchers.js +2 -2
  39. package/dist/config/dotenv.js +1 -1
  40. package/dist/config/next-config.d.ts +4 -1
  41. package/dist/config/next-config.js +82 -16
  42. package/dist/config/prerender.d.ts +12 -2
  43. package/dist/config/prerender.js +22 -12
  44. package/dist/config/server-external-packages.js +1 -1
  45. package/dist/config/tsconfig-paths.js +7 -3
  46. 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
  47. package/dist/deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js +50 -0
  48. package/dist/entries/app-rsc-entry.js +12 -5
  49. package/dist/entries/app-rsc-manifest.js +4 -4
  50. package/dist/entries/pages-client-entry.js +6 -5
  51. package/dist/entries/pages-server-entry.js +15 -26
  52. package/dist/entries/runtime-entry-module.js +2 -2
  53. package/dist/image/image-adapters-virtual.js +1 -0
  54. package/dist/index.d.ts +1 -1
  55. package/dist/index.js +500 -338
  56. package/dist/init-cloudflare.js +13 -4
  57. package/dist/init-platform.d.ts +10 -1
  58. package/dist/init-platform.js +79 -13
  59. package/dist/init.d.ts +11 -3
  60. package/dist/init.js +133 -35
  61. package/dist/plugins/ast-utils.js +1 -1
  62. package/dist/plugins/dynamic-preload-metadata.js +7 -7
  63. package/dist/plugins/extensionless-dynamic-import.js +1 -1
  64. package/dist/plugins/fonts.js +3 -3
  65. package/dist/plugins/ignore-dynamic-requests.js +13 -8
  66. package/dist/plugins/import-meta-url.js +16 -17
  67. package/dist/plugins/middleware-export-validation.js +1 -1
  68. package/dist/plugins/middleware-server-only.js +2 -2
  69. package/dist/plugins/og-asset-ownership.js +7 -6
  70. package/dist/plugins/og-assets.js +4 -5
  71. package/dist/plugins/optimize-imports.js +12 -13
  72. package/dist/plugins/postcss.js +1 -1
  73. package/dist/plugins/remove-console.js +1 -1
  74. package/dist/plugins/require-context.js +1 -1
  75. package/dist/plugins/sass.js +2 -2
  76. package/dist/plugins/server-externals-manifest.js +1 -1
  77. package/dist/plugins/strip-server-exports.js +1 -1
  78. package/dist/plugins/styled-jsx.js +3 -2
  79. package/dist/plugins/typeof-window.js +1 -1
  80. package/dist/routing/app-route-graph.d.ts +3 -10
  81. package/dist/routing/app-route-graph.js +28 -76
  82. package/dist/routing/app-router.d.ts +0 -5
  83. package/dist/routing/app-router.js +0 -5
  84. package/dist/routing/file-matcher.d.ts +2 -6
  85. package/dist/routing/file-matcher.js +10 -11
  86. package/dist/routing/pages-router.js +3 -3
  87. package/dist/server/api-handler.js +41 -33
  88. package/dist/server/app-browser-entry.js +15 -11
  89. package/dist/server/app-browser-navigation-controller.js +9 -4
  90. package/dist/server/app-browser-server-action-client.js +1 -1
  91. package/dist/server/app-elements-wire.d.ts +2 -1
  92. package/dist/server/app-fallback-renderer.d.ts +8 -0
  93. package/dist/server/app-fallback-renderer.js +13 -1
  94. package/dist/server/app-layout-param-observation.d.ts +1 -1
  95. package/dist/server/app-page-boundary-render.d.ts +14 -1
  96. package/dist/server/app-page-boundary-render.js +107 -54
  97. package/dist/server/app-page-cache-render.d.ts +1 -1
  98. package/dist/server/app-page-dispatch.d.ts +2 -1
  99. package/dist/server/app-page-dispatch.js +29 -40
  100. package/dist/server/app-page-element-builder.d.ts +2 -1
  101. package/dist/server/app-page-element-builder.js +3 -3
  102. package/dist/server/app-page-execution.d.ts +3 -1
  103. package/dist/server/app-page-execution.js +31 -39
  104. package/dist/server/app-page-render.d.ts +1 -1
  105. package/dist/server/app-page-request.js +1 -1
  106. package/dist/server/app-page-route-wiring.js +4 -4
  107. package/dist/server/app-route-handler-execution.d.ts +1 -1
  108. package/dist/server/app-route-tree-prefetch.js +1 -1
  109. package/dist/server/app-rsc-cache-busting.js +1 -2
  110. package/dist/server/app-rsc-handler.js +2 -2
  111. package/dist/server/app-rsc-redirect-flight.d.ts +66 -0
  112. package/dist/server/app-rsc-redirect-flight.js +71 -0
  113. package/dist/server/app-rsc-render-mode.d.ts +2 -5
  114. package/dist/server/app-rsc-render-mode.js +2 -12
  115. package/dist/server/app-segment-config.js +2 -2
  116. package/dist/server/app-server-action-execution.js +3 -3
  117. package/dist/server/app-ssr-entry.js +4 -1
  118. package/dist/server/app-ssr-stream.d.ts +2 -1
  119. package/dist/server/app-ssr-stream.js +4 -1
  120. package/dist/server/cache-proof.js +1 -1
  121. package/dist/server/default-global-error-module.d.ts +3 -1
  122. package/dist/server/default-not-found-module.d.ts +3 -1
  123. package/dist/server/dev-lockfile.js +2 -3
  124. package/dist/server/dev-module-runner.js +1 -1
  125. package/dist/server/dev-origin-check.d.ts +2 -2
  126. package/dist/server/dev-origin-check.js +2 -2
  127. package/dist/server/dev-route-files.js +1 -1
  128. package/dist/server/dev-server.js +256 -164
  129. package/dist/server/dev-stack-sourcemap.js +4 -3
  130. package/dist/server/headers.d.ts +3 -1
  131. package/dist/server/headers.js +3 -1
  132. package/dist/server/image-optimization.d.ts +12 -1
  133. package/dist/server/image-optimization.js +15 -3
  134. package/dist/server/implicit-tags.js +2 -1
  135. package/dist/server/instrumentation.js +2 -2
  136. package/dist/server/isr-cache.d.ts +12 -4
  137. package/dist/server/isr-cache.js +3 -3
  138. package/dist/server/metadata-routes.js +4 -4
  139. package/dist/server/middleware-response-headers.js +1 -1
  140. package/dist/server/middleware-runtime.js +1 -1
  141. package/dist/server/middleware.d.ts +1 -0
  142. package/dist/server/middleware.js +1 -1
  143. package/dist/server/navigation-planner.d.ts +2 -0
  144. package/dist/server/navigation-planner.js +8 -2
  145. package/dist/server/next-error-digest.d.ts +9 -24
  146. package/dist/server/next-error-digest.js +23 -15
  147. package/dist/server/operation-token.js +1 -1
  148. package/dist/server/pages-body-parser-config.js +2 -1
  149. package/dist/server/pages-dev-hydration.d.ts +14 -0
  150. package/dist/server/pages-dev-hydration.js +83 -0
  151. package/dist/server/pages-dev-module-url.js +2 -2
  152. package/dist/server/pages-node-compat.d.ts +13 -6
  153. package/dist/server/pages-node-compat.js +44 -45
  154. package/dist/server/pages-page-data.d.ts +1 -1
  155. package/dist/server/pages-page-data.js +5 -4
  156. package/dist/server/pages-page-handler.js +61 -29
  157. package/dist/server/pages-page-response.d.ts +2 -2
  158. package/dist/server/pages-page-response.js +2 -2
  159. package/dist/server/pages-preview.d.ts +26 -0
  160. package/dist/server/pages-preview.js +165 -0
  161. package/dist/server/pages-readiness.d.ts +2 -1
  162. package/dist/server/pages-readiness.js +4 -2
  163. package/dist/server/pages-request-pipeline.js +1 -1
  164. package/dist/server/prerender-manifest.d.ts +15 -1
  165. package/dist/server/prerender-manifest.js +29 -1
  166. package/dist/server/prod-server.d.ts +6 -5
  167. package/dist/server/prod-server.js +15 -15
  168. package/dist/server/request-pipeline.js +1 -1
  169. package/dist/server/seed-cache.js +1 -1
  170. package/dist/server/socket-error-backstop.js +1 -1
  171. package/dist/server/static-file-cache.js +8 -9
  172. package/dist/server/worker-utils.js +1 -1
  173. package/dist/shims/cache.d.ts +1 -1
  174. package/dist/shims/cache.js +2 -1
  175. package/dist/shims/cdn-cache.d.ts +2 -7
  176. package/dist/shims/cdn-cache.js +2 -14
  177. package/dist/shims/constants.js +1 -1
  178. package/dist/shims/error-boundary.d.ts +4 -4
  179. package/dist/shims/error.d.ts +21 -5
  180. package/dist/shims/error.js +52 -14
  181. package/dist/shims/fetch-cache.js +1 -1
  182. package/dist/shims/font-utils.js +1 -1
  183. package/dist/shims/form.d.ts +1 -1
  184. package/dist/shims/head.js +3 -3
  185. package/dist/shims/headers.js +6 -4
  186. package/dist/shims/internal/pages-data-fetch-dedup.js +5 -3
  187. package/dist/shims/layout-segment-context.d.ts +1 -1
  188. package/dist/shims/link.d.ts +3 -1
  189. package/dist/shims/link.js +6 -3
  190. package/dist/shims/navigation-errors.d.ts +2 -1
  191. package/dist/shims/navigation-errors.js +9 -13
  192. package/dist/shims/navigation.d.ts +1 -1
  193. package/dist/shims/navigation.js +5 -5
  194. package/dist/shims/request-state-types.d.ts +2 -2
  195. package/dist/shims/router-state.d.ts +1 -0
  196. package/dist/shims/router.d.ts +2 -1
  197. package/dist/shims/router.js +18 -11
  198. package/dist/shims/script.js +1 -1
  199. package/dist/shims/server.js +2 -2
  200. package/dist/shims/slot.d.ts +1 -1
  201. package/dist/shims/thenable-params.js +1 -1
  202. package/dist/shims/unified-request-context.d.ts +1 -1
  203. package/dist/typegen.js +9 -11
  204. package/dist/utils/client-build-manifest.js +2 -2
  205. package/dist/utils/client-entry-manifest.js +1 -1
  206. package/dist/utils/client-runtime-metadata.js +1 -1
  207. package/dist/utils/commonjs-loader.js +3 -3
  208. package/dist/utils/mdx-scan.js +1 -1
  209. package/dist/utils/path.d.ts +1 -13
  210. package/dist/utils/path.js +1 -15
  211. package/dist/utils/plugin-options.d.ts +4 -0
  212. package/dist/utils/plugin-options.js +8 -0
  213. package/dist/utils/project.d.ts +1 -7
  214. package/dist/utils/project.js +2 -8
  215. package/dist/utils/public-routes.js +2 -2
  216. package/dist/utils/react-version.js +1 -1
  217. package/dist/utils/redirect-digest.d.ts +9 -0
  218. package/dist/utils/redirect-digest.js +25 -0
  219. package/dist/utils/vinext-root.js +1 -1
  220. package/dist/utils/vite-version.d.ts +6 -13
  221. package/dist/utils/vite-version.js +68 -34
  222. package/package.json +33 -14
  223. package/dist/cloudflare/index.d.ts +0 -3
  224. package/dist/cloudflare/index.js +0 -3
  225. package/dist/packages/cloudflare/src/cache/cdn-adapter.runtime.js +0 -102
  226. package/dist/packages/cloudflare/src/cache/kv-data-adapter.runtime.d.ts +0 -126
  227. package/dist/packages/cloudflare/src/cache/kv-data-adapter.runtime.js +0 -442
  228. package/dist/packages/cloudflare/src/deploy-config.js +0 -150
  229. package/dist/packages/cloudflare/src/deploy-help.js +0 -55
  230. package/dist/packages/cloudflare/src/deploy.js +0 -272
  231. package/dist/packages/cloudflare/src/tpr.d.ts +0 -45
  232. package/dist/packages/cloudflare/src/tpr.js +0 -582
  233. package/dist/packages/cloudflare/src/utils/cache-control-metadata.js +0 -20
  234. /package/dist/build/google-fonts/{fallback-metrics-data.js → fallback-metrics-data.json.js} +0 -0
  235. /package/dist/build/google-fonts/{font-data.js → font-data.json.js} +0 -0
  236. /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,9 @@
1
1
  import { isUnknownRecord } from "../utils/record.js";
2
+ import { flattenPluginOptions } from "../utils/plugin-options.js";
3
+ import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, findVinextCacheConfigInPlugins, loadVinextCacheConfigFromViteConfig } from "../cache/cache-adapters-virtual.js";
2
4
  //#region src/config/prerender.ts
3
5
  const VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY = "__vinextPrerenderConfig";
6
+ const VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY = "__vinextRouteRootConfig";
4
7
  function normalizeVinextPrerenderConfig(config) {
5
8
  if (config === void 0) return null;
6
9
  if (config === true) return { routes: "*" };
@@ -8,16 +11,8 @@ function normalizeVinextPrerenderConfig(config) {
8
11
  if (config.routes === "*") return { routes: "*" };
9
12
  throw new Error("[vinext] Unsupported `prerender.routes` config. Currently only `routes: \"*\"` is supported.");
10
13
  }
11
- function flattenPluginOptions(value, target) {
12
- if (Array.isArray(value)) {
13
- for (const item of value) flattenPluginOptions(item, target);
14
- return;
15
- }
16
- if (value) target.push(value);
17
- }
18
- function findVinextPrerenderConfigInPlugins(plugins) {
19
- const flattened = [];
20
- flattenPluginOptions(plugins, flattened);
14
+ async function findVinextPrerenderConfigInPlugins(plugins) {
15
+ const flattened = await flattenPluginOptions(plugins);
21
16
  for (const plugin of flattened) {
22
17
  if (!isUnknownRecord(plugin)) continue;
23
18
  const prerenderConfig = plugin[VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY];
@@ -25,8 +20,23 @@ function findVinextPrerenderConfigInPlugins(plugins) {
25
20
  }
26
21
  return null;
27
22
  }
23
+ async function findVinextRouteRootConfigInPlugins(plugins) {
24
+ const flattened = await flattenPluginOptions(plugins);
25
+ for (const plugin of flattened) {
26
+ if (!isUnknownRecord(plugin)) continue;
27
+ const routeRootConfig = plugin[VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY];
28
+ if (routeRootConfig) return routeRootConfig;
29
+ }
30
+ return null;
31
+ }
28
32
  async function loadVinextPrerenderConfigFromViteConfig(vite, root) {
29
- return findVinextPrerenderConfigInPlugins((await vite.loadConfigFromFile({
33
+ return await findVinextPrerenderConfigInPlugins((await vite.loadConfigFromFile({
34
+ command: "build",
35
+ mode: "production"
36
+ }, void 0, root))?.config.plugins);
37
+ }
38
+ async function loadVinextRouteRootConfigFromViteConfig(vite, root) {
39
+ return await findVinextRouteRootConfigInPlugins((await vite.loadConfigFromFile({
30
40
  command: "build",
31
41
  mode: "production"
32
42
  }, void 0, root))?.config.plugins);
@@ -52,4 +62,4 @@ function formatVinextPrerenderLabel(decision) {
52
62
  return "Pre-rendering all routes...";
53
63
  }
54
64
  //#endregion
55
- export { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, findVinextPrerenderConfigInPlugins, formatVinextPrerenderLabel, loadVinextPrerenderConfigFromViteConfig, normalizeVinextPrerenderConfig, resolveVinextPrerenderDecision };
65
+ export { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY, findVinextCacheConfigInPlugins, findVinextPrerenderConfigInPlugins, findVinextRouteRootConfigInPlugins, formatVinextPrerenderLabel, loadVinextCacheConfigFromViteConfig, loadVinextPrerenderConfigFromViteConfig, loadVinextRouteRootConfigFromViteConfig, normalizeVinextPrerenderConfig, resolveVinextPrerenderDecision };
@@ -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
  }
@@ -143,7 +143,11 @@ function loadTsconfigResolutionForRoot(projectRoot) {
143
143
  for (const name of TSCONFIG_FILES) {
144
144
  const candidate = path.join(projectRoot, name);
145
145
  if (!fs.existsSync(candidate)) continue;
146
- return loadResolutionFromTsconfigFile(candidate, /* @__PURE__ */ new Set());
146
+ const resolution = loadResolutionFromTsconfigFile(candidate, /* @__PURE__ */ new Set());
147
+ return {
148
+ aliases: Object.fromEntries(Object.entries(resolution.aliases).sort((a, b) => b[0].length - a[0].length)),
149
+ baseUrl: resolution.baseUrl
150
+ };
147
151
  }
148
152
  return emptyResolution();
149
153
  }
@@ -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.
@@ -44,6 +44,7 @@ function generateImageAdaptersModule(images) {
44
44
  "let __vinextImageOptimizerRegistered = false;",
45
45
  "",
46
46
  "export function registerConfiguredImageOptimizer(env) {",
47
+ " if (typeof process !== 'undefined' && process.env?.__VINEXT_PRERENDER_PATH_DISCOVERY === '1') return;",
47
48
  " if (__vinextImageOptimizerRegistered) return;",
48
49
  " __vinextImageOptimizerRegistered = true;",
49
50
  " try {",
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { NextConfig, NextConfigInput } from "./config/next-config.js";
2
- import { AppStaticExportOptions, StaticExportOptions, StaticExportResult, staticExportApp, staticExportPages } from "./build/static-export.js";
3
2
  import { VinextCacheConfig } from "./cache/cache-adapters-virtual.js";
4
3
  import { VinextPrerenderConfig } from "./config/prerender.js";
4
+ import { AppStaticExportOptions, StaticExportOptions, StaticExportResult, staticExportApp, staticExportPages } from "./build/static-export.js";
5
5
  import { VinextImageConfig } from "./image/image-adapters-virtual.js";
6
6
  import { PluginOption } from "vite";
7
7
  import { Options } from "@vitejs/plugin-react";