vinext 1.0.0-beta.6 → 1.0.0-beta.7

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 (176) hide show
  1. package/README.md +20 -3
  2. package/dist/build/action-owner-manifest.d.ts +42 -0
  3. package/dist/build/action-owner-manifest.js +110 -0
  4. package/dist/build/clean-output.js +1 -4
  5. package/dist/build/client-build-config.js +10 -11
  6. package/dist/build/prerender.d.ts +1 -1
  7. package/dist/build/prerender.js +12 -6
  8. package/dist/build/report.d.ts +1 -1
  9. package/dist/build/route-classification-manifest.d.ts +1 -1
  10. package/dist/build/static-export.d.ts +1 -1
  11. package/dist/client/app-nav-failure-handler.js +1 -0
  12. package/dist/client/navigation-runtime.d.ts +5 -3
  13. package/dist/client/navigation-runtime.js +4 -8
  14. package/dist/entries/app-browser-entry.d.ts +1 -1
  15. package/dist/entries/app-rsc-entry.d.ts +2 -1
  16. package/dist/entries/app-rsc-entry.js +111 -8
  17. package/dist/entries/pages-client-entry.d.ts +1 -1
  18. package/dist/entries/pages-server-entry.d.ts +1 -1
  19. package/dist/index.js +108 -22
  20. package/dist/plugins/action-owner-manifest.d.ts +14 -0
  21. package/dist/plugins/action-owner-manifest.js +84 -0
  22. package/dist/plugins/ast-utils.d.ts +30 -1
  23. package/dist/plugins/ast-utils.js +76 -1
  24. package/dist/plugins/css-module-imports.d.ts +2 -2
  25. package/dist/plugins/css-module-imports.js +5 -13
  26. package/dist/plugins/dynamic-preload-metadata.js +13 -34
  27. package/dist/plugins/environment.d.ts +11 -0
  28. package/dist/plugins/environment.js +7 -0
  29. package/dist/plugins/extensionless-dynamic-import.js +11 -35
  30. package/dist/plugins/fonts.js +8 -12
  31. package/dist/plugins/ignore-dynamic-requests.d.ts +2 -4
  32. package/dist/plugins/ignore-dynamic-requests.js +29 -59
  33. package/dist/plugins/import-meta-url.d.ts +15 -9
  34. package/dist/plugins/import-meta-url.js +309 -85
  35. package/dist/plugins/instrumentation-client.js +4 -5
  36. package/dist/plugins/middleware-export-validation.js +5 -17
  37. package/dist/plugins/middleware-server-only.js +2 -2
  38. package/dist/plugins/og-asset-ownership.js +18 -26
  39. package/dist/plugins/og-assets.js +2 -4
  40. package/dist/plugins/optimize-imports.js +2 -4
  41. package/dist/plugins/pages-node-externals.js +13 -40
  42. package/dist/plugins/remove-console.js +2 -4
  43. package/dist/plugins/require-condition-resolution.d.ts +16 -0
  44. package/dist/plugins/require-condition-resolution.js +167 -0
  45. package/dist/plugins/require-context.js +11 -46
  46. package/dist/plugins/sass.js +1 -1
  47. package/dist/plugins/server-externals-manifest.js +1 -23
  48. package/dist/plugins/strip-server-exports.js +13 -19
  49. package/dist/plugins/styled-jsx.js +17 -19
  50. package/dist/plugins/transform-result.d.ts +10 -0
  51. package/dist/plugins/transform-result.js +10 -0
  52. package/dist/plugins/transitive-externals.js +7 -21
  53. package/dist/plugins/typeof-window.d.ts +3 -8
  54. package/dist/plugins/typeof-window.js +5 -15
  55. package/dist/plugins/use-cache-callable.js +12 -22
  56. package/dist/plugins/wasm-module-import.js +1 -1
  57. package/dist/plugins/worker-image-imports.d.ts +12 -0
  58. package/dist/plugins/worker-image-imports.js +136 -0
  59. package/dist/routing/app-route-graph.d.ts +3 -2
  60. package/dist/routing/app-route-graph.js +1 -1
  61. package/dist/routing/route-pattern.d.ts +8 -1
  62. package/dist/routing/route-pattern.js +28 -1
  63. package/dist/routing/route-validation.js +7 -1
  64. package/dist/server/accept-encoding.d.ts +1 -2
  65. package/dist/server/accept-encoding.js +1 -4
  66. package/dist/server/app-action-forwarding.d.ts +18 -0
  67. package/dist/server/app-action-forwarding.js +140 -0
  68. package/dist/server/app-browser-entry.js +231 -50
  69. package/dist/server/app-browser-error.d.ts +1 -2
  70. package/dist/server/app-browser-error.js +1 -5
  71. package/dist/server/app-browser-history-controller.d.ts +16 -1
  72. package/dist/server/app-browser-history-controller.js +135 -18
  73. package/dist/server/app-browser-navigation-abort.d.ts +16 -0
  74. package/dist/server/app-browser-navigation-abort.js +29 -0
  75. package/dist/server/app-browser-navigation-controller.d.ts +4 -0
  76. package/dist/server/app-browser-navigation-controller.js +22 -6
  77. package/dist/server/app-browser-navigation-response.d.ts +11 -0
  78. package/dist/server/app-browser-navigation-response.js +8 -0
  79. package/dist/server/app-browser-popstate.d.ts +6 -1
  80. package/dist/server/app-browser-popstate.js +6 -2
  81. package/dist/server/app-browser-server-action-client.js +1 -1
  82. package/dist/server/app-browser-state.d.ts +2 -2
  83. package/dist/server/app-browser-state.js +3 -3
  84. package/dist/server/app-browser-stream.d.ts +0 -2
  85. package/dist/server/app-browser-supplemental-refresh.d.ts +49 -0
  86. package/dist/server/app-browser-supplemental-refresh.js +190 -0
  87. package/dist/server/app-browser-visible-commit.js +23 -12
  88. package/dist/server/app-elements-wire.d.ts +2 -0
  89. package/dist/server/app-elements-wire.js +7 -0
  90. package/dist/server/app-history-state.d.ts +22 -1
  91. package/dist/server/app-history-state.js +93 -9
  92. package/dist/server/app-optimistic-routing.d.ts +22 -1
  93. package/dist/server/app-optimistic-routing.js +137 -12
  94. package/dist/server/app-page-cache-finalizer.d.ts +3 -1
  95. package/dist/server/app-page-cache-finalizer.js +6 -6
  96. package/dist/server/app-page-cache.d.ts +2 -1
  97. package/dist/server/app-page-cache.js +2 -2
  98. package/dist/server/app-page-dispatch.d.ts +4 -1
  99. package/dist/server/app-page-dispatch.js +10 -1
  100. package/dist/server/app-page-element-builder.d.ts +1 -0
  101. package/dist/server/app-page-element-builder.js +1 -0
  102. package/dist/server/app-page-ppr-runtime.js +3 -2
  103. package/dist/server/app-page-render.d.ts +2 -1
  104. package/dist/server/app-page-render.js +6 -3
  105. package/dist/server/app-page-request.d.ts +2 -33
  106. package/dist/server/app-page-request.js +1 -27
  107. package/dist/server/app-page-route-wiring.d.ts +1 -0
  108. package/dist/server/app-page-route-wiring.js +4 -0
  109. package/dist/server/app-page-segment-state.d.ts +2 -2
  110. package/dist/server/app-page-segment-state.js +14 -8
  111. package/dist/server/app-ppr-fallback-shell.d.ts +2 -2
  112. package/dist/server/app-ppr-fallback-shell.js +3 -6
  113. package/dist/server/app-route-handler-dispatch.js +4 -1
  114. package/dist/server/app-route-handler-execution.js +1 -1
  115. package/dist/server/app-rsc-cache-busting.d.ts +2 -1
  116. package/dist/server/app-rsc-cache-busting.js +34 -8
  117. package/dist/server/app-rsc-handler.d.ts +4 -2
  118. package/dist/server/app-rsc-handler.js +57 -9
  119. package/dist/server/app-rsc-request-normalization.d.ts +2 -0
  120. package/dist/server/app-rsc-request-normalization.js +5 -1
  121. package/dist/server/app-rsc-route-matching.d.ts +4 -3
  122. package/dist/server/app-rsc-route-matching.js +14 -42
  123. package/dist/server/app-server-action-execution.d.ts +3 -0
  124. package/dist/server/app-server-action-execution.js +77 -2
  125. package/dist/server/app-ssr-entry.js +6 -6
  126. package/dist/server/app-ssr-stream.d.ts +1 -1
  127. package/dist/server/app-ssr-stream.js +2 -2
  128. package/dist/server/app-visited-response-cache.d.ts +6 -1
  129. package/dist/server/app-visited-response-cache.js +18 -2
  130. package/dist/server/dev-route-files.js +2 -5
  131. package/dist/server/dev-server.d.ts +5 -13
  132. package/dist/server/dev-server.js +22 -22
  133. package/dist/server/dev-stack-sourcemap.d.ts +1 -2
  134. package/dist/server/dev-stack-sourcemap.js +1 -4
  135. package/dist/server/headers.d.ts +5 -1
  136. package/dist/server/headers.js +5 -1
  137. package/dist/server/isr-cache.d.ts +6 -14
  138. package/dist/server/isr-cache.js +6 -27
  139. package/dist/server/middleware.d.ts +3 -16
  140. package/dist/server/middleware.js +2 -19
  141. package/dist/server/navigation-planner.d.ts +1 -0
  142. package/dist/server/navigation-planner.js +57 -9
  143. package/dist/server/navigation-trace.d.ts +1 -0
  144. package/dist/server/navigation-trace.js +1 -0
  145. package/dist/server/pages-data-route.d.ts +1 -10
  146. package/dist/server/pages-data-route.js +1 -12
  147. package/dist/server/pages-node-compat.d.ts +1 -4
  148. package/dist/server/pages-node-compat.js +1 -7
  149. package/dist/server/pages-readiness.js +4 -4
  150. package/dist/server/prerender-route-params.d.ts +1 -2
  151. package/dist/server/prerender-route-params.js +1 -4
  152. package/dist/server/prod-server.js +3 -1
  153. package/dist/shims/cache-runtime.js +39 -22
  154. package/dist/shims/cache.d.ts +1 -1
  155. package/dist/shims/dynamic.d.ts +3 -3
  156. package/dist/shims/dynamic.js +4 -6
  157. package/dist/shims/error.js +1 -1
  158. package/dist/shims/fetch-cache.d.ts +3 -1
  159. package/dist/shims/fetch-cache.js +23 -4
  160. package/dist/shims/internal/app-route-prefetch-policy.d.ts +6 -7
  161. package/dist/shims/internal/app-route-prefetch-policy.js +5 -4
  162. package/dist/shims/link.js +1 -1
  163. package/dist/shims/navigation.d.ts +12 -3
  164. package/dist/shims/navigation.js +46 -11
  165. package/dist/shims/navigation.react-server.js +1 -1
  166. package/dist/shims/request-state-types.d.ts +1 -1
  167. package/dist/shims/router.js +75 -4
  168. package/dist/shims/unified-request-context.d.ts +1 -1
  169. package/dist/shims/unified-request-context.js +1 -0
  170. package/dist/utils/built-asset-url.d.ts +1 -1
  171. package/dist/utils/built-asset-url.js +4 -2
  172. package/dist/utils/package-name.d.ts +11 -0
  173. package/dist/utils/package-name.js +18 -0
  174. package/dist/utils/path.d.ts +8 -1
  175. package/dist/utils/path.js +21 -1
  176. package/package.json +2 -1
