vinext 0.1.2 → 0.1.3

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 (199) hide show
  1. package/dist/build/prerender.d.ts +9 -1
  2. package/dist/build/prerender.js +41 -12
  3. package/dist/build/run-prerender.d.ts +10 -2
  4. package/dist/build/run-prerender.js +15 -1
  5. package/dist/client/app-nav-failure-handler.d.ts +8 -0
  6. package/dist/client/app-nav-failure-handler.js +44 -0
  7. package/dist/client/vinext-next-data.d.ts +18 -1
  8. package/dist/client/window-next.d.ts +2 -1
  9. package/dist/client/window-next.js +12 -1
  10. package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +6 -1
  11. package/dist/config/config-matchers.js +73 -14
  12. package/dist/config/next-config.d.ts +46 -4
  13. package/dist/config/next-config.js +147 -48
  14. package/dist/deploy.d.ts +30 -11
  15. package/dist/deploy.js +180 -99
  16. package/dist/entries/app-browser-entry.d.ts +9 -3
  17. package/dist/entries/app-browser-entry.js +21 -3
  18. package/dist/entries/app-rsc-entry.d.ts +2 -0
  19. package/dist/entries/app-rsc-entry.js +64 -5
  20. package/dist/entries/app-rsc-manifest.js +2 -0
  21. package/dist/entries/app-ssr-entry.js +1 -1
  22. package/dist/entries/pages-client-entry.js +53 -8
  23. package/dist/entries/pages-server-entry.js +41 -5
  24. package/dist/index.js +200 -62
  25. package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
  26. package/dist/plugins/extensionless-dynamic-import.js +152 -0
  27. package/dist/plugins/optimize-imports.d.ts +2 -1
  28. package/dist/plugins/optimize-imports.js +11 -9
  29. package/dist/plugins/postcss.js +7 -7
  30. package/dist/plugins/typeof-window.d.ts +14 -0
  31. package/dist/plugins/typeof-window.js +150 -0
  32. package/dist/routing/app-route-graph.d.ts +2 -1
  33. package/dist/routing/app-route-graph.js +44 -14
  34. package/dist/routing/file-matcher.d.ts +10 -1
  35. package/dist/routing/file-matcher.js +22 -1
  36. package/dist/routing/pages-router.js +3 -3
  37. package/dist/routing/utils.d.ts +35 -6
  38. package/dist/routing/utils.js +59 -7
  39. package/dist/server/api-handler.d.ts +6 -1
  40. package/dist/server/api-handler.js +21 -15
  41. package/dist/server/app-browser-action-result.d.ts +19 -6
  42. package/dist/server/app-browser-action-result.js +19 -10
  43. package/dist/server/app-browser-entry.js +167 -90
  44. package/dist/server/app-browser-error.d.ts +10 -6
  45. package/dist/server/app-browser-error.js +43 -8
  46. package/dist/server/app-browser-hydration.d.ts +2 -0
  47. package/dist/server/app-browser-hydration.js +1 -0
  48. package/dist/server/app-browser-navigation-controller.d.ts +4 -2
  49. package/dist/server/app-browser-navigation-controller.js +23 -2
  50. package/dist/server/app-browser-server-action-navigation.d.ts +6 -0
  51. package/dist/server/app-browser-server-action-navigation.js +9 -0
  52. package/dist/server/app-browser-stream.js +86 -43
  53. package/dist/server/app-elements-wire.d.ts +6 -1
  54. package/dist/server/app-elements-wire.js +14 -4
  55. package/dist/server/app-elements.d.ts +2 -2
  56. package/dist/server/app-elements.js +2 -2
  57. package/dist/server/app-fallback-renderer.d.ts +1 -0
  58. package/dist/server/app-fallback-renderer.js +3 -1
  59. package/dist/server/app-optimistic-routing.js +2 -2
  60. package/dist/server/app-page-boundary-render.d.ts +1 -0
  61. package/dist/server/app-page-boundary-render.js +27 -14
  62. package/dist/server/app-page-cache-render.d.ts +53 -0
  63. package/dist/server/app-page-cache-render.js +91 -0
  64. package/dist/server/app-page-cache.d.ts +16 -2
  65. package/dist/server/app-page-cache.js +62 -1
  66. package/dist/server/app-page-dispatch.d.ts +26 -0
  67. package/dist/server/app-page-dispatch.js +149 -92
  68. package/dist/server/app-page-element-builder.d.ts +1 -0
  69. package/dist/server/app-page-element-builder.js +5 -2
  70. package/dist/server/app-page-execution.d.ts +6 -1
  71. package/dist/server/app-page-execution.js +21 -1
  72. package/dist/server/app-page-probe.d.ts +1 -0
  73. package/dist/server/app-page-probe.js +4 -0
  74. package/dist/server/app-page-render-observation.d.ts +3 -1
  75. package/dist/server/app-page-render-observation.js +17 -1
  76. package/dist/server/app-page-render.d.ts +12 -1
  77. package/dist/server/app-page-render.js +42 -4
  78. package/dist/server/app-page-request.d.ts +2 -0
  79. package/dist/server/app-page-request.js +2 -1
  80. package/dist/server/app-page-route-wiring.d.ts +3 -1
  81. package/dist/server/app-page-route-wiring.js +14 -5
  82. package/dist/server/app-page-stream.d.ts +15 -3
  83. package/dist/server/app-page-stream.js +11 -5
  84. package/dist/server/app-pages-bridge.d.ts +18 -0
  85. package/dist/server/app-pages-bridge.js +22 -5
  86. package/dist/server/app-ppr-fallback-shell-render.d.ts +17 -0
  87. package/dist/server/app-ppr-fallback-shell-render.js +26 -0
  88. package/dist/server/app-ppr-fallback-shell.d.ts +13 -1
  89. package/dist/server/app-ppr-fallback-shell.js +8 -1
  90. package/dist/server/app-route-handler-dispatch.js +9 -2
  91. package/dist/server/app-route-handler-policy.d.ts +1 -0
  92. package/dist/server/app-router-entry.js +5 -0
  93. package/dist/server/app-rsc-cache-busting.js +2 -0
  94. package/dist/server/app-rsc-handler.d.ts +25 -0
  95. package/dist/server/app-rsc-handler.js +154 -54
  96. package/dist/server/app-rsc-route-matching.d.ts +3 -0
  97. package/dist/server/app-rsc-route-matching.js +2 -0
  98. package/dist/server/app-segment-config.d.ts +9 -1
  99. package/dist/server/app-segment-config.js +12 -3
  100. package/dist/server/app-server-action-execution.d.ts +1 -0
  101. package/dist/server/app-server-action-execution.js +42 -13
  102. package/dist/server/app-ssr-entry.d.ts +2 -0
  103. package/dist/server/app-ssr-entry.js +83 -10
  104. package/dist/server/cache-control.js +4 -0
  105. package/dist/server/dev-server.d.ts +2 -2
  106. package/dist/server/dev-server.js +244 -51
  107. package/dist/server/hybrid-route-priority.d.ts +22 -0
  108. package/dist/server/hybrid-route-priority.js +33 -0
  109. package/dist/server/image-optimization.d.ts +18 -9
  110. package/dist/server/image-optimization.js +37 -23
  111. package/dist/server/implicit-tags.d.ts +2 -1
  112. package/dist/server/implicit-tags.js +4 -1
  113. package/dist/server/navigation-planner.d.ts +133 -30
  114. package/dist/server/navigation-planner.js +114 -0
  115. package/dist/server/navigation-trace.d.ts +8 -1
  116. package/dist/server/navigation-trace.js +8 -1
  117. package/dist/server/pages-api-route.d.ts +6 -0
  118. package/dist/server/pages-api-route.js +13 -2
  119. package/dist/server/pages-asset-tags.d.ts +2 -1
  120. package/dist/server/pages-asset-tags.js +6 -2
  121. package/dist/server/pages-data-route.d.ts +8 -1
  122. package/dist/server/pages-data-route.js +11 -2
  123. package/dist/server/pages-get-initial-props.d.ts +54 -4
  124. package/dist/server/pages-get-initial-props.js +43 -1
  125. package/dist/server/pages-node-compat.js +2 -2
  126. package/dist/server/pages-page-data.d.ts +11 -2
  127. package/dist/server/pages-page-data.js +204 -33
  128. package/dist/server/pages-page-handler.d.ts +4 -2
  129. package/dist/server/pages-page-handler.js +59 -22
  130. package/dist/server/pages-page-response.d.ts +2 -1
  131. package/dist/server/pages-page-response.js +7 -4
  132. package/dist/server/pages-request-pipeline.d.ts +1 -0
  133. package/dist/server/pages-request-pipeline.js +73 -36
  134. package/dist/server/pregenerated-concrete-paths.d.ts +1 -17
  135. package/dist/server/pregenerated-concrete-paths.js +2 -19
  136. package/dist/server/prerender-manifest.d.ts +33 -0
  137. package/dist/server/prerender-manifest.js +54 -0
  138. package/dist/server/prerender-route-params.d.ts +1 -2
  139. package/dist/server/prod-server.js +9 -3
  140. package/dist/server/request-pipeline.d.ts +3 -15
  141. package/dist/server/request-pipeline.js +58 -47
  142. package/dist/server/rsc-stream-hints.d.ts +5 -1
  143. package/dist/server/rsc-stream-hints.js +6 -1
  144. package/dist/server/seed-cache.js +10 -18
  145. package/dist/shims/app-router-scroll-state.d.ts +3 -1
  146. package/dist/shims/app-router-scroll-state.js +14 -2
  147. package/dist/shims/app-router-scroll.d.ts +3 -0
  148. package/dist/shims/app-router-scroll.js +28 -18
  149. package/dist/shims/cache-runtime.js +3 -2
  150. package/dist/shims/cache.d.ts +1 -0
  151. package/dist/shims/cache.js +1 -1
  152. package/dist/shims/cdn-cache.d.ts +5 -5
  153. package/dist/shims/dynamic-preload-chunks.js +6 -4
  154. package/dist/shims/error-boundary.d.ts +2 -0
  155. package/dist/shims/error-boundary.js +7 -0
  156. package/dist/shims/error.js +3 -2
  157. package/dist/shims/error.react-server.d.ts +9 -0
  158. package/dist/shims/error.react-server.js +6 -0
  159. package/dist/shims/fetch-cache.d.ts +3 -1
  160. package/dist/shims/fetch-cache.js +45 -20
  161. package/dist/shims/hash-scroll.js +6 -1
  162. package/dist/shims/headers.js +29 -4
  163. package/dist/shims/internal/als-registry.js +28 -1
  164. package/dist/shims/internal/app-route-detection.js +8 -17
  165. package/dist/shims/internal/hybrid-client-route-owner.d.ts +31 -0
  166. package/dist/shims/internal/hybrid-client-route-owner.js +143 -0
  167. package/dist/shims/internal/navigation-untracked.d.ts +35 -0
  168. package/dist/shims/internal/navigation-untracked.js +55 -0
  169. package/dist/shims/internal/pages-data-target.d.ts +7 -2
  170. package/dist/shims/internal/pages-data-target.js +17 -8
  171. package/dist/shims/internal/pages-router-accessor.d.ts +19 -0
  172. package/dist/shims/internal/pages-router-accessor.js +13 -0
  173. package/dist/shims/internal/router-context.d.ts +2 -1
  174. package/dist/shims/internal/router-context.js +3 -1
  175. package/dist/shims/link.js +12 -5
  176. package/dist/shims/navigation.d.ts +8 -2
  177. package/dist/shims/navigation.js +61 -31
  178. package/dist/shims/ppr-fallback-shell.d.ts +5 -1
  179. package/dist/shims/ppr-fallback-shell.js +28 -7
  180. package/dist/shims/router.d.ts +13 -2
  181. package/dist/shims/router.js +419 -128
  182. package/dist/shims/server.d.ts +16 -1
  183. package/dist/shims/server.js +44 -12
  184. package/dist/shims/unified-request-context.js +1 -0
  185. package/dist/utils/built-asset-url.d.ts +4 -0
  186. package/dist/utils/built-asset-url.js +11 -0
  187. package/dist/utils/commonjs-loader.d.ts +16 -0
  188. package/dist/utils/commonjs-loader.js +100 -0
  189. package/dist/utils/deployment-id.d.ts +8 -0
  190. package/dist/utils/deployment-id.js +22 -0
  191. package/dist/utils/html-limited-bots.d.ts +18 -1
  192. package/dist/utils/html-limited-bots.js +23 -1
  193. package/dist/utils/parse-cookie.d.ts +13 -0
  194. package/dist/utils/parse-cookie.js +52 -0
  195. package/dist/utils/path.d.ts +7 -1
  196. package/dist/utils/path.js +9 -1
  197. package/package.json +2 -2
  198. package/dist/shims/internal/parse-cookie-header.d.ts +0 -14
  199. package/dist/shims/internal/parse-cookie-header.js +0 -30
