vinext 0.1.4 → 0.1.6
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 +2 -2
- package/dist/build/css-url-assets.d.ts +1 -1
- package/dist/build/css-url-assets.js +9 -7
- package/dist/build/google-fonts/find-font-files-in-css.d.ts +16 -0
- package/dist/build/google-fonts/find-font-files-in-css.js +28 -0
- package/dist/build/prerender.js +2 -1
- package/dist/build/report.d.ts +1 -2
- package/dist/build/report.js +2 -11
- package/dist/build/run-prerender.js +1 -1
- package/dist/cache/cache-adapters-virtual.js +1 -1
- package/dist/check.js +3 -3
- package/dist/client/pages-router-link-navigation.d.ts +10 -0
- package/dist/client/pages-router-link-navigation.js +3 -3
- package/dist/cloudflare/src/cache/kv-data-adapter.runtime.d.ts +1 -1
- package/dist/deploy.js +3 -3
- package/dist/entries/app-rsc-entry.js +25 -20
- package/dist/entries/app-rsc-manifest.js +76 -46
- package/dist/entries/pages-server-entry.js +3 -1
- package/dist/index.js +254 -198
- package/dist/init.d.ts +5 -4
- package/dist/init.js +27 -8
- package/dist/plugins/css-data-url.js +30 -26
- package/dist/plugins/extensionless-dynamic-import.js +27 -24
- package/dist/plugins/fonts.js +3 -1
- package/dist/plugins/import-meta-url.js +21 -15
- package/dist/plugins/instrumentation-client.js +1 -1
- package/dist/plugins/middleware-export-validation.d.ts +5 -0
- package/dist/plugins/middleware-export-validation.js +36 -0
- package/dist/plugins/middleware-server-only.js +7 -6
- package/dist/plugins/og-asset-ownership.d.ts +27 -0
- package/dist/plugins/og-asset-ownership.js +285 -0
- package/dist/plugins/og-assets.js +66 -46
- package/dist/plugins/optimize-imports.js +9 -3
- package/dist/plugins/remove-console.d.ts +7 -1
- package/dist/plugins/remove-console.js +4 -1
- package/dist/plugins/require-context.js +21 -20
- package/dist/plugins/strip-server-exports.d.ts +7 -1
- package/dist/plugins/strip-server-exports.js +4 -1
- package/dist/server/accept-encoding.d.ts +29 -0
- package/dist/server/accept-encoding.js +95 -0
- package/dist/server/app-bfcache-identity.d.ts +26 -0
- package/dist/server/app-bfcache-identity.js +127 -0
- package/dist/server/app-browser-entry.js +17 -11
- package/dist/server/app-browser-rsc-redirect.d.ts +2 -1
- package/dist/server/app-browser-rsc-redirect.js +8 -1
- package/dist/server/app-browser-state.d.ts +2 -21
- package/dist/server/app-browser-state.js +4 -128
- package/dist/server/app-browser-stream.js +1 -1
- package/dist/server/app-browser-visible-commit.js +3 -2
- package/dist/server/app-fallback-renderer.d.ts +1 -1
- package/dist/server/app-layout-param-observation.d.ts +1 -1
- package/dist/server/app-layout-param-observation.js +1 -1
- package/dist/server/app-middleware.d.ts +1 -0
- package/dist/server/app-middleware.js +3 -1
- package/dist/server/app-page-boundary-render.d.ts +1 -1
- package/dist/server/app-page-boundary.js +1 -1
- package/dist/server/app-page-cache-finalizer.d.ts +62 -0
- package/dist/server/app-page-cache-finalizer.js +122 -0
- package/dist/server/app-page-cache-render.d.ts +2 -2
- package/dist/server/app-page-cache-render.js +1 -1
- package/dist/server/app-page-cache.d.ts +2 -53
- package/dist/server/app-page-cache.js +5 -131
- package/dist/server/app-page-dispatch.d.ts +4 -4
- package/dist/server/app-page-dispatch.js +10 -8
- package/dist/server/app-page-head.js +2 -2
- package/dist/server/app-page-probe.js +3 -2
- package/dist/server/app-page-render-observation.js +2 -2
- package/dist/server/app-page-render.d.ts +3 -3
- package/dist/server/app-page-render.js +3 -2
- package/dist/server/app-page-request.d.ts +7 -0
- package/dist/server/app-page-request.js +19 -1
- package/dist/server/app-page-stream.d.ts +2 -9
- package/dist/server/app-page-stream.js +1 -35
- package/dist/server/app-prerender-endpoints.d.ts +3 -3
- package/dist/server/app-prerender-endpoints.js +3 -4
- package/dist/server/app-request-context.d.ts +1 -2
- package/dist/server/app-request-context.js +2 -1
- package/dist/server/app-route-handler-dispatch.js +3 -2
- 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-route-handler-response.d.ts +1 -1
- package/dist/server/app-route-module-loader.d.ts +62 -14
- package/dist/server/app-route-module-loader.js +61 -10
- package/dist/server/app-router-entry.js +2 -1
- package/dist/server/app-rsc-handler.d.ts +7 -6
- package/dist/server/app-rsc-handler.js +51 -40
- package/dist/server/app-rsc-response-finalizer.js +1 -1
- package/dist/server/app-rsc-route-matching.d.ts +9 -0
- package/dist/server/app-rsc-route-matching.js +13 -0
- package/dist/server/app-server-action-execution.d.ts +1 -1
- package/dist/server/app-server-action-execution.js +5 -4
- package/dist/server/app-ssr-entry.d.ts +1 -1
- package/dist/server/app-ssr-entry.js +9 -7
- package/dist/server/app-ssr-router-instance.d.ts +6 -0
- package/dist/server/app-ssr-router-instance.js +24 -0
- package/dist/server/app-ssr-stream.js +1 -1
- package/dist/server/artifact-compatibility.js +1 -1
- package/dist/server/client-reuse-manifest.js +1 -1
- package/dist/server/defer-until-stream-consumed.d.ts +7 -0
- package/dist/server/defer-until-stream-consumed.js +34 -0
- package/dist/server/dev-server.js +1 -1
- package/dist/server/headers.d.ts +5 -1
- package/dist/server/headers.js +5 -1
- package/dist/server/instrumentation.js +1 -1
- package/dist/server/isr-cache.d.ts +1 -1
- package/dist/server/isr-cache.js +1 -1
- package/dist/server/isr-decision.d.ts +1 -1
- package/dist/server/metadata-route-response.d.ts +3 -3
- package/dist/server/middleware-matcher.js +8 -6
- package/dist/server/middleware-runtime.d.ts +2 -1
- package/dist/server/middleware-runtime.js +21 -10
- package/dist/server/middleware.d.ts +2 -2
- package/dist/server/middleware.js +26 -11
- package/dist/server/open-redirect.d.ts +12 -0
- package/dist/server/open-redirect.js +21 -0
- package/dist/server/pages-page-data.d.ts +1 -1
- package/dist/server/pages-page-response.d.ts +1 -1
- package/dist/server/pages-page-response.js +2 -2
- package/dist/server/pages-request-pipeline.d.ts +3 -1
- package/dist/server/pages-request-pipeline.js +4 -2
- package/dist/server/prod-server.d.ts +1 -1
- package/dist/server/prod-server.js +87 -73
- package/dist/server/request-pipeline.d.ts +1 -24
- package/dist/server/request-pipeline.js +1 -33
- package/dist/server/seed-cache.d.ts +1 -1
- package/dist/shims/cache-handler.d.ts +106 -0
- package/dist/shims/cache-handler.js +176 -0
- package/dist/shims/cache-request-state.d.ts +47 -0
- package/dist/shims/cache-request-state.js +126 -0
- package/dist/shims/cache-runtime.d.ts +2 -2
- package/dist/shims/cache-runtime.js +3 -14
- package/dist/shims/cache.d.ts +3 -231
- package/dist/shims/cache.js +17 -383
- package/dist/shims/cdn-cache.d.ts +1 -1
- package/dist/shims/cdn-cache.js +1 -1
- package/dist/shims/error-boundary-navigation.d.ts +7 -0
- package/dist/shims/error-boundary-navigation.js +44 -0
- package/dist/shims/error-boundary.js +10 -8
- package/dist/shims/error.js +2 -1
- package/dist/shims/fetch-cache.js +1 -1
- package/dist/shims/font-google-base.d.ts +1 -0
- package/dist/shims/font-google-base.js +6 -21
- package/dist/shims/form.js +1 -1
- package/dist/shims/image.js +67 -9
- package/dist/shims/internal/app-page-props-cache-key.d.ts +5 -0
- package/dist/shims/internal/app-page-props-cache-key.js +16 -0
- package/dist/shims/internal/interpolate-as.d.ts +25 -0
- package/dist/shims/internal/interpolate-as.js +196 -0
- package/dist/shims/internal/navigation-untracked.js +2 -1
- package/dist/shims/layout-segment-context.d.ts +1 -1
- package/dist/shims/layout-segment-context.js +2 -1
- package/dist/shims/link.js +26 -3
- package/dist/shims/navigation-context-state.d.ts +40 -0
- package/dist/shims/navigation-context-state.js +116 -0
- package/dist/shims/navigation-errors.d.ts +55 -0
- package/dist/shims/navigation-errors.js +110 -0
- package/dist/shims/navigation-server.d.ts +3 -0
- package/dist/shims/navigation-server.js +3 -0
- package/dist/shims/navigation-state.d.ts +1 -2
- package/dist/shims/navigation-state.js +2 -1
- package/dist/shims/navigation.d.ts +3 -291
- package/dist/shims/navigation.js +13 -444
- package/dist/shims/navigation.react-server.d.ts +2 -2
- package/dist/shims/navigation.react-server.js +4 -2
- package/dist/shims/request-state-types.d.ts +3 -3
- package/dist/shims/router.d.ts +1 -3
- package/dist/shims/router.js +62 -18
- package/dist/shims/script.js +1 -1
- package/dist/shims/slot.js +3 -1
- package/dist/shims/unified-request-context.d.ts +2 -2
- package/dist/typegen.js +2 -10
- package/dist/utils/project.d.ts +7 -1
- package/dist/utils/project.js +16 -2
- package/dist/utils/virtual-module.d.ts +5 -0
- package/dist/utils/virtual-module.js +0 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -404,7 +404,7 @@ These are deployed to Cloudflare Workers and updated on every push to `main`:
|
|
|
404
404
|
| App Router (minimal) | Minimal App Router on Workers | [app-router-cloudflare.vinext.workers.dev](https://app-router-cloudflare.vinext.workers.dev) |
|
|
405
405
|
| Pages Router (minimal) | Minimal Pages Router on Workers | [pages-router-cloudflare.vinext.workers.dev](https://pages-router-cloudflare.vinext.workers.dev) |
|
|
406
406
|
| RealWorld API | REST API routes example | [realworld-api-rest.vinext.workers.dev](https://realworld-api-rest.vinext.workers.dev) |
|
|
407
|
-
| Benchmarks Dashboard | Build performance tracking over time (D1-backed) | [
|
|
407
|
+
| Benchmarks Dashboard | Build performance tracking over time (D1-backed) | [vinext-web.vinext.workers.dev/benchmarks](https://vinext-web.vinext.workers.dev/benchmarks) |
|
|
408
408
|
| App Router + Nitro | App Router deployed via Nitro (multi-platform) | [examples/app-router-nitro](examples/app-router-nitro) |
|
|
409
409
|
|
|
410
410
|
## API coverage
|
|
@@ -614,7 +614,7 @@ We measure three things:
|
|
|
614
614
|
- **Client bundle size** — gzipped output of each build.
|
|
615
615
|
- **Dev server cold start** — 10 runs, randomized execution order. Vite's dependency optimizer cache is cleared before each run.
|
|
616
616
|
|
|
617
|
-
Benchmarks run on GitHub CI runners (2-core Ubuntu) on every merge to `main`. See the launch numbers in the [announcement blog post](https://blog.cloudflare.com/vinext/) and the latest results at **[
|
|
617
|
+
Benchmarks run on GitHub CI runners (2-core Ubuntu) on every merge to `main`. See the launch numbers in the [announcement blog post](https://blog.cloudflare.com/vinext/) and the latest results at **[vinext-web.vinext.workers.dev/benchmarks](https://vinext-web.vinext.workers.dev/benchmarks)**.
|
|
618
618
|
|
|
619
619
|
<details>
|
|
620
620
|
<summary>Why the bundle size difference?</summary>
|
|
@@ -10,7 +10,7 @@ type EmitRestoredCssUrlAsset = (asset: {
|
|
|
10
10
|
/**
|
|
11
11
|
* Append the private provenance marker to each relative asset `url()` in a CSS
|
|
12
12
|
* source. Idempotent and side-effect free (only adds a query param), so it is
|
|
13
|
-
* safe to run on every
|
|
13
|
+
* safe to run on every build-environment stylesheet, vendored CSS included.
|
|
14
14
|
*/
|
|
15
15
|
declare function markCssUrlAssetReferences(code: string, id: string): string | null;
|
|
16
16
|
/**
|
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
* vitejs/vite#8632). The one native escape hatch is `this.emitFile({ fileName })`:
|
|
13
13
|
* assets emitted with an explicit `fileName` are *never* deduped. So we:
|
|
14
14
|
*
|
|
15
|
-
* 1. mark — during
|
|
16
|
-
* with a private `?vinext_css_url_asset=<source-basename>` query.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
15
|
+
* 1. mark — during every production CSS transform, tag each relative asset
|
|
16
|
+
* `url()` with a private `?vinext_css_url_asset=<source-basename>` query.
|
|
17
|
+
* Using identical transformed CSS in server and client environments is
|
|
18
|
+
* required because the default CSS Modules scoped name hashes the full CSS
|
|
19
|
+
* text. The marker is also the only durable carrier of per-reference
|
|
20
|
+
* provenance: once Rolldown dedupes, the emitted bundle cannot tell which
|
|
21
|
+
* `url()` came from which source, and bundle metadata records the source
|
|
22
|
+
* set but not the mapping per reference.
|
|
21
23
|
*
|
|
22
24
|
* 2. restore — at `generateBundle`, read each marked reference's source
|
|
23
25
|
* basename back out. When it differs from the deduped output's basename,
|
|
@@ -109,7 +111,7 @@ function rewriteCssUrls(code, replace) {
|
|
|
109
111
|
/**
|
|
110
112
|
* Append the private provenance marker to each relative asset `url()` in a CSS
|
|
111
113
|
* source. Idempotent and side-effect free (only adds a query param), so it is
|
|
112
|
-
* safe to run on every
|
|
114
|
+
* safe to run on every build-environment stylesheet, vendored CSS included.
|
|
113
115
|
*/
|
|
114
116
|
function markCssUrlAssetReferences(code, id) {
|
|
115
117
|
if (!isCssRequest(id) || !code.includes("url(")) return null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/build/google-fonts/find-font-files-in-css.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Find all font files in the CSS response and determine which files should be preloaded.
|
|
4
|
+
* In Google Fonts responses, the @font-face's subset is above it in a comment.
|
|
5
|
+
* Walk through the CSS from top to bottom, keeping track of the current subset.
|
|
6
|
+
*
|
|
7
|
+
* Ported from Next.js:
|
|
8
|
+
* packages/font/src/google/find-font-files-in-css.ts
|
|
9
|
+
* https://github.com/vercel/next.js/blob/canary/packages/font/src/google/find-font-files-in-css.ts
|
|
10
|
+
*/
|
|
11
|
+
declare function findFontFilesInCss(css: string, subsetsToPreload?: string[]): {
|
|
12
|
+
googleFontFileUrl: string;
|
|
13
|
+
preloadFontFile: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
//#endregion
|
|
16
|
+
export { findFontFilesInCss };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/build/google-fonts/find-font-files-in-css.ts
|
|
2
|
+
/**
|
|
3
|
+
* Find all font files in the CSS response and determine which files should be preloaded.
|
|
4
|
+
* In Google Fonts responses, the @font-face's subset is above it in a comment.
|
|
5
|
+
* Walk through the CSS from top to bottom, keeping track of the current subset.
|
|
6
|
+
*
|
|
7
|
+
* Ported from Next.js:
|
|
8
|
+
* packages/font/src/google/find-font-files-in-css.ts
|
|
9
|
+
* https://github.com/vercel/next.js/blob/canary/packages/font/src/google/find-font-files-in-css.ts
|
|
10
|
+
*/
|
|
11
|
+
function findFontFilesInCss(css, subsetsToPreload) {
|
|
12
|
+
const fontFiles = [];
|
|
13
|
+
let currentSubset = "";
|
|
14
|
+
for (const line of css.split("\n")) {
|
|
15
|
+
const newSubset = /\/\* (.+?) \*\//.exec(line)?.[1];
|
|
16
|
+
if (newSubset) currentSubset = newSubset;
|
|
17
|
+
else {
|
|
18
|
+
const googleFontFileUrl = /src: url\((.+?)\)/.exec(line)?.[1];
|
|
19
|
+
if (googleFontFileUrl && !fontFiles.some((foundFile) => foundFile.googleFontFileUrl === googleFontFileUrl)) fontFiles.push({
|
|
20
|
+
googleFontFileUrl,
|
|
21
|
+
preloadFontFile: !!subsetsToPreload?.includes(currentSubset)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return fontFiles;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { findFontFilesInCss };
|
package/dist/build/prerender.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createValidFileMatcher, findFileWithExtensions } from "../routing/file-matcher.js";
|
|
2
2
|
import { VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER } from "../server/headers.js";
|
|
3
3
|
import { normalizeStaticPathsEntry } from "../routing/route-pattern.js";
|
|
4
|
+
import { NoOpCacheHandler, getCacheHandler, setCacheHandler } from "../shims/cache-handler.js";
|
|
4
5
|
import { headersContextFromRequest, runWithHeadersContext } from "../shims/headers.js";
|
|
5
|
-
import {
|
|
6
|
+
import { _consumeRequestScopedCacheLife } from "../shims/cache-request-state.js";
|
|
6
7
|
import { classifyAppRoute, classifyPagesRoute, getAppRouteRenderEntryPath } from "./report.js";
|
|
7
8
|
import { BLOCKED_PAGES } from "../shims/constants.js";
|
|
8
9
|
import { concatUint8Arrays, decodeRscEmbeddedChunk } from "../server/app-rsc-embedded-chunks.js";
|
package/dist/build/report.d.ts
CHANGED
|
@@ -117,7 +117,6 @@ declare function buildReportRows(options: {
|
|
|
117
117
|
* ○ Static ◐ ISR ƒ Dynamic λ API
|
|
118
118
|
*/
|
|
119
119
|
declare function formatBuildReport(rows: RouteRow[], routerLabel?: string): string;
|
|
120
|
-
declare function findDir(root: string, ...candidates: string[]): string | null;
|
|
121
120
|
/**
|
|
122
121
|
* Scans the project at `root`, classifies all routes, and prints the
|
|
123
122
|
* Next.js-style build report to stdout.
|
|
@@ -130,4 +129,4 @@ declare function printBuildReport(options: {
|
|
|
130
129
|
prerenderResult?: PrerenderResult;
|
|
131
130
|
}): Promise<void>;
|
|
132
131
|
//#endregion
|
|
133
|
-
export { RouteRow, RouteType, buildReportRows, classifyAppRoute, classifyLayoutSegmentConfig, classifyPagesRoute, extractExportConstNumber, extractExportConstString, extractGetStaticPropsRevalidate,
|
|
132
|
+
export { RouteRow, RouteType, buildReportRows, classifyAppRoute, classifyLayoutSegmentConfig, classifyPagesRoute, extractExportConstNumber, extractExportConstString, extractGetStaticPropsRevalidate, formatBuildReport, getAppRouteRenderEntryPath, hasNamedExport, printBuildReport };
|
package/dist/build/report.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { findDir } from "../utils/project.js";
|
|
1
2
|
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
3
|
import { parseSync } from "vite";
|
|
4
4
|
//#region src/build/report.ts
|
|
5
5
|
/**
|
|
@@ -470,15 +470,6 @@ function formatBuildReport(rows, routerLabel = "app") {
|
|
|
470
470
|
}
|
|
471
471
|
return lines.join("\n");
|
|
472
472
|
}
|
|
473
|
-
function findDir(root, ...candidates) {
|
|
474
|
-
for (const candidate of candidates) {
|
|
475
|
-
const full = path.join(root, candidate);
|
|
476
|
-
try {
|
|
477
|
-
if (fs.statSync(full).isDirectory()) return full;
|
|
478
|
-
} catch {}
|
|
479
|
-
}
|
|
480
|
-
return null;
|
|
481
|
-
}
|
|
482
473
|
/**
|
|
483
474
|
* Scans the project at `root`, classifies all routes, and prints the
|
|
484
475
|
* Next.js-style build report to stdout.
|
|
@@ -510,4 +501,4 @@ async function printBuildReport(options) {
|
|
|
510
501
|
}
|
|
511
502
|
}
|
|
512
503
|
//#endregion
|
|
513
|
-
export { buildReportRows, classifyAppRoute, classifyLayoutSegmentConfig, classifyPagesRoute, extractExportConstNumber, extractExportConstString, extractGetStaticPropsRevalidate,
|
|
504
|
+
export { buildReportRows, classifyAppRoute, classifyLayoutSegmentConfig, classifyPagesRoute, extractExportConstNumber, extractExportConstString, extractGetStaticPropsRevalidate, formatBuildReport, getAppRouteRenderEntryPath, hasNamedExport, printBuildReport };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { findDir } from "../utils/project.js";
|
|
1
2
|
import { apiRouter, pagesRouter } from "../routing/pages-router.js";
|
|
2
3
|
import { appRouter } from "../routing/app-router.js";
|
|
3
4
|
import { scanMetadataFiles } from "../server/metadata-routes.js";
|
|
4
|
-
import { findDir } from "./report.js";
|
|
5
5
|
import { loadNextConfig, resolveNextConfig } from "../config/next-config.js";
|
|
6
6
|
import { readPrerenderSecret } from "./server-manifest.js";
|
|
7
7
|
import { startProdServer } from "../server/prod-server.js";
|
|
@@ -29,7 +29,7 @@ function generateCacheAdaptersModule(cache) {
|
|
|
29
29
|
const lines = ["// vinext: generated from the `cache` option in your vinext() plugin config."];
|
|
30
30
|
if (data?.adapter) {
|
|
31
31
|
lines.push(`import __vinextDataAdapterFactory from ${JSON.stringify(data.adapter)};`);
|
|
32
|
-
lines.push(`import { setDataCacheHandler } from "vinext/shims/cache";`);
|
|
32
|
+
lines.push(`import { setDataCacheHandler } from "vinext/shims/cache-handler";`);
|
|
33
33
|
}
|
|
34
34
|
if (cdn?.adapter) {
|
|
35
35
|
lines.push(`import __vinextCdnAdapterFactory from ${JSON.stringify(cdn.adapter)};`);
|
package/dist/check.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { detectPackageManager } from "./utils/project.js";
|
|
1
|
+
import { detectPackageManager, findDir } from "./utils/project.js";
|
|
2
2
|
import { normalizePathSeparators } from "./utils/path.js";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
@@ -780,8 +780,8 @@ function checkLibraries(root) {
|
|
|
780
780
|
*/
|
|
781
781
|
function checkConventions(root) {
|
|
782
782
|
const items = [];
|
|
783
|
-
const pagesDir =
|
|
784
|
-
const appDirPath =
|
|
783
|
+
const pagesDir = findDir(root, "pages", path.join("src", "pages"));
|
|
784
|
+
const appDirPath = findDir(root, "app", path.join("src", "app"));
|
|
785
785
|
const hasPages = pagesDir !== null;
|
|
786
786
|
const hasApp = appDirPath !== null;
|
|
787
787
|
const hasProxy = fs.existsSync(path.join(root, "proxy.ts")) || fs.existsSync(path.join(root, "proxy.js"));
|
|
@@ -11,6 +11,15 @@ type PagesRouterLinkRuntime = {
|
|
|
11
11
|
};
|
|
12
12
|
type PagesRouterLinkNavigation = {
|
|
13
13
|
href: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional `as` mask — the browser-bar URL when it differs from `href`
|
|
16
|
+
* (a Pages Router route pattern, e.g. `<Link href="/posts/[id]" as="/posts/1">`).
|
|
17
|
+
* When present, `router.push/replace(href, as, ...)` is invoked with both
|
|
18
|
+
* values so the upstream (url, as) pair survives end-to-end. Mirrors
|
|
19
|
+
* Next.js's Link → Router contract: packages/next/src/client/link.tsx
|
|
20
|
+
* → router.push(href, as).
|
|
21
|
+
*/
|
|
22
|
+
as?: string;
|
|
14
23
|
replace: boolean;
|
|
15
24
|
scroll: boolean;
|
|
16
25
|
shallow?: boolean;
|
|
@@ -30,6 +39,7 @@ declare function resolvePagesRouterQueryOnlyHref(href: string, {
|
|
|
30
39
|
}): string;
|
|
31
40
|
declare function navigatePagesRouterLink(router: PagesRouterLinkRuntime, {
|
|
32
41
|
href,
|
|
42
|
+
as,
|
|
33
43
|
replace,
|
|
34
44
|
scroll,
|
|
35
45
|
shallow,
|
|
@@ -14,15 +14,15 @@ function resolvePagesRouterQueryOnlyHref(href, { asPath, basePath, fallbackHref,
|
|
|
14
14
|
return href;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
async function navigatePagesRouterLink(router, { href, replace, scroll, shallow, locale, interpolateDynamicRoute = false }) {
|
|
17
|
+
async function navigatePagesRouterLink(router, { href, as, replace, scroll, shallow, locale, interpolateDynamicRoute = false }) {
|
|
18
18
|
const routerOptions = {
|
|
19
19
|
scroll,
|
|
20
20
|
locale
|
|
21
21
|
};
|
|
22
22
|
if (interpolateDynamicRoute) routerOptions._vinextInterpolateDynamicRoute = true;
|
|
23
23
|
if (shallow !== void 0) routerOptions.shallow = shallow;
|
|
24
|
-
if (replace) await router.replace(href,
|
|
25
|
-
else await router.push(href,
|
|
24
|
+
if (replace) await router.replace(href, as, routerOptions);
|
|
25
|
+
else await router.push(href, as, routerOptions);
|
|
26
26
|
}
|
|
27
27
|
async function navigatePagesRouterLinkWithFallback({ router, loadRouter, navigation, fallback }) {
|
|
28
28
|
let pagesRouter = router;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { CacheHandler, CacheHandlerValue, IncrementalCacheValue } from "../../../shims/cache-handler.js";
|
|
1
2
|
import { ExecutionContextLike } from "../../../shims/request-context.js";
|
|
2
|
-
import { CacheHandler, CacheHandlerValue, IncrementalCacheValue } from "../../../shims/cache.js";
|
|
3
3
|
|
|
4
4
|
//#region ../cloudflare/src/cache/kv-data-adapter.runtime.d.ts
|
|
5
5
|
type KVNamespace = {
|
package/dist/deploy.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { detectPackageManager as detectPackageManager$1, ensureESModule as ensureESModule$1, findInNodeModules, renameCJSConfigs as renameCJSConfigs$1 } from "./utils/project.js";
|
|
1
|
+
import { detectPackageManager as detectPackageManager$1, ensureESModule as ensureESModule$1, findDir, findInNodeModules, hasAppDir, renameCJSConfigs as renameCJSConfigs$1 } from "./utils/project.js";
|
|
2
2
|
import { parsePositiveIntegerArg } from "./cli-args.js";
|
|
3
3
|
import { escapeRegExp } from "./utils/regex.js";
|
|
4
4
|
import { loadNextConfig, resolveNextConfig } from "./config/next-config.js";
|
|
@@ -108,8 +108,8 @@ function formatMissingCloudflarePluginError(options) {
|
|
|
108
108
|
return `[vinext] Missing @cloudflare/vite-plugin in ${configRef}.\n\n Cloudflare Workers builds require the cloudflare() plugin.\n Add it to ${configRef}:\n\n import { cloudflare } from "@cloudflare/vite-plugin";\n\n export default defineConfig({\n plugins: [\n vinext(),\n cloudflare(${cfArg}),\n ],\n });\n\n Or delete ${configRef} and re-run \`vinext deploy\` to auto-generate it.`;
|
|
109
109
|
}
|
|
110
110
|
function detectProject(root) {
|
|
111
|
-
const hasApp =
|
|
112
|
-
const hasPages =
|
|
111
|
+
const hasApp = hasAppDir(root);
|
|
112
|
+
const hasPages = findDir(root, "pages", path.join("src", "pages")) !== null;
|
|
113
113
|
const isAppRouter = hasApp;
|
|
114
114
|
const isPagesRouter = !hasApp && hasPages;
|
|
115
115
|
const hasViteConfig = fs.existsSync(path.join(root, "vite.config.ts")) || fs.existsSync(path.join(root, "vite.config.js")) || fs.existsSync(path.join(root, "vite.config.mjs"));
|
|
@@ -18,7 +18,6 @@ const DEFAULT_EXPIRE_TIME = 31536e3;
|
|
|
18
18
|
const DEFAULT_REACT_MAX_HEADERS_LENGTH = 6e3;
|
|
19
19
|
const middlewareRequestHeadersPath = resolveEntryPath("../server/middleware-request-headers.js", import.meta.url);
|
|
20
20
|
const normalizePathModulePath = resolveEntryPath("../server/normalize-path.js", import.meta.url);
|
|
21
|
-
const appRscHandlerPath = resolveEntryPath("../server/app-rsc-handler.js", import.meta.url);
|
|
22
21
|
const appRouteHandlerDispatchPath = resolveEntryPath("../server/app-route-handler-dispatch.js", import.meta.url);
|
|
23
22
|
const appRouteHandlerResponsePath = resolveEntryPath("../server/app-route-handler-response.js", import.meta.url);
|
|
24
23
|
const appServerActionExecutionPath = resolveEntryPath("../server/app-server-action-execution.js", import.meta.url);
|
|
@@ -110,29 +109,21 @@ const prerenderToReadableStream = createRscPrerenderer(async (model, options) =>
|
|
|
110
109
|
);
|
|
111
110
|
import { createElement } from "react";
|
|
112
111
|
import { getNavigationContext as _getNavigationContext } from "next/navigation";
|
|
113
|
-
import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "
|
|
112
|
+
import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "vinext/shims/cache-handler";
|
|
114
113
|
import { headersContextFromRequest, getDraftModeCookieHeader, getAndClearPendingCookies, consumeDynamicUsage, consumeInvalidDynamicUsageError, setHeadersAccessPhase } from "next/headers";
|
|
115
114
|
import { mergeMetadata, resolveModuleMetadata, mergeViewport, resolveModuleViewport } from "vinext/metadata";
|
|
116
115
|
${middlewarePath ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};` : ""}
|
|
117
116
|
${instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(normalizePathSeparators(instrumentationPath))};
|
|
118
117
|
import { ensureInstrumentationRegistered as __ensureInstrumentationRegistered } from ${JSON.stringify(instrumentationRuntimePath)};` : ""}
|
|
119
|
-
import { createAppRscHandler
|
|
118
|
+
import { createAppRscHandler } from "vinext/server/app-rsc-handler";
|
|
120
119
|
import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
|
|
121
120
|
import { decodePathParams as __decodePathParams } from ${JSON.stringify(normalizePathModulePath)};
|
|
122
121
|
import { buildRequestHeadersFromMiddlewareResponse as __buildRequestHeadersFromMiddlewareResponse } from ${JSON.stringify(middlewareRequestHeadersPath)};
|
|
123
|
-
import {
|
|
124
|
-
dispatchAppRouteHandler as __dispatchAppRouteHandler,
|
|
125
|
-
} from ${JSON.stringify(appRouteHandlerDispatchPath)};
|
|
126
|
-
import {
|
|
122
|
+
${hasPagesDir ? `import {
|
|
127
123
|
applyRouteHandlerMiddlewareContext as __applyRouteHandlerMiddlewareContext,
|
|
128
|
-
} from ${JSON.stringify(appRouteHandlerResponsePath)}
|
|
129
|
-
import
|
|
130
|
-
|
|
131
|
-
handleServerActionRscRequest as __handleServerActionRscRequest,
|
|
132
|
-
isProgressiveServerActionRequest as __isProgressiveServerActionRequest,
|
|
133
|
-
readActionBodyWithLimit as __readBodyWithLimit,
|
|
134
|
-
readActionFormDataWithLimit as __readFormDataWithLimit,
|
|
135
|
-
} from ${JSON.stringify(appServerActionExecutionPath)};
|
|
124
|
+
} from ${JSON.stringify(appRouteHandlerResponsePath)};` : ""}
|
|
125
|
+
const __loadAppRouteHandlerDispatch = () => import(${JSON.stringify(appRouteHandlerDispatchPath)});
|
|
126
|
+
const __loadAppServerActionExecution = () => import(${JSON.stringify(appServerActionExecutionPath)});
|
|
136
127
|
import {
|
|
137
128
|
sanitizeErrorForClient as __sanitizeErrorForClient,
|
|
138
129
|
} from ${JSON.stringify(appRscErrorsPath)};
|
|
@@ -198,7 +189,6 @@ import { clearAppRequestContext as __clearRequestContext, setAppNavigationContex
|
|
|
198
189
|
__configureMemoryCacheHandler({ cacheMaxMemorySize: ${JSON.stringify(cacheMaxMemorySize)} });
|
|
199
190
|
import { createAppPrerenderStaticParamsResolver as __createAppPrerenderStaticParamsResolver } from ${JSON.stringify(appPrerenderStaticParamsPath)};
|
|
200
191
|
import { ensureAppRouteModulesLoaded as __ensureRouteLoaded } from ${JSON.stringify(appRouteModuleLoaderPath)};
|
|
201
|
-
import { seedMemoryCacheFromPrerender as __seedMemoryCacheFromPrerender } from ${JSON.stringify(seedCachePath)};
|
|
202
192
|
import {
|
|
203
193
|
getRenderedConcreteUrlPathsForRoute as __getRenderedConcreteUrlPathsForRoute,
|
|
204
194
|
initPregeneratedPathsFromGlobals as __initPregeneratedPathsFromGlobals,
|
|
@@ -408,7 +398,9 @@ export const __hasPagesDir = ${JSON.stringify(hasPagesDir)};
|
|
|
408
398
|
export const getRenderedConcreteUrlPathsForRoute = __getRenderedConcreteUrlPathsForRoute;
|
|
409
399
|
const __cacheComponents = ${JSON.stringify(cacheComponents)};
|
|
410
400
|
|
|
411
|
-
export function seedMemoryCacheFromPrerender(serverDir) {
|
|
401
|
+
export async function seedMemoryCacheFromPrerender(serverDir) {
|
|
402
|
+
const { seedMemoryCacheFromPrerender: __seedMemoryCacheFromPrerender } =
|
|
403
|
+
await import(${JSON.stringify(seedCachePath)});
|
|
412
404
|
return __seedMemoryCacheFromPrerender(serverDir, {
|
|
413
405
|
buildAppPageHtmlKey(pathname) {
|
|
414
406
|
return __isrHtmlKey(pathname);
|
|
@@ -450,7 +442,7 @@ const rootParamNamesMap = {
|
|
|
450
442
|
${rootParamNameEntries.join("\n")}
|
|
451
443
|
};
|
|
452
444
|
|
|
453
|
-
export default
|
|
445
|
+
export default createAppRscHandler({
|
|
454
446
|
basePath: __basePath,
|
|
455
447
|
buildId: process.env.__VINEXT_BUILD_ID ?? null,
|
|
456
448
|
ensureRouteLoaded: __ensureRouteLoaded,
|
|
@@ -652,7 +644,7 @@ export default __createAppRscHandler({
|
|
|
652
644
|
renderMode,
|
|
653
645
|
});
|
|
654
646
|
},
|
|
655
|
-
dispatchMatchedRouteHandler({
|
|
647
|
+
async dispatchMatchedRouteHandler({
|
|
656
648
|
cleanPathname,
|
|
657
649
|
middlewareContext,
|
|
658
650
|
params,
|
|
@@ -660,6 +652,8 @@ export default __createAppRscHandler({
|
|
|
660
652
|
route,
|
|
661
653
|
searchParams,
|
|
662
654
|
}) {
|
|
655
|
+
const { dispatchAppRouteHandler: __dispatchAppRouteHandler } =
|
|
656
|
+
await __loadAppRouteHandlerDispatch();
|
|
663
657
|
return __dispatchAppRouteHandler({
|
|
664
658
|
basePath: __basePath,
|
|
665
659
|
cleanPathname,
|
|
@@ -689,13 +683,18 @@ export default __createAppRscHandler({
|
|
|
689
683
|
${instrumentationPath ? `ensureInstrumentation() {
|
|
690
684
|
return __ensureInstrumentationRegistered(_instrumentation);
|
|
691
685
|
},` : ""}
|
|
692
|
-
handleProgressiveActionRequest({
|
|
686
|
+
async handleProgressiveActionRequest({
|
|
693
687
|
actionId,
|
|
694
688
|
cleanPathname,
|
|
695
689
|
contentType,
|
|
696
690
|
middlewareContext,
|
|
697
691
|
request,
|
|
698
692
|
}) {
|
|
693
|
+
const {
|
|
694
|
+
handleProgressiveServerActionRequest: __handleProgressiveServerActionRequest,
|
|
695
|
+
isProgressiveServerActionRequest: __isProgressiveServerActionRequest,
|
|
696
|
+
readActionFormDataWithLimit: __readFormDataWithLimit,
|
|
697
|
+
} = await __loadAppServerActionExecution();
|
|
699
698
|
// A multipart form POST to a page is always a server-action attempt, so a
|
|
700
699
|
// body that decodes to no action must surface as 404 action-not-found
|
|
701
700
|
// (#1340). Route handlers run after this dispatch and accept raw multipart
|
|
@@ -749,6 +748,11 @@ export default __createAppRscHandler({
|
|
|
749
748
|
request,
|
|
750
749
|
searchParams,
|
|
751
750
|
}) {
|
|
751
|
+
const {
|
|
752
|
+
handleServerActionRscRequest: __handleServerActionRscRequest,
|
|
753
|
+
readActionBodyWithLimit: __readBodyWithLimit,
|
|
754
|
+
readActionFormDataWithLimit: __readFormDataWithLimit,
|
|
755
|
+
} = await __loadAppServerActionExecution();
|
|
752
756
|
const __actionMatch = matchRoute(cleanPathname);
|
|
753
757
|
if (__actionMatch) await __ensureRouteLoaded(__actionMatch.route);
|
|
754
758
|
const __actionIsEdgeRuntime = __actionMatch
|
|
@@ -862,6 +866,7 @@ export default __createAppRscHandler({
|
|
|
862
866
|
makeThenableParams,
|
|
863
867
|
matchRoute,
|
|
864
868
|
metadataRoutes,
|
|
869
|
+
middlewareFilePath: ${middlewarePath ? JSON.stringify(normalizePathSeparators(middlewarePath)) : "null"},
|
|
865
870
|
middlewareModule: ${middlewarePath ? "middlewareModule" : "null"},
|
|
866
871
|
publicFiles: __publicFiles,
|
|
867
872
|
renderNotFound({ isRscRequest, matchedParams, middlewareContext, request, route, scriptNonce }) {
|
|
@@ -50,58 +50,68 @@ function registerRouteModules(routes, imports) {
|
|
|
50
50
|
for (const route of routes) {
|
|
51
51
|
if (route.pagePath) imports.getLazyLoaderVar(route.pagePath);
|
|
52
52
|
if (route.routePath) imports.getLazyLoaderVar(route.routePath);
|
|
53
|
-
for (const layout of route.layouts) imports.
|
|
54
|
-
for (const tmpl of route.templates) imports.
|
|
55
|
-
if (route.loadingPath) imports.
|
|
56
|
-
if (route.errorPath) imports.
|
|
53
|
+
for (const layout of route.layouts) imports.getLazyLoaderVar(layout);
|
|
54
|
+
for (const tmpl of route.templates) imports.getLazyLoaderVar(tmpl);
|
|
55
|
+
if (route.loadingPath) imports.getLazyLoaderVar(route.loadingPath);
|
|
56
|
+
if (route.errorPath) imports.getLazyLoaderVar(route.errorPath);
|
|
57
57
|
if (route.layoutErrorPaths) {
|
|
58
|
-
for (const ep of route.layoutErrorPaths) if (ep) imports.
|
|
58
|
+
for (const ep of route.layoutErrorPaths) if (ep) imports.getLazyLoaderVar(ep);
|
|
59
59
|
}
|
|
60
|
-
if (route.errorPaths) for (const ep of route.errorPaths) imports.
|
|
61
|
-
if (route.notFoundPath) imports.
|
|
60
|
+
if (route.errorPaths) for (const ep of route.errorPaths) imports.getLazyLoaderVar(ep);
|
|
61
|
+
if (route.notFoundPath) imports.getLazyLoaderVar(route.notFoundPath);
|
|
62
62
|
if (route.notFoundPaths) {
|
|
63
|
-
for (const nfp of route.notFoundPaths) if (nfp) imports.
|
|
63
|
+
for (const nfp of route.notFoundPaths) if (nfp) imports.getLazyLoaderVar(nfp);
|
|
64
64
|
}
|
|
65
|
-
if (route.forbiddenPath) imports.
|
|
65
|
+
if (route.forbiddenPath) imports.getLazyLoaderVar(route.forbiddenPath);
|
|
66
66
|
if (route.forbiddenPaths) {
|
|
67
|
-
for (const fp of route.forbiddenPaths) if (fp) imports.
|
|
67
|
+
for (const fp of route.forbiddenPaths) if (fp) imports.getLazyLoaderVar(fp);
|
|
68
68
|
}
|
|
69
|
-
if (route.unauthorizedPath) imports.
|
|
69
|
+
if (route.unauthorizedPath) imports.getLazyLoaderVar(route.unauthorizedPath);
|
|
70
70
|
if (route.unauthorizedPaths) {
|
|
71
|
-
for (const up of route.unauthorizedPaths) if (up) imports.
|
|
71
|
+
for (const up of route.unauthorizedPaths) if (up) imports.getLazyLoaderVar(up);
|
|
72
72
|
}
|
|
73
73
|
for (const slot of route.parallelSlots) {
|
|
74
|
-
if (slot.pagePath) imports.
|
|
75
|
-
if (slot.defaultPath) imports.
|
|
76
|
-
if (slot.layoutPath) imports.
|
|
77
|
-
if (slot.loadingPath) imports.
|
|
78
|
-
if (slot.errorPath) imports.
|
|
74
|
+
if (slot.pagePath) imports.getLazyLoaderVar(slot.pagePath);
|
|
75
|
+
if (slot.defaultPath) imports.getLazyLoaderVar(slot.defaultPath);
|
|
76
|
+
if (slot.layoutPath) imports.getLazyLoaderVar(slot.layoutPath);
|
|
77
|
+
if (slot.loadingPath) imports.getLazyLoaderVar(slot.loadingPath);
|
|
78
|
+
if (slot.errorPath) imports.getLazyLoaderVar(slot.errorPath);
|
|
79
79
|
for (const ir of slot.interceptingRoutes) {
|
|
80
80
|
imports.getLazyLoaderVar(ir.pagePath);
|
|
81
|
-
for (const layoutPath of ir.layoutPaths) imports.
|
|
81
|
+
for (const layoutPath of ir.layoutPaths) imports.getLazyLoaderVar(layoutPath);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
for (const ir of route.siblingIntercepts ?? []) {
|
|
85
85
|
imports.getLazyLoaderVar(ir.pagePath);
|
|
86
|
-
for (const layoutPath of ir.layoutPaths) imports.
|
|
86
|
+
for (const layoutPath of ir.layoutPaths) imports.getLazyLoaderVar(layoutPath);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
+
function moduleArray(length) {
|
|
91
|
+
return `[${Array.from({ length }, () => "null").join(", ")}]`;
|
|
92
|
+
}
|
|
93
|
+
function lazyLoaderArray(filePaths, imports) {
|
|
94
|
+
return `[${filePaths.map((filePath) => filePath ? imports.getLazyLoaderVar(filePath) : "null").join(", ")}]`;
|
|
95
|
+
}
|
|
90
96
|
function buildRouteEntries(routes, imports) {
|
|
91
97
|
return routes.map((route, routeIdx) => {
|
|
92
98
|
const staticSiblings = route.isDynamic ? computeAppRouteStaticSiblings(routes, route) : [];
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
99
|
+
const layoutLoaders = lazyLoaderArray(route.layouts, imports);
|
|
100
|
+
const templateLoaders = lazyLoaderArray(route.templates, imports);
|
|
101
|
+
const notFoundPaths = route.notFoundPaths ?? [];
|
|
102
|
+
const forbiddenPaths = route.forbiddenPaths ?? [];
|
|
103
|
+
const unauthorizedPaths = route.unauthorizedPaths ?? [];
|
|
104
|
+
const notFoundLoaders = lazyLoaderArray(notFoundPaths, imports);
|
|
105
|
+
const forbiddenLoaders = lazyLoaderArray(forbiddenPaths, imports);
|
|
106
|
+
const unauthorizedLoaders = lazyLoaderArray(unauthorizedPaths, imports);
|
|
98
107
|
const siblingInterceptEntries = (route.siblingIntercepts ?? []).map((ir) => ` {
|
|
99
108
|
convention: ${JSON.stringify(ir.convention)},
|
|
100
109
|
targetPattern: ${JSON.stringify(ir.targetPattern)},
|
|
101
110
|
sourceMatchPattern: ${JSON.stringify(ir.sourceMatchPattern)},
|
|
102
111
|
sourcePageSegments: ${JSON.stringify(ir.sourcePageSegments)},
|
|
103
112
|
slotId: ${JSON.stringify(ir.slotId ?? null)},
|
|
104
|
-
interceptLayouts:
|
|
113
|
+
interceptLayouts: ${moduleArray(ir.layoutPaths.length)},
|
|
114
|
+
__loadInterceptLayouts: ${lazyLoaderArray(ir.layoutPaths, imports)},
|
|
105
115
|
page: null,
|
|
106
116
|
__pageLoader: ${imports.getLazyLoaderVar(ir.pagePath)},
|
|
107
117
|
params: ${JSON.stringify(ir.params)},
|
|
@@ -112,7 +122,8 @@ function buildRouteEntries(routes, imports) {
|
|
|
112
122
|
targetPattern: ${JSON.stringify(ir.targetPattern)},
|
|
113
123
|
sourceMatchPattern: ${JSON.stringify(ir.sourceMatchPattern)},
|
|
114
124
|
sourcePageSegments: ${JSON.stringify(ir.sourcePageSegments)},
|
|
115
|
-
interceptLayouts:
|
|
125
|
+
interceptLayouts: ${moduleArray(ir.layoutPaths.length)},
|
|
126
|
+
__loadInterceptLayouts: ${lazyLoaderArray(ir.layoutPaths, imports)},
|
|
116
127
|
page: null,
|
|
117
128
|
__pageLoader: ${imports.getLazyLoaderVar(ir.pagePath)},
|
|
118
129
|
params: ${JSON.stringify(ir.params)},
|
|
@@ -120,11 +131,16 @@ function buildRouteEntries(routes, imports) {
|
|
|
120
131
|
return ` ${JSON.stringify(slot.key)}: {
|
|
121
132
|
id: ${JSON.stringify(slot.id ?? null)},
|
|
122
133
|
name: ${JSON.stringify(slot.name)},
|
|
123
|
-
page:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
134
|
+
page: null,
|
|
135
|
+
__loadPage: ${slot.pagePath ? imports.getLazyLoaderVar(slot.pagePath) : "null"},
|
|
136
|
+
default: null,
|
|
137
|
+
__loadDefault: ${slot.defaultPath ? imports.getLazyLoaderVar(slot.defaultPath) : "null"},
|
|
138
|
+
layout: null,
|
|
139
|
+
__loadLayout: ${slot.layoutPath ? imports.getLazyLoaderVar(slot.layoutPath) : "null"},
|
|
140
|
+
loading: null,
|
|
141
|
+
__loadLoading: ${slot.loadingPath ? imports.getLazyLoaderVar(slot.loadingPath) : "null"},
|
|
142
|
+
error: null,
|
|
143
|
+
__loadError: ${slot.errorPath ? imports.getLazyLoaderVar(slot.errorPath) : "null"},
|
|
128
144
|
layoutIndex: ${slot.layoutIndex},
|
|
129
145
|
routeSegments: ${JSON.stringify(slot.routeSegments)},
|
|
130
146
|
slotPatternParts: ${slot.slotPatternParts ? JSON.stringify(slot.slotPatternParts) : "null"},
|
|
@@ -134,8 +150,10 @@ ${interceptEntries.join(",\n")}
|
|
|
134
150
|
],
|
|
135
151
|
}`;
|
|
136
152
|
});
|
|
137
|
-
const
|
|
138
|
-
const
|
|
153
|
+
const layoutErrorPaths = route.layoutErrorPaths ?? [];
|
|
154
|
+
const errorPaths = route.errorPaths ?? [];
|
|
155
|
+
const layoutErrorLoaders = lazyLoaderArray(layoutErrorPaths, imports);
|
|
156
|
+
const errorLoaders = lazyLoaderArray(errorPaths, imports);
|
|
139
157
|
const loadPageField = route.pagePath ? imports.getLazyLoaderVar(route.pagePath) : "null";
|
|
140
158
|
const loadRouteHandlerField = route.routePath ? imports.getLazyLoaderVar(route.routePath) : "null";
|
|
141
159
|
return ` {
|
|
@@ -152,13 +170,17 @@ ${interceptEntries.join(",\n")}
|
|
|
152
170
|
__loadPage: ${loadPageField},
|
|
153
171
|
routeHandler: null,
|
|
154
172
|
__loadRouteHandler: ${loadRouteHandlerField},
|
|
155
|
-
layouts:
|
|
173
|
+
layouts: ${moduleArray(route.layouts.length)},
|
|
174
|
+
__loadLayouts: ${layoutLoaders},
|
|
156
175
|
routeSegments: ${JSON.stringify(route.routeSegments)},
|
|
157
176
|
templateTreePositions: ${JSON.stringify(route.templateTreePositions)},
|
|
158
177
|
layoutTreePositions: ${JSON.stringify(route.layoutTreePositions)},
|
|
159
|
-
templates:
|
|
160
|
-
|
|
161
|
-
|
|
178
|
+
templates: ${moduleArray(route.templates.length)},
|
|
179
|
+
__loadTemplates: ${templateLoaders},
|
|
180
|
+
errors: ${moduleArray(layoutErrorPaths.length)},
|
|
181
|
+
__loadErrors: ${layoutErrorLoaders},
|
|
182
|
+
errorPaths: ${moduleArray(errorPaths.length)},
|
|
183
|
+
__loadErrorPaths: ${errorLoaders},
|
|
162
184
|
errorTreePositions: ${JSON.stringify(route.errorTreePositions ?? null)},
|
|
163
185
|
slots: {
|
|
164
186
|
${slotEntries.join(",\n")}
|
|
@@ -166,14 +188,22 @@ ${slotEntries.join(",\n")}
|
|
|
166
188
|
siblingIntercepts: [
|
|
167
189
|
${siblingInterceptEntries.join(",\n")}
|
|
168
190
|
],
|
|
169
|
-
loading:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
191
|
+
loading: null,
|
|
192
|
+
__loadLoading: ${route.loadingPath ? imports.getLazyLoaderVar(route.loadingPath) : "null"},
|
|
193
|
+
error: null,
|
|
194
|
+
__loadError: ${route.errorPath ? imports.getLazyLoaderVar(route.errorPath) : "null"},
|
|
195
|
+
notFound: null,
|
|
196
|
+
__loadNotFound: ${route.notFoundPath ? imports.getLazyLoaderVar(route.notFoundPath) : "null"},
|
|
197
|
+
notFounds: ${moduleArray(notFoundPaths.length)},
|
|
198
|
+
__loadNotFounds: ${notFoundLoaders},
|
|
199
|
+
forbidden: null,
|
|
200
|
+
__loadForbidden: ${route.forbiddenPath ? imports.getLazyLoaderVar(route.forbiddenPath) : "null"},
|
|
201
|
+
forbiddens: ${moduleArray(forbiddenPaths.length)},
|
|
202
|
+
__loadForbiddens: ${forbiddenLoaders},
|
|
203
|
+
unauthorized: null,
|
|
204
|
+
__loadUnauthorized: ${route.unauthorizedPath ? imports.getLazyLoaderVar(route.unauthorizedPath) : "null"},
|
|
205
|
+
unauthorizeds: ${moduleArray(unauthorizedPaths.length)},
|
|
206
|
+
__loadUnauthorizeds: ${unauthorizedLoaders},
|
|
177
207
|
}`;
|
|
178
208
|
});
|
|
179
209
|
}
|
|
@@ -217,7 +247,7 @@ function buildGenerateStaticParamsEntries(routes, imports, namesByPattern) {
|
|
|
217
247
|
const sourcesByPattern = /* @__PURE__ */ new Map();
|
|
218
248
|
for (const route of routes) {
|
|
219
249
|
if (!route.isDynamic) continue;
|
|
220
|
-
for (const [index, layoutPath] of route.layouts.entries()) appendStaticParamSource(sourcesByPattern, createRoutePatternPrefix(route.routeSegments, route.layoutTreePositions[index] ?? 0)?.pattern ?? null,
|
|
250
|
+
for (const [index, layoutPath] of route.layouts.entries()) appendStaticParamSource(sourcesByPattern, createRoutePatternPrefix(route.routeSegments, route.layoutTreePositions[index] ?? 0)?.pattern ?? null, `{ load: ${imports.getLazyLoaderVar(layoutPath)} }`);
|
|
221
251
|
if (route.pagePath) appendStaticParamSource(sourcesByPattern, route.pattern, `{ load: ${imports.getLazyLoaderVar(route.pagePath)} }`);
|
|
222
252
|
}
|
|
223
253
|
return Array.from(sourcesByPattern.entries()).map(([pattern, sources]) => {
|
|
@@ -103,6 +103,7 @@ export async function runMiddleware(request, ctx, options) {
|
|
|
103
103
|
return __runGeneratedMiddleware({
|
|
104
104
|
basePath: vinextConfig.basePath,
|
|
105
105
|
ctx,
|
|
106
|
+
filePath: ${JSON.stringify(normalizePathSeparators(middlewarePath))},
|
|
106
107
|
i18nConfig,
|
|
107
108
|
isDataRequest: options?.isDataRequest === true,
|
|
108
109
|
isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
|
|
@@ -123,7 +124,8 @@ import { renderToReadableStream } from "react-dom/server.edge";
|
|
|
123
124
|
import { resetSSRHead, getSSRHeadHTML, setDocumentInitialHead } from "next/head";
|
|
124
125
|
import { flushPreloads } from "next/dynamic";
|
|
125
126
|
import Router, { setSSRContext, wrapWithRouterContext, getPagesNavigationIsReadyFromSerializedState } from "next/router";
|
|
126
|
-
import { _runWithCacheState
|
|
127
|
+
import { _runWithCacheState } from "vinext/shims/cache-request-state";
|
|
128
|
+
import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "vinext/shims/cache-handler";
|
|
127
129
|
import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
|
|
128
130
|
import { runWithPrivateCache } from "vinext/cache-runtime";
|
|
129
131
|
import { ensureFetchPatch, runWithFetchCache } from "vinext/fetch-cache";
|