@@ -1,9 +1,11 @@
1
1
  import { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
2
2
  import { resolveEntryPath } from "./runtime-entry-module.js";
3
3
  import { isProxyFile } from "../server/middleware.js";
4
+ import { safeJsonStringify } from "../server/html.js";
4
5
  import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES } from "../server/image-optimization.js";
5
6
  import { buildAppRscManifestCode } from "./app-rsc-manifest.js";
6
7
  import { generateDevOriginCheckCode } from "../server/dev-origin-check.js";
8
+ import { ACTION_OWNER_MANIFEST_ID } from "../plugins/action-owner-manifest.js";
7
9
  import { randomUUID } from "node:crypto";
8
10
  //#region src/entries/app-rsc-entry.ts
9
11
  /**
@@ -22,9 +24,10 @@ const normalizePathModulePath = resolveEntryPath("../server/normalize-path.js",
22
24
  const appRouteHandlerDispatchPath = resolveEntryPath("../server/app-route-handler-dispatch.js", import.meta.url);
23
25
  const appRouteRequestBuiltInsPath = resolveEntryPath("../server/app-route-request-built-ins.js", import.meta.url);
24
26
  const appRouteHandlerResponsePath = resolveEntryPath("../server/app-route-handler-response.js", import.meta.url);
27
+ const appServerActionExecutionPath = resolveEntryPath("../server/app-server-action-execution.js", import.meta.url);
28
+ const appActionForwardingPath = resolveEntryPath("../server/app-action-forwarding.js", import.meta.url);
25
29
  const appMiddlewarePath = resolveEntryPath("../server/app-middleware.js", import.meta.url);
26
30
  const metadataRouteResponsePath = resolveEntryPath("../server/metadata-route-response.js", import.meta.url);
27
- const appServerActionExecutionPath = resolveEntryPath("../server/app-server-action-execution.js", import.meta.url);
28
31
  const appRscErrorsPath = resolveEntryPath("../server/app-rsc-errors.js", import.meta.url);
29
32
  const appPageExecutionPath = resolveEntryPath("../server/app-page-execution.js", import.meta.url);
30
33
  const appFallbackRendererPath = resolveEntryPath("../server/app-fallback-renderer.js", import.meta.url);
@@ -81,6 +84,7 @@ function generateRscEntry(appDir, routes, middlewarePath, metadataRoutes, global
81
84
  const cacheComponents = config?.cacheComponents === true;
82
85
  const prefetchInlining = config?.prefetchInlining ?? false;
83
86
  const hasServerActions = config?.hasServerActions !== false;
87
+ const actionOwners = config?.actionOwners;
84
88
  const hasAppRouteHandlers = routes.some((route) => route.routePath !== null);
85
89
  const i18nConfig = config?.i18n ?? null;
86
90
  const hasPagesDir = config?.hasPagesDir ?? false;
@@ -130,6 +134,7 @@ const prerenderToReadableStream = createRscPrerenderer(async (model, options) =>
130
134
  import { createElement } from "react";
131
135
  import { getNavigationContext as _getNavigationContext } from "next/navigation";
132
136
  import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "vinext/shims/cache-handler";
137
+ import { getRequestExecutionContext as __getRequestExecutionContext } from "vinext/shims/request-context";
133
138
  import { headersContextFromRequest, getDraftModeCookieHeader, getAndClearPendingCookies, consumeDynamicUsage, consumeInvalidDynamicUsageError, setHeadersAccessPhase } from "next/headers";
134
139
  import { mergeMetadata, resolveModuleMetadata, mergeViewport, resolveModuleViewport } from "vinext/metadata";
135
140
  ${middlewarePath ? `import * as middlewareModule from ${JSON.stringify(toSlash(middlewarePath))};
@@ -139,6 +144,7 @@ import { ensureInstrumentationRegistered as __ensureInstrumentationRegistered }
139
144
  import { createAppRscHandler } from "vinext/server/app-rsc-handler";
140
145
  import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
141
146
  import __pagesClientAssets from "virtual:vinext-pages-client-assets";
147
+ ${actionOwners === void 0 ? `import __vinextActionOwners from ${JSON.stringify(ACTION_OWNER_MANIFEST_ID)};` : ""}
142
148
  import { setPagesClientAssets as __setPagesClientAssets } from "vinext/server/pages-client-assets";
143
149
  import { decodePathParams as __decodePathParams } from ${JSON.stringify(normalizePathModulePath)};
144
150
  import { buildRequestHeadersFromMiddlewareResponse as __buildRequestHeadersFromMiddlewareResponse } from ${JSON.stringify(middlewareRequestHeadersPath)};
@@ -146,7 +152,8 @@ ${hasPagesDir ? `import {
146
152
  applyRouteHandlerMiddlewareContext as __applyRouteHandlerMiddlewareContext,
147
153
  } from ${JSON.stringify(appRouteHandlerResponsePath)};` : ""}
148
154
  const __loadAppRouteHandlerDispatch = () => import(${JSON.stringify(appRouteHandlerDispatchPath)});
149
- ${hasServerActions ? `const __loadAppServerActionExecution = () => import(${JSON.stringify(appServerActionExecutionPath)});` : ""}
155
+ ${hasServerActions ? `const __loadAppServerActionExecution = () => import(${JSON.stringify(appServerActionExecutionPath)});
156
+ const __loadAppActionForwarding = () => import(${JSON.stringify(appActionForwardingPath)});` : ""}
150
157
  ${(metadataRoutes?.length ?? 0) > 0 ? `const __loadMetadataRouteResponse = () => import(${JSON.stringify(metadataRouteResponsePath)});` : ""}
151
158
  ${(metadataRoutes?.length ?? 0) > 0 ? `const __loadFileBasedMetadata = () => import(${JSON.stringify(fileBasedMetadataPath)});
152
159
  async function __applyFileBasedMetadata(...args) {
@@ -219,7 +226,6 @@ import { renderPagesFallback as __renderPagesFallback } from ${JSON.stringify(ap
219
226
  // so per-route dispatch can opt into suppression via .run(true, ...).
220
227
  import { suppressHookWarningAls } from ${JSON.stringify(appHookWarningSuppressionPath)};
221
228
  import { clearAppRequestContext as __clearRequestContext, setAppNavigationContext as setNavigationContext } from ${JSON.stringify(appRequestContextPath)};
222
-
223
229
  __configureMemoryCacheHandler({ cacheMaxMemorySize: ${JSON.stringify(cacheMaxMemorySize)} });
224
230
  import { createAppPrerenderStaticParamsResolver as __createAppPrerenderStaticParamsResolver } from ${JSON.stringify(appPrerenderStaticParamsPath)};
225
231
  import { ensureAppRouteModulesLoaded as __ensureRouteLoaded, loadAppInterceptPage as __loadAppInterceptPage } from ${JSON.stringify(appRouteModuleLoaderPath)};
@@ -283,6 +289,18 @@ function __resolveRouteDynamicConfig(route) {
283
289
  }).dynamicConfig ?? null;
284
290
  }
285
291
 
292
+ function __resolveRouteRevalidateSeconds(route) {
293
+ return __resolveAppPageSegmentConfig({
294
+ layouts: route.layouts,
295
+ page: route.page,
296
+ parallelSegments: Object.values(route.slots ?? {}).flatMap((slot) => [
297
+ slot.layout,
298
+ ...(slot.configLayouts ?? []),
299
+ slot.page ?? slot.default,
300
+ ]),
301
+ }).revalidateSeconds;
302
+ }
303
+
286
304
  function __resolveRouteRuntime(route) {
287
305
  return __resolveAppPageSegmentConfig({
288
306
  layouts: route.layouts,
@@ -415,8 +433,12 @@ function matchRequestRoute(url) {
415
433
  * Check if a pathname matches any intercepting route.
416
434
  * Returns the match info or null.
417
435
  */
