vinext 0.1.5 → 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/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/report.d.ts +1 -2
- package/dist/build/report.js +2 -11
- package/dist/build/run-prerender.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/deploy.js +3 -3
- package/dist/entries/app-rsc-entry.js +1 -0
- package/dist/entries/app-rsc-manifest.js +76 -46
- package/dist/entries/pages-server-entry.js +1 -0
- package/dist/index.js +69 -54
- package/dist/init.d.ts +5 -4
- package/dist/init.js +27 -8
- package/dist/plugins/fonts.js +3 -1
- package/dist/plugins/middleware-export-validation.d.ts +5 -0
- package/dist/plugins/middleware-export-validation.js +36 -0
- 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 +22 -4
- package/dist/server/accept-encoding.d.ts +29 -0
- package/dist/server/accept-encoding.js +95 -0
- package/dist/server/app-browser-entry.js +8 -5
- package/dist/server/app-browser-navigation-controller.js +1 -1
- 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.js +1 -1
- package/dist/server/app-browser-visible-commit.js +1 -1
- package/dist/server/app-middleware.d.ts +1 -0
- package/dist/server/app-middleware.js +1 -0
- package/dist/server/app-page-dispatch.d.ts +2 -2
- package/dist/server/app-page-head.js +2 -2
- package/dist/server/app-page-request.d.ts +7 -0
- package/dist/server/app-page-request.js +19 -1
- package/dist/server/app-prerender-endpoints.d.ts +3 -3
- package/dist/server/app-prerender-endpoints.js +3 -4
- 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-rsc-handler.d.ts +7 -6
- package/dist/server/app-rsc-handler.js +31 -26
- 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-ssr-entry.js +2 -2
- package/dist/server/headers.d.ts +5 -1
- package/dist/server/headers.js +5 -1
- package/dist/server/metadata-route-response.d.ts +3 -3
- package/dist/server/middleware-runtime.d.ts +2 -1
- package/dist/server/middleware-runtime.js +19 -8
- package/dist/server/middleware.d.ts +2 -2
- package/dist/server/middleware.js +26 -11
- 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 +85 -72
- package/dist/shims/font-google-base.d.ts +1 -0
- package/dist/shims/font-google-base.js +6 -21
- package/dist/shims/internal/interpolate-as.d.ts +25 -0
- package/dist/shims/internal/interpolate-as.js +196 -0
- package/dist/shims/link.js +24 -1
- package/dist/shims/navigation.js +1 -1
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/router.d.ts +1 -3
- package/dist/shims/router.js +62 -18
- package/dist/typegen.js +2 -10
- package/dist/utils/project.d.ts +7 -1
- package/dist/utils/project.js +16 -2
- package/package.json +3 -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>
|
|
@@ -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/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";
|
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;
|
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"));
|
|
@@ -866,6 +866,7 @@ export default createAppRscHandler({
|
|
|
866
866
|
makeThenableParams,
|
|
867
867
|
matchRoute,
|
|
868
868
|
metadataRoutes,
|
|
869
|
+
middlewareFilePath: ${middlewarePath ? JSON.stringify(normalizePathSeparators(middlewarePath)) : "null"},
|
|
869
870
|
middlewareModule: ${middlewarePath ? "middlewareModule" : "null"},
|
|
870
871
|
publicFiles: __publicFiles,
|
|
871
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))},
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
|
|
|
9
9
|
import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
|
|
10
10
|
import { isOpenRedirectShaped } from "./server/open-redirect.js";
|
|
11
11
|
import { filterInternalHeaders, normalizeTrailingSlash } from "./server/request-pipeline.js";
|
|
12
|
-
import { findMiddlewareFile, runMiddleware } from "./server/middleware.js";
|
|
12
|
+
import { findMiddlewareFile, isProxyFile, runMiddleware } from "./server/middleware.js";
|
|
13
13
|
import { generateServerEntry } from "./entries/pages-server-entry.js";
|
|
14
14
|
import { generateClientEntry } from "./entries/pages-client-entry.js";
|
|
15
15
|
import { appRouteGraph, appRouter, invalidateAppRouteCache, matchAppRoute } from "./routing/app-router.js";
|
|
@@ -52,6 +52,7 @@ import { createRscClientReferenceLoadersPlugin } from "./plugins/rsc-client-refe
|
|
|
52
52
|
import { createInstrumentationClientTransformPlugin } from "./plugins/instrumentation-client.js";
|
|
53
53
|
import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
|
|
54
54
|
import { createMiddlewareServerOnlyPlugin } from "./plugins/middleware-server-only.js";
|
|
55
|
+
import { validateMiddlewareModuleExports } from "./plugins/middleware-export-validation.js";
|
|
55
56
|
import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
|
|
56
57
|
import { augmentSsrManifestFromBundle, relativeWithinRoot, tryRealpathSync } from "./build/ssr-manifest.js";
|
|
57
58
|
import { createDynamicPreloadMetadataPlugin } from "./plugins/dynamic-preload-metadata.js";
|
|
@@ -331,7 +332,7 @@ function createStaticImageAsset(imagePath) {
|
|
|
331
332
|
*/
|
|
332
333
|
const _shimsDir = normalizePathSeparators(path.resolve(__dirname, "shims")) + "/";
|
|
333
334
|
const _fontGoogleShimPath = resolveShimModulePath(_shimsDir, "font-google");
|
|
334
|
-
const _appRscHandlerPath = resolveShimModulePath(path.resolve(__dirname, "server"), "app-rsc-handler");
|
|
335
|
+
const _appRscHandlerPath = resolveShimModulePath(normalizePathSeparators(path.resolve(__dirname, "server")), "app-rsc-handler");
|
|
335
336
|
const _canExternalizeAppRscHandler = _appRscHandlerPath.endsWith(".js");
|
|
336
337
|
function isValidExportIdentifier(name) {
|
|
337
338
|
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
@@ -449,7 +450,7 @@ function vinext(options = {}) {
|
|
|
449
450
|
const sassComposesLoader = createSassAwareFileSystemLoader();
|
|
450
451
|
const typeofWindowIdFilter = { exclude: /(?!)/ };
|
|
451
452
|
let rscClassificationManifest = null;
|
|
452
|
-
const shimsDir = path.resolve(__dirname, "shims");
|
|
453
|
+
const shimsDir = normalizePathSeparators(path.resolve(__dirname, "shims"));
|
|
453
454
|
const canonicalize = (p) => normalizePathSeparators(tryRealpathSync(p) ?? p);
|
|
454
455
|
const pageTransformCanonicalPaths = /* @__PURE__ */ new Map();
|
|
455
456
|
const canonicalizePageTransformPath = (modulePath) => {
|
|
@@ -658,7 +659,8 @@ function vinext(options = {}) {
|
|
|
658
659
|
fileMatcher = createValidFileMatcher(nextConfig.pageExtensions);
|
|
659
660
|
instrumentationPath = findInstrumentationFile(root, fileMatcher);
|
|
660
661
|
instrumentationClientPath = findInstrumentationClientFile(root, fileMatcher);
|
|
661
|
-
|
|
662
|
+
const middlewareConventionDir = canonicalize(baseDir) === canonicalize(path.posix.join(root, "src")) ? path.posix.join(root, "src") : root;
|
|
663
|
+
middlewarePath = findMiddlewareFile(root, fileMatcher, middlewareConventionDir);
|
|
662
664
|
const instrumentationClientInjects = nextConfig.instrumentationClientInject.map((spec) => spec.startsWith("./") || spec.startsWith("../") ? path.resolve(root, spec) : spec);
|
|
663
665
|
clientInjectModule = instrumentationClientInjects.length ? generateInstrumentationClientInjectModule(instrumentationClientInjects, instrumentationClientPath, INSTRUMENTATION_CLIENT_EMPTY_MODULE) : null;
|
|
664
666
|
if (env?.command === "build") await writeRouteTypes();
|
|
@@ -721,55 +723,55 @@ function vinext(options = {}) {
|
|
|
721
723
|
}
|
|
722
724
|
for (const key of Object.keys(nextConfig.compilerDefineServer)) if (key in defines) throw new Error(`The \`compiler.defineServer\` option is configured to replace the \`${key}\` variable. This variable is either part of a built-in or is already configured.`);
|
|
723
725
|
nextShimMap = Object.fromEntries(Object.entries({
|
|
724
|
-
"next/link": path.join(shimsDir, "link"),
|
|
725
|
-
"next/head": path.join(shimsDir, "head"),
|
|
726
|
-
"next/router": path.join(shimsDir, "router"),
|
|
727
|
-
"next/compat/router": path.join(shimsDir, "compat-router"),
|
|
728
|
-
"next/image": path.join(shimsDir, "image"),
|
|
729
|
-
"next/legacy/image": path.join(shimsDir, "legacy-image"),
|
|
730
|
-
"next/dynamic": path.join(shimsDir, "dynamic"),
|
|
731
|
-
"next/app": path.join(shimsDir, "app"),
|
|
732
|
-
"next/document": path.join(shimsDir, "document"),
|
|
733
|
-
"next/config": path.join(shimsDir, "config"),
|
|
734
|
-
"next/script": path.join(shimsDir, "script"),
|
|
735
|
-
"next/server": path.join(shimsDir, "server"),
|
|
736
|
-
"next/headers": path.join(shimsDir, "headers"),
|
|
737
|
-
"next/font/google": path.join(shimsDir, "font-google"),
|
|
738
|
-
"next/font/local": path.join(shimsDir, "font-local"),
|
|
739
|
-
"next/cache": path.join(shimsDir, "cache"),
|
|
740
|
-
"next/form": path.join(shimsDir, "form"),
|
|
741
|
-
"next/og": path.join(shimsDir, "og"),
|
|
742
|
-
"next/web-vitals": path.join(shimsDir, "web-vitals"),
|
|
743
|
-
"next/amp": path.join(shimsDir, "amp"),
|
|
744
|
-
"next/offline": path.join(shimsDir, "offline"),
|
|
745
|
-
"next/constants": path.join(shimsDir, "constants"),
|
|
746
|
-
"next/dist/shared/lib/app-router-context.shared-runtime": path.join(shimsDir, "internal", "app-router-context"),
|
|
747
|
-
"next/dist/shared/lib/app-router-context": path.join(shimsDir, "internal", "app-router-context"),
|
|
748
|
-
"next/dist/shared/lib/router-context.shared-runtime": path.join(shimsDir, "internal", "router-context"),
|
|
749
|
-
"next/dist/shared/lib/utils": path.join(shimsDir, "internal", "utils"),
|
|
750
|
-
"next/dist/server/api-utils": path.join(shimsDir, "internal", "api-utils"),
|
|
751
|
-
"next/dist/server/web/spec-extension/cookies": path.join(shimsDir, "internal", "cookies"),
|
|
752
|
-
"next/dist/compiled/@edge-runtime/cookies": path.join(shimsDir, "internal", "cookies"),
|
|
753
|
-
"next/dist/server/app-render/work-unit-async-storage.external": path.join(shimsDir, "internal", "work-unit-async-storage"),
|
|
754
|
-
"next/dist/client/components/work-unit-async-storage.external": path.join(shimsDir, "internal", "work-unit-async-storage"),
|
|
755
|
-
"next/dist/client/components/request-async-storage.external": path.join(shimsDir, "internal", "work-unit-async-storage"),
|
|
756
|
-
"next/dist/client/components/request-async-storage": path.join(shimsDir, "internal", "work-unit-async-storage"),
|
|
757
|
-
"next/dist/server/request/root-params": path.join(shimsDir, "root-params"),
|
|
758
|
-
"next/dist/server/config-shared": path.join(shimsDir, "internal", "utils"),
|
|
759
|
-
"server-only": path.join(shimsDir, "server-only"),
|
|
760
|
-
"client-only": path.join(shimsDir, "client-only"),
|
|
761
|
-
"vinext/error-boundary": path.join(shimsDir, "error-boundary"),
|
|
762
|
-
"vinext/layout-segment-context": path.join(shimsDir, "layout-segment-context"),
|
|
763
|
-
"vinext/metadata": path.join(shimsDir, "metadata"),
|
|
764
|
-
"vinext/fetch-cache": path.join(shimsDir, "fetch-cache"),
|
|
765
|
-
"vinext/cache-runtime": path.join(shimsDir, "cache-runtime"),
|
|
766
|
-
"vinext/navigation-state": path.join(shimsDir, "navigation-state"),
|
|
767
|
-
"vinext/unified-request-context": path.join(shimsDir, "unified-request-context"),
|
|
768
|
-
"vinext/pages-router-runtime": path.join(shimsDir, "pages-router-runtime"),
|
|
769
|
-
"vinext/router-state": path.join(shimsDir, "router-state"),
|
|
770
|
-
"vinext/head-state": path.join(shimsDir, "head-state"),
|
|
771
|
-
"vinext/i18n-state": path.join(shimsDir, "i18n-state"),
|
|
772
|
-
"vinext/i18n-context": path.join(shimsDir, "i18n-context"),
|
|
726
|
+
"next/link": path.posix.join(shimsDir, "link"),
|
|
727
|
+
"next/head": path.posix.join(shimsDir, "head"),
|
|
728
|
+
"next/router": path.posix.join(shimsDir, "router"),
|
|
729
|
+
"next/compat/router": path.posix.join(shimsDir, "compat-router"),
|
|
730
|
+
"next/image": path.posix.join(shimsDir, "image"),
|
|
731
|
+
"next/legacy/image": path.posix.join(shimsDir, "legacy-image"),
|
|
732
|
+
"next/dynamic": path.posix.join(shimsDir, "dynamic"),
|
|
733
|
+
"next/app": path.posix.join(shimsDir, "app"),
|
|
734
|
+
"next/document": path.posix.join(shimsDir, "document"),
|
|
735
|
+
"next/config": path.posix.join(shimsDir, "config"),
|
|
736
|
+
"next/script": path.posix.join(shimsDir, "script"),
|
|
737
|
+
"next/server": path.posix.join(shimsDir, "server"),
|
|
738
|
+
"next/headers": path.posix.join(shimsDir, "headers"),
|
|
739
|
+
"next/font/google": path.posix.join(shimsDir, "font-google"),
|
|
740
|
+
"next/font/local": path.posix.join(shimsDir, "font-local"),
|
|
741
|
+
"next/cache": path.posix.join(shimsDir, "cache"),
|
|
742
|
+
"next/form": path.posix.join(shimsDir, "form"),
|
|
743
|
+
"next/og": path.posix.join(shimsDir, "og"),
|
|
744
|
+
"next/web-vitals": path.posix.join(shimsDir, "web-vitals"),
|
|
745
|
+
"next/amp": path.posix.join(shimsDir, "amp"),
|
|
746
|
+
"next/offline": path.posix.join(shimsDir, "offline"),
|
|
747
|
+
"next/constants": path.posix.join(shimsDir, "constants"),
|
|
748
|
+
"next/dist/shared/lib/app-router-context.shared-runtime": path.posix.join(shimsDir, "internal", "app-router-context"),
|
|
749
|
+
"next/dist/shared/lib/app-router-context": path.posix.join(shimsDir, "internal", "app-router-context"),
|
|
750
|
+
"next/dist/shared/lib/router-context.shared-runtime": path.posix.join(shimsDir, "internal", "router-context"),
|
|
751
|
+
"next/dist/shared/lib/utils": path.posix.join(shimsDir, "internal", "utils"),
|
|
752
|
+
"next/dist/server/api-utils": path.posix.join(shimsDir, "internal", "api-utils"),
|
|
753
|
+
"next/dist/server/web/spec-extension/cookies": path.posix.join(shimsDir, "internal", "cookies"),
|
|
754
|
+
"next/dist/compiled/@edge-runtime/cookies": path.posix.join(shimsDir, "internal", "cookies"),
|
|
755
|
+
"next/dist/server/app-render/work-unit-async-storage.external": path.posix.join(shimsDir, "internal", "work-unit-async-storage"),
|
|
756
|
+
"next/dist/client/components/work-unit-async-storage.external": path.posix.join(shimsDir, "internal", "work-unit-async-storage"),
|
|
757
|
+
"next/dist/client/components/request-async-storage.external": path.posix.join(shimsDir, "internal", "work-unit-async-storage"),
|
|
758
|
+
"next/dist/client/components/request-async-storage": path.posix.join(shimsDir, "internal", "work-unit-async-storage"),
|
|
759
|
+
"next/dist/server/request/root-params": path.posix.join(shimsDir, "root-params"),
|
|
760
|
+
"next/dist/server/config-shared": path.posix.join(shimsDir, "internal", "utils"),
|
|
761
|
+
"server-only": path.posix.join(shimsDir, "server-only"),
|
|
762
|
+
"client-only": path.posix.join(shimsDir, "client-only"),
|
|
763
|
+
"vinext/error-boundary": path.posix.join(shimsDir, "error-boundary"),
|
|
764
|
+
"vinext/layout-segment-context": path.posix.join(shimsDir, "layout-segment-context"),
|
|
765
|
+
"vinext/metadata": path.posix.join(shimsDir, "metadata"),
|
|
766
|
+
"vinext/fetch-cache": path.posix.join(shimsDir, "fetch-cache"),
|
|
767
|
+
"vinext/cache-runtime": path.posix.join(shimsDir, "cache-runtime"),
|
|
768
|
+
"vinext/navigation-state": path.posix.join(shimsDir, "navigation-state"),
|
|
769
|
+
"vinext/unified-request-context": path.posix.join(shimsDir, "unified-request-context"),
|
|
770
|
+
"vinext/pages-router-runtime": path.posix.join(shimsDir, "pages-router-runtime"),
|
|
771
|
+
"vinext/router-state": path.posix.join(shimsDir, "router-state"),
|
|
772
|
+
"vinext/head-state": path.posix.join(shimsDir, "head-state"),
|
|
773
|
+
"vinext/i18n-state": path.posix.join(shimsDir, "i18n-state"),
|
|
774
|
+
"vinext/i18n-context": path.posix.join(shimsDir, "i18n-context"),
|
|
773
775
|
"vinext/cache": path.resolve(__dirname, "cache"),
|
|
774
776
|
"vinext/instrumentation": path.resolve(__dirname, "server", "instrumentation"),
|
|
775
777
|
"vinext/instrumentation-client": path.resolve(__dirname, "client", "instrumentation-client"),
|
|
@@ -1858,6 +1860,17 @@ function vinext(options = {}) {
|
|
|
1858
1860
|
};
|
|
1859
1861
|
}
|
|
1860
1862
|
},
|
|
1863
|
+
{
|
|
1864
|
+
name: "vinext:validate-middleware-exports",
|
|
1865
|
+
enforce: "pre",
|
|
1866
|
+
transform(code, id) {
|
|
1867
|
+
if (!middlewarePath) return null;
|
|
1868
|
+
const modulePath = stripViteModuleQuery(id);
|
|
1869
|
+
if (canonicalize(modulePath) !== canonicalize(middlewarePath)) return null;
|
|
1870
|
+
validateMiddlewareModuleExports(code, modulePath, middlewarePath, isProxyFile(middlewarePath));
|
|
1871
|
+
return null;
|
|
1872
|
+
}
|
|
1873
|
+
},
|
|
1861
1874
|
{
|
|
1862
1875
|
name: "vinext:validate-page-exports",
|
|
1863
1876
|
transform: {
|
|
@@ -2048,7 +2061,9 @@ function vinext(options = {}) {
|
|
|
2048
2061
|
const varName = specifier.local?.name;
|
|
2049
2062
|
if (!varName) continue;
|
|
2050
2063
|
const dir = path.dirname(id);
|
|
2051
|
-
const
|
|
2064
|
+
const resolvedImage = importPath.startsWith(".") ? path.resolve(dir, importPath) : (await this.resolve(importPath, id, { skipSelf: true }))?.id;
|
|
2065
|
+
if (!resolvedImage) continue;
|
|
2066
|
+
const absImagePath = normalizePathSeparators(resolvedImage.split("?", 1)[0]);
|
|
2052
2067
|
if (!fs.existsSync(absImagePath)) continue;
|
|
2053
2068
|
imageImports.add(absImagePath);
|
|
2054
2069
|
const urlVar = `__vinext_img_url_${varName}`;
|