vinext 1.0.0-beta.6 → 1.0.0-beta.8
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.
- package/README.md +47 -3
- package/dist/build/action-owner-manifest.d.ts +42 -0
- package/dist/build/action-owner-manifest.js +110 -0
- package/dist/build/clean-output.js +1 -4
- package/dist/build/client-build-config.js +10 -11
- package/dist/build/prerender.d.ts +1 -1
- package/dist/build/prerender.js +12 -6
- package/dist/build/report.d.ts +1 -1
- package/dist/build/route-classification-manifest.d.ts +1 -1
- package/dist/build/static-export.d.ts +1 -1
- package/dist/client/app-nav-failure-handler.js +1 -0
- package/dist/client/navigation-runtime.d.ts +5 -3
- package/dist/client/navigation-runtime.js +4 -8
- package/dist/entries/app-browser-entry.d.ts +1 -1
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +111 -8
- package/dist/entries/pages-client-entry.d.ts +1 -1
- package/dist/entries/pages-server-entry.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +119 -26
- package/dist/plugins/action-owner-manifest.d.ts +14 -0
- package/dist/plugins/action-owner-manifest.js +84 -0
- package/dist/plugins/ast-utils.d.ts +30 -1
- package/dist/plugins/ast-utils.js +76 -1
- package/dist/plugins/css-module-imports.d.ts +2 -2
- package/dist/plugins/css-module-imports.js +5 -13
- package/dist/plugins/dynamic-preload-metadata.js +13 -34
- package/dist/plugins/environment.d.ts +11 -0
- package/dist/plugins/environment.js +7 -0
- package/dist/plugins/extensionless-dynamic-import.js +11 -35
- package/dist/plugins/fonts.js +8 -12
- package/dist/plugins/ignore-dynamic-requests.d.ts +2 -4
- package/dist/plugins/ignore-dynamic-requests.js +29 -59
- package/dist/plugins/import-meta-url.d.ts +15 -9
- package/dist/plugins/import-meta-url.js +310 -85
- package/dist/plugins/instrumentation-client.js +4 -5
- package/dist/plugins/middleware-export-validation.js +5 -17
- package/dist/plugins/middleware-server-only.js +2 -2
- package/dist/plugins/og-asset-ownership.js +18 -26
- package/dist/plugins/og-assets.js +2 -4
- package/dist/plugins/optimize-imports.js +2 -4
- package/dist/plugins/pages-node-externals.js +13 -40
- package/dist/plugins/remove-console.js +2 -4
- package/dist/plugins/require-condition-resolution.d.ts +16 -0
- package/dist/plugins/require-condition-resolution.js +167 -0
- package/dist/plugins/require-context.js +11 -46
- package/dist/plugins/sass.js +1 -1
- package/dist/plugins/server-externals-manifest.js +1 -23
- package/dist/plugins/strip-server-exports.js +13 -19
- package/dist/plugins/styled-jsx.js +17 -19
- package/dist/plugins/transform-result.d.ts +10 -0
- package/dist/plugins/transform-result.js +10 -0
- package/dist/plugins/transitive-externals.js +7 -21
- package/dist/plugins/typeof-window.d.ts +3 -8
- package/dist/plugins/typeof-window.js +5 -15
- package/dist/plugins/use-cache-callable.js +12 -22
- package/dist/plugins/wasm-module-import.js +1 -1
- package/dist/plugins/worker-image-imports.d.ts +12 -0
- package/dist/plugins/worker-image-imports.js +136 -0
- package/dist/routing/app-route-graph.d.ts +3 -2
- package/dist/routing/app-route-graph.js +1 -1
- package/dist/routing/route-pattern.d.ts +8 -1
- package/dist/routing/route-pattern.js +28 -1
- package/dist/routing/route-validation.js +7 -1
- package/dist/server/accept-encoding.d.ts +1 -2
- package/dist/server/accept-encoding.js +1 -4
- package/dist/server/app-action-forwarding.d.ts +18 -0
- package/dist/server/app-action-forwarding.js +140 -0
- package/dist/server/app-browser-entry.js +231 -50
- package/dist/server/app-browser-error.d.ts +1 -2
- package/dist/server/app-browser-error.js +1 -5
- package/dist/server/app-browser-history-controller.d.ts +16 -1
- package/dist/server/app-browser-history-controller.js +135 -18
- package/dist/server/app-browser-navigation-abort.d.ts +16 -0
- package/dist/server/app-browser-navigation-abort.js +29 -0
- package/dist/server/app-browser-navigation-controller.d.ts +4 -0
- package/dist/server/app-browser-navigation-controller.js +22 -6
- package/dist/server/app-browser-navigation-response.d.ts +11 -0
- package/dist/server/app-browser-navigation-response.js +8 -0
- package/dist/server/app-browser-popstate.d.ts +6 -1
- package/dist/server/app-browser-popstate.js +6 -2
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-browser-state.d.ts +2 -2
- package/dist/server/app-browser-state.js +3 -3
- package/dist/server/app-browser-stream.d.ts +0 -2
- package/dist/server/app-browser-supplemental-refresh.d.ts +49 -0
- package/dist/server/app-browser-supplemental-refresh.js +190 -0
- package/dist/server/app-browser-visible-commit.js +23 -12
- package/dist/server/app-elements-wire.d.ts +2 -0
- package/dist/server/app-elements-wire.js +7 -0
- package/dist/server/app-history-state.d.ts +22 -1
- package/dist/server/app-history-state.js +93 -9
- package/dist/server/app-optimistic-routing.d.ts +22 -1
- package/dist/server/app-optimistic-routing.js +137 -12
- package/dist/server/app-page-cache-finalizer.d.ts +3 -1
- package/dist/server/app-page-cache-finalizer.js +6 -6
- package/dist/server/app-page-cache.d.ts +2 -1
- package/dist/server/app-page-cache.js +2 -2
- package/dist/server/app-page-dispatch.d.ts +4 -1
- package/dist/server/app-page-dispatch.js +10 -1
- package/dist/server/app-page-element-builder.d.ts +1 -0
- package/dist/server/app-page-element-builder.js +1 -0
- package/dist/server/app-page-ppr-runtime.js +3 -2
- package/dist/server/app-page-render.d.ts +2 -1
- package/dist/server/app-page-render.js +6 -3
- package/dist/server/app-page-request.d.ts +2 -33
- package/dist/server/app-page-request.js +1 -27
- package/dist/server/app-page-route-wiring.d.ts +1 -0
- package/dist/server/app-page-route-wiring.js +4 -0
- package/dist/server/app-page-segment-state.d.ts +2 -2
- package/dist/server/app-page-segment-state.js +14 -8
- package/dist/server/app-ppr-fallback-shell.d.ts +2 -2
- package/dist/server/app-ppr-fallback-shell.js +3 -6
- package/dist/server/app-route-handler-dispatch.js +4 -1
- package/dist/server/app-route-handler-execution.js +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.js +34 -8
- package/dist/server/app-rsc-handler.d.ts +4 -2
- package/dist/server/app-rsc-handler.js +57 -9
- package/dist/server/app-rsc-request-normalization.d.ts +2 -0
- package/dist/server/app-rsc-request-normalization.js +5 -1
- package/dist/server/app-rsc-route-matching.d.ts +4 -3
- package/dist/server/app-rsc-route-matching.js +14 -42
- package/dist/server/app-server-action-execution.d.ts +3 -0
- package/dist/server/app-server-action-execution.js +77 -2
- package/dist/server/app-ssr-entry.js +6 -6
- package/dist/server/app-ssr-stream.d.ts +1 -1
- package/dist/server/app-ssr-stream.js +2 -2
- package/dist/server/app-visited-response-cache.d.ts +6 -1
- package/dist/server/app-visited-response-cache.js +18 -2
- package/dist/server/dev-route-files.js +2 -5
- package/dist/server/dev-server.d.ts +5 -13
- package/dist/server/dev-server.js +22 -22
- package/dist/server/dev-stack-sourcemap.d.ts +1 -2
- package/dist/server/dev-stack-sourcemap.js +1 -4
- package/dist/server/headers.d.ts +5 -1
- package/dist/server/headers.js +5 -1
- package/dist/server/isr-cache.d.ts +6 -14
- package/dist/server/isr-cache.js +6 -27
- package/dist/server/middleware.d.ts +3 -16
- package/dist/server/middleware.js +2 -19
- package/dist/server/navigation-planner.d.ts +1 -0
- package/dist/server/navigation-planner.js +57 -9
- package/dist/server/navigation-trace.d.ts +1 -0
- package/dist/server/navigation-trace.js +1 -0
- package/dist/server/pages-data-route.d.ts +1 -10
- package/dist/server/pages-data-route.js +1 -12
- package/dist/server/pages-node-compat.d.ts +1 -4
- package/dist/server/pages-node-compat.js +1 -7
- package/dist/server/pages-readiness.js +4 -4
- package/dist/server/prerender-route-params.d.ts +1 -2
- package/dist/server/prerender-route-params.js +1 -4
- package/dist/server/prod-server.js +3 -1
- package/dist/shims/cache-runtime.js +39 -22
- package/dist/shims/cache.d.ts +1 -1
- package/dist/shims/dynamic.d.ts +3 -3
- package/dist/shims/dynamic.js +4 -6
- package/dist/shims/error.js +1 -1
- package/dist/shims/fetch-cache.d.ts +3 -1
- package/dist/shims/fetch-cache.js +23 -4
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +6 -7
- package/dist/shims/internal/app-route-prefetch-policy.js +5 -4
- package/dist/shims/link.js +1 -1
- package/dist/shims/navigation.d.ts +12 -3
- package/dist/shims/navigation.js +46 -11
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/router.js +75 -4
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/utils/built-asset-url.d.ts +1 -1
- package/dist/utils/built-asset-url.js +4 -2
- package/dist/utils/package-name.d.ts +11 -0
- package/dist/utils/package-name.js +18 -0
- package/dist/utils/path.d.ts +8 -1
- package/dist/utils/path.js +21 -1
- package/dist/utils/react-compiler-support.d.ts +20 -0
- package/dist/utils/react-compiler-support.js +29 -0
- package/package.json +3 -2
|
@@ -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
|
-
|
|
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
|
-
|
|
1025
|
-
|
|
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.d.ts
CHANGED
|
@@ -61,6 +61,9 @@ type VinextOptions = {
|
|
|
61
61
|
* Enabled by default. Set to `false` to disable (e.g. if you configure
|
|
62
62
|
* @vitejs/plugin-react manually in your vite.config.ts), or pass an options
|
|
63
63
|
* object to customize the Babel transform.
|
|
64
|
+
*
|
|
65
|
+
* Pass `{ compiler: true }` to enable the React Compiler. That requires
|
|
66
|
+
* @vitejs/plugin-react 6.1+ and the optional `oxc-transform-react` package.
|
|
64
67
|
* @default true
|
|
65
68
|
*/
|
|
66
69
|
react?: Options | boolean;
|
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";
|
|
@@ -53,6 +55,7 @@ import { readTrustedRevalidationHostname } from "./server/revalidation-host.js";
|
|
|
53
55
|
import { installDevStackSourcemapMiddleware } from "./server/dev-stack-sourcemap.js";
|
|
54
56
|
import { runPagesRequest } from "./server/pages-request-pipeline.js";
|
|
55
57
|
import { pagesRouteHasPriorityOverAppRoute, validateHybridRouteConflicts } from "./server/hybrid-route-priority.js";
|
|
58
|
+
import { hasReactCompilerPlugin, isReactCompilerPlugin, isReactCompilerRequested, reactCompilerUnsupportedMessage } from "./utils/react-compiler-support.js";
|
|
56
59
|
import { VIRTUAL_MODULE_ID_RE } from "./utils/virtual-module.js";
|
|
57
60
|
import { assertNoPublicDirAssetConflict, assertNoPublicNextRequestConflict } from "./build/public-dir-conflict.js";
|
|
58
61
|
import { renderVinextBuiltUrl } from "./utils/built-asset-url.js";
|
|
@@ -66,7 +69,6 @@ import { createInstrumentationClientTransformPlugin } from "./plugins/instrument
|
|
|
66
69
|
import { createStyledJsxPlugin } from "./plugins/styled-jsx.js";
|
|
67
70
|
import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
|
|
68
71
|
import { createMiddlewareServerOnlyPlugin } from "./plugins/middleware-server-only.js";
|
|
69
|
-
import { stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
|
|
70
72
|
import { createPagesNodeExternalsPlugin } from "./plugins/pages-node-externals.js";
|
|
71
73
|
import { validateMiddlewareModuleExports } from "./plugins/middleware-export-validation.js";
|
|
72
74
|
import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
|
|
@@ -91,7 +93,9 @@ import { createClientAssetFileNames, createClientCodeSplittingConfig, createClie
|
|
|
91
93
|
import { hasExportAllCandidate, stripServerExports, validatePageExports } from "./plugins/strip-server-exports.js";
|
|
92
94
|
import { removeConsoleCalls } from "./plugins/remove-console.js";
|
|
93
95
|
import { createImportMetaUrlPlugin } from "./plugins/import-meta-url.js";
|
|
96
|
+
import { createWorkerImageImportsPlugin } from "./plugins/worker-image-imports.js";
|
|
94
97
|
import { createRequireContextPlugin } from "./plugins/require-context.js";
|
|
98
|
+
import { createRequireConditionResolutionPlugin, isConditionalRequireScriptModuleId } from "./plugins/require-condition-resolution.js";
|
|
95
99
|
import { createTransformCache } from "./plugins/transform-cache.js";
|
|
96
100
|
import { createExtensionlessDynamicImportPlugin } from "./plugins/extensionless-dynamic-import.js";
|
|
97
101
|
import { createWasmModuleImportPlugin } from "./plugins/wasm-module-import.js";
|
|
@@ -105,7 +109,7 @@ import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGI
|
|
|
105
109
|
import { staticExportApp, staticExportPages } from "./build/static-export.js";
|
|
106
110
|
import { createRequire } from "node:module";
|
|
107
111
|
import fs from "node:fs";
|
|
108
|
-
import { createLogger, parseAst, transformWithOxc } from "vite";
|
|
112
|
+
import { createIdResolver, createLogger, parseAst, transformWithOxc } from "vite";
|
|
109
113
|
import { pathToFileURL } from "node:url";
|
|
110
114
|
import { createHash, randomBytes } from "node:crypto";
|
|
111
115
|
import commonjs from "vite-plugin-commonjs";
|
|
@@ -124,10 +128,6 @@ const OPTIONAL_OPTIMIZE_DEPS_WARNING_RE = /Failed to resolve dependency: .*use-s
|
|
|
124
128
|
const VINEXT_FILTERED_OPTIMIZE_DEPS_WARN = Symbol.for("vinext.filteredOptimizeDepsWarn");
|
|
125
129
|
const ANSI_ESCAPE_RE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
|
|
126
130
|
installSocketErrorBackstop();
|
|
127
|
-
function isInsideDirectory(dir, filePath) {
|
|
128
|
-
const relativePath = path.relative(dir, filePath);
|
|
129
|
-
return relativePath !== "" && !relativePath.startsWith("..") && !path.isAbsolute(relativePath);
|
|
130
|
-
}
|
|
131
131
|
function hasServerOnlyMarkerImport(code) {
|
|
132
132
|
if (!code.includes("server-only")) return false;
|
|
133
133
|
let ast;
|
|
@@ -254,9 +254,11 @@ function isolateGlobalNotFoundStylesheetImports(code, id) {
|
|
|
254
254
|
function isScriptModuleId(id) {
|
|
255
255
|
return SCRIPT_IMPORT_RE.test(stripViteModuleQuery(id).toLowerCase());
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function commonjsTransformFilter(id, transformProjectLocalCommonJs = false, transformBundledDependencies = false, isBundledCommonJsDependency = () => false) {
|
|
258
258
|
const cleanId = toSlash(stripViteModuleQuery(id));
|
|
259
|
-
|
|
259
|
+
if (isConditionalRequireScriptModuleId(cleanId)) return true;
|
|
260
|
+
if (transformBundledDependencies && isBundledCommonJsDependency(cleanId)) return true;
|
|
261
|
+
if (/\.c[jt]s$/i.test(cleanId) && !cleanId.includes("node_modules")) return transformProjectLocalCommonJs;
|
|
260
262
|
}
|
|
261
263
|
function hasOnlyTypeSpecifiers(statement) {
|
|
262
264
|
return statement.specifiers !== void 0 && statement.specifiers.length > 0 && statement.specifiers.every((specifier) => specifier.importKind === "type" || specifier.exportKind === "type");
|
|
@@ -749,6 +751,21 @@ function getClientOutputConfig(assetsDir, preserveAppRouteBoundaries = false) {
|
|
|
749
751
|
codeSplitting
|
|
750
752
|
};
|
|
751
753
|
}
|
|
754
|
+
function createServerEnvironmentFileNameResolver(config, outputRoot) {
|
|
755
|
+
const resolvedOutputRoot = path.resolve(config.root, outputRoot);
|
|
756
|
+
const outputPrefixes = new Map(["rsc", "ssr"].map((name) => {
|
|
757
|
+
const outDir = config.environments[name]?.build.outDir;
|
|
758
|
+
if (!outDir) return [name, ""];
|
|
759
|
+
const resolvedOutDir = path.resolve(config.root, outDir);
|
|
760
|
+
if (!isPathInsideOrEqual(resolvedOutputRoot, resolvedOutDir)) return [name, ""];
|
|
761
|
+
const relative = path.relative(resolvedOutputRoot, resolvedOutDir);
|
|
762
|
+
return [name, relative === "." ? "" : relative];
|
|
763
|
+
}));
|
|
764
|
+
return (environmentName, fileName) => {
|
|
765
|
+
const prefix = environmentName ? outputPrefixes.get(environmentName) : void 0;
|
|
766
|
+
return prefix ? path.join(prefix, fileName) : fileName;
|
|
767
|
+
};
|
|
768
|
+
}
|
|
752
769
|
function vinext(options = {}) {
|
|
753
770
|
const { supportsNativeTypeofWindowFolding: useNativeTypeofWindowFolding } = assertSupportedViteVersion();
|
|
754
771
|
const prerenderConfig = normalizeVinextPrerenderConfig(options.prerender);
|
|
@@ -774,6 +791,13 @@ function vinext(options = {}) {
|
|
|
774
791
|
let pagesBundledPackages = /* @__PURE__ */ new Set();
|
|
775
792
|
let isServeCommand = false;
|
|
776
793
|
let pagesOptimizeEntries = [];
|
|
794
|
+
const importMetaUrlCapability = createImportMetaUrlPlugin({
|
|
795
|
+
getRoot: () => root,
|
|
796
|
+
createEmittedModuleFileNameResolver(config) {
|
|
797
|
+
if (!hasCloudflarePlugin || !hasAppDir) return void 0;
|
|
798
|
+
return createServerEnvironmentFileNameResolver(config, config.environments.rsc?.build.outDir ?? options.rscOutDir ?? "dist/server");
|
|
799
|
+
}
|
|
800
|
+
});
|
|
777
801
|
const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
|
|
778
802
|
let pagesClientAssetsModule = null;
|
|
779
803
|
let devPublicFileRoutes = null;
|
|
@@ -783,6 +807,8 @@ function vinext(options = {}) {
|
|
|
783
807
|
let previewBuildCredentials;
|
|
784
808
|
const sassComposesLoader = createSassAwareFileSystemLoader();
|
|
785
809
|
let rscClassificationManifest = null;
|
|
810
|
+
let rscActionOwnerRoutes = null;
|
|
811
|
+
let rscActionOwnerSharedRoots = [];
|
|
786
812
|
const shimsDir = path.resolve(__dirname, "shims");
|
|
787
813
|
const canonicalize = (p) => toSlash(tryRealpathSync(p) ?? p);
|
|
788
814
|
const pageTransformCanonicalPaths = /* @__PURE__ */ new Map();
|
|
@@ -885,14 +911,17 @@ function vinext(options = {}) {
|
|
|
885
911
|
const { getPluginApi } = await rscPluginModulePromise;
|
|
886
912
|
const pluginApi = getPluginApi(config);
|
|
887
913
|
if (!pluginApi || pluginApi.manager.isScanBuild) return true;
|
|
888
|
-
return
|
|
914
|
+
return pluginApi.manager.serverReferences.metaMap.size > 0;
|
|
889
915
|
}
|
|
890
916
|
const configuredReactOptions = options.react && options.react !== true ? options.react : void 0;
|
|
891
917
|
const reactOptions = configuredReactOptions;
|
|
892
918
|
let reactPluginPromise = null;
|
|
919
|
+
let reactCompilerPluginPromise = null;
|
|
893
920
|
if (options.react !== false) {
|
|
894
921
|
if (!resolvedReactPath) throw new Error("vinext: @vitejs/plugin-react is not installed.\nRun: " + detectPackageManager(process.cwd()) + " @vitejs/plugin-react");
|
|
895
|
-
|
|
922
|
+
const allReactPlugins = import(pathToFileURL(resolvedReactPath).href).catch((cause) => {
|
|
923
|
+
throw new Error("vinext: Failed to load @vitejs/plugin-react.", { cause });
|
|
924
|
+
}).then((mod) => {
|
|
896
925
|
const react = mod.default;
|
|
897
926
|
const limitToCommand = (plugin, command) => {
|
|
898
927
|
const originalApply = plugin.apply;
|
|
@@ -906,15 +935,17 @@ function vinext(options = {}) {
|
|
|
906
935
|
}
|
|
907
936
|
};
|
|
908
937
|
};
|
|
909
|
-
const
|
|
938
|
+
const resolvedBuildPlugins = react(reactOptions);
|
|
939
|
+
if (isReactCompilerRequested(configuredReactOptions) && !hasReactCompilerPlugin(resolvedBuildPlugins)) throw new Error(reactCompilerUnsupportedMessage(detectPackageManager(process.cwd())));
|
|
940
|
+
const buildPlugins = resolvedBuildPlugins.map((plugin) => limitToCommand(plugin, "build"));
|
|
910
941
|
const servePlugins = react(configuredReactOptions !== void 0 && Object.prototype.hasOwnProperty.call(configuredReactOptions, "include") ? reactOptions : {
|
|
911
942
|
...reactOptions,
|
|
912
943
|
include: /\.(?:[tj]sx?|mdx)$/i
|
|
913
944
|
}).map((plugin) => limitToCommand(plugin, "serve"));
|
|
914
945
|
return [...buildPlugins, ...servePlugins];
|
|
915
|
-
}).catch((cause) => {
|
|
916
|
-
throw new Error("vinext: Failed to load @vitejs/plugin-react.", { cause });
|
|
917
946
|
});
|
|
947
|
+
reactPluginPromise = allReactPlugins.then((plugins) => plugins.filter((plugin) => !isReactCompilerPlugin(plugin)));
|
|
948
|
+
reactCompilerPluginPromise = allReactPlugins.then((plugins) => plugins.filter(isReactCompilerPlugin));
|
|
918
949
|
}
|
|
919
950
|
const imageImportDimCache = /* @__PURE__ */ new Map();
|
|
920
951
|
const staticImageAssets = /* @__PURE__ */ new Map();
|
|
@@ -980,12 +1011,36 @@ function vinext(options = {}) {
|
|
|
980
1011
|
}
|
|
981
1012
|
};
|
|
982
1013
|
const cachedConsumerConditionTransform = createTransformCache();
|
|
1014
|
+
let transformProjectLocalCommonJs = false;
|
|
1015
|
+
let transformBundledCommonJsDependencies = false;
|
|
1016
|
+
const commonJsPlugin = commonjs({ filter(id) {
|
|
1017
|
+
return commonjsTransformFilter(id, transformProjectLocalCommonJs, transformBundledCommonJsDependencies, importMetaUrlCapability.isBundledCommonJsDependencyId);
|
|
1018
|
+
} });
|
|
1019
|
+
const commonJsTransform = commonJsPlugin.transform;
|
|
1020
|
+
if (typeof commonJsTransform === "function") commonJsPlugin.transform = function environmentAwareCommonJsTransform(code, id, ...args) {
|
|
1021
|
+
if (this.environment.mode === "dev" && this.environment.depsOptimizer?.isOptimizedDepFile(id)) return null;
|
|
1022
|
+
const isDev = this.environment.mode === "dev";
|
|
1023
|
+
const isServer = this.environment.config.consumer === "server";
|
|
1024
|
+
const bundledDependency = isDev && isServer && (code.includes("__filename") || code.includes("__dirname")) && importMetaUrlCapability.isBundledCommonJsDependencyId(id);
|
|
1025
|
+
const projectLocal = !bundledDependency && !id.includes("/node_modules/") && !id.includes("\\node_modules\\");
|
|
1026
|
+
const previousProjectLocal = transformProjectLocalCommonJs;
|
|
1027
|
+
const previous = transformBundledCommonJsDependencies;
|
|
1028
|
+
transformProjectLocalCommonJs = projectLocal && isDev;
|
|
1029
|
+
transformBundledCommonJsDependencies = bundledDependency;
|
|
1030
|
+
try {
|
|
1031
|
+
return commonJsTransform.call(this, code, id, ...args);
|
|
1032
|
+
} finally {
|
|
1033
|
+
transformProjectLocalCommonJs = previousProjectLocal;
|
|
1034
|
+
transformBundledCommonJsDependencies = previous;
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
983
1037
|
const plugins = [
|
|
984
1038
|
createStyledJsxPlugin(earlyBaseDir),
|
|
985
1039
|
mdxProxyPlugin,
|
|
986
1040
|
reactPluginPromise,
|
|
987
1041
|
createIgnoreDynamicRequestsPlugin(() => nextConfig?.turbopackTranspilePackages ?? []),
|
|
988
|
-
|
|
1042
|
+
createRequireConditionResolutionPlugin(createIdResolver, commonjsTransformFilter),
|
|
1043
|
+
commonJsPlugin,
|
|
989
1044
|
{
|
|
990
1045
|
name: "vinext:global-not-found-css-isolation",
|
|
991
1046
|
apply: "build",
|
|
@@ -1009,7 +1064,7 @@ function vinext(options = {}) {
|
|
|
1009
1064
|
filter: { id: /\.m?js(?:\?.*)?$/ },
|
|
1010
1065
|
async handler(code, id) {
|
|
1011
1066
|
const cleanId = toSlash(stripViteModuleQuery(id));
|
|
1012
|
-
if (
|
|
1067
|
+
if (isPathInside(__dirname, cleanId)) return;
|
|
1013
1068
|
if (cleanId.includes("/node_modules/")) {
|
|
1014
1069
|
if (!code.includes("use client") && !code.includes("use server")) return;
|
|
1015
1070
|
if (!hasReactDirective(code)) return;
|
|
@@ -1026,6 +1081,7 @@ function vinext(options = {}) {
|
|
|
1026
1081
|
}
|
|
1027
1082
|
}
|
|
1028
1083
|
},
|
|
1084
|
+
reactCompilerPluginPromise,
|
|
1029
1085
|
createMiddlewareServerOnlyPlugin({
|
|
1030
1086
|
getMiddlewarePath: () => middlewarePath,
|
|
1031
1087
|
getCanonicalMiddlewarePath: () => middlewarePath ? tryRealpathSync(middlewarePath) ?? middlewarePath : null,
|
|
@@ -1286,6 +1342,7 @@ function vinext(options = {}) {
|
|
|
1286
1342
|
...!isSSR && !isMultiEnv ? { output: getClientOutputConfig(clientAssetsDir) } : {}
|
|
1287
1343
|
})
|
|
1288
1344
|
},
|
|
1345
|
+
worker: { plugins: () => [createWorkerImageImportsPlugin({ deploymentId: nextConfig.deploymentId })] },
|
|
1289
1346
|
server: {
|
|
1290
1347
|
cors: {
|
|
1291
1348
|
preflightContinue: true,
|
|
@@ -1326,7 +1383,7 @@ function vinext(options = {}) {
|
|
|
1326
1383
|
},
|
|
1327
1384
|
define: defines,
|
|
1328
1385
|
...nextConfig.basePath ? { base: nextConfig.basePath + "/" } : {},
|
|
1329
|
-
...nextConfig.assetPrefix || nextConfig.deploymentId ? { experimental: { renderBuiltUrl: (filename, context) => renderVinextBuiltUrl(filename, nextConfig.assetPrefix, nextConfig.deploymentId, context.hostType) } } : {},
|
|
1386
|
+
...nextConfig.assetPrefix || nextConfig.deploymentId ? { experimental: { renderBuiltUrl: (filename, context) => renderVinextBuiltUrl(filename, nextConfig.assetPrefix, nextConfig.deploymentId, context.hostType, context.hostId) } } : {},
|
|
1330
1387
|
css: {
|
|
1331
1388
|
...nextConfig.useLightningcss ? {
|
|
1332
1389
|
transformer: "lightningcss",
|
|
@@ -1512,7 +1569,7 @@ function vinext(options = {}) {
|
|
|
1512
1569
|
noExternal: true
|
|
1513
1570
|
},
|
|
1514
1571
|
optimizeDeps: {
|
|
1515
|
-
exclude: ["ipaddr.js"],
|
|
1572
|
+
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], Object.keys(nextShimMap)),
|
|
1516
1573
|
...depOptimizeNodeEnvOptions
|
|
1517
1574
|
},
|
|
1518
1575
|
build: {
|
|
@@ -1531,6 +1588,12 @@ function vinext(options = {}) {
|
|
|
1531
1588
|
return viteConfig;
|
|
1532
1589
|
},
|
|
1533
1590
|
configEnvironment(name, config) {
|
|
1591
|
+
if (name !== "client" && config.consumer !== "client") {
|
|
1592
|
+
config.optimizeDeps ??= {};
|
|
1593
|
+
config.optimizeDeps.rolldownOptions ??= {};
|
|
1594
|
+
const configuredPlugins = config.optimizeDeps.rolldownOptions.plugins;
|
|
1595
|
+
config.optimizeDeps.rolldownOptions.plugins = [...Array.isArray(configuredPlugins) ? configuredPlugins : configuredPlugins ? [configuredPlugins] : [], importMetaUrlCapability.optimizeDepsPlugin];
|
|
1596
|
+
}
|
|
1534
1597
|
if (isServeCommand && hasCloudflarePlugin && hasPagesDir && !hasAppDir && name !== "client") {
|
|
1535
1598
|
config.optimizeDeps ??= {};
|
|
1536
1599
|
config.optimizeDeps.entries = mergeStringArrayValues(config.optimizeDeps.entries, pagesOptimizeEntries);
|
|
@@ -1545,6 +1608,19 @@ function vinext(options = {}) {
|
|
|
1545
1608
|
},
|
|
1546
1609
|
async configResolved(config) {
|
|
1547
1610
|
if (isServeCommand && hasCloudflarePlugin && hasPagesDir && !hasAppDir) suppressOptionalOptimizeDepsWarnings(config.logger);
|
|
1611
|
+
if (config.worker?.rolldownOptions) {
|
|
1612
|
+
const workerFileNames = `${resolveAssetsDir(nextConfig.assetPrefix ?? "")}/workers/[name]-[hash].js`;
|
|
1613
|
+
const workerOutputs = config.worker.rolldownOptions.output;
|
|
1614
|
+
config.worker.rolldownOptions.output = Array.isArray(workerOutputs) ? (workerOutputs.length > 0 ? workerOutputs : [{}]).map((output) => ({
|
|
1615
|
+
...output,
|
|
1616
|
+
entryFileNames: workerFileNames,
|
|
1617
|
+
chunkFileNames: workerFileNames
|
|
1618
|
+
})) : {
|
|
1619
|
+
...workerOutputs,
|
|
1620
|
+
entryFileNames: workerFileNames,
|
|
1621
|
+
chunkFileNames: workerFileNames
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1548
1624
|
sassComposesLoader.setResolvedConfig(config);
|
|
1549
1625
|
if (config.command === "build" && hasAppDir && hasPagesDir) {
|
|
1550
1626
|
const [appRoutes, pageRoutes, apiRoutes] = await Promise.all([
|
|
@@ -1663,6 +1739,8 @@ function vinext(options = {}) {
|
|
|
1663
1739
|
const globalErrorPath = findFileWithExts(appDir, "global-error", fileMatcher);
|
|
1664
1740
|
const globalNotFoundPath = nextConfig?.globalNotFound ? findFileWithExts(appDir, "global-not-found", fileMatcher) : null;
|
|
1665
1741
|
rscClassificationManifest = collectRouteClassificationManifest(routes);
|
|
1742
|
+
rscActionOwnerRoutes = this.environment.config.command === "build" && hasServerActions ? routes : null;
|
|
1743
|
+
rscActionOwnerSharedRoots = [globalErrorPath, globalNotFoundPath].filter((path) => path !== null);
|
|
1666
1744
|
return generateRscEntry(appDir, routes, middlewarePath, metaRoutes, globalErrorPath, nextConfig?.basePath, nextConfig?.trailingSlash, {
|
|
1667
1745
|
redirects: nextConfig?.redirects,
|
|
1668
1746
|
rewrites: nextConfig?.rewrites,
|
|
@@ -1682,6 +1760,7 @@ function vinext(options = {}) {
|
|
|
1682
1760
|
cacheComponents: nextConfig?.cacheComponents,
|
|
1683
1761
|
prefetchInlining: nextConfig?.prefetchInlining,
|
|
1684
1762
|
hasServerActions,
|
|
1763
|
+
actionOwners: this.environment.config.command === "build" ? void 0 : null,
|
|
1685
1764
|
i18n: nextConfig?.i18n,
|
|
1686
1765
|
imageConfig: {
|
|
1687
1766
|
deviceSizes: nextConfig?.images?.deviceSizes,
|
|
@@ -1732,9 +1811,10 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1732
1811
|
handler(code, chunk) {
|
|
1733
1812
|
if (this.environment?.name !== "rsc") return null;
|
|
1734
1813
|
if (!rscClassificationManifest) return null;
|
|
1735
|
-
|
|
1814
|
+
const hasClassificationStub = code.includes("__VINEXT_CLASS");
|
|
1815
|
+
if (!hasClassificationStub) return null;
|
|
1736
1816
|
const enableClassificationDebug = Boolean(process.env.VINEXT_DEBUG_CLASSIFICATION);
|
|
1737
|
-
const patchPlan = planRouteClassificationInjection({
|
|
1817
|
+
const patchPlan = hasClassificationStub && rscClassificationManifest ? planRouteClassificationInjection({
|
|
1738
1818
|
canonicalizeLayoutPath: canonicalize,
|
|
1739
1819
|
chunks: [{
|
|
1740
1820
|
code,
|
|
@@ -1751,12 +1831,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1751
1831
|
dynamicImportedIds: info.dynamicallyImportedIds ?? []
|
|
1752
1832
|
};
|
|
1753
1833
|
} }
|
|
1754
|
-
});
|
|
1834
|
+
}) : { kind: "skip" };
|
|
1835
|
+
const nextCode = patchPlan.kind === "skip" ? code : patchPlan.code;
|
|
1755
1836
|
if (patchPlan.kind === "skip") return null;
|
|
1756
1837
|
rscClassificationManifest = null;
|
|
1757
1838
|
return {
|
|
1758
|
-
code:
|
|
1759
|
-
map:
|
|
1839
|
+
code: nextCode,
|
|
1840
|
+
map: null
|
|
1760
1841
|
};
|
|
1761
1842
|
}
|
|
1762
1843
|
}
|
|
@@ -1960,6 +2041,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1960
2041
|
}
|
|
1961
2042
|
},
|
|
1962
2043
|
configureServer(server) {
|
|
2044
|
+
const devBuildId = nextConfig?.buildId ?? process.env.__VINEXT_BUILD_ID ?? "development";
|
|
1963
2045
|
server.middlewares.use((req, _res, next) => {
|
|
1964
2046
|
req.__vinextOriginalEncodedUrl ??= req.url;
|
|
1965
2047
|
next();
|
|
@@ -2458,7 +2540,6 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2458
2540
|
let isDataReq = false;
|
|
2459
2541
|
let dataNotFoundResponse = null;
|
|
2460
2542
|
if (isNextDataPathname(pathname)) {
|
|
2461
|
-
const devBuildId = nextConfig?.buildId ?? process.env.__VINEXT_BUILD_ID ?? "development";
|
|
2462
2543
|
const dataMatch = parseNextDataPathname(pathname, devBuildId);
|
|
2463
2544
|
if (dataMatch) {
|
|
2464
2545
|
isDataReq = true;
|
|
@@ -2687,7 +2768,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2687
2768
|
}
|
|
2688
2769
|
if (!cachedSSRHandler || cachedSSRHandler.routes !== routes) cachedSSRHandler = {
|
|
2689
2770
|
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)
|
|
2771
|
+
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
2772
|
};
|
|
2692
2773
|
flushStagedHeaders();
|
|
2693
2774
|
flushRequestHeaders();
|
|
@@ -2996,7 +3077,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2996
3077
|
createLocalFontsPlugin(_shimsDir),
|
|
2997
3078
|
createOptimizeImportsPlugin(() => nextConfig, () => root),
|
|
2998
3079
|
createDynamicPreloadMetadataPlugin(),
|
|
2999
|
-
|
|
3080
|
+
importMetaUrlCapability.vitePlugin,
|
|
3000
3081
|
createExtensionlessDynamicImportPlugin(),
|
|
3001
3082
|
createRequireContextPlugin(),
|
|
3002
3083
|
createOgInlineFetchAssetsPlugin(),
|
|
@@ -3344,8 +3425,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3344
3425
|
}
|
|
3345
3426
|
}
|
|
3346
3427
|
];
|
|
3428
|
+
if (rscPluginPromise) plugins.push(rscPluginPromise);
|
|
3429
|
+
if (earlyAppDirExists) plugins.push(createActionOwnerManifestPlugin({
|
|
3430
|
+
canonicalizeModuleId: canonicalize,
|
|
3431
|
+
async getManager(config) {
|
|
3432
|
+
return (await rscPluginModulePromise)?.getPluginApi(config)?.manager;
|
|
3433
|
+
},
|
|
3434
|
+
getRoutes: () => rscActionOwnerRoutes ?? [],
|
|
3435
|
+
getSharedRoots: () => rscActionOwnerSharedRoots,
|
|
3436
|
+
onComplete() {
|
|
3437
|
+
rscActionOwnerRoutes = null;
|
|
3438
|
+
rscActionOwnerSharedRoots = [];
|
|
3439
|
+
}
|
|
3440
|
+
}));
|
|
3347
3441
|
if (rscPluginPromise) {
|
|
3348
|
-
plugins.push(rscPluginPromise);
|
|
3349
3442
|
plugins.push(createRscReferenceValidationNormalizerPlugin());
|
|
3350
3443
|
plugins.push(createRscClientReferenceLoadersPlugin());
|
|
3351
3444
|
} else if (manualUseCachePluginPromise) plugins.push(manualUseCachePluginPromise);
|