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,15 +1,17 @@
1
- import { collectBindingNames, forEachAstChild, hasRange, isAstRecord, isIdentifierNamed, mayContainDynamicImport, nodeArray } from "./ast-utils.js";
1
+ import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
+ import { DYNAMIC_IMPORT_PRESCAN, collectBindingNames, forEachAstChild, hasRange, isAstRecord, isIdentifierNamed, mayContainDynamicImport, nodeArray } from "./ast-utils.js";
2
3
  import { collectDirectScopeBindings, collectLoopScopeBindings, collectSwitchScopeBindings, collectVarScopeBindings, hasAstBinding, isFunctionNode } from "./ast-scope.js";
3
- import path from "node:path";
4
4
  import { parseAst } from "vite";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import MagicString from "magic-string";
7
7
  //#region src/plugins/ignore-dynamic-requests.ts
8
8
  const DYNAMIC_REQUEST_ERROR = "Cannot find module as expression is too dynamic";
9
+ const REQUIRE_PRESCAN = /(?:\brequire\b|(?:r|\\u(?:0072|\{0*72\}))(?:e|\\u(?:0065|\{0*65\}))(?:q|\\u(?:0071|\{0*71\}))(?:u|\\u(?:0075|\{0*75\}))(?:i|\\u(?:0069|\{0*69\}))(?:r|\\u(?:0072|\{0*72\}))(?:e|\\u(?:0065|\{0*65\})))/i;
10
+ const DYNAMIC_REQUEST_PRESCAN = new RegExp(String.raw`(?:${REQUIRE_PRESCAN.source}|${DYNAMIC_IMPORT_PRESCAN.source})`, "i");
9
11
  const MAX_CONSTANT_BINDING_DEPTH = 1500;
10
12
  const VINEXT_SOURCE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
11
13
  const PLUGIN_RSC_PATH = /[\\/]node_modules[\\/](?:\.pnpm[\\/][^/\\]+[\\/]node_modules[\\/])?@vitejs[\\/]plugin-rsc[\\/]/;
