vinext 0.2.1 → 1.0.0-beta.0
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 +50 -29
- package/dist/build/client-build-config.d.ts +13 -92
- package/dist/build/client-build-config.js +17 -95
- package/dist/build/prerender-paths.d.ts +23 -0
- package/dist/build/prerender-paths.js +296 -0
- package/dist/build/prerender.d.ts +12 -1
- package/dist/build/prerender.js +1 -1
- package/dist/cache/cache-adapters-virtual.d.ts +7 -1
- package/dist/cache/cache-adapters-virtual.js +26 -2
- package/dist/check.js +5 -0
- package/dist/cli.js +33 -53
- package/dist/config/next-config.js +1 -2
- package/dist/config/prerender.d.ts +11 -1
- package/dist/config/prerender.js +19 -1
- package/dist/config/tsconfig-paths.js +5 -1
- package/dist/image/image-adapters-virtual.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +248 -146
- package/dist/init-cloudflare.js +12 -3
- package/dist/init-platform.d.ts +10 -1
- package/dist/init-platform.js +78 -12
- package/dist/init.d.ts +11 -3
- package/dist/init.js +129 -31
- package/dist/server/app-browser-entry.js +4 -6
- package/dist/server/app-browser-navigation-controller.js +6 -3
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-visible-commit.js +1 -1
- package/dist/server/app-layout-param-observation.d.ts +1 -1
- package/dist/server/app-page-cache-render.d.ts +1 -1
- package/dist/server/app-page-dispatch.d.ts +1 -1
- package/dist/server/app-page-dispatch.js +3 -3
- package/dist/server/app-page-render.d.ts +1 -1
- package/dist/server/app-page-route-wiring.js +3 -3
- package/dist/server/app-route-handler-execution.d.ts +1 -1
- package/dist/server/app-route-handler-execution.js +1 -1
- package/dist/server/app-rsc-cache-busting.js +0 -1
- package/dist/server/app-rsc-handler.js +1 -1
- package/dist/server/app-rsc-render-mode.d.ts +2 -5
- package/dist/server/app-rsc-render-mode.js +2 -12
- package/dist/server/app-server-action-execution.js +4 -4
- package/dist/server/app-ssr-entry.js +2 -2
- package/dist/server/dev-module-runner.js +1 -1
- package/dist/server/dev-origin-check.d.ts +2 -2
- package/dist/server/dev-origin-check.js +2 -2
- package/dist/server/dev-server.js +4 -4
- package/dist/server/image-optimization.d.ts +12 -1
- package/dist/server/image-optimization.js +13 -1
- package/dist/server/isr-cache.d.ts +12 -4
- package/dist/server/isr-cache.js +2 -2
- package/dist/server/pages-page-data.js +1 -1
- package/dist/server/pages-page-response.js +2 -2
- package/dist/server/pages-request-pipeline.js +1 -1
- package/dist/server/prerender-manifest.d.ts +15 -1
- package/dist/server/prerender-manifest.js +29 -1
- package/dist/server/prod-server.d.ts +6 -5
- package/dist/server/prod-server.js +6 -7
- package/dist/server/static-file-cache.js +1 -1
- package/dist/shims/cache.d.ts +1 -1
- package/dist/shims/cdn-cache.d.ts +2 -7
- package/dist/shims/cdn-cache.js +2 -14
- package/dist/shims/form.d.ts +1 -1
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/request-state-types.d.ts +2 -2
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/utils/project.d.ts +1 -1
- package/dist/utils/vite-version.d.ts +3 -13
- package/dist/utils/vite-version.js +38 -30
- package/package.json +31 -13
- package/dist/cloudflare/index.d.ts +0 -3
- package/dist/cloudflare/index.js +0 -3
- package/dist/packages/cloudflare/src/cache/cdn-adapter.runtime.js +0 -102
- package/dist/packages/cloudflare/src/cache/kv-data-adapter.runtime.d.ts +0 -126
- package/dist/packages/cloudflare/src/cache/kv-data-adapter.runtime.js +0 -442
- package/dist/packages/cloudflare/src/deploy-config.js +0 -150
- package/dist/packages/cloudflare/src/deploy-help.js +0 -55
- package/dist/packages/cloudflare/src/deploy.js +0 -272
- package/dist/packages/cloudflare/src/tpr.d.ts +0 -45
- package/dist/packages/cloudflare/src/tpr.js +0 -582
- package/dist/packages/cloudflare/src/utils/cache-control-metadata.js +0 -20
|
@@ -2,7 +2,7 @@ import { createRequestContext, runWithRequestContext } from "../shims/unified-re
|
|
|
2
2
|
import { getRequestExecutionContext } from "../shims/request-context.js";
|
|
3
3
|
import "../utils/protocol-headers.js";
|
|
4
4
|
import { AppElementsWire } from "./app-elements-wire.js";
|
|
5
|
-
import { APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL
|
|
5
|
+
import { APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL } from "./app-rsc-render-mode.js";
|
|
6
6
|
import "./app-elements.js";
|
|
7
7
|
import { consumeDynamicUsage, consumeInvalidDynamicUsageError, getAndClearPendingCookies, getDraftModeCookieHeader, getHeadersContext, isDraftModeRequest, markDynamicUsage, peekDynamicUsage, peekRenderRequestApiUsage, setHeadersContext } from "../shims/headers.js";
|
|
8
8
|
import { _consumeRequestScopedCacheLife, _peekRequestScopedCacheLife } from "../shims/cache-request-state.js";
|
|
@@ -167,7 +167,7 @@ async function dispatchAppPageInner(options) {
|
|
|
167
167
|
const hasRequestSearchParams = !shouldUseEmptySearchParams && hasSearchParams(options.searchParams);
|
|
168
168
|
const pageSearchParams = shouldUseEmptySearchParams ? new URLSearchParams() : options.searchParams;
|
|
169
169
|
const layoutParamAccess = createAppLayoutParamAccessTracker();
|
|
170
|
-
const hasActiveLoadingBoundary =
|
|
170
|
+
const hasActiveLoadingBoundary = Boolean(route.loading?.default);
|
|
171
171
|
setCurrentFetchSoftTags(buildAppPageTags(options.cleanPathname, [], route.routeSegments));
|
|
172
172
|
setCurrentFetchCacheMode(options.fetchCache ?? null);
|
|
173
173
|
setCurrentForceDynamicFetchDefault(isForceDynamic);
|
|
@@ -401,7 +401,7 @@ async function dispatchAppPageInner(options) {
|
|
|
401
401
|
});
|
|
402
402
|
},
|
|
403
403
|
async probePageSpecialError() {
|
|
404
|
-
if (
|
|
404
|
+
if (route.loading?.default) return null;
|
|
405
405
|
return resolveAppPageSpecialError(await probeAppPageThrownError({
|
|
406
406
|
probePage: () => options.probePage(pageSearchParams),
|
|
407
407
|
runWithSuppressedHookWarning(probe) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CachedAppPageValue } from "../shims/cache-handler.js";
|
|
2
1
|
import { ClientReuseManifestParseResult, ClientReuseManifestSkipDisposition } from "./client-reuse-manifest.js";
|
|
3
2
|
import { AppOutgoingElements } from "./app-elements-wire.js";
|
|
4
3
|
import { NavigationContext } from "../shims/navigation-context-state.js";
|
|
@@ -7,6 +6,7 @@ import { AppPageMiddlewareContext } from "./app-page-response.js";
|
|
|
7
6
|
import { RootParams } from "../shims/root-params.js";
|
|
8
7
|
import { AppPageSsrHandler } from "./app-page-stream.js";
|
|
9
8
|
import { AppLayoutParamAccessTracker } from "./app-layout-param-observation.js";
|
|
9
|
+
import { CachedAppPageValue } from "../shims/cache-handler.js";
|
|
10
10
|
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
11
11
|
import { AppPageRenderObservationState } from "./app-page-render-observation.js";
|
|
12
12
|
import { ReactNode } from "react";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createAppRenderDependency, registerAppElementRenderDependencies, renderAfterAppDependencies, renderWithAppDependencyBarrier } from "./app-render-dependency.js";
|
|
2
2
|
import { APP_STATIC_SIBLINGS_KEY, AppElementsWire, normalizeAppElementsSlotBindings } from "./app-elements-wire.js";
|
|
3
|
-
import { APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL
|
|
3
|
+
import { APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL } from "./app-rsc-render-mode.js";
|
|
4
4
|
import { APP_PREFETCH_LOADING_SHELL_MARKER_KEY } from "./app-elements.js";
|
|
5
5
|
import DefaultGlobalError from "../shims/default-global-error.js";
|
|
6
6
|
import { ErrorBoundary, ForbiddenBoundary, GlobalErrorBoundary, NotFoundBoundary, RedirectBoundary, UnauthorizedBoundary } from "../shims/error-boundary.js";
|
|
@@ -353,7 +353,7 @@ function buildAppPageElements(options) {
|
|
|
353
353
|
children: slotElement
|
|
354
354
|
});
|
|
355
355
|
const slotLoadingComponent = getDefaultExport(slot.loading);
|
|
356
|
-
if (slotLoadingComponent
|
|
356
|
+
if (slotLoadingComponent) slotElement = /* @__PURE__ */ jsx(Suspense, {
|
|
357
357
|
fallback: /* @__PURE__ */ jsx(slotLoadingComponent, {}),
|
|
358
358
|
children: slotElement
|
|
359
359
|
}, slotResetKey);
|
|
@@ -374,7 +374,7 @@ function buildAppPageElements(options) {
|
|
|
374
374
|
else routeChildren = /* @__PURE__ */ jsx(routeLoadingComponent, {});
|
|
375
375
|
else {
|
|
376
376
|
routeChildren = /* @__PURE__ */ jsx(RedirectBoundary, { children: routeChildren });
|
|
377
|
-
if (routeLoadingComponent
|
|
377
|
+
if (routeLoadingComponent) routeChildren = /* @__PURE__ */ jsx(Suspense, {
|
|
378
378
|
fallback: /* @__PURE__ */ jsx(routeLoadingComponent, {}),
|
|
379
379
|
children: routeChildren
|
|
380
380
|
}, routeResetKey);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NextI18nConfig } from "../config/next-config.js";
|
|
2
|
-
import { CachedRouteValue } from "../shims/cache-handler.js";
|
|
3
2
|
import { ExecutionContextLike } from "../shims/request-context.js";
|
|
4
3
|
import { NextRequest } from "../shims/server.js";
|
|
4
|
+
import { CachedRouteValue } from "../shims/cache-handler.js";
|
|
5
5
|
import { HeadersAccessPhase } from "../shims/headers.js";
|
|
6
6
|
import { RouteHandlerMiddlewareContext } from "./app-route-handler-response.js";
|
|
7
7
|
import { AppRouteHandlerModule } from "./app-route-handler-policy.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isDraftModeRequest, setHeadersContext } from "../shims/headers.js";
|
|
2
|
-
import { runWithRootParamsUsage } from "../shims/root-params.js";
|
|
3
2
|
import { isPossibleAppRouteActionRequest } from "./app-action-request.js";
|
|
3
|
+
import { runWithRootParamsUsage } from "../shims/root-params.js";
|
|
4
4
|
import { applyRouteHandlerMiddlewareContext, applyRouteHandlerRevalidateHeader, assertSupportedAppRouteHandlerResponse, buildAppRouteCacheValue, finalizeRouteHandlerResponse, markRouteHandlerCacheMiss } from "./app-route-handler-response.js";
|
|
5
5
|
import { createTrackedAppRouteRequest, markKnownDynamicAppRoute } from "./app-route-handler-runtime.js";
|
|
6
6
|
import { createStaticGenerationHeadersContext, getAppRouteStaticGenerationErrorMessage } from "./app-static-generation.js";
|
|
@@ -14,7 +14,6 @@ const VINEXT_RSC_COMPATIBILITY_ID_HEADER = "X-Vinext-RSC-Compatibility-Id";
|
|
|
14
14
|
const VINEXT_RSC_CONTENT_TYPE = "text/x-component";
|
|
15
15
|
const VINEXT_RSC_VARY_HEADER = [
|
|
16
16
|
"RSC",
|
|
17
|
-
"Accept",
|
|
18
17
|
NEXT_ROUTER_STATE_TREE_HEADER,
|
|
19
18
|
NEXT_ROUTER_PREFETCH_HEADER,
|
|
20
19
|
NEXT_ROUTER_SEGMENT_PREFETCH_HEADER,
|
|
@@ -19,10 +19,10 @@ import "./app-page-response.js";
|
|
|
19
19
|
import { parseNextHttpErrorDigest } from "./next-error-digest.js";
|
|
20
20
|
import { matchPrerenderRouteParamsPayload, readTrustedPrerenderRouteParams, serializePrerenderRouteParamsHeader } from "./prerender-route-params.js";
|
|
21
21
|
import { getRenderedConcreteUrlPathsForRoute } from "./pregenerated-concrete-paths.js";
|
|
22
|
-
import { pickRootParams, setRootParams } from "../shims/root-params.js";
|
|
23
22
|
import { createServerActionNotFoundResponse, getServerActionNotFoundMessage } from "./server-action-not-found.js";
|
|
24
23
|
import { buildPageCacheTags } from "./implicit-tags.js";
|
|
25
24
|
import { buildPostMwRequestContext } from "./app-post-middleware-context.js";
|
|
25
|
+
import { pickRootParams, setRootParams } from "../shims/root-params.js";
|
|
26
26
|
import { createRouteTreePrefetchResponse, isRouteTreePrefetchRequest } from "./app-route-tree-prefetch.js";
|
|
27
27
|
import { flattenErrorCauses } from "../utils/error-cause.js";
|
|
28
28
|
import { finalizeAppRscResponse } from "./app-rsc-response-finalizer.js";
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
//#region src/server/app-rsc-render-mode.d.ts
|
|
2
|
-
type AppRscRenderMode = "navigation" | "prefetch-dynamic-shell" | "prefetch-loading-shell"
|
|
2
|
+
type AppRscRenderMode = "navigation" | "prefetch-dynamic-shell" | "prefetch-loading-shell";
|
|
3
3
|
declare const APP_RSC_RENDER_MODE_NAVIGATION = "navigation";
|
|
4
4
|
declare const APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL = "prefetch-dynamic-shell";
|
|
5
5
|
declare const APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL = "prefetch-loading-shell";
|
|
6
|
-
declare const APP_RSC_RENDER_MODE_REFRESH_PRESERVE_UI = "refresh-preserve-ui";
|
|
7
|
-
declare const APP_RSC_RENDER_MODE_ACTION_RERENDER_PRESERVE_UI = "action-rerender-preserve-ui";
|
|
8
|
-
declare function shouldSuppressLoadingBoundaries(mode: AppRscRenderMode): boolean;
|
|
9
6
|
declare function getRscRenderModeCacheVariant(mode: AppRscRenderMode): string | null;
|
|
10
7
|
declare function parseAppRscRenderMode(value: string | null): AppRscRenderMode;
|
|
11
8
|
//#endregion
|
|
12
|
-
export {
|
|
9
|
+
export { APP_RSC_RENDER_MODE_NAVIGATION, APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL, APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL, AppRscRenderMode, getRscRenderModeCacheVariant, parseAppRscRenderMode };
|
|
@@ -2,27 +2,17 @@
|
|
|
2
2
|
const APP_RSC_RENDER_MODE_NAVIGATION = "navigation";
|
|
3
3
|
const APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL = "prefetch-dynamic-shell";
|
|
4
4
|
const APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL = "prefetch-loading-shell";
|
|
5
|
-
const APP_RSC_RENDER_MODE_REFRESH_PRESERVE_UI = "refresh-preserve-ui";
|
|
6
|
-
const APP_RSC_RENDER_MODE_ACTION_RERENDER_PRESERVE_UI = "action-rerender-preserve-ui";
|
|
7
|
-
function shouldSuppressLoadingBoundaries(mode) {
|
|
8
|
-
return mode === "refresh-preserve-ui" || mode === "action-rerender-preserve-ui";
|
|
9
|
-
}
|
|
10
|
-
function shouldUsePreserveUiCacheVariant(mode) {
|
|
11
|
-
return shouldSuppressLoadingBoundaries(mode);
|
|
12
|
-
}
|
|
13
5
|
function getRscRenderModeCacheVariant(mode) {
|
|
14
6
|
if (mode === "prefetch-dynamic-shell") return "prefetch-dynamic-shell";
|
|
15
7
|
if (mode === "prefetch-loading-shell") return "prefetch-loading-shell";
|
|
16
|
-
return
|
|
8
|
+
return null;
|
|
17
9
|
}
|
|
18
10
|
function parseAppRscRenderMode(value) {
|
|
19
11
|
switch (value) {
|
|
20
12
|
case APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL: return APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL;
|
|
21
13
|
case APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL: return APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL;
|
|
22
|
-
case APP_RSC_RENDER_MODE_REFRESH_PRESERVE_UI: return APP_RSC_RENDER_MODE_REFRESH_PRESERVE_UI;
|
|
23
|
-
case APP_RSC_RENDER_MODE_ACTION_RERENDER_PRESERVE_UI: return APP_RSC_RENDER_MODE_ACTION_RERENDER_PRESERVE_UI;
|
|
24
14
|
default: return APP_RSC_RENDER_MODE_NAVIGATION;
|
|
25
15
|
}
|
|
26
16
|
}
|
|
27
17
|
//#endregion
|
|
28
|
-
export {
|
|
18
|
+
export { APP_RSC_RENDER_MODE_NAVIGATION, APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL, APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL, getRscRenderModeCacheVariant, parseAppRscRenderMode };
|
|
@@ -4,7 +4,7 @@ import { ACTION_FORWARDED_HEADER, ACTION_REDIRECT_HEADER, ACTION_REDIRECT_STATUS
|
|
|
4
4
|
import { isExternalUrl } from "../config/config-matchers.js";
|
|
5
5
|
import { internalServerErrorResponse, payloadTooLargeResponse } from "./http-error-responses.js";
|
|
6
6
|
import { validateCsrfOrigin, validateServerActionPayload } from "./request-pipeline.js";
|
|
7
|
-
import {
|
|
7
|
+
import { APP_RSC_RENDER_MODE_NAVIGATION } from "./app-rsc-render-mode.js";
|
|
8
8
|
import { headersContextFromRequest, isDraftModeRequest, setHeadersContext } from "../shims/headers.js";
|
|
9
9
|
import { getAndClearActionRevalidationKind } from "../shims/cache-request-state.js";
|
|
10
10
|
import { setCurrentFetchCacheMode, setCurrentFetchSoftTags, setCurrentForceDynamicFetchDefault } from "../shims/fetch-cache.js";
|
|
@@ -13,13 +13,13 @@ import { VINEXT_RSC_CONTENT_TYPE, VINEXT_RSC_VARY_HEADER, applyRscCompatibilityI
|
|
|
13
13
|
import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
|
|
14
14
|
import { applyEdgeRuntimeHeader } from "./app-page-response.js";
|
|
15
15
|
import { getNextErrorDigest, parseNextHttpErrorDigest, parseNextRedirectDigest } from "./next-error-digest.js";
|
|
16
|
-
import { createRootParamsUsageController, pickRootParams, runWithRootParamsScope, runWithRootParamsUsage } from "../shims/root-params.js";
|
|
17
16
|
import { createServerActionNotFoundResponse, getServerActionNotFoundMessage, isServerActionNotFoundError } from "./server-action-not-found.js";
|
|
18
17
|
import { deferUntilStreamConsumed } from "./defer-until-stream-consumed.js";
|
|
19
18
|
import "./app-page-stream.js";
|
|
20
19
|
import { buildAppPageTags } from "./implicit-tags.js";
|
|
21
20
|
import { resolveAppPageNavigationParams } from "./app-page-element-builder.js";
|
|
22
21
|
import { resolveAppPageActionRerenderTarget } from "./app-page-request.js";
|
|
22
|
+
import { createRootParamsUsageController, pickRootParams, runWithRootParamsScope, runWithRootParamsUsage } from "../shims/root-params.js";
|
|
23
23
|
import { getSetCookieName } from "./cookie-utils.js";
|
|
24
24
|
import { createStaticGenerationHeadersContext } from "./app-static-generation.js";
|
|
25
25
|
//#region src/server/app-server-action-execution.ts
|
|
@@ -684,7 +684,7 @@ async function handleServerActionRscRequest(options) {
|
|
|
684
684
|
request: redirectRenderRequest,
|
|
685
685
|
route: targetMatch.route,
|
|
686
686
|
searchParams: redirectSearchParams,
|
|
687
|
-
renderMode:
|
|
687
|
+
renderMode: APP_RSC_RENDER_MODE_NAVIGATION,
|
|
688
688
|
observeMetadataSearchParamsAccess: redirectDynamicConfig !== "force-static",
|
|
689
689
|
observePageSearchParamsAccess: redirectDynamicConfig !== "force-static"
|
|
690
690
|
});
|
|
@@ -778,7 +778,7 @@ async function handleServerActionRscRequest(options) {
|
|
|
778
778
|
request: options.request,
|
|
779
779
|
route: actionRerenderTarget.route,
|
|
780
780
|
searchParams: actionRerenderSearchParams,
|
|
781
|
-
renderMode:
|
|
781
|
+
renderMode: APP_RSC_RENDER_MODE_NAVIGATION,
|
|
782
782
|
observeMetadataSearchParamsAccess: actionRerenderDynamicConfig !== "force-static",
|
|
783
783
|
observePageSearchParamsAccess: actionRerenderDynamicConfig !== "force-static"
|
|
784
784
|
});
|
|
@@ -17,12 +17,12 @@ import DefaultGlobalError from "../shims/default-global-error.js";
|
|
|
17
17
|
import { BfcacheStateKeyMapContext, ElementsContext, Slot } from "../shims/slot.js";
|
|
18
18
|
import { createSsrErrorMetaRenderer } from "./app-ssr-error-meta.js";
|
|
19
19
|
import { createNavigationRuntimeRscMetadataScript, createRscEmbedTransform, createTickBufferedTransform } from "./app-ssr-stream.js";
|
|
20
|
-
import { BeforeInteractiveContext } from "../shims/before-interactive-context.js";
|
|
21
|
-
import { runWithRootParamsScope } from "../shims/root-params.js";
|
|
22
20
|
import { createInitialBfcacheMaps } from "./app-bfcache-identity.js";
|
|
23
21
|
import { RSC_FORM_STATE_GLOBAL } from "./app-browser-hydration.js";
|
|
24
22
|
import { createClientReferencePreloader } from "./app-client-reference-preloader.js";
|
|
25
23
|
import { deferUntilStreamConsumed } from "./defer-until-stream-consumed.js";
|
|
24
|
+
import { runWithRootParamsScope } from "../shims/root-params.js";
|
|
25
|
+
import { BeforeInteractiveContext } from "../shims/before-interactive-context.js";
|
|
26
26
|
import { renderBeforeInteractiveInlineScripts } from "./before-interactive-head.js";
|
|
27
27
|
import { createInitialDevServerErrorScript } from "./dev-initial-server-error.js";
|
|
28
28
|
import { ssrAppRouterInstance } from "./app-ssr-router-instance.js";
|
|
@@ -8,7 +8,7 @@ import { ESModulesEvaluator, ModuleRunner, createNodeImportMeta } from "vite/mod
|
|
|
8
8
|
*
|
|
9
9
|
* ## Why this exists
|
|
10
10
|
*
|
|
11
|
-
* Vite
|
|
11
|
+
* Vite's `server.ssrLoadModule()` and the lazy `RunnableDevEnvironment.runner`
|
|
12
12
|
* getter both use `SSRCompatModuleRunner`, which constructs a
|
|
13
13
|
* `createServerModuleRunnerTransport` synchronously. That transport calls
|
|
14
14
|
* `connect()` immediately, which reads `environment.hot.api.outsideEmitter` —
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Prevents external websites from making cross-origin requests to the
|
|
6
6
|
* local dev server and reading the responses (data exfiltration).
|
|
7
7
|
*
|
|
8
|
-
* Vite
|
|
9
|
-
*
|
|
8
|
+
* Vite provides built-in CORS and WebSocket origin protection, but vinext
|
|
9
|
+
* overrides Vite's CORS config to allow OPTIONS passthrough.
|
|
10
10
|
* This module adds origin verification to vinext's own request handlers.
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Prevents external websites from making cross-origin requests to the
|
|
6
6
|
* local dev server and reading the responses (data exfiltration).
|
|
7
7
|
*
|
|
8
|
-
* Vite
|
|
9
|
-
*
|
|
8
|
+
* Vite provides built-in CORS and WebSocket origin protection, but vinext
|
|
9
|
+
* overrides Vite's CORS config to allow OPTIONS passthrough.
|
|
10
10
|
* This module adds origin verification to vinext's own request handlers.
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
@@ -180,7 +180,7 @@ async function streamPageToResponse(res, element, options) {
|
|
|
180
180
|
const suffix = transformedShell.slice(markerIdx + 25);
|
|
181
181
|
const bufferedBody = bufferBodyBeforeHeaders ? await new Response(bodyStream).text() : null;
|
|
182
182
|
const headers = {
|
|
183
|
-
"Content-Type": "text/html",
|
|
183
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
184
184
|
"Transfer-Encoding": "chunked"
|
|
185
185
|
};
|
|
186
186
|
if (extraHeaders) for (const [key, val] of Object.entries(extraHeaders)) if (Array.isArray(val)) res.setHeader(key, val);
|
|
@@ -535,7 +535,7 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
535
535
|
revalidateSeconds: getRevalidateDuration(cacheKey) ?? 60
|
|
536
536
|
});
|
|
537
537
|
const hitHeaders = {
|
|
538
|
-
"Content-Type": "text/html",
|
|
538
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
539
539
|
...buildCacheStateHeaders("HIT"),
|
|
540
540
|
"Cache-Control": hitCacheControl
|
|
541
541
|
};
|
|
@@ -709,7 +709,7 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
709
709
|
revalidateSeconds: getRevalidateDuration(cacheKey) ?? 60
|
|
710
710
|
});
|
|
711
711
|
const staleHeaders = {
|
|
712
|
-
"Content-Type": "text/html",
|
|
712
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
713
713
|
...buildCacheStateHeaders("STALE"),
|
|
714
714
|
"Cache-Control": staleCacheControl
|
|
715
715
|
};
|
|
@@ -1148,7 +1148,7 @@ async function renderErrorPage(server, runner, req, res, url, pagesDir, statusCo
|
|
|
1148
1148
|
</body>
|
|
1149
1149
|
</html>`;
|
|
1150
1150
|
const transformedHtml = await server.transformIndexHtml(url, html);
|
|
1151
|
-
res.writeHead(statusCode, { "Content-Type": "text/html" });
|
|
1151
|
+
res.writeHead(statusCode, { "Content-Type": "text/html; charset=utf-8" });
|
|
1152
1152
|
res.end(transformedHtml);
|
|
1153
1153
|
}
|
|
1154
1154
|
return;
|
|
@@ -26,7 +26,18 @@ declare const IMAGE_OPTIMIZATION_PATH = "/_next/image";
|
|
|
26
26
|
* for any newly generated URLs.
|
|
27
27
|
*/
|
|
28
28
|
declare const VINEXT_IMAGE_OPTIMIZATION_PATH = "/_vinext/image";
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Returns true when `pathname` is either supported image optimization
|
|
31
|
+
* endpoint.
|
|
32
|
+
*
|
|
33
|
+
* A single trailing slash is accepted (`/_next/image/`): with
|
|
34
|
+
* `trailingSlash: true`, Next.js 308-redirects `/_next/image?url=...` to
|
|
35
|
+
* `/_next/image/?url=...` and then serves the slashed form — its route
|
|
36
|
+
* matching strips a trailing slash before matching internal paths (see
|
|
37
|
+
* getItem in packages/next/src/server/lib/router-utils/filesystem.ts).
|
|
38
|
+
* Rejecting the slashed form 404'd every dev-mode next/image request under
|
|
39
|
+
* `trailingSlash: true`.
|
|
40
|
+
*/
|
|
30
41
|
declare function isImageOptimizationPath(pathname: string): boolean;
|
|
31
42
|
/**
|
|
32
43
|
* Image security configuration from next.config.js `images` section.
|
|
@@ -27,8 +27,20 @@ const IMAGE_OPTIMIZATION_PATH = "/_next/image";
|
|
|
27
27
|
* for any newly generated URLs.
|
|
28
28
|
*/
|
|
29
29
|
const VINEXT_IMAGE_OPTIMIZATION_PATH = "/_vinext/image";
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Returns true when `pathname` is either supported image optimization
|
|
32
|
+
* endpoint.
|
|
33
|
+
*
|
|
34
|
+
* A single trailing slash is accepted (`/_next/image/`): with
|
|
35
|
+
* `trailingSlash: true`, Next.js 308-redirects `/_next/image?url=...` to
|
|
36
|
+
* `/_next/image/?url=...` and then serves the slashed form — its route
|
|
37
|
+
* matching strips a trailing slash before matching internal paths (see
|
|
38
|
+
* getItem in packages/next/src/server/lib/router-utils/filesystem.ts).
|
|
39
|
+
* Rejecting the slashed form 404'd every dev-mode next/image request under
|
|
40
|
+
* `trailingSlash: true`.
|
|
41
|
+
*/
|
|
31
42
|
function isImageOptimizationPath(pathname) {
|
|
43
|
+
if (pathname.length > 1 && pathname.endsWith("/")) pathname = pathname.slice(0, -1);
|
|
32
44
|
return pathname === "/_next/image" || pathname === "/_vinext/image";
|
|
33
45
|
}
|
|
34
46
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RenderObservation } from "./cache-proof.js";
|
|
2
|
-
import { CacheHandlerValue, CachedAppPageValue, CachedPagesValue, IncrementalCacheValue } from "../shims/cache-handler.js";
|
|
3
1
|
import { OnRequestErrorContext } from "./instrumentation.js";
|
|
2
|
+
import { RenderObservation } from "./cache-proof.js";
|
|
4
3
|
import { normalizeMountedSlotsHeader } from "./app-mounted-slots-header.js";
|
|
4
|
+
import { CacheHandlerValue, CachedAppPageValue, CachedPagesValue, IncrementalCacheValue } from "../shims/cache-handler.js";
|
|
5
5
|
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
6
6
|
|
|
7
7
|
//#region src/server/isr-cache.d.ts
|
|
@@ -102,13 +102,21 @@ declare function buildAppPageCacheValue(html: string, rscData?: ArrayBuffer, sta
|
|
|
102
102
|
* Long pathnames are hashed to stay within KV key-length limits (512 bytes).
|
|
103
103
|
*/
|
|
104
104
|
declare function isrCacheKey(router: string, pathname: string, buildId?: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Compute an App Router ISR key for one cache artifact.
|
|
107
|
+
*
|
|
108
|
+
* App pages store HTML, RSC payloads, and route-handler responses separately.
|
|
109
|
+
* The suffix mirrors Next.js's separate on-disk app artifacts while keeping the
|
|
110
|
+
* Cloudflare KV key under its 512-byte limit for long pathnames.
|
|
111
|
+
*/
|
|
112
|
+
declare function appIsrCacheKey(pathname: string, suffix: string, buildId?: string | undefined): string;
|
|
105
113
|
declare function appIsrHtmlKey(pathname: string): string;
|
|
106
114
|
/**
|
|
107
115
|
* Build the ISR cache key for an RSC payload.
|
|
108
116
|
*
|
|
109
117
|
* Variants are sequenced in order: `source:<hash>` (intercepted source context,
|
|
110
118
|
* only when an interception context is present), `slots:<hash>` (mounted parallel
|
|
111
|
-
* route slots), and optionally `<render-mode-variant>` (
|
|
119
|
+
* route slots), and optionally `<render-mode-variant>` (for example,
|
|
112
120
|
* `prefetch-loading-shell`). Existing cached entries under the old format will
|
|
113
121
|
* become unreachable after deployment. This is acceptable because ISR entries
|
|
114
122
|
* have TTLs and will be regenerated on the next request.
|
|
@@ -125,4 +133,4 @@ declare function setRevalidateDuration(key: string, seconds: number): void;
|
|
|
125
133
|
*/
|
|
126
134
|
declare function getRevalidateDuration(key: string): number | undefined;
|
|
127
135
|
//#endregion
|
|
128
|
-
export { ISRCacheEntry, PRERENDER_REVALIDATE_HEADER, PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER, appIsrHtmlKey, appIsrRouteKey, appIsrRscKey, buildAppPageCacheValue, buildPagesCacheValue, getRevalidateDuration, getRevalidateSecret, isOnDemandRevalidateRequest, isRevalidateSecret, isrCacheKey, isrGet, isrSet, isrSetPrerenderedAppPage, normalizeMountedSlotsHeader, setRevalidateDuration, triggerBackgroundRegeneration };
|
|
136
|
+
export { ISRCacheEntry, PRERENDER_REVALIDATE_HEADER, PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER, appIsrCacheKey, appIsrHtmlKey, appIsrRouteKey, appIsrRscKey, buildAppPageCacheValue, buildPagesCacheValue, getRevalidateDuration, getRevalidateSecret, isOnDemandRevalidateRequest, isRevalidateSecret, isrCacheKey, isrGet, isrSet, isrSetPrerenderedAppPage, normalizeMountedSlotsHeader, setRevalidateDuration, triggerBackgroundRegeneration };
|
package/dist/server/isr-cache.js
CHANGED
|
@@ -242,7 +242,7 @@ function normalizeInterceptionContextForCacheKey(interceptionContext) {
|
|
|
242
242
|
*
|
|
243
243
|
* Variants are sequenced in order: `source:<hash>` (intercepted source context,
|
|
244
244
|
* only when an interception context is present), `slots:<hash>` (mounted parallel
|
|
245
|
-
* route slots), and optionally `<render-mode-variant>` (
|
|
245
|
+
* route slots), and optionally `<render-mode-variant>` (for example,
|
|
246
246
|
* `prefetch-loading-shell`). Existing cached entries under the old format will
|
|
247
247
|
* become unreachable after deployment. This is acceptable because ISR entries
|
|
248
248
|
* have TTLs and will be regenerated on the next request.
|
|
@@ -283,4 +283,4 @@ function getRevalidateDuration(key) {
|
|
|
283
283
|
return revalidateDurations.get(key);
|
|
284
284
|
}
|
|
285
285
|
//#endregion
|
|
286
|
-
export { PRERENDER_REVALIDATE_HEADER, PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER, appIsrHtmlKey, appIsrRouteKey, appIsrRscKey, buildAppPageCacheValue, buildPagesCacheValue, getRevalidateDuration, getRevalidateSecret, isOnDemandRevalidateRequest, isRevalidateSecret, isrCacheKey, isrGet, isrSet, isrSetPrerenderedAppPage, normalizeMountedSlotsHeader, setRevalidateDuration, triggerBackgroundRegeneration };
|
|
286
|
+
export { PRERENDER_REVALIDATE_HEADER, PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER, appIsrCacheKey, appIsrHtmlKey, appIsrRouteKey, appIsrRscKey, buildAppPageCacheValue, buildPagesCacheValue, getRevalidateDuration, getRevalidateSecret, isOnDemandRevalidateRequest, isRevalidateSecret, isrCacheKey, isrGet, isrSet, isrSetPrerenderedAppPage, normalizeMountedSlotsHeader, setRevalidateDuration, triggerBackgroundRegeneration };
|
|
@@ -179,7 +179,7 @@ function buildPagesCacheResponse(html, cacheState, fontLinkHeader, revalidateSec
|
|
|
179
179
|
cacheControlMeta: cacheControl
|
|
180
180
|
});
|
|
181
181
|
const headers = new Headers({
|
|
182
|
-
"Content-Type": "text/html",
|
|
182
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
183
183
|
...buildCacheStateHeaders(cacheState)
|
|
184
184
|
});
|
|
185
185
|
applyCdnResponseHeaders(headers, { cacheControl: cacheControlHeader });
|
|
@@ -167,7 +167,7 @@ function applyGsspHeaders(headers, gsspRes, statusCode) {
|
|
|
167
167
|
}
|
|
168
168
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") headers.set(key, String(value));
|
|
169
169
|
}
|
|
170
|
-
headers.set("Content-Type", "text/html");
|
|
170
|
+
headers.set("Content-Type", "text/html; charset=utf-8");
|
|
171
171
|
return statusCode ?? gsspRes.statusCode;
|
|
172
172
|
}
|
|
173
173
|
async function renderPagesPageResponse(options) {
|
|
@@ -232,7 +232,7 @@ async function renderPagesPageResponse(options) {
|
|
|
232
232
|
const markerIndex = shellHtml.indexOf(bodyMarker);
|
|
233
233
|
const shellPrefix = shellHtml.slice(0, markerIndex);
|
|
234
234
|
const shellSuffix = shellHtml.slice(markerIndex + 25);
|
|
235
|
-
const responseHeaders = new Headers({ "Content-Type": "text/html" });
|
|
235
|
+
const responseHeaders = new Headers({ "Content-Type": "text/html; charset=utf-8" });
|
|
236
236
|
const finalStatus = applyGsspHeaders(responseHeaders, options.gsspRes ?? options.documentReqRes?.res ?? null, options.statusCode);
|
|
237
237
|
let responseBodyStream = bodyStream;
|
|
238
238
|
if (!options.scriptNonce && options.isrRevalidateSeconds !== null && options.isrRevalidateSeconds > 0) {
|
|
@@ -320,7 +320,7 @@ async function runPagesRequest(request, deps) {
|
|
|
320
320
|
return {
|
|
321
321
|
type: "response",
|
|
322
322
|
response: merged,
|
|
323
|
-
defaultContentType: "text/html"
|
|
323
|
+
defaultContentType: "text/html; charset=utf-8"
|
|
324
324
|
};
|
|
325
325
|
}
|
|
326
326
|
let devPageMatch = isOutsideBasePathUnclaimed() ? null : resolvedPathnameChanged ? deps.matchPageRoute ? deps.matchPageRoute(resolvedPathname, request) : null : pageMatch;
|
|
@@ -15,6 +15,10 @@ type PrerenderManifest = {
|
|
|
15
15
|
routes?: PrerenderManifestRoute[];
|
|
16
16
|
pregeneratedConcretePaths?: Array<[string, string[]]>;
|
|
17
17
|
};
|
|
18
|
+
type PrerenderedPathSelectionOptions = {
|
|
19
|
+
includeFallbackShells?: boolean;
|
|
20
|
+
includeErrorDocuments?: boolean;
|
|
21
|
+
};
|
|
18
22
|
declare function readPrerenderManifest(manifestPath: string): PrerenderManifest | null;
|
|
19
23
|
declare function getRenderedAppRoutes(routes: PrerenderManifestRoute[]): PrerenderManifestRoute[];
|
|
20
24
|
/**
|
|
@@ -31,5 +35,15 @@ declare function isFallbackShellArtifactPath(pathname: string, route?: Prerender
|
|
|
31
35
|
* rendered App routes or all routes are fallback-shell artifacts.
|
|
32
36
|
*/
|
|
33
37
|
declare function buildPregeneratedConcretePathTable(manifest: PrerenderManifest): Array<[string, string[]]>;
|
|
38
|
+
/**
|
|
39
|
+
* Select concrete URL paths that were rendered by the prerender engine.
|
|
40
|
+
*
|
|
41
|
+
* This intentionally includes both App Router and Pages Router entries because
|
|
42
|
+
* deploy-time cache warmup should exercise the same URLs the prerender phase
|
|
43
|
+
* proved are statically renderable. PPR fallback-shell placeholder artifacts
|
|
44
|
+
* and known error documents are excluded by default so warmup does not request
|
|
45
|
+
* synthetic bracket paths or treat a healthy 404 response as a failed warmup.
|
|
46
|
+
*/
|
|
47
|
+
declare function getPrerenderedConcretePaths(manifest: PrerenderManifest, options?: PrerenderedPathSelectionOptions): string[];
|
|
34
48
|
//#endregion
|
|
35
|
-
export { PrerenderManifest, buildPregeneratedConcretePathTable, getRenderedAppRoutes, isFallbackShellArtifactPath, readPrerenderManifest };
|
|
49
|
+
export { PrerenderManifest, PrerenderManifestRoute, PrerenderedPathSelectionOptions, buildPregeneratedConcretePathTable, getPrerenderedConcretePaths, getRenderedAppRoutes, isFallbackShellArtifactPath, readPrerenderManifest };
|
|
@@ -22,6 +22,9 @@ function groupRoutesByPattern(routes) {
|
|
|
22
22
|
}
|
|
23
23
|
return byPattern;
|
|
24
24
|
}
|
|
25
|
+
function isErrorDocumentRoute(pathname, route) {
|
|
26
|
+
return pathname === "/404" || pathname === "/500" || pathname === "/_error" || route.route === "/404" || route.route === "/500" || route.route === "/_error";
|
|
27
|
+
}
|
|
25
28
|
/**
|
|
26
29
|
* Returns true when `pathname` contains bracket-delimited route params,
|
|
27
30
|
* indicating it is a fallback-shell placeholder (e.g. `/en/blog/[slug]`)
|
|
@@ -50,5 +53,30 @@ function buildPregeneratedConcretePathTable(manifest) {
|
|
|
50
53
|
});
|
|
51
54
|
return Array.from(groupRoutesByPattern(concreteRoutes).entries());
|
|
52
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Select concrete URL paths that were rendered by the prerender engine.
|
|
58
|
+
*
|
|
59
|
+
* This intentionally includes both App Router and Pages Router entries because
|
|
60
|
+
* deploy-time cache warmup should exercise the same URLs the prerender phase
|
|
61
|
+
* proved are statically renderable. PPR fallback-shell placeholder artifacts
|
|
62
|
+
* and known error documents are excluded by default so warmup does not request
|
|
63
|
+
* synthetic bracket paths or treat a healthy 404 response as a failed warmup.
|
|
64
|
+
*/
|
|
65
|
+
function getPrerenderedConcretePaths(manifest, options) {
|
|
66
|
+
const routes = manifest.routes;
|
|
67
|
+
if (!routes?.length) return [];
|
|
68
|
+
const paths = [];
|
|
69
|
+
const seen = /* @__PURE__ */ new Set();
|
|
70
|
+
for (const route of routes) {
|
|
71
|
+
if (route.status !== "rendered") continue;
|
|
72
|
+
const pathname = route.path ?? route.route;
|
|
73
|
+
if (!options?.includeFallbackShells && isFallbackShellArtifactPath(pathname, route)) continue;
|
|
74
|
+
if (!options?.includeErrorDocuments && isErrorDocumentRoute(pathname, route)) continue;
|
|
75
|
+
if (seen.has(pathname)) continue;
|
|
76
|
+
seen.add(pathname);
|
|
77
|
+
paths.push(pathname);
|
|
78
|
+
}
|
|
79
|
+
return paths;
|
|
80
|
+
}
|
|
53
81
|
//#endregion
|
|
54
|
-
export { buildPregeneratedConcretePathTable, getRenderedAppRoutes, isFallbackShellArtifactPath, readPrerenderManifest };
|
|
82
|
+
export { buildPregeneratedConcretePathTable, getPrerenderedConcretePaths, getRenderedAppRoutes, isFallbackShellArtifactPath, readPrerenderManifest };
|
|
@@ -10,10 +10,9 @@ import { IncomingMessage, ServerResponse } from "node:http";
|
|
|
10
10
|
*
|
|
11
11
|
* The first import of a given path uses the plain file:// URL with NO query
|
|
12
12
|
* string. This is load-bearing: code-split builds emit lazy chunks that
|
|
13
|
-
* import the entry back by bare specifier (default Vite builds
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* entry chunk, which the chunks then import as e.g. "../../index.js").
|
|
13
|
+
* import the entry back by bare specifier (default Vite/Rolldown builds hoist
|
|
14
|
+
* modules shared between the entry's static graph and lazy route chunks into
|
|
15
|
+
* the entry chunk, which the chunks then import as e.g. "../../index.js").
|
|
17
16
|
* Node keys its ESM cache on the full URL including the query string, so if
|
|
18
17
|
* the server imported the entry as `index.js?t=<mtime>`, a chunk's bare
|
|
19
18
|
* back-import would evaluate the entire server bundle a second time and
|
|
@@ -48,7 +47,9 @@ declare function readNodeStream(req: IncomingMessage): ReadableStream<Uint8Array
|
|
|
48
47
|
type ProdServerOptions = {
|
|
49
48
|
/** Port to listen on */port?: number; /** Host to bind to */
|
|
50
49
|
host?: string; /** Path to the build output directory */
|
|
51
|
-
outDir?: string; /**
|
|
50
|
+
outDir?: string; /** Explicit App Router RSC entry path. Defaults to `<outDir>/server/index.js`. */
|
|
51
|
+
rscEntryPath?: string; /** Explicit Pages Router server entry path. Defaults to `<outDir>/server/entry.js`. */
|
|
52
|
+
serverEntryPath?: string; /** Disable compression (default: false) */
|
|
52
53
|
noCompression?: boolean;
|
|
53
54
|
/**
|
|
54
55
|
* Narrow startup context for callers that need a more precise log line.
|
|
@@ -74,10 +74,9 @@ function resolveCanonicalServerEntry(entryPath) {
|
|
|
74
74
|
*
|
|
75
75
|
* The first import of a given path uses the plain file:// URL with NO query
|
|
76
76
|
* string. This is load-bearing: code-split builds emit lazy chunks that
|
|
77
|
-
* import the entry back by bare specifier (default Vite builds
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* entry chunk, which the chunks then import as e.g. "../../index.js").
|
|
77
|
+
* import the entry back by bare specifier (default Vite/Rolldown builds hoist
|
|
78
|
+
* modules shared between the entry's static graph and lazy route chunks into
|
|
79
|
+
* the entry chunk, which the chunks then import as e.g. "../../index.js").
|
|
81
80
|
* Node keys its ESM cache on the full URL including the query string, so if
|
|
82
81
|
* the server imported the entry as `index.js?t=<mtime>`, a chunk's bare
|
|
83
82
|
* back-import would evaluate the entire server bundle a second time and
|
|
@@ -633,12 +632,12 @@ async function sendWebResponse(webResponse, req, res, compress) {
|
|
|
633
632
|
*/
|
|
634
633
|
async function startProdServer(options = {}) {
|
|
635
634
|
installSocketErrorBackstop();
|
|
636
|
-
const { port = process.env.PORT ? parseInt(process.env.PORT) : 3e3, host = "0.0.0.0", outDir = path.resolve("dist"), noCompression = false, purpose, silent = false } = options;
|
|
635
|
+
const { port = process.env.PORT ? parseInt(process.env.PORT) : 3e3, host = "0.0.0.0", outDir = path.resolve("dist"), rscEntryPath: explicitRscEntryPath, serverEntryPath: explicitServerEntryPath, noCompression = false, purpose, silent = false } = options;
|
|
637
636
|
const compress = !noCompression;
|
|
638
637
|
const resolvedOutDir = path.resolve(outDir);
|
|
639
638
|
const clientDir = path.join(resolvedOutDir, "client");
|
|
640
|
-
const rscEntryPath = path.join(resolvedOutDir, "server", "index.js");
|
|
641
|
-
const serverEntryPath = path.join(resolvedOutDir, "server", "entry.js");
|
|
639
|
+
const rscEntryPath = explicitRscEntryPath ? path.resolve(explicitRscEntryPath) : path.join(resolvedOutDir, "server", "index.js");
|
|
640
|
+
const serverEntryPath = explicitServerEntryPath ? path.resolve(explicitServerEntryPath) : path.join(resolvedOutDir, "server", "entry.js");
|
|
642
641
|
const isAppRouter = fs.existsSync(rscEntryPath);
|
|
643
642
|
if (!isAppRouter && !fs.existsSync(serverEntryPath)) {
|
|
644
643
|
console.error(`[vinext] No build output found in ${outDir}`);
|
|
@@ -21,7 +21,7 @@ const CONTENT_TYPES = {
|
|
|
21
21
|
".js": "application/javascript",
|
|
22
22
|
".mjs": "application/javascript",
|
|
23
23
|
".css": "text/css",
|
|
24
|
-
".html": "text/html",
|
|
24
|
+
".html": "text/html; charset=utf-8",
|
|
25
25
|
".json": "application/json",
|
|
26
26
|
".txt": "text/plain; charset=utf-8",
|
|
27
27
|
".png": "image/png",
|
package/dist/shims/cache.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, ActionRevalidationKind, CacheLifeConfig, CacheState, UnstableCacheObservation, UnstableCacheRevalidationMode, _consumeRequestScopedCacheLife, _initRequestScopedCacheState, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, getRegisteredCacheContext, markActionRevalidation, recordUnstableCacheObservation, shouldServeStaleUnstableCacheEntry } from "./cache-request-state.js";
|
|
2
|
-
import { CacheControlMetadata, CacheHandler, CacheHandlerContext, CacheHandlerValue, CachedAppPageValue, CachedFetchValue, CachedImageValue, CachedPagesValue, CachedRedirectValue, CachedRouteValue, IncrementalCacheValue, MemoryCacheHandler, NoOpCacheHandler, configureMemoryCacheHandler, getCacheHandler, getDataCacheHandler, setCacheHandler, setDataCacheHandler } from "./cache-handler.js";
|
|
3
2
|
import { ExecutionContextLike, getRequestExecutionContext, runWithExecutionContext } from "./request-context.js";
|
|
3
|
+
import { CacheControlMetadata, CacheHandler, CacheHandlerContext, CacheHandlerValue, CachedAppPageValue, CachedFetchValue, CachedImageValue, CachedPagesValue, CachedRedirectValue, CachedRouteValue, IncrementalCacheValue, MemoryCacheHandler, NoOpCacheHandler, configureMemoryCacheHandler, getCacheHandler, getDataCacheHandler, setCacheHandler, setDataCacheHandler } from "./cache-handler.js";
|
|
4
4
|
|
|
5
5
|
//#region src/shims/cache.d.ts
|
|
6
6
|
/**
|
|
@@ -112,13 +112,8 @@ declare class DefaultCdnCacheAdapter implements CdnCacheAdapter {
|
|
|
112
112
|
*/
|
|
113
113
|
declare function setCdnCacheAdapter(adapter: CdnCacheAdapter): void;
|
|
114
114
|
/**
|
|
115
|
-
* Get the active CDN cache adapter.
|
|
116
|
-
*
|
|
117
|
-
* {@link DefaultCdnCacheAdapter}.
|
|
118
|
-
*
|
|
119
|
-
* Auto-detection of the Cloudflare Workers Cache (`ctx.cache`) only runs when
|
|
120
|
-
* `VINEXT_CDN_CACHE_AUTO_DETECT === "1"`; otherwise the default adapter is used
|
|
121
|
-
* unless an adapter was set explicitly.
|
|
115
|
+
* Get the active CDN cache adapter. An explicitly configured adapter wins;
|
|
116
|
+
* otherwise the origin-managed {@link DefaultCdnCacheAdapter} is used.
|
|
122
117
|
*/
|
|
123
118
|
declare function getCdnCacheAdapter(): CdnCacheAdapter;
|
|
124
119
|
//#endregion
|