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
package/README.md CHANGED
@@ -32,7 +32,23 @@ Run `vinext check` against an existing application before migrating. If a gap is
32
32
 
33
33
  ## Quick start
34
34
 
35
- vinext includes an [Agent Skill](https://agentskills.io/home) that handles migration for you. It works with Claude Code, OpenCode, Cursor, Codex, and dozens of other AI coding tools. Install it, open your Next.js project, and tell the AI to migrate:
35
+ **Use the official setup commands below.** They are the recommended way to create or migrate a vinext project because they configure dependencies, scripts, Vite, and your deployment target for you.
36
+
37
+ Start a new project with `create-vinext-app`:
38
+
39
+ ```bash
40
+ pnpm create vinext-app@latest my-app
41
+ ```
42
+
43
+ Migrate an existing Next.js project with `vinext init`:
44
+
45
+ ```bash
46
+ npx vinext init
47
+ ```
48
+
49
+ ### Optional: migrate with an AI agent
50
+
51
+ Prefer `vinext init` for a direct, repeatable migration. If you want an AI agent to investigate compatibility issues and guide the migration, vinext also includes an optional [Agent Skill](https://agentskills.io/home). It works with Claude Code, OpenCode, Cursor, Codex, and dozens of other AI coding tools:
36
52
 
37
53
  ```sh
38
54
  npx skills add cloudflare/vinext
@@ -1,5 +1,5 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import fs from "node:fs";
2
- import path from "node:path";
3
3
  //#region src/build/assets-ignore.ts
4
4
  /**
5
5
  * Build metadata that must never be served by the Cloudflare ASSETS binding.
@@ -1,5 +1,5 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import fs from "node:fs";
2
- import path from "node:path";
3
3
  //#region src/build/clean-output.ts
4
4
  function resolveOutDir(root, outDir) {
5
5
  const resolvedRoot = path.resolve(root);
@@ -1,5 +1,6 @@
1
+ import { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  //#region src/build/client-build-config.ts
2
- const ROUTE_OWNED_CLIENT_SHIMS = new Set([
3
+ const ROUTE_OWNED_CLIENT_SHIMS = /* @__PURE__ */ new Set([
3
4
  "compat-router",
4
5
  "dynamic",
5
6
  "dynamic-preload-chunks",
@@ -47,7 +48,7 @@ function createClientAssetFileNames(assetsDir) {
47
48
  * (node_modules/.pnpm/pkg@ver/node_modules/pkg).
48
49
  */
49
50
  function getPackageName(id) {
50
- const normalizedId = id.replaceAll("\\", "/");
51
+ const normalizedId = toSlash(id);
51
52
  const nmIdx = normalizedId.lastIndexOf("node_modules/");
52
53
  if (nmIdx === -1) return null;
53
54
  const rest = normalizedId.slice(nmIdx + 13);
@@ -90,9 +91,10 @@ function createClientManualChunks(shimsDir, preserveRouteBoundaries = false) {
90
91
  if (pkg === "react" || pkg === "react-dom" || pkg === "scheduler") return "framework";
91
92
  return;
92
93
  }
93
- if (id.startsWith(shimsDir)) {
94
+ const slashedId = toSlash(id);
95
+ if (slashedId.startsWith(shimsDir)) {
94
96
  if (preserveRouteBoundaries) {
95
- const relativeId = id.slice(shimsDir.length).split("?", 1)[0] ?? "";
97
+ const relativeId = slashedId.slice(shimsDir.length).split("?", 1)[0] ?? "";
96
98
  const extensionIndex = relativeId.lastIndexOf(".");
97
99
  const shimName = extensionIndex === -1 ? relativeId : relativeId.slice(0, extensionIndex);
98
100
  if (ROUTE_OWNED_CLIENT_SHIMS.has(shimName)) return void 0;
@@ -1,4 +1,4 @@
1
- import path from "node:path";
1
+ import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
2
  //#region src/build/css-url-assets.ts
3
3
  /**
4
4
  * Next-parity for CSS `url()` asset dependencies.
@@ -35,7 +35,7 @@ const CSS_URL_RE = /url\(\s*(?:"([^"]*)"|'([^']*)'|([^'")]*?))\s*\)/g;
35
35
  const CSS_ASSET_EXT_RE = /\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp|woff2?|eot|ttf|otf|mp4|webm|ogg|mp3|wav|flac|aac|wasm)$/i;
36
36
  const CSS_REQUEST_RE = /\.(?:css|scss|sass|less|styl|stylus)(?:\?|$)/i;
37
37
  function basename(value) {
38
- const normalized = value.replaceAll("\\", "/");
38
+ const normalized = toSlash(value);
39
39
  const slash = normalized.lastIndexOf("/");
40
40
  return slash === -1 ? normalized : normalized.slice(slash + 1);
41
41
  }
@@ -137,7 +137,7 @@ function rebaseCssUrlAssetReferences(code, sourceDirectory, targetDirectory) {
137
137
  const lower = parts.path.toLowerCase();
138
138
  if (!CSS_ASSET_EXT_RE.test(lower) || lower.endsWith(".css")) return null;
139
139
  const absolutePath = path.resolve(sourceDirectory, parts.path);
140
- let rebasedPath = path.relative(targetDirectory, absolutePath).replaceAll("\\", "/");
140
+ let rebasedPath = path.relative(targetDirectory, absolutePath);
141
141
  if (!rebasedPath.startsWith(".")) rebasedPath = `./${rebasedPath}`;
142
142
  return joinUrl({
143
143
  ...parts,
@@ -1,5 +1,5 @@
1
1
  import { escapeCSSString } from "../../shims/font-utils.js";
2
- import fallback_metrics_data_default from "./fallback-metrics-data.js";
2
+ import fallback_metrics_data_default from "./fallback-metrics-data.json.js";
3
3
  //#region src/build/google-fonts/fallback-metrics.ts
4
4
  const EXPECTED_METRIC_LENGTH = 6;
5
5
  const fallbackMetrics = fallback_metrics_data_default;
@@ -1,4 +1,4 @@
1
- import font_data_default from "./font-data.js";
1
+ import font_data_default from "./font-data.json.js";
2
2
  //#region src/build/google-fonts/font-metadata.ts
3
3
  const googleFontsMetadata = font_data_default;
4
4
  //#endregion
@@ -1,7 +1,7 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { escapeRegExp } from "../utils/regex.js";
2
3
  import { readPrerenderManifest } from "../server/prerender-manifest.js";
3
4
  import fs from "node:fs";
4
- import path from "node:path";
5
5
  //#region src/build/inject-pregenerated-paths.ts
6
6
  const VINEXT_PREGEN_START = "/* __VINEXT_PREGENERATED_CONCRETE_PATHS_START__ */";
7
7
  const VINEXT_PREGEN_END = "/* __VINEXT_PREGENERATED_CONCRETE_PATHS_END__ */";
@@ -1,6 +1,6 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { resolveAssetUrlPrefix, resolveAssetsDir } from "../utils/asset-prefix.js";
2
3
  import fs from "node:fs";
3
- import path from "node:path";
4
4
  //#region src/build/inline-css.ts
5
5
  const INLINE_CSS_GLOBAL_MARKER = "globalThis.__VINEXT_INLINE_CSS__ = ";
6
6
  function collectCssFiles(directory) {
@@ -12,9 +12,6 @@ function collectCssFiles(directory) {
12
12
  }
13
13
  return files;
14
14
  }
15
- function toUrlPath(filePath) {
16
- return filePath.split(path.sep).join("/");
17
- }
18
15
  function addPathnameAlias(manifest, href, css) {
19
16
  try {
20
17
  const url = new URL(href);
@@ -27,7 +24,7 @@ function collectInlineCssManifest(clientDir, assetPrefix) {
27
24
  const urlPrefix = resolveAssetUrlPrefix(assetPrefix);
28
25
  const manifest = {};
29
26
  for (const filePath of collectCssFiles(assetsDir)) {
30
- const href = `${urlPrefix}${toUrlPath(path.relative(assetsDir, filePath))}`;
27
+ const href = `${urlPrefix}${path.relative(assetsDir, filePath)}`;
31
28
  const css = fs.readFileSync(filePath, "utf8");
32
29
  manifest[href] = css;
33
30
  addPathnameAlias(manifest, href, css);
@@ -0,0 +1,4 @@
1
+ //#region src/build/module-dependency-cache.d.ts
2
+ declare function createModuleDependencyCache<T>(collect: (moduleId: string) => Promise<T>): (moduleId: string) => Promise<T>;
3
+ //#endregion
4
+ export { createModuleDependencyCache };
@@ -0,0 +1,13 @@
1
+ //#region src/build/module-dependency-cache.ts
2
+ function createModuleDependencyCache(collect) {
3
+ const cache = /* @__PURE__ */ new Map();
4
+ return function getModuleDependencies(moduleId) {
5
+ const cached = cache.get(moduleId);
6
+ if (cached) return cached;
7
+ const pending = collect(moduleId);
8
+ cache.set(moduleId, pending);
9
+ return pending;
10
+ };
11
+ }
12
+ //#endregion
13
+ export { createModuleDependencyCache };
@@ -1,5 +1,5 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import fs from "node:fs";
2
- import path from "node:path";
3
3
  //#region src/build/next-client-runtime-manifests.ts
4
4
  function normalizeRewriteForClientManifest(rewrite) {
5
5
  if (rewrite.destination.startsWith("/")) return {
@@ -1,5 +1,5 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import fs from "node:fs";
2
- import path from "node:path";
3
3
  //#region src/build/pages-client-assets-module.ts
4
4
  const PAGES_CLIENT_ASSETS_MODULE = "vinext-client-assets.js";
5
5
  const pagesClientAssetsByBuildSession = /* @__PURE__ */ new Map();
@@ -1,6 +1,6 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { ASSET_PREFIX_URL_DIR } from "../utils/asset-prefix.js";
2
- import path from "node:path";
3
- import fs from "node:fs/promises";
3
+ import fsp from "node:fs/promises";
4
4
  import os from "node:os";
5
5
  import zlib from "node:zlib";
6
6
  import { promisify } from "node:util";
@@ -20,7 +20,7 @@ const brotliCompress = promisify(zlib.brotliCompress);
20
20
  const gzip = promisify(zlib.gzip);
21
21
  const zstdCompress = typeof zlib.zstdCompress === "function" ? promisify(zlib.zstdCompress) : null;
22
22
  /** File extensions worth compressing (text-based, not already compressed). */
23
- const COMPRESSIBLE_EXTENSIONS = new Set([
23
+ const COMPRESSIBLE_EXTENSIONS = /* @__PURE__ */ new Set([
24
24
  ".js",
25
25
  ".mjs",
26
26
  ".css",
@@ -46,7 +46,7 @@ const CONCURRENCY = Math.min(os.availableParallelism(), 8);
46
46
  async function* walkFiles(dir, base = dir) {
47
47
  let entries;
48
48
  try {
49
- entries = await fs.readdir(dir, { withFileTypes: true });
49
+ entries = await fsp.readdir(dir, { withFileTypes: true });
50
50
  } catch {
51
51
  return;
52
52
  }
@@ -89,13 +89,13 @@ async function precompressAssets(clientDir, options = {}) {
89
89
  for (let i = 0; i < filePaths.length; i += CONCURRENCY) {
90
90
  const chunk = filePaths.slice(i, i + CONCURRENCY);
91
91
  await Promise.all(chunk.map(async (fullPath) => {
92
- const content = await fs.readFile(fullPath);
92
+ const content = await fsp.readFile(fullPath);
93
93
  if (content.length < MIN_SIZE) return;
94
94
  const compressions = [brotliCompress(content, { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 5 } }), gzip(content, { level: 8 })];
95
95
  if (zstdCompress) compressions.push(zstdCompress(content, { params: { [zlib.constants.ZSTD_c_compressionLevel]: 8 } }));
96
96
  const [brContent, gzContent, zstdContent] = await Promise.all(compressions);
97
- const writes = [fs.writeFile(fullPath + ".br", brContent), fs.writeFile(fullPath + ".gz", gzContent)];
98
- if (zstdContent) writes.push(fs.writeFile(fullPath + ".zst", zstdContent));
97
+ const writes = [fsp.writeFile(fullPath + ".br", brContent), fsp.writeFile(fullPath + ".gz", gzContent)];
98
+ if (zstdContent) writes.push(fsp.writeFile(fullPath + ".zst", zstdContent));
99
99
  await Promise.all(writes);
100
100
  result.filesCompressed++;
101
101
  result.totalOriginalBytes += content.length;
@@ -10,8 +10,8 @@ type PrerenderPathManifest = {
10
10
  declare const PRERENDER_PATH_DISCOVERY_ENV = "__VINEXT_PRERENDER_PATH_DISCOVERY";
11
11
  declare const PRERENDER_PATHS_MANIFEST = "vinext-prerender-paths.json";
12
12
  type EmitPrerenderPathManifestOptions = {
13
- root: string;
14
- nextConfigOverride?: Partial<ResolvedNextConfig>;
13
+ root: string; /** Fully resolved Next.js config. Loaded from disk when omitted. */
14
+ nextConfig?: ResolvedNextConfig;
15
15
  appDir?: string | null;
16
16
  pagesDir?: string | null;
17
17
  routeRootConfig?: VinextRouteRootConfig | null;
@@ -1,5 +1,5 @@
1
+ import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { findDir } from "../utils/project.js";
2
- import { normalizePathSeparators } from "../utils/path.js";
3
3
  import { apiRouter, pagesRouter } from "../routing/pages-router.js";
4
4
  import { VINEXT_PRERENDER_SECRET_HEADER } from "../utils/protocol-headers.js";
5
5
  import { classifyAppRoute, classifyPagesRoute, getAppRouteRenderEntryPath, hasNamedExport } from "./report.js";
@@ -11,7 +11,6 @@ import { readPrerenderSecret } from "./server-manifest.js";
11
11
  import { startProdServer } from "../server/prod-server.js";
12
12
  import { buildUrlFromParams, resolveParentParams } from "./prerender.js";
13
13
  import fs from "node:fs";
14
- import path from "node:path";
15
14
  //#region src/build/prerender-paths.ts
16
15
  const PRERENDER_PATH_DISCOVERY_ENV = "__VINEXT_PRERENDER_PATH_DISCOVERY";
17
16
  const PRERENDER_PATHS_MANIFEST = "vinext-prerender-paths.json";
@@ -68,16 +67,16 @@ function resolveConfiguredRouteDirs(root, routeRootConfig) {
68
67
  let baseDir;
69
68
  if (routeRootConfig.appDir) {
70
69
  baseDir = path.isAbsolute(routeRootConfig.appDir) ? routeRootConfig.appDir : path.resolve(root, routeRootConfig.appDir);
71
- baseDir = normalizePathSeparators(baseDir);
70
+ baseDir = toSlash(baseDir);
72
71
  } else {
73
- const hasRootApp = fs.existsSync(path.posix.join(root, "app"));
74
- const hasRootPages = fs.existsSync(path.posix.join(root, "pages"));
75
- const hasSrcApp = fs.existsSync(path.posix.join(root, "src", "app"));
76
- const hasSrcPages = fs.existsSync(path.posix.join(root, "src", "pages"));
77
- baseDir = hasRootApp || hasRootPages ? root : hasSrcApp || hasSrcPages ? path.posix.join(root, "src") : root;
72
+ const hasRootApp = fs.existsSync(path.join(root, "app"));
73
+ const hasRootPages = fs.existsSync(path.join(root, "pages"));
74
+ const hasSrcApp = fs.existsSync(path.join(root, "src", "app"));
75
+ const hasSrcPages = fs.existsSync(path.join(root, "src", "pages"));
76
+ baseDir = hasRootApp || hasRootPages ? root : hasSrcApp || hasSrcPages ? path.join(root, "src") : root;
78
77
  }
79
- const appDir = path.posix.join(baseDir, "app");
80
- const pagesDir = path.posix.join(baseDir, "pages");
78
+ const appDir = path.join(baseDir, "app");
79
+ const pagesDir = path.join(baseDir, "pages");
81
80
  return {
82
81
  appDir: !routeRootConfig.disableAppRouter && fs.existsSync(appDir) ? appDir : null,
83
82
  pagesDir: fs.existsSync(pagesDir) ? pagesDir : null
@@ -237,11 +236,7 @@ async function emitPrerenderPathManifest(options) {
237
236
  const pagesBundlePath = options.pagesBundlePath ?? path.join(root, "dist", "server", "entry.js");
238
237
  const bundleServerDir = fs.existsSync(rscBundlePath) ? path.dirname(rscBundlePath) : path.dirname(pagesBundlePath);
239
238
  const manifestDir = path.join(root, "dist", "server");
240
- const loadedConfig = await resolveNextConfig(await loadNextConfig(root, PHASE_PRODUCTION_BUILD), root);
241
- const config = options.nextConfigOverride ? {
242
- ...loadedConfig,
243
- ...options.nextConfigOverride
244
- } : { ...loadedConfig };
239
+ const config = options.nextConfig ? { ...options.nextConfig } : { ...await resolveNextConfig(await loadNextConfig(root, PHASE_PRODUCTION_BUILD), root) };
245
240
  const builtBuildId = readBuiltBuildId(manifestDir) ?? readBuiltBuildId(bundleServerDir);
246
241
  if (builtBuildId) config.buildId = builtBuildId;
247
242
  const paths = [];
@@ -1,5 +1,5 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import fs from "node:fs";
2
- import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import os from "node:os";
5
5
  import { fork } from "node:child_process";
@@ -50,7 +50,7 @@ const APPROX_BYTES_PER_WORKER = 768 * 1024 * 1024;
50
50
  const WORKER_READY_TIMEOUT_MS = 6e4;
51
51
  /** Best-effort close timeout so build cleanup is not blocked forever by a wedged child. */
52
52
  const WORKER_CLOSE_TIMEOUT_MS = 5e3;
53
- const PRERENDER_WORKER_TRANSPORT_ERROR_CODES = new Set([
53
+ const PRERENDER_WORKER_TRANSPORT_ERROR_CODES = /* @__PURE__ */ new Set([
54
54
  "ECONNREFUSED",
55
55
  "ECONNRESET",
56
56
  "EPIPE",
@@ -1,3 +1,4 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { createValidFileMatcher, findFileWithExtensions } from "../routing/file-matcher.js";
2
3
  import { VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER, VINEXT_PRERENDER_SPECULATIVE_HEADER } from "../utils/protocol-headers.js";
3
4
  import { VINEXT_PRERENDER_CACHE_LIFE_HEADER } from "../server/headers.js";
@@ -17,7 +18,6 @@ import { getOutputPath, getRscOutputPath } from "../utils/prerender-output-paths
17
18
  import { startProdServer } from "../server/prod-server.js";
18
19
  import { prerenderPoolAvailable, resolvePrerenderPoolSize, startPrerenderServerPool } from "./prerender-server-pool.js";
19
20
  import fs from "node:fs";
20
- import path from "node:path";
21
21
  import os from "node:os";
22
22
  //#region src/build/prerender.ts
23
23
  /**
@@ -0,0 +1,11 @@
1
+ //#region src/build/preview-credentials.d.ts
2
+ type PreviewBuildCredentials = {
3
+ id: string;
4
+ signingKey: string;
5
+ encryptionKey: string;
6
+ };
7
+ declare function createPreviewBuildCredentials(): PreviewBuildCredentials;
8
+ declare function getPreviewBuildCredentials(): PreviewBuildCredentials | undefined;
9
+ declare function runWithPreviewBuildCredentials<T>(callback: () => T): T;
10
+ //#endregion
11
+ export { PreviewBuildCredentials, createPreviewBuildCredentials, getPreviewBuildCredentials, runWithPreviewBuildCredentials };
@@ -0,0 +1,19 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { randomBytes } from "node:crypto";
3
+ //#region src/build/preview-credentials.ts
4
+ const previewBuildCredentialsStorage = new AsyncLocalStorage();
5
+ function createPreviewBuildCredentials() {
6
+ return {
7
+ id: randomBytes(16).toString("hex"),
8
+ signingKey: randomBytes(32).toString("hex"),
9
+ encryptionKey: randomBytes(32).toString("hex")
10
+ };
11
+ }
12
+ function getPreviewBuildCredentials() {
13
+ return previewBuildCredentialsStorage.getStore();
14
+ }
15
+ function runWithPreviewBuildCredentials(callback) {
16
+ return previewBuildCredentialsStorage.run(createPreviewBuildCredentials(), callback);
17
+ }
18
+ //#endregion
19
+ export { createPreviewBuildCredentials, getPreviewBuildCredentials, runWithPreviewBuildCredentials };
@@ -130,9 +130,6 @@ declare function formatBuildReport(rows: RouteRow[], routerLabel?: string): stri
130
130
  /**
131
131
  * Scans the project at `root`, classifies all routes, and prints the
132
132
  * Next.js-style build report to stdout.
133
- *
134
- * `root` must be forward-slash — it is passed to `findDir`. The caller (the
135
- * `vinext build` entry in cli.ts) normalizes it.
136
133
  */
137
134
  declare function printBuildReport(options: {
138
135
  root: string;
@@ -1,3 +1,4 @@
1
+ import { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { findDir } from "../utils/project.js";
2
3
  import fs from "node:fs";
3
4
  import { parseSync } from "vite";
@@ -415,7 +416,7 @@ function classifyLayoutSegmentConfig(code) {
415
416
  * API routes (files under pages/api/) are always `api`.
416
417
  */
417
418
  function classifyPagesRoute(filePath) {
418
- if (filePath.replace(/\\/g, "/").includes("/pages/api/")) return { type: "api" };
419
+ if (toSlash(filePath).includes("/pages/api/")) return { type: "api" };
419
420
  let code;
420
421
  try {
421
422
  code = fs.readFileSync(filePath, "utf8");
@@ -569,9 +570,6 @@ function formatBuildReport(rows, routerLabel = "app") {
569
570
  /**
570
571
  * Scans the project at `root`, classifies all routes, and prints the
571
572
  * Next.js-style build report to stdout.
572
- *
573
- * `root` must be forward-slash — it is passed to `findDir`. The caller (the
574
- * `vinext build` entry in cli.ts) normalizes it.
575
573
  */
576
574
  async function printBuildReport(options) {
577
575
  const { root } = options;
@@ -3,13 +3,8 @@ import { PrerenderResult, PrerenderRouteResult } from "./prerender.js";
3
3
 
4
4
  //#region src/build/run-prerender.d.ts
5
5
  type RunPrerenderOptions = {
6
- /** Project root directory. */root: string;
7
- /**
8
- * Override next.config values. Merged on top of the config loaded from disk.
9
- * Intended for tests that need to exercise a specific config (e.g. output: 'export')
10
- * without writing a next.config file.
11
- */
12
- nextConfigOverride?: Partial<ResolvedNextConfig>;
6
+ /** Project root directory. */root: string; /** Fully resolved Next.js config. Loaded from disk when omitted. */
7
+ nextConfig?: ResolvedNextConfig;
13
8
  /**
14
9
  * Override the path to the Pages Router server bundle.
15
10
  * Defaults to `<root>/dist/server/entry.js`.
@@ -58,10 +53,6 @@ type RunPrerenderOptions = {
58
53
  declare function assertNoFatalPrerenderRoutes(routes: readonly PrerenderRouteResult[]): void;
59
54
  /**
60
55
  * Statically generate routes and return the prerender result.
61
- *
62
- * `options.root` must be forward-slash — it is passed to `findDir` and flows
63
- * into the route model. The caller (the `vinext build` entry in cli.ts)
64
- * normalizes it.
65
56
  */
66
57
  declare function runPrerender(options: RunPrerenderOptions): Promise<PrerenderResult | null>;
67
58
  //#endregion
@@ -1,3 +1,4 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { findDir } from "../utils/project.js";
2
3
  import { apiRouter, pagesRouter } from "../routing/pages-router.js";
3
4
  import { appRouter } from "../routing/app-router.js";
@@ -8,7 +9,6 @@ import { rememberCurrentServerEntryImportMtime, startProdServer } from "../serve
8
9
  import { prerenderApp, prerenderPages, writePrerenderIndex } from "./prerender.js";
9
10
  import { injectPregeneratedConcretePaths } from "./inject-pregenerated-paths.js";
10
11
  import fs from "node:fs";
11
- import path from "node:path";
12
12
  //#region src/build/run-prerender.ts
13
13
  /**
14
14
  * Shared prerender runner used by both `vinext build` (cli.ts) and
@@ -98,10 +98,6 @@ function assertNoFatalPrerenderRoutes(routes) {
98
98
  }
99
99
  /**
100
100
  * Statically generate routes and return the prerender result.
101
- *
102
- * `options.root` must be forward-slash — it is passed to `findDir` and flows
103
- * into the route model. The caller (the `vinext build` entry in cli.ts)
104
- * normalizes it.
105
101
  */
106
102
  async function runPrerender(options) {
107
103
  const { root } = options;
@@ -113,11 +109,7 @@ async function runPrerender(options) {
113
109
  const manifestDir = path.join(root, "dist", "server");
114
110
  const rscBundlePath = options.rscBundlePath ?? path.join(root, "dist", "server", "index.js");
115
111
  const serverDir = path.dirname(rscBundlePath);
116
- const loadedConfig = await resolveNextConfig(await loadNextConfig(root), root);
117
- const config = options.nextConfigOverride ? {
118
- ...loadedConfig,
119
- ...options.nextConfigOverride
120
- } : { ...loadedConfig };
112
+ const config = options.nextConfig ? { ...options.nextConfig } : { ...await resolveNextConfig(await loadNextConfig(root), root) };
121
113
  const builtBuildId = readBuiltBuildId(serverDir);
122
114
  if (builtBuildId) config.buildId = builtBuildId;
123
115
  const mode = config.output === "export" ? "export" : "default";
@@ -1,5 +1,5 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { readJsonFile } from "../utils/safe-json-file.js";
2
- import path from "node:path";
3
3
  //#region src/build/server-manifest.ts
4
4
  /**
5
5
  * Shared utilities for reading/writing vinext-server.json.
@@ -9,6 +9,10 @@ type BundleBackfillChunk = {
9
9
  importedAssets?: Set<string>;
10
10
  };
11
11
  };
12
+ /**
13
+ * Realpath with NATIVE separators (backslashes on Windows). Callers apply
14
+ * `toSlash` where the result becomes a module id / manifest key.
15
+ */
12
16
  declare function tryRealpathSync(candidate: string): string | null;
13
17
  declare function relativeWithinRoot(root: string, moduleId: string): string | null;
14
18
  declare function augmentSsrManifestFromBundle(ssrManifest: Record<string, string[]>, bundle: Record<string, BundleBackfillChunk | {
@@ -1,7 +1,11 @@
1
+ import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { collapseDuplicateBase, manifestFileWithBase } from "../utils/manifest-paths.js";
2
3
  import fs from "node:fs";
3
- import path from "node:path";
4
4
  //#region src/build/ssr-manifest.ts
5
+ /**
6
+ * Realpath with NATIVE separators (backslashes on Windows). Callers apply
7
+ * `toSlash` where the result becomes a module id / manifest key.
8
+ */
5
9
  function tryRealpathSync(candidate) {
6
10
  try {
7
11
  return fs.realpathSync.native(candidate);
@@ -13,26 +17,26 @@ function isWindowsAbsolutePath(candidate) {
13
17
  return /^[a-zA-Z]:[\\/]/.test(candidate) || candidate.startsWith("\\\\");
14
18
  }
15
19
  function relativeWithinRoot(root, moduleId) {
16
- const relativeId = (isWindowsAbsolutePath(root) || isWindowsAbsolutePath(moduleId) ? path.win32.relative(root, moduleId) : path.relative(root, moduleId)).replace(/\\/g, "/");
20
+ const relativeId = isWindowsAbsolutePath(root) || isWindowsAbsolutePath(moduleId) ? path.win32.relative(root, moduleId) : path.relative(root, moduleId);
17
21
  if (!relativeId || relativeId === ".." || relativeId.startsWith("../")) return null;
18
22
  return relativeId;
19
23
  }
20
24
  function normalizeManifestModuleId(moduleId, root) {
21
- const normalizedId = moduleId.replace(/\\/g, "/");
25
+ const normalizedId = toSlash(moduleId);
22
26
  if (normalizedId.startsWith("\0")) return normalizedId;
23
27
  if (normalizedId.startsWith("node_modules/") || normalizedId.includes("/node_modules/")) return normalizedId;
24
28
  if (!isWindowsAbsolutePath(moduleId) && !path.isAbsolute(moduleId)) {
25
29
  if (!normalizedId.startsWith(".") && !normalizedId.includes("../")) return normalizedId;
26
30
  }
27
- const rootCandidates = new Set([root]);
31
+ const rootCandidates = /* @__PURE__ */ new Set([root]);
28
32
  const realRoot = tryRealpathSync(root);
29
- if (realRoot) rootCandidates.add(realRoot);
33
+ if (realRoot) rootCandidates.add(toSlash(realRoot));
30
34
  const moduleCandidates = /* @__PURE__ */ new Set();
31
35
  if (isWindowsAbsolutePath(moduleId) || path.isAbsolute(moduleId)) moduleCandidates.add(moduleId);
32
36
  else moduleCandidates.add(path.resolve(root, moduleId));
33
37
  for (const candidate of moduleCandidates) {
34
38
  const realCandidate = tryRealpathSync(candidate);
35
- if (realCandidate) moduleCandidates.add(realCandidate);
39
+ if (realCandidate) moduleCandidates.add(toSlash(realCandidate));
36
40
  }
37
41
  for (const rootCandidate of rootCandidates) for (const moduleCandidate of moduleCandidates) {
38
42
  const relativeId = relativeWithinRoot(rootCandidate, moduleCandidate);