12
- const TRANSFORMABLE_EXTENSIONS = new Set([
14
+ const TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
13
15
  ".js",
14
16
  ".jsx",
15
17
  ".mjs",
@@ -19,7 +21,7 @@ const TRANSFORMABLE_EXTENSIONS = new Set([
19
21
  ".mts",
20
22
  ".cts"
21
23
  ]);
22
- const TRANSPARENT_EXPRESSIONS = new Set([
24
+ const TRANSPARENT_EXPRESSIONS = /* @__PURE__ */ new Set([
23
25
  "ChainExpression",
24
26
  "ParenthesizedExpression",
25
27
  "TSAsExpression",
@@ -382,7 +384,7 @@ function dynamicImportReplacement() {
382
384
  return `Promise.resolve().then(() => { const error = new Error(${JSON.stringify(DYNAMIC_REQUEST_ERROR)}); error.code = "MODULE_NOT_FOUND"; throw error; })`;
383
385
  }
384
386
  function transformVeryDynamicRequests(code, id) {
385
- if (!code.includes("require") && !mayContainDynamicImport(code)) return null;
387
+ if (!REQUIRE_PRESCAN.test(code) && !mayContainDynamicImport(code)) return null;
386
388
  const extension = path.extname(id.split("?", 1)[0]);
387
389
  const lang = extension === ".ts" || extension === ".mts" || extension === ".cts" ? "ts" : extension === ".tsx" ? "tsx" : extension === ".js" || extension === ".jsx" || extension === ".mjs" || extension === ".cjs" ? "jsx" : "js";
388
390
  let ast;
@@ -507,13 +509,16 @@ function createIgnoreDynamicRequestsPlugin(getTranspiledPackages = () => []) {
507
509
  name: "vinext:ignore-dynamic-requests",
508
510
  enforce: "pre",
509
511
  transform: {
510
- filter: { id: { include: /\.(?:[cm]?[jt]s|[jt]sx)(?:\?.*)?$/ } },
512
+ filter: {
513
+ id: { include: /\.(?:[cm]?[jt]s|[jt]sx)(?:\?.*)?$/ },
514
+ code: DYNAMIC_REQUEST_PRESCAN
515
+ },
511
516
  handler(code, id) {
512
517
  const cleanId = id.split("?", 1)[0];
513
518
  if (!TRANSFORMABLE_EXTENSIONS.has(path.extname(cleanId))) return null;
514
519
  if (!shouldTransformVeryDynamicRequests(this.environment, cleanId, getTranspiledPackages())) return null;
515
520
  const absoluteId = path.resolve(cleanId);
516
- if (absoluteId === VINEXT_SOURCE_ROOT || absoluteId.startsWith(`${VINEXT_SOURCE_ROOT}${path.sep}`) || PLUGIN_RSC_PATH.test(absoluteId)) return null;
521
+ if (absoluteId === VINEXT_SOURCE_ROOT || absoluteId.startsWith(`${VINEXT_SOURCE_ROOT}/`) || PLUGIN_RSC_PATH.test(absoluteId)) return null;
517
522
  return transformVeryDynamicRequests(code, id);
518
523
  }
519
524
  }
@@ -521,7 +526,7 @@ function createIgnoreDynamicRequestsPlugin(getTranspiledPackages = () => []) {
521
526
  }
522
527
  function shouldTransformVeryDynamicRequests(environment, id, transpiledPackages) {
523
528
  if (environment.config.consumer === "server") return true;
524
- const normalizedId = id.replaceAll("\\", "/");
529
+ const normalizedId = toSlash(id);
525
530
  if (!normalizedId.includes("/node_modules/")) return false;
526
531
  return !transpiledPackages.some((packageName) => normalizedId.includes(`/node_modules/${packageName}/`));
527
532
  }
@@ -1,12 +1,12 @@
1
+ import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { VIRTUAL_MODULE_ID_RE } from "../utils/virtual-module.js";
2
3
  import { collectBindingNames, forEachAstChild, hasRange, isAstRecord, isIdentifierNamed, nodeArray } from "./ast-utils.js";
3
4
  import { tryRealpathSync } from "../build/ssr-manifest.js";
4
- import path from "node:path";
5
- import { normalizePath, parseAst } from "vite";
5
+ import { parseAst } from "vite";
6
6
  import { pathToFileURL } from "node:url";
7
7
  import MagicString from "magic-string";
8
8
  //#region src/plugins/import-meta-url.ts
9
- const TRANSFORMABLE_SCRIPT_EXTENSIONS = new Set([
9
+ const TRANSFORMABLE_SCRIPT_EXTENSIONS = /* @__PURE__ */ new Set([
10
10
  ".cjs",
11
11
  ".cts",
12
12
  ".js",
@@ -104,23 +104,21 @@ function cleanModuleId(id) {
104
104
  }
105
105
  function createRootPaths(root, options = {}) {
106
106
  const canonicalRoot = canonicalizePath(root);
107
- const normalizedRoot = normalizePath(canonicalRoot);
108
107
  return {
109
108
  root,
110
109
  canonicalRoot,
111
- normalizedRoot,
112
- excludedRelativePrefixes: excludedRelativePrefixes(canonicalRoot, normalizedRoot, options)
110
+ excludedRelativePrefixes: excludedRelativePrefixes(canonicalRoot, options)
113
111
  };
114
112
  }
115
113
  function transformableModuleCanonicalId(id, rootPaths) {
116
114
  if (!id || id.startsWith("\0")) return null;
117
115
  if (!path.isAbsolute(id)) return null;
118
- const normalizedInputId = normalizePath(id);
119
- if (normalizedInputId.includes("/node_modules/")) return null;
120
- if (!TRANSFORMABLE_SCRIPT_EXTENSIONS.has(path.extname(normalizedInputId))) return null;
116
+ const slashedInputId = toSlash(id);
117
+ if (slashedInputId.includes("/node_modules/")) return null;
118
+ if (!TRANSFORMABLE_SCRIPT_EXTENSIONS.has(path.extname(slashedInputId))) return null;
121
119
  const canonicalId = canonicalizePath(id);
122
- if (!isPathWithin(normalizePath(canonicalId), rootPaths.normalizedRoot)) return null;
123
- if (isExcludedRelativePath(normalizePath(path.relative(rootPaths.canonicalRoot, canonicalId)), rootPaths.excludedRelativePrefixes)) return null;
120
+ if (!isPathWithin(canonicalId, rootPaths.canonicalRoot)) return null;
121
+ if (isExcludedRelativePath(path.relative(rootPaths.canonicalRoot, canonicalId), rootPaths.excludedRelativePrefixes)) return null;
124
122
  return canonicalId;
125
123
  }
126
124
  function mayContainImportMetaUrl(code) {
@@ -129,8 +127,8 @@ function mayContainImportMetaUrl(code) {
129
127
  function mayContainServerCjsGlobal(code) {
130
128
  return code.includes("__filename") || code.includes("__dirname");
131
129
  }
132
- function excludedRelativePrefixes(canonicalRoot, normalizedRoot, options) {
133
- const prefixes = new Set([
130
+ function excludedRelativePrefixes(canonicalRoot, options) {
131
+ const prefixes = /* @__PURE__ */ new Set([
134
132
  ".next",
135
133
  ".vinext",
136
134
  ".vinext-local-package",
@@ -139,8 +137,8 @@ function excludedRelativePrefixes(canonicalRoot, normalizedRoot, options) {
139
137
  ]);
140
138
  for (const outputDir of options.outputDirs ?? []) {
141
139
  const canonicalOutputDir = canonicalizePath(path.isAbsolute(outputDir) ? outputDir : path.resolve(canonicalRoot, outputDir));
142
- if (!isPathWithin(normalizePath(canonicalOutputDir), normalizedRoot)) continue;
143
- const relativePath = normalizePath(path.relative(canonicalRoot, canonicalOutputDir));
140
+ if (!isPathWithin(canonicalOutputDir, canonicalRoot)) continue;
141
+ const relativePath = path.relative(canonicalRoot, canonicalOutputDir);
144
142
  if (relativePath && relativePath !== ".") prefixes.add(relativePath);
145
143
  }
146
144
  return [...prefixes];
@@ -152,11 +150,12 @@ function isPathWithin(candidate, root) {
152
150
  return candidate === root || candidate.startsWith(root.endsWith("/") ? root : `${root}/`);
153
151
  }
154
152
  function importMetaUrlValue(canonicalId, rootPaths, environment) {
155
- if (environment === "client") return `file:///ROOT/${normalizePath(path.relative(rootPaths.canonicalRoot, canonicalId))}`;
153
+ if (environment === "client") return `file:///ROOT/${path.relative(rootPaths.canonicalRoot, canonicalId)}`;
156
154
  return pathToFileURL(canonicalId).href;
157
155
  }
158
156
  function canonicalizePath(value) {
159
- return tryRealpathSync(value) ?? path.resolve(value);
157
+ const real = tryRealpathSync(value);
158
+ return real === null ? path.resolve(value) : toSlash(real);
160
159
  }
161
160
  function collectImportMetaUrlRanges(ast) {
162
161
  const ranges = [];
@@ -1,5 +1,5 @@
1
- import { stripViteModuleQuery } from "../utils/path.js";
2
1
  import { createMiddlewareMissingExportError } from "../server/middleware-runtime.js";
2
+ import { stripViteModuleQuery } from "../utils/path.js";
3
3
  import { parseAst } from "vite";
4
4
  //#region src/plugins/middleware-export-validation.ts
5
5
  function parserLanguage(id) {
@@ -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
  //#region src/plugins/middleware-server-only.ts
3
3
  /**
4
4
  * Allow `import 'server-only'` from neutral server targets (and any module
@@ -48,7 +48,7 @@ function createMiddlewareServerOnlyPlugin(options) {
48
48
  const tainted = /* @__PURE__ */ new Set();
49
49
  function canonicalizeId(id) {
50
50
  const queryIndex = id.indexOf("?");
51
- return normalizePathSeparators(queryIndex === -1 ? id : id.slice(0, queryIndex));
51
+ return toSlash(queryIndex === -1 ? id : id.slice(0, queryIndex));
52
52
  }
53
53
  function isTainted(id) {
54
54
  if (!id) return false;
@@ -1,11 +1,12 @@
1
+ import path, { toSlash } 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 { promisify } from "node:util";
4
4
  //#region src/plugins/og-asset-ownership.ts
5
- const realpathNative = promisify(fs.realpath.native);
5
+ const promisifiedRealpathNative = promisify(fs.realpath.native);
6
+ const realpathNative = async (target) => toSlash(await promisifiedRealpathNative(target));
6
7
  function isPathInside(root, target) {
7
8
  const relative = path.relative(root, target);
8
- return relative === "" || !path.isAbsolute(relative) && !relative.startsWith(`..${path.sep}`) && relative !== "..";
9
+ return relative === "" || !path.isAbsolute(relative) && !relative.startsWith("../") && relative !== "..";
9
10
  }
10
11
  async function findPackageRoot(moduleDir, expectedPackageName) {
11
12
  let currentDir = moduleDir;
@@ -46,7 +47,7 @@ function getNodeModulesPackageRoot(logicalProjectRoot, logicalModulePath) {
46
47
  const isProjectPath = isPathInside(logicalProjectRoot, logicalModulePath);
47
48
  const parsedPath = path.parse(logicalModulePath);
48
49
  const baseRoot = isProjectPath ? logicalProjectRoot : parsedPath.root;
49
- const segments = (isProjectPath ? path.relative(logicalProjectRoot, logicalModulePath) : logicalModulePath.slice(parsedPath.root.length)).split(path.sep);
50
+ const segments = (isProjectPath ? path.relative(logicalProjectRoot, logicalModulePath) : logicalModulePath.slice(parsedPath.root.length)).split("/");
50
51
  const nodeModulesIndex = segments.lastIndexOf("node_modules");
51
52
  if (nodeModulesIndex === -1) return null;
52
53
  const packageSegment = segments[nodeModulesIndex + 1];
@@ -94,7 +95,7 @@ async function packageOwnsAliasDirectory(packageRoot, packageName, aliasDirector
94
95
  }
95
96
  }
96
97
  var OgAssetOwnership = class {
97
- projectRoot = process.cwd();
98
+ projectRoot = toSlash(process.cwd());
98
99
  linkedPackageRoots = /* @__PURE__ */ new Set();
99
100
  dependencyPackageNames = /* @__PURE__ */ new Map();
100
101
  stringAliasesByFirstCharacter = /* @__PURE__ */ new Map();
@@ -187,7 +188,7 @@ var OgAssetOwnership = class {
187
188
  const declaredPackageName = await readPackageName(logicalPackageRoot);
188
189
  if (declaredPackageName === null) return null;
189
190
  const logicalModuleRelativePath = path.relative(logicalPackageRoot, modulePath);
190
- if (path.isAbsolute(logicalModuleRelativePath) || logicalModuleRelativePath === ".." || logicalModuleRelativePath.startsWith(`..${path.sep}`)) return null;
191
+ if (path.isAbsolute(logicalModuleRelativePath) || logicalModuleRelativePath === ".." || logicalModuleRelativePath.startsWith("../")) return null;
191
192
  const canonicalPackageRoot = await findPackageRoot(moduleDir, declaredPackageName);
192
193
  if (canonicalPackageRoot === null) return null;
193
194
  if (path.relative(canonicalPackageRoot, realModulePath) !== logicalModuleRelativePath) return null;
@@ -1,8 +1,7 @@
1
- import { normalizePathSeparators } from "../utils/path.js";
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
2
  import { OgAssetOwnership } from "./og-asset-ownership.js";
3
3
  import { createRequire } from "node:module";
4
4
  import fs from "node:fs";
5
- import path from "node:path";
6
5
  import MagicString from "magic-string";
7
6
  //#region src/plugins/og-assets.ts
8
7
  /**
@@ -113,7 +112,7 @@ function findEmittedWasmAsset(bundle, baseName) {
113
112
  const re = new RegExp(`^${stem}(?:-[\\w-]+)?\\.wasm$`);
114
113
  for (const output of Object.values(bundle)) {
115
114
  if (output.type !== "asset") continue;
116
- if (re.test(path.posix.basename(output.fileName))) return output.fileName;
115
+ if (re.test(path.basename(output.fileName))) return output.fileName;
117
116
  }
118
117
  return null;
119
118
  }
@@ -182,8 +181,8 @@ function createOgAssetsPlugin() {
182
181
  if (!emitted) continue;
183
182
  for (const chunk of chunks) {
184
183
  const re = fallbackUrlRegex(base);
185
- const chunkDir = path.posix.dirname(chunk.fileName);
186
- const rel = normalizePathSeparators(path.relative(chunkDir, emitted));
184
+ const chunkDir = path.dirname(chunk.fileName);
185
+ const rel = path.relative(chunkDir, emitted);
187
186
  const ref = rel.startsWith(".") ? rel : `./${rel}`;
188
187
  const s = new MagicString(chunk.code);
189
188
  let edited = false;
@@ -1,11 +1,10 @@
1
- import { normalizePathSeparators } from "../utils/path.js";
1
+ import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
2
  import { escapeRegExp } from "../utils/regex.js";
3
3
  import { VIRTUAL_MODULE_ID_RE } from "../utils/virtual-module.js";
4
4
  import { getAstName } from "./ast-utils.js";
5
5
  import { createRequire } from "node:module";
6
- import path from "node:path";
7
6
  import { parseAst } from "vite";
8
- import fs from "node:fs/promises";
7
+ import fsp from "node:fs/promises";
9
8
  import MagicString from "magic-string";
10
9
  //#region src/plugins/optimize-imports.ts
11
10
  /**
@@ -14,7 +13,7 @@ import MagicString from "magic-string";
14
13
  */
15
14
  async function readFileSafe(filepath) {
16
15
  try {
17
- return await fs.readFile(filepath, "utf-8");
16
+ return await fsp.readFile(filepath, "utf-8");
18
17
  } catch {
19
18
  return null;
20
19
  }
@@ -151,7 +150,7 @@ async function resolvePackageInfo(packageName, projectRoot) {
151
150
  const pkgJsonPath = req.resolve(`${packageName}/package.json`);
152
151
  return {
153
152
  pkgDir: path.dirname(pkgJsonPath),
154
- pkgJson: JSON.parse(await fs.readFile(pkgJsonPath, "utf-8"))
153
+ pkgJson: JSON.parse(await fsp.readFile(pkgJsonPath, "utf-8"))
155
154
  };
156
155
  } catch {
157
156
  try {
@@ -160,7 +159,7 @@ async function resolvePackageInfo(packageName, projectRoot) {
160
159
  for (let i = 0; i < 10; i++) {
161
160
  const candidate = path.join(dir, "package.json");
162
161
  try {
163
- const parsed = JSON.parse(await fs.readFile(candidate, "utf-8"));
162
+ const parsed = JSON.parse(await fsp.readFile(candidate, "utf-8"));
164
163
  if (parsed.name === packageName) return {
165
164
  pkgDir: dir,
166
165
  pkgJson: parsed
@@ -194,12 +193,12 @@ async function resolvePackageEntry(packageName, projectRoot, preferReactServer)
194
193
  const dotExport = pkgJson.exports["."];
195
194
  if (dotExport) {
196
195
  const entryPath = resolveExportsValue(dotExport, preferReactServer);
197
- if (entryPath) return normalizePathSeparators(path.resolve(pkgDir, entryPath));
196
+ if (entryPath) return path.resolve(pkgDir, entryPath);
198
197
  }
199
198
  }
200
199
  const entryField = pkgJson.module ?? pkgJson.main;
201
- if (typeof entryField === "string") return normalizePathSeparators(path.resolve(pkgDir, entryField));
202
- return normalizePathSeparators(createRequire(path.join(projectRoot, "package.json")).resolve(packageName));
200
+ if (typeof entryField === "string") return path.resolve(pkgDir, entryField);
201
+ return toSlash(createRequire(path.join(projectRoot, "package.json")).resolve(packageName));
203
202
  } catch {
204
203
  return null;
205
204
  }
@@ -237,14 +236,14 @@ async function buildExportMapFromFile(filePath, readFile, cache, visited, initia
237
236
  const exportMap = /* @__PURE__ */ new Map();
238
237
  const importBindings = /* @__PURE__ */ new Map();
239
238
  const localDeclarations = /* @__PURE__ */ new Set();
240
- const fileDir = path.posix.dirname(filePath);
239
+ const fileDir = path.dirname(filePath);
241
240
  /**
242
241
  * Normalize a source specifier: resolve relative paths to absolute so that
243
242
  * entries in the export map always store absolute paths for file references.
244
243
  * Bare package specifiers (e.g. "@radix-ui/react-slot") are returned unchanged.
245
244
  */
246
245
  function normalizeSource(source) {
247
- return source.startsWith(".") ? path.posix.join(fileDir, source) : source;
246
+ return source.startsWith(".") ? path.join(fileDir, source) : source;
248
247
  }
249
248
  function recordLocalDeclaration(node) {
250
249
  if (!node) return;
@@ -306,7 +305,7 @@ async function buildExportMapFromFile(filePath, readFile, cache, visited, initia
306
305
  isNamespace: true
307
306
  });
308
307
  } else if (rawSource.startsWith(".")) {
309
- const subPath = path.posix.join(fileDir, rawSource);
308
+ const subPath = path.join(fileDir, rawSource);
310
309
  const candidates = [
311
310
  subPath,
312
311
  `${subPath}.js`,
@@ -431,7 +430,7 @@ function createOptimizeImportsPlugin(getNextConfig, getRoot) {
431
430
  name: "vinext:optimize-imports",
432
431
  buildStart() {
433
432
  const nextConfig = getNextConfig();
434
- optimizedPackages = new Set([...DEFAULT_OPTIMIZE_PACKAGES, ...nextConfig?.optimizePackageImports ?? []]);
433
+ optimizedPackages = /* @__PURE__ */ new Set([...DEFAULT_OPTIMIZE_PACKAGES, ...nextConfig?.optimizePackageImports ?? []]);
435
434
  hasOptimizedImportSource = createOptimizedImportSourceMatcher(optimizedPackages);
436
435
  entryPathCache.clear();
437
436
  barrelCaches.exportMapCache.clear();
@@ -1,7 +1,7 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { importExportWithCommonJsFallback } from "../utils/commonjs-loader.js";
2
3
  import { createRequire } from "node:module";
3
4
  import fs from "node:fs";
4
- import path from "node:path";
5
5
  //#region src/plugins/postcss.ts
6
6
  async function loadPluginExport(resolvedPath) {
7
7
  return importExportWithCommonJsFallback(resolvedPath);
@@ -17,7 +17,7 @@ import MagicString from "magic-string";
17
17
  * Uses Vite's `parseAst` (OXC/acorn) for parsing and `MagicString` for
18
18
  * surgical source replacement. Returns `null` when no changes are made.
19
19
  */
20
- const SCOPE_ENTERING_TYPES = new Set([
20
+ const SCOPE_ENTERING_TYPES = /* @__PURE__ */ new Set([
21
21
  "FunctionDeclaration",
22
22
  "FunctionExpression",
23
23
  "ArrowFunctionExpression"
@@ -2,7 +2,7 @@ import { forEachAstChild, hasRange, isAstRecord, nodeArray } from "./ast-utils.j
2
2
  import { parseAst } from "vite";
3
3
  import MagicString from "magic-string";
4
4
  //#region src/plugins/require-context.ts
5
- const TRANSFORMABLE_EXTENSIONS = new Set([
5
+ const TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
6
6
  ".js",
7
7
  ".jsx",
8
8
  ".ts",
@@ -1,7 +1,7 @@
1
+ import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { markCssUrlAssetReferences, rebaseCssUrlAssetReferences } from "../build/css-url-assets.js";
2
3
  import { createRequire } from "node:module";
3
4
  import fs from "node:fs";
4
- import path from "node:path";
5
5
  import { preprocessCSS } from "vite";
6
6
  import { pathToFileURL } from "node:url";
7
7
  //#region src/plugins/sass.ts
@@ -98,7 +98,7 @@ function sassStylesheetCandidates(importPath) {
98
98
  return candidates;
99
99
  }
100
100
  function deriveSassNamespace(importUrl) {
101
- const parts = importUrl.replaceAll("\\", "/").replace(/\/$/, "").split("/");
101
+ const parts = toSlash(importUrl).replace(/\/$/, "").split("/");
102
102
  let basename = parts.pop() ?? "stylesheet";
103
103
  basename = basename.replace(/^_/, "").replace(/\..*$/, "");
104
104
  if (basename === "index" && parts.length > 0) basename = (parts.pop() ?? basename).replace(/^_/, "").replace(/\..*$/, "");
@@ -1,6 +1,6 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { builtinModules } from "node:module";
2
3
  import fs from "node:fs";
3
- import path from "node:path";
4
4
  //#region src/plugins/server-externals-manifest.ts
5
5
  const BUILTIN_MODULES = new Set(builtinModules.flatMap((name) => name.startsWith("node:") ? [name, name.slice(5)] : [name, `node:${name}`]));
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import { parseAst } from "vite";
2
2
  import MagicString from "magic-string";
3
3
  //#region src/plugins/strip-server-exports.ts
4
- const SERVER_EXPORTS = new Set([
4
+ const SERVER_EXPORTS = /* @__PURE__ */ new Set([
5
5
  "getServerSideProps",
6
6
  "getStaticProps",
7
7
  "getStaticPaths",
@@ -1,5 +1,5 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { createRequire } from "node:module";
2
- import path from "node:path";
3
3
  import { parseAst } from "vite";
4
4
  import { pathToFileURL } from "node:url";
5
5
  //#region src/plugins/styled-jsx.ts
@@ -75,7 +75,8 @@ function createStyledJsxPlugin(initialProjectRoot, options = {}) {
75
75
  if (!compilerPromise) {
76
76
  const requireFromNext = getNextRequire();
77
77
  if (!requireFromNext) throw new Error("[vinext] styled-jsx requires an installed next package so vinext can use its matching compiler.");
78
- compilerPromise = importModule(pathToFileURL(requireFromNext.resolve("next/dist/build/swc")).href).then(async (compiler) => {
78
+ const compilerPath = requireFromNext.resolve("next/dist/build/swc");
79
+ compilerPromise = importModule(pathToFileURL(compilerPath).href).then(async (compiler) => {
79
80
  await compiler.loadBindings();
80
81
  return compiler;
81
82
  });
@@ -1,6 +1,6 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { collectBindingNames, forEachAstChild, hasRange, isAstRecord, isIdentifierNamed, nodeArray } from "./ast-utils.js";
2
3
  import { collectDirectScopeBindings, collectLoopScopeBindings, collectSwitchScopeBindings, collectVarScopeBindings, createAstScope, hasAstBinding, isFunctionNode } from "./ast-scope.js";
3
- import path from "node:path";
4
4
  import { parseAst } from "vite";
5
5
  import MagicString from "magic-string";
6
6
  //#region src/plugins/typeof-window.ts
@@ -292,10 +292,6 @@ type RouteManifest = {
292
292
  };
293
293
  /**
294
294
  * Build the App Router route graph by scanning `appDir`.
295
- *
296
- * `appDir` must be forward-slash. Every path in the graph is derived from it
297
- * with `path.posix.*` and `findFile`, so a native appDir would produce mixed
298
- * separators on Windows. Production callers normalize it at their entry.
299
295
  */
300
296
  declare function buildAppRouteGraph(appDir: string, matcher: ValidFileMatcher): Promise<{
301
297
  routes: AppRouteGraphRoute[];
@@ -314,12 +310,9 @@ declare function computeRootParamNames(routeSegments: readonly string[], layoutT
314
310
  * no sibling pages at all (e.g. `deep/path/(...)target` with no
315
311
  * `deep/path/page.tsx`).
316
312
  *
317
- * All comparisons happen in forward-slash space: `appDir` is forward-slash
318
- * (normalized once in the config hook), but `dir` and route file paths
319
- * descend through native `path.join`/`path.dirname`, which reintroduce
320
- * backslashes on Windows. Without normalizing, the `current === appDir`
321
- * termination never fires there and the walk overshoots the app root.
322
- * `routesByDir` keys must be forward-slash dirnames of the route file paths.
313
+ * Comparisons happen in forward-slash space — inputs go through `toSlash` so
314
+ * callers still holding native-separator paths hit the `current === appDir`
315
+ * termination instead of overshooting the app root.
323
316
  *
324
317
  * Exported for tests.
325
318
  */