@@ -1,10 +1,11 @@
1
1
  import { normalizePageExtensions } from "../routing/file-matcher.js";
2
2
  import { applyLocaleToRoutes, isExternalUrl } from "./config-matchers.js";
3
3
  import { isUnknownRecord } from "../utils/record.js";
4
- import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "../shims/constants.js";
5
4
  import { getHtmlLimitedBotRegex } from "../utils/html-limited-bots.js";
5
+ import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "../shims/constants.js";
6
6
  import { loadTsconfigResolutionForRoot } from "./tsconfig-paths.js";
7
7
  import { getViteMajorVersion } from "../utils/vite-version.js";
8
+ import { loadCommonJsModule, shouldRetryAsCommonJs } from "../utils/commonjs-loader.js";
8
9
  import { createRequire } from "node:module";
9
10
  import fs from "node:fs";
10
11
  import path from "node:path";
@@ -259,31 +260,16 @@ async function resolveNextConfigInput(config, phase = PHASE_DEVELOPMENT_SERVER)
259
260
  *
260
261
  * For `.cjs` (or `.js` in a non-type-module package) Node's loader picks the
261
262
  * right format automatically and `require()` just works. For `.js` in a
262
- * `"type": "module"` package, Node infers ESM from package.json and the file
263
- * fails with `require is not defined`. In that case we copy the source to a
264
- * sibling temp `.cjs` (where the explicit extension forces CJS regardless of
265
- * the parent type field) and require *that*. Relative imports inside the
266
- * config still resolve against the original directory.
263
+ * `"type": "module"` package, retry through the shared in-memory CommonJS
264
+ * loader so nested local `.js` dependencies retain CommonJS semantics too.
267
265
  */