418
- function findIntercept(pathname, sourcePathname = null) {
419
- return __routeMatcher.findIntercept(pathname, sourcePathname);
436
+ function findIntercept(pathname, sourcePathname = null, interceptionId = null) {
437
+ return __routeMatcher.findIntercept(pathname, sourcePathname, interceptionId);
438
+ }
439
+
440
+ function hasInterceptionId(interceptionId) {
441
+ return __routeMatcher.hasInterceptionId(interceptionId);
420
442
  }
421
443
 
422
444
  async function buildPageElements(route, params, routePath, pageRequest, layoutParamAccess, displayPathname = routePath, scriptNonce) {
@@ -515,7 +537,8 @@ ${rootParamNameEntries.join("\n")}
515
537
  };
516
538
 
517
539
  __setPagesClientAssets(__pagesClientAssets);
518
- export default createAppRscHandler({
540
+ function __VINEXT_ACTION_OWNERS() { return ${actionOwners === void 0 ? "__vinextActionOwners" : safeJsonStringify(actionOwners)}; }
541
+ const __appRscHandler = createAppRscHandler({
519
542
  basePath: __basePath,
520
543
  buildId: process.env.__VINEXT_BUILD_ID ?? null,
521
544
  ensureRouteLoaded: __ensureRouteLoaded,
@@ -542,6 +565,7 @@ export default createAppRscHandler({
542
565
  actionFailed,
543
566
  handlerStart,
544
567
  interceptionContext,
568
+ interceptionId,
545
569
  interceptionPathname,
546
570
  isProgressiveActionRender,
547
571
  isRscRequest,
@@ -632,6 +656,7 @@ export default createAppRscHandler({
632
656
  return findIntercept(
633
657
  pathname === cleanPathname ? interceptionPathname : pathname,
634
658
  interceptionContext,
659
+ interceptionId,
635
660
  );
636
661
  },
637
662
  generateStaticParams: __generateStaticParams,
@@ -731,6 +756,9 @@ export default createAppRscHandler({
731
756
  resolveRouteFetchCacheMode(targetRoute) {
732
757
  return __resolveRouteFetchCacheMode(targetRoute);
733
758
  },
759
+ resolveRouteRevalidateSeconds(targetRoute) {
760
+ return __resolveRouteRevalidateSeconds(targetRoute);
761
+ },
734
762
  resolveRouteDynamicConfig(targetRoute) {
735
763
  return __resolveRouteDynamicConfig(targetRoute);
736
764
  },
@@ -803,6 +831,10 @@ export default createAppRscHandler({
803
831
  isProgressiveServerActionRequest: __isProgressiveServerActionRequest,
804
832
  readActionFormDataWithLimit: __readFormDataWithLimit,
805
833
  } = await __loadAppServerActionExecution();
834
+ const {
835
+ areServerActionsOwnedByRoute: __areServerActionsOwnedByRoute,
836
+ forwardServerActionIfNeeded: __forwardServerActionIfNeeded,
837
+ } = await __loadAppActionForwarding();
806
838
  // A multipart form POST to a page is always a server-action attempt, so a
807
839
  // body that decodes to no action must surface as 404 action-not-found
808
840
  // (#1340). Route handlers run after this dispatch and accept raw multipart
@@ -835,6 +867,39 @@ export default createAppRscHandler({
835
867
  decodeFormState,
836
868
  getAndClearPendingCookies,
837
869
  getDraftModeCookieHeader,
870
+ forwardAction(__progressiveActionId) {
871
+ return __forwardServerActionIfNeeded({
872
+ actionId: __progressiveActionId,
873
+ actionOwners: __VINEXT_ACTION_OWNERS(),
874
+ allowedOrigins: __allowedOrigins,
875
+ basePath: __basePath,
876
+ clearRequestContext: __clearRequestContext,
877
+ currentRoutePattern: routeMatch?.route.pattern ?? null,
878
+ dispatch(__forwardRequest) {
879
+ const __executionContext = __getRequestExecutionContext();
880
+ return __appRscHandler(
881
+ __forwardRequest,
882
+ __executionContext
883
+ ? {
884
+ actionForwarded: true,
885
+ cache: __executionContext.cache,
886
+ passThroughOnException: __executionContext.passThroughOnException?.bind(__executionContext),
887
+ waitUntil: __executionContext.waitUntil.bind(__executionContext),
888
+ }
889
+ : { actionForwarded: true },
890
+ );
891
+ },
892
+ middlewareContext,
893
+ request,
894
+ });
895
+ },
896
+ validateActionReferences(__progressiveActionIds) {
897
+ return __areServerActionsOwnedByRoute(
898
+ __VINEXT_ACTION_OWNERS(),
899
+ __progressiveActionIds,
900
+ routeMatch?.route.pattern ?? null,
901
+ );
902
+ },
838
903
  hasPageRoute: __hasPageRoute,
839
904
  maxActionBodySize: __MAX_ACTION_BODY_SIZE,
840
905
  middlewareHeaders: middlewareContext.headers,
@@ -860,6 +925,34 @@ export default createAppRscHandler({
860
925
  sourceConfigHeaders,
861
926
  searchParams,
862
927
  }) {
928
+ const { forwardServerActionIfNeeded: __forwardServerActionIfNeeded } =
929
+ await __loadAppActionForwarding();
930
+ const __currentActionMatch = routeMatch;
931
+ const __forwardResponse = await __forwardServerActionIfNeeded({
932
+ actionId,
933
+ actionOwners: __VINEXT_ACTION_OWNERS(),
934
+ allowedOrigins: __allowedOrigins,
935
+ basePath: __basePath,
936
+ clearRequestContext: __clearRequestContext,
937
+ currentRoutePattern: __currentActionMatch?.route.pattern ?? null,
938
+ dispatch(__forwardRequest) {
939
+ const __executionContext = __getRequestExecutionContext();
940
+ return __appRscHandler(
941
+ __forwardRequest,
942
+ __executionContext
943
+ ? {
944
+ actionForwarded: true,
945
+ cache: __executionContext.cache,
946
+ passThroughOnException: __executionContext.passThroughOnException?.bind(__executionContext),
947
+ waitUntil: __executionContext.waitUntil.bind(__executionContext),
948
+ }
949
+ : { actionForwarded: true },
950
+ );
951
+ },
952
+ middlewareContext,
953
+ request,
954
+ });
955
+ if (__forwardResponse) return __forwardResponse;
863
956
  const {
864
957
  handleServerActionRscRequest: __handleServerActionRscRequest,
865
958
  readActionBodyWithLimit: __readBodyWithLimit,
@@ -926,6 +1019,9 @@ export default createAppRscHandler({
926
1019
  },
927
1020
  createTemporaryReferenceSet,
928
1021
  decodeReply,
1022
+ dispatchRedirectRequest(redirectRequest) {
1023
+ return __appRscHandler(redirectRequest, undefined);
1024
+ },
929
1025
  draftModeSecret: __draftModeSecret,
930
1026
  findIntercept(pathnameToMatch) {
931
1027
  return findIntercept(pathnameToMatch, interceptionContext);
@@ -958,6 +1054,9 @@ export default createAppRscHandler({
958
1054
  resolveRouteFetchCacheMode(targetRoute) {
959
1055
  return __resolveRouteFetchCacheMode(targetRoute);
960
1056
  },
1057
+ resolveRouteRevalidateSeconds(targetRoute) {
1058
+ return __resolveRouteRevalidateSeconds(targetRoute);
1059
+ },
961
1060
  resolveRouteDynamicConfig(targetRoute) {
962
1061
  return __resolveRouteDynamicConfig(targetRoute);
963
1062
  },
@@ -973,6 +1072,7 @@ export default createAppRscHandler({
973
1072
  setNavigationContext,
974
1073
  toInterceptOpts(intercept) {
975
1074
  return {
1075
+ interceptionId: intercept.interceptionId,
976
1076
  interceptGraphId: intercept.interceptionGraphId,
977
1077
  interceptionContext,
978
1078
  interceptLayouts: intercept.interceptLayouts,
@@ -1021,8 +1121,9 @@ export default createAppRscHandler({
1021
1121
  },` : ""}
1022
1122
  matchRoute,
1023
1123
  matchRequestRoute,
1024
- matchInterceptRoute(pathname, sourcePathname) {
1025
- const intercept = findIntercept(pathname, sourcePathname);
1124
+ hasInterceptionId,
1125
+ matchInterceptRoute(pathname, sourcePathname, interceptionId) {
1126
+ const intercept = findIntercept(pathname, sourcePathname, interceptionId);
1026
1127
  if (!intercept) return null;
1027
1128
  const route = routes[intercept.sourceRouteIndex];
1028
1129
  if (!route) return null;
@@ -1078,6 +1179,8 @@ export default createAppRscHandler({
1078
1179
  validateDevRequestOrigin: __validateDevRequestOrigin,
1079
1180
  });
1080
1181
 
1182
+ export default __appRscHandler;
1183
+
1081
1184
  if (import.meta.hot) {
1082
1185
  import.meta.hot.accept();
1083
1186
  }
@@ -1,5 +1,5 @@
1
- import { ResolvedNextConfig } from "../config/next-config.js";
2
1
  import { createValidFileMatcher } from "../routing/file-matcher.js";
2
+ import { ResolvedNextConfig } from "../config/next-config.js";
3
3
  import { StaticMiddlewareMatcher } from "../build/report.js";
4
4
  import { VinextLinkPrefetchRoute } from "../client/vinext-next-data.js";
5
5
  //#region src/entries/pages-client-entry.d.ts
@@ -1,5 +1,5 @@
1
- import { ResolvedNextConfig } from "../config/next-config.js";
2
1
  import { createValidFileMatcher } from "../routing/file-matcher.js";
2
+ import { ResolvedNextConfig } from "../config/next-config.js";
3
3
  //#region src/entries/pages-server-entry.d.ts
4
4
  /**
5
5
  * Generate the virtual SSR server entry module.
package/dist/index.js CHANGED
@@ -29,10 +29,12 @@ import { createSSRHandler } from "./server/dev-server.js";
29
29
  import { handleApiRoute } from "./server/api-handler.js";
30
30
  import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath, resolveDevImageRedirect } from "./server/image-optimization.js";
31
31
  import { installSocketErrorBackstop } from "./server/socket-error-backstop.js";
32
+ import { isPathInside, isPathInsideOrEqual, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
32
33
  import { invalidateMetadataFileCache, scanMetadataFiles } from "./server/metadata-routes.js";
33
34
  import { shouldInvalidateAppRouteFile } from "./server/dev-route-files.js";
34
35
  import { createDirectRunner } from "./server/dev-module-runner.js";
35
36
  import { validateDevRequest } from "./server/dev-origin-check.js";
37
+ import { createActionOwnerManifestPlugin } from "./plugins/action-owner-manifest.js";
36
38
  import { generateRscEntry } from "./entries/app-rsc-entry.js";
37
39
  import { generateSsrEntry } from "./entries/app-ssr-entry.js";
38
40
  import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VIRTUAL_CACHE_ADAPTERS, generateCacheAdaptersModule } from "./cache/cache-adapters-virtual.js";
@@ -66,7 +68,6 @@ import { createInstrumentationClientTransformPlugin } from "./plugins/instrument
66
68
  import { createStyledJsxPlugin } from "./plugins/styled-jsx.js";
67
69
  import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
68
70
  import { createMiddlewareServerOnlyPlugin } from "./plugins/middleware-server-only.js";
69
- import { stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
70
71
  import { createPagesNodeExternalsPlugin } from "./plugins/pages-node-externals.js";
71
72
  import { validateMiddlewareModuleExports } from "./plugins/middleware-export-validation.js";
72
73
  import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
@@ -91,7 +92,9 @@ import { createClientAssetFileNames, createClientCodeSplittingConfig, createClie
91
92
  import { hasExportAllCandidate, stripServerExports, validatePageExports } from "./plugins/strip-server-exports.js";
92
93
  import { removeConsoleCalls } from "./plugins/remove-console.js";
93
94
  import { createImportMetaUrlPlugin } from "./plugins/import-meta-url.js";
95
+ import { createWorkerImageImportsPlugin } from "./plugins/worker-image-imports.js";
94
96
  import { createRequireContextPlugin } from "./plugins/require-context.js";
97
+ import { createRequireConditionResolutionPlugin, isConditionalRequireScriptModuleId } from "./plugins/require-condition-resolution.js";
95
98
  import { createTransformCache } from "./plugins/transform-cache.js";
96
99
  import { createExtensionlessDynamicImportPlugin } from "./plugins/extensionless-dynamic-import.js";
97
100
  import { createWasmModuleImportPlugin } from "./plugins/wasm-module-import.js";
@@ -105,7 +108,7 @@ import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGI
105
108
  import { staticExportApp, staticExportPages } from "./build/static-export.js";
106
109
  import { createRequire } from "node:module";
107
110
  import fs from "node:fs";
108
- import { createLogger, parseAst, transformWithOxc } from "vite";
111
+ import { createIdResolver, createLogger, parseAst, transformWithOxc } from "vite";
109
112
  import { pathToFileURL } from "node:url";
110
113
  import { createHash, randomBytes } from "node:crypto";
111
114
  import commonjs from "vite-plugin-commonjs";
@@ -124,10 +127,6 @@ const OPTIONAL_OPTIMIZE_DEPS_WARNING_RE = /Failed to resolve dependency: .*use-s
124
127
  const VINEXT_FILTERED_OPTIMIZE_DEPS_WARN = Symbol.for("vinext.filteredOptimizeDepsWarn");
125
128
  const ANSI_ESCAPE_RE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
126
129
  installSocketErrorBackstop();
127
- function isInsideDirectory(dir, filePath) {
128
- const relativePath = path.relative(dir, filePath);
129
- return relativePath !== "" && !relativePath.startsWith("..") && !path.isAbsolute(relativePath);
130
- }
131
130
  function hasServerOnlyMarkerImport(code) {
132
131
  if (!code.includes("server-only")) return false;
133
132
  let ast;
@@ -254,9 +253,11 @@ function isolateGlobalNotFoundStylesheetImports(code, id) {
254
253
  function isScriptModuleId(id) {
255
254
  return SCRIPT_IMPORT_RE.test(stripViteModuleQuery(id).toLowerCase());
256
255
  }
257
- function skipCommonjsForLocalCjs(id) {
256
+ function commonjsTransformFilter(id, transformProjectLocalCommonJs = false, transformBundledDependencies = false, isBundledCommonJsDependency = () => false) {
258
257
  const cleanId = toSlash(stripViteModuleQuery(id));
259
- return /\.c[jt]s$/i.test(cleanId) && !cleanId.includes("node_modules") ? false : void 0;
258
+ if (isConditionalRequireScriptModuleId(cleanId)) return true;
259
+ if (transformBundledDependencies && isBundledCommonJsDependency(cleanId)) return true;
260
+ if (/\.c[jt]s$/i.test(cleanId) && !cleanId.includes("node_modules")) return transformProjectLocalCommonJs;
260
261
  }
261
262
  function hasOnlyTypeSpecifiers(statement) {
262
263
  return statement.specifiers !== void 0 && statement.specifiers.length > 0 && statement.specifiers.every((specifier) => specifier.importKind === "type" || specifier.exportKind === "type");
@@ -749,6 +750,21 @@ function getClientOutputConfig(assetsDir, preserveAppRouteBoundaries = false) {
749
750
  codeSplitting
750
751
  };
751
752
  }
753
+ function createServerEnvironmentFileNameResolver(config, outputRoot) {
754
+ const resolvedOutputRoot = path.resolve(config.root, outputRoot);
755
+ const outputPrefixes = new Map(["rsc", "ssr"].map((name) => {
756
+ const outDir = config.environments[name]?.build.outDir;
757
+ if (!outDir) return [name, ""];
758
+ const resolvedOutDir = path.resolve(config.root, outDir);
759
+ if (!isPathInsideOrEqual(resolvedOutputRoot, resolvedOutDir)) return [name, ""];
760
+ const relative = path.relative(resolvedOutputRoot, resolvedOutDir);
761
+ return [name, relative === "." ? "" : relative];
762
+ }));
763
+ return (environmentName, fileName) => {
764
+ const prefix = environmentName ? outputPrefixes.get(environmentName) : void 0;
765
+ return prefix ? path.join(prefix, fileName) : fileName;
766
+ };
767
+ }
752
768
  function vinext(options = {}) {
753
769
  const { supportsNativeTypeofWindowFolding: useNativeTypeofWindowFolding } = assertSupportedViteVersion();
754
770
  const prerenderConfig = normalizeVinextPrerenderConfig(options.prerender);
@@ -774,6 +790,13 @@ function vinext(options = {}) {
774
790
  let pagesBundledPackages = /* @__PURE__ */ new Set();
775
791
  let isServeCommand = false;
776
792
  let pagesOptimizeEntries = [];
793
+ const importMetaUrlCapability = createImportMetaUrlPlugin({
794
+ getRoot: () => root,
795
+ createEmittedModuleFileNameResolver(config) {
796
+ if (!hasCloudflarePlugin || !hasAppDir) return void 0;
797
+ return createServerEnvironmentFileNameResolver(config, config.environments.rsc?.build.outDir ?? options.rscOutDir ?? "dist/server");
798
+ }
799
+ });
777
800
  const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
778
801
  let pagesClientAssetsModule = null;
779
802
  let devPublicFileRoutes = null;
@@ -783,6 +806,8 @@ function vinext(options = {}) {
783
806
  let previewBuildCredentials;
784
807
  const sassComposesLoader = createSassAwareFileSystemLoader();
785
808
  let rscClassificationManifest = null;
809
+ let rscActionOwnerRoutes = null;
810
+ let rscActionOwnerSharedRoots = [];
786
811
  const shimsDir = path.resolve(__dirname, "shims");
787
812
  const canonicalize = (p) => toSlash(tryRealpathSync(p) ?? p);
788
813
  const pageTransformCanonicalPaths = /* @__PURE__ */ new Map();
@@ -885,7 +910,7 @@ function vinext(options = {}) {
885
910
  const { getPluginApi } = await rscPluginModulePromise;
886
911
  const pluginApi = getPluginApi(config);
887
912
  if (!pluginApi || pluginApi.manager.isScanBuild) return true;
888
- return Object.keys(pluginApi.manager.serverReferenceMetaMap).length > 0;
913
+ return pluginApi.manager.serverReferences.metaMap.size > 0;
889
914
  }
890
915
  const configuredReactOptions = options.react && options.react !== true ? options.react : void 0;
891
916
  const reactOptions = configuredReactOptions;
@@ -980,12 +1005,36 @@ function vinext(options = {}) {
980
1005
  }
981
1006
  };
982
1007
  const cachedConsumerConditionTransform = createTransformCache();
1008
+ let transformProjectLocalCommonJs = false;
1009
+ let transformBundledCommonJsDependencies = false;
1010
+ const commonJsPlugin = commonjs({ filter(id) {
1011
+ return commonjsTransformFilter(id, transformProjectLocalCommonJs, transformBundledCommonJsDependencies, importMetaUrlCapability.isBundledCommonJsDependencyId);
1012
+ } });
1013
+ const commonJsTransform = commonJsPlugin.transform;
1014
+ if (typeof commonJsTransform === "function") commonJsPlugin.transform = function environmentAwareCommonJsTransform(code, id, ...args) {
1015
+ if (this.environment.mode === "dev" && this.environment.depsOptimizer?.isOptimizedDepFile(id)) return null;
1016
+ const isDev = this.environment.mode === "dev";
1017
+ const isServer = this.environment.config.consumer === "server";
1018
+ const bundledDependency = isDev && isServer && (code.includes("__filename") || code.includes("__dirname")) && importMetaUrlCapability.isBundledCommonJsDependencyId(id);
1019
+ const projectLocal = !bundledDependency && !id.includes("/node_modules/") && !id.includes("\\node_modules\\");
1020
+ const previousProjectLocal = transformProjectLocalCommonJs;
1021
+ const previous = transformBundledCommonJsDependencies;
1022
+ transformProjectLocalCommonJs = projectLocal && isDev;
1023
+ transformBundledCommonJsDependencies = bundledDependency;
1024
+ try {
1025
+ return commonJsTransform.call(this, code, id, ...args);
1026
+ } finally {
1027
+ transformProjectLocalCommonJs = previousProjectLocal;
1028
+ transformBundledCommonJsDependencies = previous;
1029
+ }
1030
+ };
983
1031
  const plugins = [
984
1032
  createStyledJsxPlugin(earlyBaseDir),
985
1033
  mdxProxyPlugin,
986
1034
  reactPluginPromise,
987
1035
  createIgnoreDynamicRequestsPlugin(() => nextConfig?.turbopackTranspilePackages ?? []),
988
- commonjs({ filter: skipCommonjsForLocalCjs }),
1036
+ createRequireConditionResolutionPlugin(createIdResolver, commonjsTransformFilter),
1037
+ commonJsPlugin,
989
1038
  {
990
1039
  name: "vinext:global-not-found-css-isolation",
991
1040
  apply: "build",
@@ -1009,7 +1058,7 @@ function vinext(options = {}) {
1009
1058
  filter: { id: /\.m?js(?:\?.*)?$/ },
1010
1059
  async handler(code, id) {
1011
1060
  const cleanId = toSlash(stripViteModuleQuery(id));
1012
- if (isInsideDirectory(__dirname, cleanId)) return;
1061
+ if (isPathInside(__dirname, cleanId)) return;
1013
1062
  if (cleanId.includes("/node_modules/")) {
1014
1063
  if (!code.includes("use client") && !code.includes("use server")) return;
1015
1064
  if (!hasReactDirective(code)) return;
@@ -1286,6 +1335,7 @@ function vinext(options = {}) {
1286
1335
  ...!isSSR && !isMultiEnv ? { output: getClientOutputConfig(clientAssetsDir) } : {}
1287
1336
  })
1288
1337
  },
1338
+ worker: { plugins: () => [createWorkerImageImportsPlugin({ deploymentId: nextConfig.deploymentId })] },
1289
1339
  server: {
1290
1340
  cors: {
1291
1341
  preflightContinue: true,
@@ -1326,7 +1376,7 @@ function vinext(options = {}) {
1326
1376
  },
1327
1377
  define: defines,
1328
1378
  ...nextConfig.basePath ? { base: nextConfig.basePath + "/" } : {},
1329
- ...nextConfig.assetPrefix || nextConfig.deploymentId ? { experimental: { renderBuiltUrl: (filename, context) => renderVinextBuiltUrl(filename, nextConfig.assetPrefix, nextConfig.deploymentId, context.hostType) } } : {},
1379
+ ...nextConfig.assetPrefix || nextConfig.deploymentId ? { experimental: { renderBuiltUrl: (filename, context) => renderVinextBuiltUrl(filename, nextConfig.assetPrefix, nextConfig.deploymentId, context.hostType, context.hostId) } } : {},
1330
1380
  css: {
1331
1381
  ...nextConfig.useLightningcss ? {
1332
1382
  transformer: "lightningcss",
@@ -1512,7 +1562,7 @@ function vinext(options = {}) {
1512
1562
  noExternal: true
1513
1563
  },
1514
1564
  optimizeDeps: {
1515
- exclude: ["ipaddr.js"],
1565
+ exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], Object.keys(nextShimMap)),
1516
1566
  ...depOptimizeNodeEnvOptions
1517
1567
  },
1518
1568
  build: {
@@ -1531,6 +1581,12 @@ function vinext(options = {}) {
1531
1581
  return viteConfig;
1532
1582
  },
1533
1583
  configEnvironment(name, config) {
1584
+ if (name !== "client" && config.consumer !== "client") {
1585
+ config.optimizeDeps ??= {};
1586
+ config.optimizeDeps.rolldownOptions ??= {};
1587
+ const configuredPlugins = config.optimizeDeps.rolldownOptions.plugins;
1588
+ config.optimizeDeps.rolldownOptions.plugins = [...Array.isArray(configuredPlugins) ? configuredPlugins : configuredPlugins ? [configuredPlugins] : [], importMetaUrlCapability.optimizeDepsPlugin];
1589
+ }
1534
1590
  if (isServeCommand && hasCloudflarePlugin && hasPagesDir && !hasAppDir && name !== "client") {
1535
1591
  config.optimizeDeps ??= {};
1536
1592
  config.optimizeDeps.entries = mergeStringArrayValues(config.optimizeDeps.entries, pagesOptimizeEntries);
@@ -1545,6 +1601,19 @@ function vinext(options = {}) {
1545
1601
  },
1546
1602
  async configResolved(config) {
1547
1603
  if (isServeCommand && hasCloudflarePlugin && hasPagesDir && !hasAppDir) suppressOptionalOptimizeDepsWarnings(config.logger);
1604
+ if (config.worker?.rolldownOptions) {
1605
+ const workerFileNames = `${resolveAssetsDir(nextConfig.assetPrefix ?? "")}/workers/[name]-[hash].js`;
1606
+ const workerOutputs = config.worker.rolldownOptions.output;
1607
+ config.worker.rolldownOptions.output = Array.isArray(workerOutputs) ? (workerOutputs.length > 0 ? workerOutputs : [{}]).map((output) => ({
1608
+ ...output,
1609
+ entryFileNames: workerFileNames,
1610
+ chunkFileNames: workerFileNames
1611
+ })) : {
1612
+ ...workerOutputs,
1613
+ entryFileNames: workerFileNames,
1614
+ chunkFileNames: workerFileNames
1615
+ };
1616
+ }
1548
1617
  sassComposesLoader.setResolvedConfig(config);
1549
1618
  if (config.command === "build" && hasAppDir && hasPagesDir) {
1550
1619
  const [appRoutes, pageRoutes, apiRoutes] = await Promise.all([
@@ -1663,6 +1732,8 @@ function vinext(options = {}) {
1663
1732
  const globalErrorPath = findFileWithExts(appDir, "global-error", fileMatcher);
1664
1733
  const globalNotFoundPath = nextConfig?.globalNotFound ? findFileWithExts(appDir, "global-not-found", fileMatcher) : null;
1665
1734
  rscClassificationManifest = collectRouteClassificationManifest(routes);
1735
+ rscActionOwnerRoutes = this.environment.config.command === "build" && hasServerActions ? routes : null;
1736
+ rscActionOwnerSharedRoots = [globalErrorPath, globalNotFoundPath].filter((path) => path !== null);
1666
1737
  return generateRscEntry(appDir, routes, middlewarePath, metaRoutes, globalErrorPath, nextConfig?.basePath, nextConfig?.trailingSlash, {
1667
1738
  redirects: nextConfig?.redirects,
1668
1739
  rewrites: nextConfig?.rewrites,
@@ -1682,6 +1753,7 @@ function vinext(options = {}) {
1682
1753
  cacheComponents: nextConfig?.cacheComponents,
1683
1754
  prefetchInlining: nextConfig?.prefetchInlining,
1684
1755
  hasServerActions,
1756
+ actionOwners: this.environment.config.command === "build" ? void 0 : null,
1685
1757
  i18n: nextConfig?.i18n,
1686
1758
  imageConfig: {
1687
1759
  deviceSizes: nextConfig?.images?.deviceSizes,
@@ -1732,9 +1804,10 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1732
1804
  handler(code, chunk) {
1733
1805
  if (this.environment?.name !== "rsc") return null;
1734
1806
  if (!rscClassificationManifest) return null;
1735
- if (!code.includes("__VINEXT_CLASS")) return null;
1807
+ const hasClassificationStub = code.includes("__VINEXT_CLASS");
1808
+ if (!hasClassificationStub) return null;
1736
1809
  const enableClassificationDebug = Boolean(process.env.VINEXT_DEBUG_CLASSIFICATION);
1737
- const patchPlan = planRouteClassificationInjection({
1810
+ const patchPlan = hasClassificationStub && rscClassificationManifest ? planRouteClassificationInjection({
1738
1811
  canonicalizeLayoutPath: canonicalize,
1739
1812
  chunks: [{
1740
1813
  code,
@@ -1751,12 +1824,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1751
1824
  dynamicImportedIds: info.dynamicallyImportedIds ?? []
1752
1825
  };
1753
1826
  } }
1754
- });
1827
+ }) : { kind: "skip" };
1828
+ const nextCode = patchPlan.kind === "skip" ? code : patchPlan.code;
1755
1829
  if (patchPlan.kind === "skip") return null;
1756
1830
  rscClassificationManifest = null;
1757
1831
  return {
1758
- code: patchPlan.code,
1759
- map: patchPlan.map
1832
+ code: nextCode,
1833
+ map: null
1760
1834
  };
1761
1835
  }
1762
1836
  }
@@ -1960,6 +2034,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
1960
2034
  }
1961
2035
  },
1962
2036
  configureServer(server) {
2037
+ const devBuildId = nextConfig?.buildId ?? process.env.__VINEXT_BUILD_ID ?? "development";
1963
2038
  server.middlewares.use((req, _res, next) => {
1964
2039
  req.__vinextOriginalEncodedUrl ??= req.url;
1965
2040
  next();
@@ -2458,7 +2533,6 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2458
2533
  let isDataReq = false;
2459
2534
  let dataNotFoundResponse = null;
2460
2535
  if (isNextDataPathname(pathname)) {
2461
- const devBuildId = nextConfig?.buildId ?? process.env.__VINEXT_BUILD_ID ?? "development";
2462
2536
  const dataMatch = parseNextDataPathname(pathname, devBuildId);
2463
2537
  if (dataMatch) {
2464
2538
  isDataReq = true;
@@ -2687,7 +2761,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2687
2761
  }
2688
2762
  if (!cachedSSRHandler || cachedSSRHandler.routes !== routes) cachedSSRHandler = {
2689
2763
  routes,
2690
- handler: createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false, middlewarePath !== null, (nextConfig?.rewrites.beforeFiles.length ?? 0) > 0 || (nextConfig?.rewrites.afterFiles.length ?? 0) > 0 || (nextConfig?.rewrites.fallback.length ?? 0) > 0, nextConfig?.clientTraceMetadata, nextConfig?.htmlLimitedBots, nextConfig?.reactStrictMode === true, nextConfig?.expireTime, nextConfig?.crossOrigin)
2764
+ handler: createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false, middlewarePath !== null, (nextConfig?.rewrites.beforeFiles.length ?? 0) > 0 || (nextConfig?.rewrites.afterFiles.length ?? 0) > 0 || (nextConfig?.rewrites.fallback.length ?? 0) > 0, nextConfig?.clientTraceMetadata, nextConfig?.htmlLimitedBots, nextConfig?.reactStrictMode === true, nextConfig?.expireTime, nextConfig?.crossOrigin, devBuildId)
2691
2765
  };
2692
2766
  flushStagedHeaders();
2693
2767
  flushRequestHeaders();
@@ -2996,7 +3070,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2996
3070
  createLocalFontsPlugin(_shimsDir),
2997
3071
  createOptimizeImportsPlugin(() => nextConfig, () => root),
2998
3072
  createDynamicPreloadMetadataPlugin(),
2999
- createImportMetaUrlPlugin({ getRoot: () => root }),
3073
+ importMetaUrlCapability.vitePlugin,
3000
3074
  createExtensionlessDynamicImportPlugin(),
3001
3075
  createRequireContextPlugin(),
3002
3076
  createOgInlineFetchAssetsPlugin(),
@@ -3344,8 +3418,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3344
3418
  }
3345
3419
  }
3346
3420
  ];
3421
+ if (rscPluginPromise) plugins.push(rscPluginPromise);
3422
+ if (earlyAppDirExists) plugins.push(createActionOwnerManifestPlugin({
3423
+ canonicalizeModuleId: canonicalize,
3424
+ async getManager(config) {
3425
+ return (await rscPluginModulePromise)?.getPluginApi(config)?.manager;
3426
+ },
3427
+ getRoutes: () => rscActionOwnerRoutes ?? [],
3428
+ getSharedRoots: () => rscActionOwnerSharedRoots,
3429
+ onComplete() {
3430
+ rscActionOwnerRoutes = null;
3431
+ rscActionOwnerSharedRoots = [];
3432
+ }
3433
+ }));
3347
3434
  if (rscPluginPromise) {
3348
- plugins.push(rscPluginPromise);
3349
3435
  plugins.push(createRscReferenceValidationNormalizerPlugin());
3350
3436
  plugins.push(createRscClientReferenceLoadersPlugin());
3351
3437
  } else if (manualUseCachePluginPromise) plugins.push(manualUseCachePluginPromise);
@@ -0,0 +1,14 @@
1
+ import { AppRoute } from "../routing/app-route-graph.js";
2
+ import { Plugin, ResolvedConfig } from "vite";
3
+ import { RscPluginManager } from "@vitejs/plugin-rsc";
4
+ //#region src/plugins/action-owner-manifest.d.ts
5
+ declare const ACTION_OWNER_MANIFEST_ID = "virtual:vinext-action-owner-manifest";
6
+ declare function createActionOwnerManifestPlugin(options: {
7
+ canonicalizeModuleId: (id: string) => string;
8
+ getManager: (config: ResolvedConfig) => Promise<RscPluginManager | undefined>;
9
+ getRoutes: () => readonly AppRoute[];
10
+ getSharedRoots: () => readonly string[];
11
+ onComplete?: () => void;
12
+ }): Plugin;
13
+ //#endregion
14
+ export { ACTION_OWNER_MANIFEST_ID, createActionOwnerManifestPlugin };