268
266
  async function loadConfigViaRequire(configPath, root, phase) {
269
267
  const require = createRequire(path.join(root, "package.json"));
270
268
  try {
271
269
  return await unwrapConfig(require(configPath), phase);
272
270
  } catch (e) {
273
- if (!isCjsError(e) || !configPath.endsWith(".js")) throw e;
274
- return await loadConfigViaCjsTempCopy(configPath, root, phase);
275
- }
276
- }
277
- async function loadConfigViaCjsTempCopy(configPath, root, phase) {
278
- const dir = path.dirname(configPath);
279
- const tmpPath = path.join(dir, `.vinext-next-config.${process.pid}.${Date.now()}.cjs`);
280
- fs.copyFileSync(configPath, tmpPath);
281
- try {
282
- return await unwrapConfig(createRequire(path.join(root, "package.json"))(tmpPath), phase);
283
- } finally {
284
- try {
285
- fs.unlinkSync(tmpPath);
286
- } catch {}
271
+ if (!shouldRetryAsCommonJs(e, configPath)) throw e;
272
+ return await unwrapConfig(loadCommonJsModule(configPath), phase);
287
273
  }
288
274
  }
289
275
  /**
@@ -454,6 +440,58 @@ function readStringArray(value) {
454
440
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
455
441
  }
456
442
  /**
443
+ * Convert lightningcss feature names from `experimental.lightningCssFeatures`
444
+ * into a numeric bitmask consumable by the `lightningcss` `transform()` /
445
+ * `bundle()` API (the `include` / `exclude` options).
446
+ *
447
+ * The mapping mirrors Next.js exactly so the same dash-case feature names
448
+ * accepted by `next.config` produce the same bits on both sides. See:
449
+ * - `.nextjs-ref/packages/next/src/server/config-shared.ts` (`LIGHTNINGCSS_FEATURE_NAMES`)
450
+ * - `.nextjs-ref/crates/next-core/src/next_config.rs` (`lightningcss_feature_names_to_mask`)
451
+ * - `lightningcss/node/targets.d.ts` (`Features` enum bits)
452
+ *
453
+ * Unknown names emit a warning (matching the Next.js Rust path, which errors;
454
+ * we warn instead so a stray name doesn't break the whole build).
455
+ */
456
+ const LIGHTNINGCSS_FEATURE_BITS = {
457
+ nesting: 1,
458
+ "not-selector-list": 2,
459
+ "dir-selector": 4,
460
+ "lang-selector-list": 8,
461
+ "is-selector": 16,
462
+ "text-decoration-thickness-percent": 32,
463
+ "media-interval-syntax": 64,
464
+ "media-range-syntax": 128,
465
+ "custom-media-queries": 256,
466
+ "clamp-function": 512,
467
+ "color-function": 1024,
468
+ "oklab-colors": 2048,
469
+ "lab-colors": 4096,
470
+ "p3-colors": 8192,
471
+ "hex-alpha-colors": 16384,
472
+ "space-separated-color-notation": 32768,
473
+ "font-family-system-ui": 65536,
474
+ "double-position-gradients": 131072,
475
+ "vendor-prefixes": 262144,
476
+ "logical-properties": 524288,
477
+ "light-dark": 1048576,
478
+ selectors: 31,
479
+ "media-queries": 448,
480
+ colors: 1113088
481
+ };
482
+ function lightningCssFeatureNamesToMask(names) {
483
+ let mask = 0;
484
+ for (const name of names) {
485
+ const bit = LIGHTNINGCSS_FEATURE_BITS[name];
486
+ if (bit === void 0) {
487
+ console.warn(`[vinext] Unknown lightningcss feature name "${name}" in experimental.lightningCssFeatures — ignoring.`);
488
+ continue;
489
+ }
490
+ mask |= bit;
491
+ }
492
+ return mask;
493
+ }
494
+ /**
457
495
  * Serialize a `compiler.define` / `compiler.defineServer` map into the
458
496
  * Vite-friendly `Record<string, string>` shape where each value is already
459
497
  * a JSON-encoded literal of source code. Entries whose values are not a
@@ -500,7 +538,7 @@ function resolveStaleTimes(experimental) {
500
538
  * Resolve a NextConfig into a fully-resolved ResolvedNextConfig.
501
539
  * Awaits async functions for redirects/rewrites/headers.
502
540
  */
503
- async function resolveNextConfig(config, root = process.cwd()) {
541
+ async function resolveNextConfig(config, root = process.cwd(), options = {}) {
504
542
  if (!config) {
505
543
  const buildId = await resolveBuildId(void 0);
506
544
  const deploymentId = resolveDeploymentId(void 0);
@@ -511,7 +549,10 @@ async function resolveNextConfig(config, root = process.cwd()) {
511
549
  trailingSlash: false,
512
550
  output: "",
513
551
  pageExtensions: normalizePageExtensions(),
552
+ resolveExtensions: null,
553
+ serverResolveExtensions: null,
514
554
  cacheComponents: false,
555
+ appNavFailHandling: false,
515
556
  gestureTransition: false,
516
557
  prefetchInlining: false,
517
558
  redirects: [],
@@ -545,11 +586,17 @@ async function resolveNextConfig(config, root = process.cwd()) {
545
586
  sassOptions: null,
546
587
  removeConsole: false,
547
588
  disableOptimizedLoading: false,
589
+ scrollRestoration: false,
548
590
  compilerDefine: {},
549
591
  compilerDefineServer: {},
550
592
  instrumentationClientInject: [],
551
593
  clientTraceMetadata: void 0,
552
- staleTimes: { ...DEFAULT_STALE_TIMES }
594
+ staleTimes: { ...DEFAULT_STALE_TIMES },
595
+ useLightningcss: false,
596
+ lightningCssFeatures: {
597
+ include: 0,
598
+ exclude: 0
599
+ }
553
600
  };
554
601
  detectNextIntlConfig(root, resolved);
555
602
  return resolved;
@@ -587,7 +634,7 @@ async function resolveNextConfig(config, root = process.cwd()) {
587
634
  }
588
635
  let headers = [];
589
636
  if (config.headers) headers = await config.headers();
590
- const webpackProbe = await probeWebpackConfig(config, root);
637
+ const webpackProbe = await probeWebpackConfig(config, root, options.dev ?? false);
591
638
  const mdx = webpackProbe.mdx;
592
639
  const aliases = {
593
640
  ...extractTurboAliases(config, root),
@@ -621,12 +668,22 @@ async function resolveNextConfig(config, root = process.cwd()) {
621
668
  const serverExternalPackages = topLevelServerExternalPackages ?? legacyServerComponentsExternal;
622
669
  if (experimental?.swcEnvOptions !== void 0) console.warn("[vinext] next.config option \"experimental.swcEnvOptions\" is not applicable and will be ignored (vinext uses Vite, not SWC). A Vite-compatible polyfill solution may be explored in the future.");
623
670
  if (experimental?.rootParams !== void 0) console.warn("[vinext] `experimental.rootParams` is no longer needed, because `next/root-params` is available by default. You can remove it from next.config.(js|mjs|ts).");
671
+ const useLightningcss = experimental?.useLightningcss === true;
672
+ const rawLightningCssFeatures = readOptionalRecord(experimental?.lightningCssFeatures);
673
+ const lightningCssFeatures = {
674
+ include: lightningCssFeatureNamesToMask(readStringArray(rawLightningCssFeatures?.include)),
675
+ exclude: lightningCssFeatureNamesToMask(readStringArray(rawLightningCssFeatures?.exclude))
676
+ };
677
+ if (rawLightningCssFeatures && !useLightningcss) console.warn("[vinext] experimental.lightningCssFeatures is set but experimental.useLightningcss is not enabled. The lightningCssFeatures option has no effect without useLightningcss.");
624
678
  if (experimental?.cachedNavigations === true && !config.cacheComponents) console.warn("[vinext] `experimental.cachedNavigations` requires `cacheComponents: true` to have any effect. Set `cacheComponents: true` in your next.config, or remove `experimental.cachedNavigations`.");
625
- if (config.webpack !== void 0) if (mdx || Object.keys(webpackProbe.aliases).length > 0) console.warn("[vinext] next.config option \"webpack\" is only partially supported. vinext preserves resolve.alias entries and MDX loader settings, but other webpack customization is ignored");
679
+ if (config.webpack !== void 0) if (mdx || Object.keys(webpackProbe.aliases).length > 0 || webpackProbe.resolveExtensionsCustomized) console.warn("[vinext] next.config option \"webpack\" is only partially supported. vinext preserves resolve.alias, resolve.extensions, and MDX loader settings, but other webpack customization is ignored");
626
680
  else console.warn("[vinext] next.config option \"webpack\" is not yet supported and will be ignored");
627
681
  const output = readOptionalString(config.output) ?? "";
628
682
  if (output && output !== "export" && output !== "standalone") console.warn(`[vinext] Unknown output mode "${output}", ignoring`);
629
683
  const pageExtensions = normalizePageExtensions(config.pageExtensions);
684
+ const experimentalTurbo = readOptionalRecord(experimental?.turbo);
685
+ const turbopack = readOptionalRecord(config.turbopack);
686
+ const resolveExtensions = Array.isArray(turbopack?.resolveExtensions) ? readStringArray(turbopack.resolveExtensions) : Array.isArray(experimentalTurbo?.resolveExtensions) ? readStringArray(experimentalTurbo.resolveExtensions) : null;
630
687
  let i18n = null;
631
688
  if (config.i18n) i18n = {
632
689
  locales: config.i18n.locales,
@@ -654,8 +711,11 @@ async function resolveNextConfig(config, root = process.cwd()) {
654
711
  trailingSlash: config.trailingSlash ?? false,
655
712
  output: output === "export" || output === "standalone" ? output : "",
656
713
  pageExtensions,
714
+ resolveExtensions: resolveExtensions ?? webpackProbe.resolveExtensions,
715
+ serverResolveExtensions: resolveExtensions ?? webpackProbe.serverResolveExtensions,
657
716
  instrumentationClientInject: Array.isArray(config.instrumentationClientInject) ? config.instrumentationClientInject.filter((x) => typeof x === "string") : [],
658
717
  cacheComponents: config.cacheComponents ?? false,
718
+ appNavFailHandling: experimental?.appNavFailHandling === true,
659
719
  gestureTransition: experimental?.gestureTransition === true,
660
720
  prefetchInlining,
661
721
  redirects,
@@ -685,10 +745,13 @@ async function resolveNextConfig(config, root = process.cwd()) {
685
745
  sassOptions: readOptionalRecord(config.sassOptions) ?? null,
686
746
  removeConsole: config.compiler?.removeConsole === true ? true : isUnknownRecord(config.compiler?.removeConsole) ? { exclude: readStringArray(config.compiler.removeConsole.exclude) } : false,
687
747
  disableOptimizedLoading: experimental?.disableOptimizedLoading === true,
748
+ scrollRestoration: experimental?.scrollRestoration === true,
688
749
  compilerDefine: serializeCompilerDefine(config.compiler?.define),
689
750
  compilerDefineServer: serializeCompilerDefine(config.compiler?.defineServer),
690
751
  clientTraceMetadata: Array.isArray(experimental?.clientTraceMetadata) ? experimental.clientTraceMetadata.filter((value) => typeof value === "string") : void 0,
691
- staleTimes: resolveStaleTimes(experimental)
752
+ staleTimes: resolveStaleTimes(experimental),
753
+ useLightningcss,
754
+ lightningCssFeatures
692
755
  };
693
756
  detectNextIntlConfig(root, resolved);
694
757
  if (resolved.basePath !== "" && resolved.basePath !== "/" && resolved.assetPrefix === "") resolved.assetPrefix = resolved.basePath;
@@ -727,39 +790,75 @@ function extractTurboAliases(config, root) {
727
790
  ...normalizeAliasEntries(readOptionalRecord(topLevelTurbopack?.resolveAlias), root)
728
791
  };
729
792
  }
730
- async function probeWebpackConfig(config, root) {
793
+ async function probeWebpackConfig(config, root, dev) {
731
794
  if (typeof config.webpack !== "function") return {
732
795
  aliases: {},
733
- mdx: null
734
- };
735
- const mockModuleRules = [];
736
- const mockConfig = {
737
- context: root,
738
- resolve: { alias: {} },
739
- module: { rules: mockModuleRules },
740
- plugins: []
741
- };
742
- const mockOptions = {
743
- defaultLoaders: { babel: { loader: "next-babel-loader" } },
744
- isServer: false,
745
- dev: false,
746
- dir: root
796
+ mdx: null,
797
+ resolveExtensions: null,
798
+ serverResolveExtensions: null,
799
+ resolveExtensionsCustomized: false
747
800
  };
748
801
  try {
749
- const finalConfig = await config.webpack(mockConfig, mockOptions) ?? mockConfig;
750
- const rules = finalConfig.module?.rules ?? mockModuleRules;
751
- invokeLoaderSideEffects(rules, root);
802
+ const clientProbe = await runWebpackConfigProbe(config, root, {
803
+ dev,
804
+ isServer: false
805
+ });
806
+ const serverProbe = await runWebpackConfigProbe(config, root, {
807
+ dev,
808
+ isServer: true,
809
+ nextRuntime: "nodejs"
810
+ });
811
+ invokeLoaderSideEffects(clientProbe.rules, root);
752
812
  return {
753
- aliases: normalizeAliasEntries(finalConfig.resolve?.alias, root),
754
- mdx: extractMdxOptionsFromRules(rules)
813
+ aliases: normalizeAliasEntries(clientProbe.config.resolve?.alias, root),
814
+ mdx: extractMdxOptionsFromRules(clientProbe.rules),
815
+ resolveExtensions: clientProbe.resolveExtensions,
816
+ serverResolveExtensions: serverProbe.resolveExtensions,
817
+ resolveExtensionsCustomized: clientProbe.resolveExtensions !== null || serverProbe.resolveExtensions !== null
755
818
  };
756
819
  } catch {
757
820
  return {
758
821
  aliases: {},
759
- mdx: null
822
+ mdx: null,
823
+ resolveExtensions: null,
824
+ serverResolveExtensions: null,
825
+ resolveExtensionsCustomized: false
760
826
  };
761
827
  }
762
828
  }
829
+ const DEFAULT_WEBPACK_RESOLVE_EXTENSIONS = [
830
+ ".js",
831
+ ".mjs",
832
+ ".tsx",
833
+ ".ts",
834
+ ".jsx",
835
+ ".json",
836
+ ".wasm"
837
+ ];
838
+ async function runWebpackConfigProbe(config, root, options) {
839
+ const rules = [];
840
+ const mockConfig = {
841
+ context: root,
842
+ resolve: {
843
+ alias: {},
844
+ extensions: [...DEFAULT_WEBPACK_RESOLVE_EXTENSIONS]
845
+ },
846
+ module: { rules },
847
+ plugins: []
848
+ };
849
+ const finalConfig = await config.webpack(mockConfig, {
850
+ defaultLoaders: { babel: { loader: "next-babel-loader" } },
851
+ ...options,
852
+ dir: root
853
+ }) ?? mockConfig;
854
+ const finalRules = finalConfig.module?.rules ?? rules;
855
+ const extensions = Array.isArray(finalConfig.resolve?.extensions) ? readStringArray(finalConfig.resolve.extensions) : null;
856
+ return {
857
+ config: finalConfig,
858
+ rules: finalRules,
859
+ resolveExtensions: extensions !== null && (extensions.length !== DEFAULT_WEBPACK_RESOLVE_EXTENSIONS.length || extensions.some((extension, index) => extension !== DEFAULT_WEBPACK_RESOLVE_EXTENSIONS[index])) ? extensions : null
860
+ };
861
+ }
763
862
  /**
764
863
  * Walk webpack module rules and invoke each referenced loader once with a
765
864
  * dummy source string. Loaders that mutate `process.env` at compile time (a
@@ -839,7 +938,7 @@ function invokeLoaderSideEffects(rules, root) {
839
938
  * We probe the webpack function with a mock config to extract them.
840
939
  */
841
940
  async function extractMdxOptions(config, root = process.cwd()) {
842
- return (await probeWebpackConfig(config, root)).mdx;
941
+ return (await probeWebpackConfig(config, root, false)).mdx;
843
942
  }
844
943
  /**
845
944
  * Probe file candidates relative to root. Returns the first one that exists,
@@ -932,4 +1031,4 @@ function extractPluginsFromOptions(opts) {
932
1031
  return null;
933
1032
  }
934
1033
  //#endregion
935
- export { PHASE_PRODUCTION_BUILD, createRscCompatibilityId, detectNextIntlConfig, extractMdxOptions, findNextConfigPath, loadNextConfig, normalizeAssetPrefix, parseBodySizeLimit, reassignsModuleExports, referencesCjsGlobals, resolveNextConfig, resolveNextConfigInput };
1034
+ export { PHASE_PRODUCTION_BUILD, createRscCompatibilityId, detectNextIntlConfig, extractMdxOptions, findNextConfigPath, lightningCssFeatureNamesToMask, loadNextConfig, normalizeAssetPrefix, parseBodySizeLimit, reassignsModuleExports, referencesCjsGlobals, resolveNextConfig, resolveNextConfigInput };
package/dist/deploy.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ensureESModule as ensureESModule$1, renameCJSConfigs as renameCJSConfigs$1 } from "./utils/project.js";
2
+ import { execFileSync } from "node:child_process";
2
3
 
3
4
  //#region src/deploy.d.ts
4
5
  type DeployOptions = {
@@ -151,21 +152,39 @@ type WranglerDeployArgs = {
151
152
  args: string[];
152
153
  env: string | undefined;
153
154
  };
155
+ declare function validateWranglerEnvName(env: string): string;
154
156
  declare function buildWranglerDeployArgs(options: Pick<DeployOptions, "preview" | "env">): WranglerDeployArgs;
155
157
  /**
156
- * Resolve the wrangler executable in node_modules.
158
+ * Resolve Wrangler's JavaScript CLI entrypoint in node_modules.
157
159
  *
158
- * Walks up ancestor directories so the binary is found even when node_modules
159
- * is hoisted to the workspace root in a monorepo.
160
+ * Invoking the JavaScript file through `process.execPath` avoids the `.cmd`
161
+ * shim and command shell that package managers create on Windows.
162
+ */
163
+ declare function resolveWranglerBin(root: string, resolvePackageJson?: (root: string) => string | null): string;
164
+ declare function buildNodeCliInvocation(scriptPath: string, args: string[], nodeExecutable?: string): {
165
+ file: string;
166
+ args: string[];
167
+ };
168
+ declare function buildWranglerInvocation(root: string, options: Pick<DeployOptions, "preview" | "env">, nodeExecutable?: string): {
169
+ file: string;
170
+ args: string[];
171
+ env: string | undefined;
172
+ };
173
+ declare function runWranglerDeploy(root: string, options: Pick<DeployOptions, "preview" | "env">, execute?: typeof execFileSync): string;
174
+ /**
175
+ * Read the prerender manifest and inject pregenerated concrete paths into the
176
+ * App Router Worker bundle so the PPR fallback-shell guard is populated at
177
+ * module init time without calling `seedMemoryCacheFromPrerender`.
178
+ *
179
+ * The paths are injected as `globalThis.__VINEXT_PREGENERATED_CONCRETE_PATHS`
180
+ * wrapped in replaceable marker comments, and consumed by
181
+ * `initPregeneratedPathsFromGlobals` in the generated RSC entry.
160
182
  *
161
- * On Windows, `node_modules/.bin/` contains both a Unix shebang script (no
162
- * extension) and a `.CMD` shim. Node's `execFileSync` uses CreateProcess(),
163
- * which only resolves PATHEXT extensions (`.cmd`, `.exe`, ...) spawning the
164
- * bare-name shebang file fails with ENOENT even though the file exists. So on
165
- * Windows we prefer the `.CMD` shim and only fall back to the bare name for a
166
- * clearer error message if neither is present.
183
+ * Idempotent: repeated calls strip the previous injection before writing the
184
+ * new one. If the manifest is missing, corrupt, or empty, any prior injection
185
+ * is stripped and nothing new is writtenfailing closed to empty.
167
186
  */
168
- declare function resolveWranglerBin(root: string, platform?: NodeJS.Platform): string;
187
+ declare function injectPregeneratedConcretePaths(root: string): void;
169
188
  declare function deploy(options: DeployOptions): Promise<void>;
170
189
  //#endregion
171
- export { buildWranglerDeployArgs, deploy, detectProject, ensureESModule, formatMissingCacheAdapterError, formatMissingCloudflarePluginError, generateAppRouterViteConfig, generateAppRouterWorkerEntry, generatePagesRouterViteConfig, generatePagesRouterWorkerEntry, generateWranglerConfig, getFilesToGenerate, getMissingDeps, hasWranglerConfig, isPackageResolvable, parseDeployArgs, renameCJSConfigs, resolveWranglerBin, viteConfigHasCacheAdapter, viteConfigHasCloudflarePlugin, withCloudflareEnv, workerEntryHasCacheHandler };
190
+ export { buildNodeCliInvocation, buildWranglerDeployArgs, buildWranglerInvocation, deploy, detectProject, ensureESModule, formatMissingCacheAdapterError, formatMissingCloudflarePluginError, generateAppRouterViteConfig, generateAppRouterWorkerEntry, generatePagesRouterViteConfig, generatePagesRouterWorkerEntry, generateWranglerConfig, getFilesToGenerate, getMissingDeps, hasWranglerConfig, injectPregeneratedConcretePaths, isPackageResolvable, parseDeployArgs, renameCJSConfigs, resolveWranglerBin, runWranglerDeploy, validateWranglerEnvName, viteConfigHasCacheAdapter, viteConfigHasCloudflarePlugin, withCloudflareEnv, workerEntryHasCacheHandler };