vinext 1.3.1 → 1.4.1
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 +25 -22
- package/THIRD_PARTY_LICENSES.md +47 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -2
- package/dist/build/prerender.js +4 -3
- package/dist/build/report.d.ts +0 -14
- package/dist/build/report.js +1 -51
- package/dist/check.js +4 -7
- package/dist/cli.js +3 -0
- package/dist/client/dev-error-overlay-store.d.ts +1 -0
- package/dist/client/dev-error-overlay.d.ts +2 -0
- package/dist/client/dev-error-overlay.js +20 -4
- package/dist/client/navigation-runtime.d.ts +13 -1
- package/dist/client/navigation-runtime.js +1 -1
- package/dist/config/config-matchers.js +2 -0
- package/dist/config/destination-params.d.ts +2 -1
- package/dist/config/destination-params.js +52 -2
- package/dist/config/next-config.d.ts +25 -0
- package/dist/config/next-config.js +82 -4
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/dbcs-codec.js +327 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/dbcs-data.js +123 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/index.js +29 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/internal.js +134 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-codec.js +50 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-data-generated.js +455 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-data.js +147 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/big5-added.json.js +169 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp936.json.js +2584 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp949.json.js +2220 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp950.json.js +227 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/eucjp.json.js +425 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/gb18030-ranges.json.js +427 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/gbk-added.json.js +229 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/shiftjis.json.js +292 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/utf16.js +106 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/utf7.js +182 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/bom-handling.js +42 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/extend-node.js +147 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/index.js +94 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/streams.js +95 -0
- package/dist/deps/.pnpm/safer-buffer@2.1.2/deps/safer-buffer/safer.js +45 -0
- package/dist/entries/app-rsc-entry.js +17 -49
- package/dist/entries/app-rsc-manifest.js +3 -4
- package/dist/entries/app-ssr-entry.js +1 -0
- package/dist/entries/pages-server-entry.js +36 -9
- package/dist/index.js +112 -90
- package/dist/init-cloudflare.d.ts +1 -3
- package/dist/init-cloudflare.js +10 -48
- package/dist/init-platform.d.ts +2 -0
- package/dist/init-platform.js +4 -0
- package/dist/plugins/extensionless-dynamic-import.js +6 -2
- package/dist/plugins/next-intl-catalog.d.ts +12 -0
- package/dist/plugins/next-intl-catalog.js +85 -0
- package/dist/plugins/pages-node-externals.d.ts +1 -0
- package/dist/plugins/pages-node-externals.js +1 -1
- package/dist/plugins/strip-server-exports.js +2 -1
- package/dist/plugins/use-cache-callable.d.ts +1 -1
- package/dist/plugins/use-cache-callable.js +136 -94
- package/dist/routing/app-route-graph.d.ts +6 -0
- package/dist/routing/app-route-graph.js +9 -1
- package/dist/server/api-handler.js +21 -5
- package/dist/server/app-bfcache-identity.js +1 -1
- package/dist/server/app-browser-entry.js +86 -66
- package/dist/server/app-browser-history-controller.d.ts +5 -4
- package/dist/server/app-browser-history-controller.js +93 -15
- package/dist/server/app-browser-navigation-controller.d.ts +2 -2
- package/dist/server/app-browser-navigation-controller.js +1 -2
- package/dist/server/app-browser-rsc-redirect.js +7 -7
- package/dist/server/app-browser-server-action-client.d.ts +2 -0
- package/dist/server/app-browser-server-action-client.js +5 -4
- package/dist/server/app-browser-state.d.ts +2 -4
- package/dist/server/app-browser-state.js +9 -4
- package/dist/server/app-browser-supplemental-refresh.js +16 -1
- package/dist/server/app-browser-visible-commit.d.ts +1 -1
- package/dist/server/app-browser-visible-commit.js +4 -14
- package/dist/server/app-elements-wire.d.ts +6 -38
- package/dist/server/app-elements-wire.js +4 -41
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-history-state.d.ts +2 -2
- package/dist/server/app-history-state.js +5 -2
- package/dist/server/app-mounted-layouts.d.ts +21 -0
- package/dist/server/app-mounted-layouts.js +67 -0
- package/dist/server/app-optimistic-routing.d.ts +19 -1
- package/dist/server/app-optimistic-routing.js +43 -4
- package/dist/server/app-page-boundary-render.js +10 -14
- package/dist/server/app-page-boundary.js +2 -2
- package/dist/server/app-page-cache-finalizer.d.ts +12 -1
- package/dist/server/app-page-cache-finalizer.js +70 -29
- package/dist/server/app-page-cache.d.ts +13 -1
- package/dist/server/app-page-cache.js +31 -9
- package/dist/server/app-page-dispatch.d.ts +5 -11
- package/dist/server/app-page-dispatch.js +84 -155
- package/dist/server/app-page-element-builder.d.ts +2 -2
- package/dist/server/app-page-element-builder.js +13 -12
- package/dist/server/app-page-execution.d.ts +17 -52
- package/dist/server/app-page-execution.js +102 -95
- package/dist/server/app-page-head.d.ts +13 -0
- package/dist/server/app-page-head.js +44 -16
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +1 -0
- package/dist/server/app-page-http-access-fallback-metadata.js +2 -2
- package/dist/server/app-page-layout-gate.d.ts +35 -0
- package/dist/server/app-page-layout-gate.js +50 -0
- package/dist/server/app-page-params.d.ts +0 -1
- package/dist/server/app-page-params.js +1 -14
- package/dist/server/app-page-probe.d.ts +3 -21
- package/dist/server/app-page-probe.js +4 -37
- package/dist/server/app-page-render.d.ts +2 -13
- package/dist/server/app-page-render.js +103 -234
- package/dist/server/app-page-request.d.ts +1 -3
- package/dist/server/app-page-request.js +1 -1
- package/dist/server/app-page-response.js +3 -3
- package/dist/server/app-page-route-wiring.d.ts +13 -6
- package/dist/server/app-page-route-wiring.js +86 -63
- package/dist/server/app-page-rsc-render-status.d.ts +27 -1
- package/dist/server/app-page-rsc-render-status.js +121 -13
- package/dist/server/app-page-stream.d.ts +12 -8
- package/dist/server/app-page-stream.js +4 -3
- package/dist/server/app-pages-bridge.d.ts +4 -0
- package/dist/server/app-pages-bridge.js +7 -3
- package/dist/server/app-render-dependency.d.ts +11 -4
- package/dist/server/app-render-dependency.js +86 -38
- package/dist/server/app-request-stage-dispatch.js +1 -1
- package/dist/server/app-request-stage-independent-entry.js +1 -1
- package/dist/server/app-route-handler-cache.js +2 -2
- package/dist/server/app-route-handler-dispatch.js +14 -9
- package/dist/server/app-route-handler-execution.js +11 -5
- package/dist/server/app-route-handler-policy.d.ts +1 -1
- package/dist/server/app-route-handler-policy.js +3 -3
- package/dist/server/app-route-handler-response.js +1 -1
- package/dist/server/app-route-handler-runtime.d.ts +1 -1
- package/dist/server/app-route-handler-runtime.js +28 -11
- package/dist/server/app-router-entry.js +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +12 -12
- package/dist/server/app-rsc-cache-busting.js +31 -72
- package/dist/server/app-rsc-error-handler.d.ts +2 -1
- package/dist/server/app-rsc-error-handler.js +10 -2
- package/dist/server/app-rsc-errors.d.ts +8 -0
- package/dist/server/app-rsc-errors.js +11 -1
- package/dist/server/app-rsc-handler.d.ts +5 -5
- package/dist/server/app-rsc-handler.js +80 -83
- package/dist/server/app-rsc-request-normalization.d.ts +10 -16
- package/dist/server/app-rsc-request-normalization.js +12 -18
- package/dist/server/app-rsc-response-finalizer.js +2 -2
- package/dist/server/app-rsc-response-stage.js +9 -15
- package/dist/server/app-server-action-execution.d.ts +3 -1
- package/dist/server/app-server-action-execution.js +15 -8
- package/dist/server/app-ssr-entry.d.ts +8 -0
- package/dist/server/app-ssr-entry.js +22 -16
- package/dist/server/app-ssr-stream.js +1 -1
- package/dist/server/app-visited-response-cache.d.ts +36 -1
- package/dist/server/app-visited-response-cache.js +46 -5
- package/dist/server/app-worker-stages.d.ts +37 -6
- package/dist/server/app-worker-stages.js +81 -9
- package/dist/server/artifact-compatibility.d.ts +0 -1
- package/dist/server/artifact-compatibility.js +1 -10
- package/dist/server/bfcache-identity.d.ts +7 -0
- package/dist/server/bfcache-identity.js +10 -1
- package/dist/server/cache-proof.d.ts +1 -115
- package/dist/server/cache-proof.js +1 -544
- package/dist/server/cacheability-manifest.js +1 -2
- package/dist/server/cacheability-request.js +13 -8
- package/dist/server/dev-origin-check.d.ts +2 -1
- package/dist/server/dev-origin-check.js +2 -1
- package/dist/server/dev-server.js +6 -4
- package/dist/server/headers.d.ts +6 -3
- package/dist/server/headers.js +9 -5
- package/dist/server/image-optimization.d.ts +5 -0
- package/dist/server/image-optimization.js +6 -1
- package/dist/server/isr-cache.d.ts +8 -2
- package/dist/server/isr-cache.js +30 -2
- package/dist/server/metadata-route-response.js +32 -15
- package/dist/server/middleware-matcher.js +19 -6
- package/dist/server/middleware-runtime.js +6 -2
- package/dist/server/multi-stage.d.ts +57 -12
- package/dist/server/multi-stage.js +13 -1
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/pages-api-route.js +28 -19
- package/dist/server/pages-media-type.d.ts +21 -1
- package/dist/server/pages-media-type.js +69 -5
- package/dist/server/pages-node-compat.d.ts +1 -1
- package/dist/server/pages-node-compat.js +54 -27
- package/dist/server/pages-page-data.js +2 -1
- package/dist/server/pages-page-handler.js +28 -26
- package/dist/server/pages-page-response.d.ts +9 -0
- package/dist/server/pages-page-response.js +18 -4
- package/dist/server/pages-request-pipeline.d.ts +8 -0
- package/dist/server/pages-request-pipeline.js +2 -2
- package/dist/server/pages-request-stage-entry.js +36 -14
- package/dist/server/pages-response-stage-entry.js +9 -3
- package/dist/server/pages-router-entry.js +3 -2
- package/dist/server/prod-server.d.ts +2 -2
- package/dist/server/prod-server.js +47 -9
- package/dist/server/request-error-log.d.ts +9 -0
- package/dist/server/request-error-log.js +13 -0
- package/dist/server/request-pipeline.d.ts +15 -4
- package/dist/server/request-pipeline.js +43 -15
- package/dist/server/rsc-completion-metadata.js +3 -0
- package/dist/server/shared-cache-identity.d.ts +23 -0
- package/dist/server/shared-cache-identity.js +36 -0
- package/dist/server/static-file-cache.d.ts +9 -0
- package/dist/server/static-file-cache.js +13 -2
- package/dist/server/worker-stages.d.ts +16 -3
- package/dist/server/worker-stages.js +23 -4
- package/dist/shims/cache-handler.js +2 -2
- package/dist/shims/cache-request-state.d.ts +23 -26
- package/dist/shims/cache-request-state.js +22 -57
- package/dist/shims/cache-runtime.d.ts +3 -1
- package/dist/shims/cache-runtime.js +94 -48
- package/dist/shims/cache.d.ts +16 -10
- package/dist/shims/cache.js +47 -36
- package/dist/shims/cacheability-classification.d.ts +2 -0
- package/dist/shims/cdn-cache.d.ts +22 -5
- package/dist/shims/client-hook-error.d.ts +2 -0
- package/dist/shims/client-hook-error.js +16 -1
- package/dist/shims/client-page-root.js +2 -2
- package/dist/shims/dynamic.js +9 -6
- package/dist/shims/error-boundary.js +2 -2
- package/dist/shims/fetch-cache-state.d.ts +5 -1
- package/dist/shims/fetch-cache-state.js +1 -3
- package/dist/shims/fetch-cache.d.ts +2 -1
- package/dist/shims/fetch-cache.js +39 -25
- package/dist/shims/form.js +2 -2
- package/dist/shims/headers.d.ts +10 -24
- package/dist/shims/headers.js +22 -70
- package/dist/shims/internal/cache-context-accessor.d.ts +1 -1
- package/dist/shims/internal/navigation-untracked.js +1 -1
- package/dist/shims/link.js +8 -11
- package/dist/shims/metadata.d.ts +23 -21
- package/dist/shims/metadata.js +62 -24
- package/dist/shims/navigation-server.js +1 -1
- package/dist/shims/navigation.d.ts +74 -7
- package/dist/shims/navigation.js +184 -31
- package/dist/shims/navigation.react-server.js +2 -2
- package/dist/shims/request-state-types.d.ts +3 -2
- package/dist/shims/slot.d.ts +16 -0
- package/dist/shims/slot.js +44 -9
- package/dist/shims/unified-request-context.d.ts +7 -1
- package/dist/shims/unified-request-context.js +3 -3
- package/dist/utils/cache-control-metadata.d.ts +5 -0
- package/dist/utils/cache-control-metadata.js +9 -1
- package/dist/utils/cache-life-profiles.d.ts +33 -0
- package/dist/utils/cache-life-profiles.js +111 -0
- package/dist/utils/middleware-request-headers.d.ts +14 -3
- package/dist/utils/middleware-request-headers.js +54 -7
- package/dist/utils/project.d.ts +2 -2
- package/dist/utils/project.js +3 -16
- package/dist/utils/regex.d.ts +5 -0
- package/dist/utils/regex.js +11 -1
- package/dist/utils/text-stream.d.ts +10 -5
- package/dist/utils/text-stream.js +6 -6
- package/package.json +2 -1
- package/dist/build/layout-classification-types.d.ts +0 -60
- package/dist/build/layout-classification-types.js +0 -1
- package/dist/build/layout-classification.d.ts +0 -62
- package/dist/build/layout-classification.js +0 -98
- package/dist/build/route-classification-injector.d.ts +0 -33
- package/dist/build/route-classification-injector.js +0 -59
- package/dist/build/route-classification-manifest.d.ts +0 -54
- package/dist/build/route-classification-manifest.js +0 -143
- package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -11
- package/dist/server/app-browser-client-reuse-manifest.js +0 -101
- package/dist/server/app-layout-param-observation.d.ts +0 -42
- package/dist/server/app-layout-param-observation.js +0 -168
- package/dist/server/client-reuse-manifest.d.ts +0 -103
- package/dist/server/client-reuse-manifest.js +0 -209
- package/dist/server/skip-cache-proof.d.ts +0 -60
- package/dist/server/skip-cache-proof.js +0 -168
- package/dist/server/static-layout-client-reuse-proof.d.ts +0 -14
- package/dist/server/static-layout-client-reuse-proof.js +0 -33
- package/dist/utils/sorted-array.d.ts +0 -8
- package/dist/utils/sorted-array.js +0 -20
|
@@ -21,6 +21,7 @@ const _pagesI18nPath = resolveEntryPath("../server/pages-i18n.js", import.meta.u
|
|
|
21
21
|
const _pagesDataRoutePath = resolveEntryPath("../server/pages-data-route.js", import.meta.url);
|
|
22
22
|
const _pagesDefault404Path = resolveEntryPath("../server/pages-default-404.js", import.meta.url);
|
|
23
23
|
const _pagesApiRoutePath = resolveEntryPath("../server/pages-api-route.js", import.meta.url);
|
|
24
|
+
const _requestErrorLogPath = resolveEntryPath("../server/request-error-log.js", import.meta.url);
|
|
24
25
|
const _serverGlobalsPath = resolveEntryPath("../server/server-globals.js", import.meta.url);
|
|
25
26
|
const _queryUtilsPath = resolveEntryPath("../utils/query.js", import.meta.url);
|
|
26
27
|
const _pagesPageHandlerPath = resolveEntryPath("../server/pages-page-handler.js", import.meta.url);
|
|
@@ -29,11 +30,34 @@ const _isrCachePath = resolveEntryPath("../server/isr-cache.js", import.meta.url
|
|
|
29
30
|
const _revalidationRequestPath = resolveEntryPath("../server/revalidation-request.js", import.meta.url);
|
|
30
31
|
const _instrumentationRuntimePath = resolveEntryPath("../server/instrumentation-runtime.js", import.meta.url);
|
|
31
32
|
const _isolateSharedPromisePath = resolveEntryPath("../server/isolate-shared-promise.js", import.meta.url);
|
|
32
|
-
|
|
33
|
+
const GET_INITIAL_PROPS_NAME = /\bgetInitialProps\b/;
|
|
34
|
+
/**
|
|
35
|
+
* Whether a module's source names getInitialProps. Next.js serves a page
|
|
36
|
+
* without data functions as one static file only when neither it nor a
|
|
37
|
+
* custom _app defines getInitialProps, which it checks on the loaded modules:
|
|
38
|
+
* https://github.com/vercel/next.js/blob/canary/packages/next/src/build/utils.ts
|
|
39
|
+
* https://github.com/vercel/next.js/blob/canary/packages/next/src/build/index.ts
|
|
40
|
+
* The source is all the request stage has. A getInitialProps an imported
|
|
41
|
+
* wrapper attaches is only seen once the page renders.
|
|
42
|
+
*/
|
|
43
|
+
async function namesGetInitialProps(filePath) {
|
|
44
|
+
if (filePath === null) return false;
|
|
45
|
+
return GET_INITIAL_PROPS_NAME.test(await readFile(filePath, "utf8"));
|
|
46
|
+
}
|
|
47
|
+
async function getPagesRouteData(filePath, appRunsInitialProps) {
|
|
33
48
|
const source = await readFile(filePath, "utf8");
|
|
34
|
-
if (hasExportedName(source, "getStaticProps")) return
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
if (hasExportedName(source, "getStaticProps")) return {
|
|
50
|
+
dataKind: "static",
|
|
51
|
+
runsInitialProps: false
|
|
52
|
+
};
|
|
53
|
+
if (hasExportedName(source, "getServerSideProps")) return {
|
|
54
|
+
dataKind: "server",
|
|
55
|
+
runsInitialProps: false
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
dataKind: "none",
|
|
59
|
+
runsInitialProps: appRunsInitialProps || GET_INITIAL_PROPS_NAME.test(source)
|
|
60
|
+
};
|
|
37
61
|
}
|
|
38
62
|
/**
|
|
39
63
|
* Generate the request-only Pages Worker entry used by a multi-stage output.
|
|
@@ -43,9 +67,10 @@ async function generatePagesRequestEntry(pagesDir, nextConfig, fileMatcher, midd
|
|
|
43
67
|
const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
44
68
|
const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
45
69
|
const hasRequestAwareDocument = findFileWithExts(pagesDir, "_document", fileMatcher) !== null;
|
|
70
|
+
const appRunsInitialProps = await namesGetInitialProps(findFileWithExts(pagesDir, "_app", fileMatcher));
|
|
46
71
|
const pageRouteEntries = await Promise.all(pageRoutes.map(async (route) => {
|
|
47
|
-
const dataKind = await
|
|
48
|
-
return ` { pattern: ${JSON.stringify(route.pattern)}, patternParts: ${JSON.stringify(route.patternParts)}, isDynamic: ${route.isDynamic}, params: ${JSON.stringify(route.params)}, dataKind: ${JSON.stringify(dataKind)} }`;
|
|
72
|
+
const { dataKind, runsInitialProps } = await getPagesRouteData(route.filePath, appRunsInitialProps);
|
|
73
|
+
return ` { pattern: ${JSON.stringify(route.pattern)}, patternParts: ${JSON.stringify(route.patternParts)}, isDynamic: ${route.isDynamic}, params: ${JSON.stringify(route.params)}, dataKind: ${JSON.stringify(dataKind)}, runsInitialProps: ${runsInitialProps} }`;
|
|
49
74
|
}));
|
|
50
75
|
const apiRouteEntries = apiRoutes.map((route) => ` { pattern: ${JSON.stringify(route.pattern)}, patternParts: ${JSON.stringify(route.patternParts)}, isDynamic: ${route.isDynamic}, params: ${JSON.stringify(route.params)} }`);
|
|
51
76
|
const i18nConfigJson = nextConfig?.i18n ? JSON.stringify({
|
|
@@ -210,9 +235,10 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
|
|
|
210
235
|
const pageImportInitializers = pageRoutes.map((r, i) => `page_${i} = await import(${JSON.stringify(r.filePath)});`);
|
|
211
236
|
const apiImports = apiRoutes.map((r, i) => instrumentationPath ? `let api_${i};` : `import * as api_${i} from ${JSON.stringify(r.filePath)};`);
|
|
212
237
|
const apiImportInitializers = apiRoutes.map((r, i) => `api_${i} = await import(${JSON.stringify(r.filePath)});`);
|
|
238
|
+
const appRunsInitialProps = await namesGetInitialProps(findFileWithExts(pagesDir, "_app", fileMatcher));
|
|
213
239
|
const pageRouteEntries = await Promise.all(pageRoutes.map(async (r, i) => {
|
|
214
|
-
const dataKind = await
|
|
215
|
-
return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: ${instrumentationPath ? "null" : `page_${i}`}, filePath: ${JSON.stringify(r.filePath)}, dataKind: ${JSON.stringify(dataKind)} }`;
|
|
240
|
+
const { dataKind, runsInitialProps } = await getPagesRouteData(r.filePath, appRunsInitialProps);
|
|
241
|
+
return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: ${instrumentationPath ? "null" : `page_${i}`}, filePath: ${JSON.stringify(r.filePath)}, dataKind: ${JSON.stringify(dataKind)}, runsInitialProps: ${runsInitialProps} }`;
|
|
216
242
|
}));
|
|
217
243
|
const apiRouteEntries = apiRoutes.map((r, i) => ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: ${instrumentationPath ? "null" : `api_${i}`} }`);
|
|
218
244
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
@@ -345,6 +371,7 @@ import { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSO
|
|
|
345
371
|
import { reportRequestError as _reportRequestError } from "vinext/instrumentation";
|
|
346
372
|
import { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};
|
|
347
373
|
import { handlePagesApiRoute as __handlePagesApiRoute } from ${JSON.stringify(_pagesApiRoutePath)};
|
|
374
|
+
import { logRequestError as __logRequestError } from ${JSON.stringify(_requestErrorLogPath)};
|
|
348
375
|
import { normalizePagesDataRequest as __normalizePagesDataRequest, shouldAddTrailingSlashToPagesDataPath as __shouldAddTrailingSlashToPagesDataPath, buildNextDataNotFoundResponse as __buildNextDataNotFoundResponse } from ${JSON.stringify(_pagesDataRoutePath)};
|
|
349
376
|
import { buildDefaultPagesNotFoundResponse as __buildDefaultPagesNotFoundResponse } from ${JSON.stringify(_pagesDefault404Path)};
|
|
350
377
|
import { createPagesPageHandler as __createPagesPageHandler } from ${JSON.stringify(_pagesPageHandlerPath)};
|
|
@@ -593,7 +620,7 @@ export async function handleApiRoute(request, url, ctx, trustedRevalidateOrigin,
|
|
|
593
620
|
trustedRevalidateOrigin,
|
|
594
621
|
url,
|
|
595
622
|
reportRequestError(error, routePattern) {
|
|
596
|
-
|
|
623
|
+
__logRequestError("[vinext] API error:", error);
|
|
597
624
|
return _reportRequestError(
|
|
598
625
|
error,
|
|
599
626
|
{ path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { getReactUpgradeDeps, reactUpgradeRequiredMessage } from "./utils/react-
|
|
|
11
11
|
import { resolvePluginReactPath } from "./utils/plugin-react-version.js";
|
|
12
12
|
import { loadDotenv } from "./config/dotenv.js";
|
|
13
13
|
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
|
|
14
|
+
import { serializeCacheLifeProfiles } from "./utils/cache-life-profiles.js";
|
|
14
15
|
import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
|
|
15
16
|
import { encodeMiddlewareRequestHeaders } from "./utils/middleware-request-headers.js";
|
|
16
17
|
import { hasBasePath, stripBasePath } from "./utils/base-path.js";
|
|
@@ -60,8 +61,6 @@ import { generateSsrEntry } from "./entries/app-ssr-entry.js";
|
|
|
60
61
|
import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VIRTUAL_CACHE_ADAPTERS, VIRTUAL_CDN_CACHE_ADAPTER, generateCacheAdaptersModule, generateCdnCacheAdapterModule } from "./cache/cache-adapters-virtual.js";
|
|
61
62
|
import { VIRTUAL_IMAGE_ADAPTERS, generateImageAdaptersModule } from "./image/image-adapters-virtual.js";
|
|
62
63
|
import { generateBrowserEntry, generateBrowserRouteManifestModule, toHashedRouteHandlerRoutes, toLinkPrefetchRoutes } from "./entries/app-browser-entry.js";
|
|
63
|
-
import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
|
|
64
|
-
import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
|
|
65
64
|
import { createRscScanGlobImportsPlugin, isRscScanGlobImportsAffected } from "./plugins/rsc-scan-glob-imports.js";
|
|
66
65
|
import { loadOrGenerateServerActionsEncryptionKey } from "./build/server-actions-encryption-key.js";
|
|
67
66
|
import { findOpenTelemetryPackages, mergeServerExternalPackages } from "./config/server-external-packages.js";
|
|
@@ -96,6 +95,7 @@ import { createRouteClientReferencesFallbackPlugin, createRscClientReferenceLoad
|
|
|
96
95
|
import { createRscReferenceValidationNormalizerPlugin } from "./plugins/rsc-reference-validation-normalizer.js";
|
|
97
96
|
import { createScanBuildCssPlugin } from "./plugins/scan-build-css.js";
|
|
98
97
|
import { createInstrumentationClientTransformPlugin, createInstrumentationServerTransformPlugin } from "./plugins/instrumentation-client.js";
|
|
98
|
+
import { createNextIntlCatalogPlugin } from "./plugins/next-intl-catalog.js";
|
|
99
99
|
import { createStyledJsxPlugin } from "./plugins/styled-jsx.js";
|
|
100
100
|
import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
|
|
101
101
|
import { isServerEnvironment } from "./plugins/environment.js";
|
|
@@ -155,7 +155,12 @@ const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
|
155
155
|
"react/jsx-runtime",
|
|
156
156
|
"react/jsx-dev-runtime"
|
|
157
157
|
]);
|
|
158
|
-
const PAGES_CLOUDFLARE_WORKER_OPTIONAL_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
158
|
+
const PAGES_CLOUDFLARE_WORKER_OPTIONAL_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
159
|
+
"use-sync-external-store/with-selector",
|
|
160
|
+
"vinext > @vitejs/plugin-rsc/react/rsc",
|
|
161
|
+
"vinext > @unpic/react",
|
|
162
|
+
"vinext > ipaddr.js"
|
|
163
|
+
]);
|
|
159
164
|
const APP_CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
160
165
|
"use-sync-external-store/shim",
|
|
161
166
|
"use-sync-external-store/shim/index.js",
|
|
@@ -499,6 +504,7 @@ function hasZeroOrOneAsterisk(value) {
|
|
|
499
504
|
}
|
|
500
505
|
function materializeTsconfigPathAliases(pathsConfig, baseUrl, projectRoot) {
|
|
501
506
|
const vite = {};
|
|
507
|
+
const viteExact = {};
|
|
502
508
|
const sass = [];
|
|
503
509
|
for (const [find, rawTargets] of Object.entries(pathsConfig)) {
|
|
504
510
|
const targets = Array.isArray(rawTargets) ? rawTargets.filter((value) => typeof value === "string") : typeof rawTargets === "string" ? [rawTargets] : [];
|
|
@@ -521,10 +527,11 @@ function materializeTsconfigPathAliases(pathsConfig, baseUrl, projectRoot) {
|
|
|
521
527
|
vite[aliasKey] = toViteAliasReplacement(path.resolve(baseUrl, targetDir), projectRoot);
|
|
522
528
|
continue;
|
|
523
529
|
}
|
|
524
|
-
|
|
530
|
+
viteExact[find] = toViteAliasReplacement(path.resolve(baseUrl, target), projectRoot);
|
|
525
531
|
}
|
|
526
532
|
return {
|
|
527
533
|
vite,
|
|
534
|
+
viteExact,
|
|
528
535
|
sass
|
|
529
536
|
};
|
|
530
537
|
}
|
|
@@ -561,6 +568,7 @@ function loadTsconfigPathAliases(configPath, projectRoot, seen = /* @__PURE__ */
|
|
|
561
568
|
const normalizedPath = tryRealpathSync(configPath) ?? configPath;
|
|
562
569
|
if (seen.has(normalizedPath)) return {
|
|
563
570
|
vite: {},
|
|
571
|
+
viteExact: {},
|
|
564
572
|
sass: []
|
|
565
573
|
};
|
|
566
574
|
seen.add(normalizedPath);
|
|
@@ -570,15 +578,18 @@ function loadTsconfigPathAliases(configPath, projectRoot, seen = /* @__PURE__ */
|
|
|
570
578
|
} catch {
|
|
571
579
|
return {
|
|
572
580
|
vite: {},
|
|
581
|
+
viteExact: {},
|
|
573
582
|
sass: []
|
|
574
583
|
};
|
|
575
584
|
}
|
|
576
585
|
if (!parsed) return {
|
|
577
586
|
vite: {},
|
|
587
|
+
viteExact: {},
|
|
578
588
|
sass: []
|
|
579
589
|
};
|
|
580
590
|
let aliases = {
|
|
581
591
|
vite: {},
|
|
592
|
+
viteExact: {},
|
|
582
593
|
sass: []
|
|
583
594
|
};
|
|
584
595
|
for (const extendsSpecifier of normalizeTsconfigExtends(parsed.extends)) {
|
|
@@ -590,6 +601,10 @@ function loadTsconfigPathAliases(configPath, projectRoot, seen = /* @__PURE__ */
|
|
|
590
601
|
...aliases.vite,
|
|
591
602
|
...parent.vite
|
|
592
603
|
},
|
|
604
|
+
viteExact: {
|
|
605
|
+
...aliases.viteExact,
|
|
606
|
+
...parent.viteExact
|
|
607
|
+
},
|
|
593
608
|
sass: mergeSassTsconfigPathAliases(aliases.sass, parent.sass)
|
|
594
609
|
};
|
|
595
610
|
}
|
|
@@ -604,6 +619,10 @@ function loadTsconfigPathAliases(configPath, projectRoot, seen = /* @__PURE__ */
|
|
|
604
619
|
...aliases.vite,
|
|
605
620
|
...own.vite
|
|
606
621
|
},
|
|
622
|
+
viteExact: {
|
|
623
|
+
...aliases.viteExact,
|
|
624
|
+
...own.viteExact
|
|
625
|
+
},
|
|
607
626
|
sass: mergeSassTsconfigPathAliases(aliases.sass, own.sass)
|
|
608
627
|
};
|
|
609
628
|
}
|
|
@@ -672,17 +691,20 @@ function resolveTsconfigAliases(projectRoot, configuredPath) {
|
|
|
672
691
|
if (_tsconfigAliasCache.has(cacheKey)) return _tsconfigAliasCache.get(cacheKey);
|
|
673
692
|
let aliases = {
|
|
674
693
|
vite: {},
|
|
694
|
+
viteExact: {},
|
|
675
695
|
sass: []
|
|
676
696
|
};
|
|
677
697
|
for (const candidate of configPath ? [configPath] : TSCONFIG_FILES.map((name) => path.join(projectRoot, name))) {
|
|
678
698
|
if (!fs.existsSync(candidate)) continue;
|
|
679
699
|
const materialized = loadTsconfigPathAliases(candidate, projectRoot);
|
|
680
700
|
aliases = {
|
|
681
|
-
|
|
682
|
-
|
|
701
|
+
...materialized,
|
|
702
|
+
vite: sortTsconfigAliasesBySpecificity(materialized.vite)
|
|
683
703
|
};
|
|
684
704
|
break;
|
|
685
705
|
}
|
|
706
|
+
aliases.vite = Object.fromEntries(Object.entries(aliases.vite).filter(([find]) => !_reactServerShims.has(find)));
|
|
707
|
+
aliases.viteExact = Object.fromEntries(Object.entries(aliases.viteExact).filter(([find]) => !_reactServerShims.has(find)));
|
|
686
708
|
_tsconfigAliasCache.set(cacheKey, aliases);
|
|
687
709
|
return aliases;
|
|
688
710
|
}
|
|
@@ -726,20 +748,38 @@ const tsconfigAliasCustomResolver = async function(updatedId, importer, options)
|
|
|
726
748
|
skipSelf: true
|
|
727
749
|
}) ?? { id: updatedId };
|
|
728
750
|
};
|
|
751
|
+
function aliasFindMatches(find, id) {
|
|
752
|
+
if (typeof find === "string") return id === find || id.startsWith(`${find}/`);
|
|
753
|
+
const { lastIndex } = find;
|
|
754
|
+
find.lastIndex = 0;
|
|
755
|
+
const matches = find.test(id);
|
|
756
|
+
find.lastIndex = lastIndex;
|
|
757
|
+
return matches;
|
|
758
|
+
}
|
|
729
759
|
/**
|
|
730
760
|
* Convert the merged alias map into Vite alias entries, attaching the
|
|
731
761
|
* stylesheet-scoping resolver to entries that came from tsconfig `paths`.
|
|
732
762
|
* Array order preserves the map's first-match ordering.
|
|
763
|
+
*
|
|
764
|
+
* Exact tsconfig keys come first as anchored RegExps: a string `find` would
|
|
765
|
+
* also match paths below the key, so `"@acme/pkg": ["./src/index.ts"]` would
|
|
766
|
+
* rewrite `@acme/pkg/runtime` to `./src/index.ts/runtime`. TypeScript and
|
|
767
|
+
* Next.js match such keys only against the exact specifier and prefer them over
|
|
768
|
+
* `*` patterns.
|
|
733
769
|
*/
|
|
734
|
-
function buildResolveAliasEntries(aliasMap, tsconfigPathAliases, explicitAliases) {
|
|
735
|
-
return Object.entries(
|
|
770
|
+
function buildResolveAliasEntries(aliasMap, tsconfigPathAliases, tsconfigExactPathAliases, explicitAliases) {
|
|
771
|
+
return [...Object.entries(tsconfigExactPathAliases).filter(([find]) => !Object.hasOwn(explicitAliases, find)).map(([find, replacement]) => ({
|
|
772
|
+
find: new RegExp(`^${escapeRegExp(find)}$`),
|
|
773
|
+
replacement,
|
|
774
|
+
customResolver: tsconfigAliasCustomResolver
|
|
775
|
+
})), ...Object.entries(aliasMap).map(([find, replacement]) => Object.hasOwn(tsconfigPathAliases, find) && !Object.hasOwn(explicitAliases, find) ? {
|
|
736
776
|
find,
|
|
737
777
|
replacement,
|
|
738
778
|
customResolver: tsconfigAliasCustomResolver
|
|
739
779
|
} : {
|
|
740
780
|
find,
|
|
741
781
|
replacement
|
|
742
|
-
});
|
|
782
|
+
})];
|
|
743
783
|
}
|
|
744
784
|
const ALIAS_CUSTOM_RESOLVER_DEPRECATION_RE = /`resolve\.alias` contains an alias with `customResolver` option/;
|
|
745
785
|
const VINEXT_FILTERED_ALIAS_DEPRECATION_WARN = Symbol.for("vinext.filteredAliasDeprecationWarn");
|
|
@@ -973,6 +1013,7 @@ function vinext(options = {}) {
|
|
|
973
1013
|
let resolvedServerExternalPackages = [];
|
|
974
1014
|
let registerNodeOpenTelemetryLoader = false;
|
|
975
1015
|
let pagesTsconfigAliases = {};
|
|
1016
|
+
let pagesTsconfigExactAliases = {};
|
|
976
1017
|
let pagesBundledPackages = /* @__PURE__ */ new Set();
|
|
977
1018
|
let isServeCommand = false;
|
|
978
1019
|
let buildEmptyOutDir;
|
|
@@ -1006,7 +1047,6 @@ function vinext(options = {}) {
|
|
|
1006
1047
|
const devForwardedMiddlewareContextKey = randomBytes(32).toString("hex");
|
|
1007
1048
|
let previewBuildCredentials;
|
|
1008
1049
|
const sassComposesLoader = createSassAwareFileSystemLoader();
|
|
1009
|
-
const rscClassificationManifests = /* @__PURE__ */ new Map();
|
|
1010
1050
|
let rscActionOwnerRoutes = null;
|
|
1011
1051
|
let rscActionOwnerSharedRoots = [];
|
|
1012
1052
|
let clientReferenceRoutes = null;
|
|
@@ -1027,6 +1067,7 @@ function vinext(options = {}) {
|
|
|
1027
1067
|
const shimsDir = path.resolve(__dirname, "shims");
|
|
1028
1068
|
const nextImageAliasTarget = toSlash(path.join(shimsDir, "image"));
|
|
1029
1069
|
const nextImageAliasTargetRE = new RegExp(`^${nextImageAliasTarget.split("/").map(escapeRegExp).join("[\\\\/]")}$`);
|
|
1070
|
+
let nextImageAliasedByUser = false;
|
|
1030
1071
|
const canonicalize = (p) => toSlash(tryRealpathSync(p) ?? p);
|
|
1031
1072
|
const pageTransformCanonicalPaths = /* @__PURE__ */ new Map();
|
|
1032
1073
|
const canonicalizePageTransformPath = (modulePath) => {
|
|
@@ -1041,11 +1082,6 @@ function vinext(options = {}) {
|
|
|
1041
1082
|
const relativePath = fileMatcher.stripExtension(canonicalId.slice(canonicalPagesDir.length));
|
|
1042
1083
|
return relativePath === "/api" || relativePath.startsWith("/api/");
|
|
1043
1084
|
};
|
|
1044
|
-
const dynamicShimPaths = new Set([
|
|
1045
|
-
resolveShimModulePath(shimsDir, "headers"),
|
|
1046
|
-
resolveShimModulePath(shimsDir, "server"),
|
|
1047
|
-
resolveShimModulePath(shimsDir, "cache")
|
|
1048
|
-
].map(canonicalize));
|
|
1049
1085
|
let nextShimMap = {};
|
|
1050
1086
|
let shimOptimizeDepsExclude = VINEXT_OPTIMIZE_DEPS_EXCLUDE;
|
|
1051
1087
|
const createShimRequirePlugin = () => esmExternalRequirePlugin({ external: [...shimOptimizeDepsExclude] });
|
|
@@ -1115,14 +1151,14 @@ function vinext(options = {}) {
|
|
|
1115
1151
|
rscPluginPromise = rscImport.then(async (mod) => {
|
|
1116
1152
|
const rsc = mod.default;
|
|
1117
1153
|
const plugins = rsc(rscPluginOptions);
|
|
1118
|
-
const
|
|
1154
|
+
const useCachePlugins = await createUseCacheCallablePlugin({
|
|
1119
1155
|
projectRoot: earlyBaseDir,
|
|
1120
1156
|
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href,
|
|
1121
1157
|
getEncryptionKey: () => serverActionsEncryptionKey
|
|
1122
1158
|
});
|
|
1123
1159
|
const useServerIndex = plugins.findIndex((plugin) => plugin.name === "rsc:use-server");
|
|
1124
1160
|
if (useServerIndex === -1) throw new Error("vinext: Failed to locate @vitejs/plugin-rsc use-server plugin.");
|
|
1125
|
-
plugins.splice(useServerIndex, 0,
|
|
1161
|
+
plugins.splice(useServerIndex, 0, ...useCachePlugins);
|
|
1126
1162
|
return plugins.map(scopeRscPlugin);
|
|
1127
1163
|
}).catch((cause) => {
|
|
1128
1164
|
throw new Error("vinext: Failed to load @vitejs/plugin-rsc.", { cause });
|
|
@@ -1338,6 +1374,29 @@ function vinext(options = {}) {
|
|
|
1338
1374
|
});
|
|
1339
1375
|
const plugins = [
|
|
1340
1376
|
buildLifecyclePlugins[0],
|
|
1377
|
+
{
|
|
1378
|
+
name: "vinext:dev-origin-check",
|
|
1379
|
+
apply: "serve",
|
|
1380
|
+
enforce: "pre",
|
|
1381
|
+
configureServer(server) {
|
|
1382
|
+
server.middlewares.use((req, res, next) => {
|
|
1383
|
+
const blockReason = validateDevRequest({
|
|
1384
|
+
origin: req.headers.origin,
|
|
1385
|
+
host: req.headers.host,
|
|
1386
|
+
"x-forwarded-host": req.headers["x-forwarded-host"],
|
|
1387
|
+
"sec-fetch-site": req.headers["sec-fetch-site"],
|
|
1388
|
+
"sec-fetch-mode": req.headers["sec-fetch-mode"]
|
|
1389
|
+
}, nextConfig?.allowedDevOrigins);
|
|
1390
|
+
if (blockReason) {
|
|
1391
|
+
console.warn(`[vinext] Blocked dev request: ${blockReason} (${req.url})`);
|
|
1392
|
+
res.writeHead(403, { "Content-Type": "text/plain" });
|
|
1393
|
+
res.end("Forbidden");
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
next();
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
},
|
|
1341
1400
|
createStyledJsxPlugin(earlyBaseDir),
|
|
1342
1401
|
mdxProxyPlugin,
|
|
1343
1402
|
reactPluginPromise,
|
|
@@ -1401,6 +1460,7 @@ function vinext(options = {}) {
|
|
|
1401
1460
|
getPagesDir: () => hasPagesDir ? pagesDir : null,
|
|
1402
1461
|
getAliases: () => nextConfig?.aliases ?? {},
|
|
1403
1462
|
getTsconfigAliases: () => pagesTsconfigAliases,
|
|
1463
|
+
getTsconfigExactAliases: () => pagesTsconfigExactAliases,
|
|
1404
1464
|
getBundledPackages: () => pagesBundledPackages,
|
|
1405
1465
|
isEnabled: () => !hasCloudflarePlugin && !hasNitroPlugin
|
|
1406
1466
|
}),
|
|
@@ -1433,6 +1493,7 @@ function vinext(options = {}) {
|
|
|
1433
1493
|
buildLifecycleEnabled = env.command === "build" && !internalOptions.__skipBuildLifecycle && (buildLifecycleInvocation !== void 0 || claimViteCliBuildInvocation());
|
|
1434
1494
|
const userResolve = config.resolve;
|
|
1435
1495
|
let tsconfigPathAliases = {};
|
|
1496
|
+
let tsconfigExactPathAliases = {};
|
|
1436
1497
|
let sassTsconfigPathAliases = [];
|
|
1437
1498
|
const swcHelpersAlias = resolveSwcHelpersAlias(root);
|
|
1438
1499
|
const mode = env?.mode ?? "development";
|
|
@@ -1504,10 +1565,12 @@ function vinext(options = {}) {
|
|
|
1504
1565
|
const configuredTsconfigPath = isUnknownRecord(nextConfig.typescript) ? typeof nextConfig.typescript.tsconfigPath === "string" ? nextConfig.typescript.tsconfigPath : void 0 : void 0;
|
|
1505
1566
|
const resolvedTsconfigAliases = resolveTsconfigAliases(root, configuredTsconfigPath);
|
|
1506
1567
|
tsconfigPathAliases = resolvedTsconfigAliases.vite;
|
|
1568
|
+
tsconfigExactPathAliases = resolvedTsconfigAliases.viteExact;
|
|
1507
1569
|
pagesTsconfigAliases = tsconfigPathAliases;
|
|
1570
|
+
pagesTsconfigExactAliases = tsconfigExactPathAliases;
|
|
1508
1571
|
sassTsconfigPathAliases = resolvedTsconfigAliases.sass;
|
|
1509
1572
|
const shouldAutoEnableNativeTsconfigPaths = userResolve?.tsconfigPaths === void 0 && configuredTsconfigPath === void 0;
|
|
1510
|
-
if (Object.keys(tsconfigPathAliases).length > 0) config.customLogger = suppressAliasCustomResolverDeprecationWarning(config.customLogger ?? createLogger(config.logLevel, { allowClearScreen: config.clearScreen }));
|
|
1573
|
+
if (Object.keys(tsconfigPathAliases).length > 0 || Object.keys(tsconfigExactPathAliases).length > 0) config.customLogger = suppressAliasCustomResolverDeprecationWarning(config.customLogger ?? createLogger(config.logLevel, { allowClearScreen: config.clearScreen }));
|
|
1511
1574
|
if (rscCompatibilityId === void 0) {
|
|
1512
1575
|
const sharedRscCompatibilityId = process.env.__VINEXT_SHARED_RSC_COMPATIBILITY_ID;
|
|
1513
1576
|
rscCompatibilityId = sharedRscCompatibilityId && sharedRscCompatibilityId.length > 0 ? sharedRscCompatibilityId : createRscCompatibilityId(nextConfig);
|
|
@@ -1556,6 +1619,7 @@ function vinext(options = {}) {
|
|
|
1556
1619
|
defines["process.env.__VINEXT_TRAILING_SLASH"] = JSON.stringify(nextConfig.trailingSlash ? "true" : "false");
|
|
1557
1620
|
defines["process.env.__VINEXT_MANUAL_TRAILING_SLASH"] = JSON.stringify(nextConfig.skipTrailingSlashRedirect ? "true" : "false");
|
|
1558
1621
|
defines["process.env.__NEXT_CONFIG_OUTPUT"] = JSON.stringify(nextConfig.output ?? "");
|
|
1622
|
+
defines["process.env.__VINEXT_CACHE_LIFE_PROFILES"] = JSON.stringify(serializeCacheLifeProfiles(nextConfig.cacheLife));
|
|
1559
1623
|
defines["process.env.__VINEXT_IMAGE_REMOTE_PATTERNS"] = JSON.stringify(JSON.stringify(nextConfig.images?.remotePatterns ?? []));
|
|
1560
1624
|
defines["process.env.__VINEXT_IMAGE_DOMAINS"] = JSON.stringify(JSON.stringify(nextConfig.images?.domains ?? []));
|
|
1561
1625
|
{
|
|
@@ -1586,6 +1650,7 @@ function vinext(options = {}) {
|
|
|
1586
1650
|
defines["process.env.__NEXT_VERSION"] = JSON.stringify(getVinextVersion());
|
|
1587
1651
|
defines["process.env.__NEXT_APP_SHELLS"] = JSON.stringify(nextConfig.appShells);
|
|
1588
1652
|
defines["process.env.__NEXT_CACHE_COMPONENTS"] = JSON.stringify(nextConfig.cacheComponents ?? false);
|
|
1653
|
+
defines["process.env.__NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS"] = JSON.stringify(nextConfig.cachedNavigations);
|
|
1589
1654
|
for (const [key, value] of Object.entries(nextConfig.compilerDefine)) {
|
|
1590
1655
|
if (key in defines || key === "process.browser") throw new Error(`The \`compiler.define\` option is configured to replace the \`${key}\` variable. This variable is either part of a built-in or is already configured.`);
|
|
1591
1656
|
defines[key] = value;
|
|
@@ -1680,6 +1745,11 @@ function vinext(options = {}) {
|
|
|
1680
1745
|
find,
|
|
1681
1746
|
replacement
|
|
1682
1747
|
}));
|
|
1748
|
+
const tsconfigOverridingAliases = {
|
|
1749
|
+
...nextConfig.aliases,
|
|
1750
|
+
...nextShimMap,
|
|
1751
|
+
"vinext/server/pages-client-assets": _pagesClientAssetsPath
|
|
1752
|
+
};
|
|
1683
1753
|
if (config.resolve) {
|
|
1684
1754
|
config.resolve = { ...config.resolve };
|
|
1685
1755
|
delete config.resolve.alias;
|
|
@@ -1754,13 +1824,8 @@ function vinext(options = {}) {
|
|
|
1754
1824
|
alias: [...userAliasEntries, ...buildResolveAliasEntries({
|
|
1755
1825
|
...swcHelpersAlias ? { "@swc/helpers/_": swcHelpersAlias } : {},
|
|
1756
1826
|
...tsconfigPathAliases,
|
|
1757
|
-
...
|
|
1758
|
-
|
|
1759
|
-
"vinext/server/pages-client-assets": _pagesClientAssetsPath
|
|
1760
|
-
}, tsconfigPathAliases, {
|
|
1761
|
-
...nextConfig.aliases,
|
|
1762
|
-
...nextShimMap
|
|
1763
|
-
})],
|
|
1827
|
+
...tsconfigOverridingAliases
|
|
1828
|
+
}, tsconfigPathAliases, tsconfigExactPathAliases, tsconfigOverridingAliases)],
|
|
1764
1829
|
dedupe: [
|
|
1765
1830
|
"react",
|
|
1766
1831
|
"react-dom",
|
|
@@ -2120,6 +2185,8 @@ function vinext(options = {}) {
|
|
|
2120
2185
|
};
|
|
2121
2186
|
}
|
|
2122
2187
|
sassComposesLoader.setResolvedConfig(config);
|
|
2188
|
+
const nextImageAlias = config.resolve?.alias?.find(({ find }) => aliasFindMatches(find, "next/image"));
|
|
2189
|
+
nextImageAliasedByUser = nextImageAlias !== void 0 && (nextImageAlias.customResolver !== void 0 || toSlash(nextImageAlias.replacement) !== nextImageAliasTarget);
|
|
2123
2190
|
if (config.command === "build" && hasAppDir && hasPagesDir) {
|
|
2124
2191
|
const [appRoutes, pageRoutes, apiRoutes] = await Promise.all([
|
|
2125
2192
|
appRouter(appDir, nextConfig?.pageExtensions, fileMatcher),
|
|
@@ -2191,7 +2258,7 @@ function vinext(options = {}) {
|
|
|
2191
2258
|
},
|
|
2192
2259
|
resolveId: {
|
|
2193
2260
|
filter: { id: new RegExp(`${/(?:next\/|vinext\/(?:shims\/|server\/(?:app-rsc-(?:combined-)?handler|app-router-entry|pages-router-entry))|virtual:vinext-|@vercel\/og(?:\.js)?$)/.source}|${nextImageAliasTargetRE.source}`) },
|
|
2194
|
-
handler(id, importer) {
|
|
2261
|
+
handler(id, importer, options) {
|
|
2195
2262
|
if (nextImageAliasTargetRE.test(id)) return this.environment?.name === "rsc" ? RESOLVED_NEXT_IMAGE_RSC : void 0;
|
|
2196
2263
|
const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
|
|
2197
2264
|
if (cleanId === "vinext/server/app-rsc-combined-handler") {
|
|
@@ -2209,8 +2276,14 @@ function vinext(options = {}) {
|
|
|
2209
2276
|
return _appRscHandlerPath;
|
|
2210
2277
|
}
|
|
2211
2278
|
if (isVercelOgImport(cleanId) && !isVinextOgShimImporter(importer)) return resolveShimModulePath(_shimsDir, "og");
|
|
2212
|
-
if (cleanId === "vinext/shims/image" && this.environment?.name !== "rsc") return this.resolve("next/image", importer, { skipSelf: true });
|
|
2213
|
-
if (cleanId.startsWith("vinext/shims/"))
|
|
2279
|
+
if (cleanId === "vinext/shims/image" && this.environment?.name !== "rsc" && !nextImageAliasedByUser) return this.resolve("next/image", importer, { skipSelf: true });
|
|
2280
|
+
if (cleanId.startsWith("vinext/shims/")) {
|
|
2281
|
+
const shimPath = resolveShimModulePath(_shimsDir, stripJsExtension(stripViteModuleQuery(cleanId.slice(13))));
|
|
2282
|
+
return this.resolve(shimPath, importer, {
|
|
2283
|
+
...options,
|
|
2284
|
+
skipSelf: true
|
|
2285
|
+
});
|
|
2286
|
+
}
|
|
2214
2287
|
if (cleanId === VIRTUAL_WORKER_ENTRY) return RESOLVED_WORKER_ENTRY;
|
|
2215
2288
|
if (selectedMultiStageOutput && (cleanId === "vinext/server/app-router-entry" || cleanId === "vinext/server/pages-router-entry")) return RESOLVED_WORKER_ENTRY;
|
|
2216
2289
|
if (cleanId.endsWith("/" + VIRTUAL_WORKER_ENTRY)) return RESOLVED_WORKER_ENTRY;
|
|
@@ -2271,7 +2344,10 @@ function vinext(options = {}) {
|
|
|
2271
2344
|
const reactServerShim = _reactServerShims.get(cleanId);
|
|
2272
2345
|
if (reactServerShim !== void 0) {
|
|
2273
2346
|
const shimName = this.environment?.name === "rsc" ? `${reactServerShim}.react-server` : reactServerShim;
|
|
2274
|
-
return resolveShimModulePath(_shimsDir, shimName)
|
|
2347
|
+
return this.resolve(resolveShimModulePath(_shimsDir, shimName), importer, {
|
|
2348
|
+
...options,
|
|
2349
|
+
skipSelf: true
|
|
2350
|
+
});
|
|
2275
2351
|
}
|
|
2276
2352
|
}
|
|
2277
2353
|
},
|
|
@@ -2341,7 +2417,6 @@ function vinext(options = {}) {
|
|
|
2341
2417
|
const globalErrorPath = findFileWithExts(appDir, "global-error", fileMatcher);
|
|
2342
2418
|
const globalNotFoundPath = nextConfig?.globalNotFound ? findFileWithExts(appDir, "global-not-found", fileMatcher) : null;
|
|
2343
2419
|
if (id !== RESOLVED_APP_REQUEST_ENTRY) {
|
|
2344
|
-
rscClassificationManifests.set(id, collectRouteClassificationManifest(routes));
|
|
2345
2420
|
rscActionOwnerRoutes = this.environment.config.command === "build" && hasServerActions ? routes : null;
|
|
2346
2421
|
rscActionOwnerSharedRoots = [globalErrorPath, globalNotFoundPath].filter((path) => path !== null);
|
|
2347
2422
|
clientReferenceRoutes = this.environment.config.command === "build" ? routes : null;
|
|
@@ -2431,45 +2506,6 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2431
2506
|
}
|
|
2432
2507
|
if (id.startsWith("\0virtual:vinext-google-fonts?")) return generateGoogleFontsVirtualModule(id, _fontGoogleShimPath);
|
|
2433
2508
|
}
|
|
2434
|
-
},
|
|
2435
|
-
// @vitejs/plugin-rsc runs the RSC environment build in two phases:
|
|
2436
|
-
renderChunk: {
|
|
2437
|
-
order: "pre",
|
|
2438
|
-
handler(code, chunk) {
|
|
2439
|
-
if (this.environment?.name !== "rsc") return null;
|
|
2440
|
-
const hasClassificationStub = code.includes("__VINEXT_CLASS");
|
|
2441
|
-
if (!hasClassificationStub) return null;
|
|
2442
|
-
const rscEntryId = [RESOLVED_RSC_ENTRY, RESOLVED_APP_RESPONSE_ENTRY].find((id) => chunk.moduleIds.includes(id));
|
|
2443
|
-
if (!rscEntryId) return null;
|
|
2444
|
-
const rscClassificationManifest = rscClassificationManifests.get(rscEntryId);
|
|
2445
|
-
if (!rscClassificationManifest) return null;
|
|
2446
|
-
const enableClassificationDebug = Boolean(process.env.VINEXT_DEBUG_CLASSIFICATION);
|
|
2447
|
-
const patchPlan = hasClassificationStub && rscClassificationManifest ? planRouteClassificationInjection({
|
|
2448
|
-
canonicalizeLayoutPath: canonicalize,
|
|
2449
|
-
chunks: [{
|
|
2450
|
-
code,
|
|
2451
|
-
fileName: chunk.fileName
|
|
2452
|
-
}],
|
|
2453
|
-
dynamicShimPaths,
|
|
2454
|
-
enableDebugReasons: enableClassificationDebug,
|
|
2455
|
-
manifest: rscClassificationManifest,
|
|
2456
|
-
moduleInfo: { getModuleInfo: (moduleId) => {
|
|
2457
|
-
const info = this.getModuleInfo(moduleId);
|
|
2458
|
-
if (!info) return null;
|
|
2459
|
-
return {
|
|
2460
|
-
importedIds: info.importedIds ?? [],
|
|
2461
|
-
dynamicImportedIds: info.dynamicallyImportedIds ?? []
|
|
2462
|
-
};
|
|
2463
|
-
} }
|
|
2464
|
-
}) : { kind: "skip" };
|
|
2465
|
-
const nextCode = patchPlan.kind === "skip" ? code : patchPlan.code;
|
|
2466
|
-
if (patchPlan.kind === "skip") return null;
|
|
2467
|
-
rscClassificationManifests.delete(rscEntryId);
|
|
2468
|
-
return {
|
|
2469
|
-
code: nextCode,
|
|
2470
|
-
map: null
|
|
2471
|
-
};
|
|
2472
|
-
}
|
|
2473
2509
|
}
|
|
2474
2510
|
},
|
|
2475
2511
|
{
|
|
@@ -2731,6 +2767,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2731
2767
|
asyncHooksStubPlugin,
|
|
2732
2768
|
createInstrumentationClientTransformPlugin(() => instrumentationClientPath, () => nextConfig.instrumentationClientRouteManifest),
|
|
2733
2769
|
createInstrumentationServerTransformPlugin(() => instrumentationPath, () => nextConfig.instrumentationServerValueInjections),
|
|
2770
|
+
createNextIntlCatalogPlugin(() => root, () => nextConfig.nextIntlCatalogLoader),
|
|
2734
2771
|
{
|
|
2735
2772
|
name: "vinext:instrumentation-client-inject",
|
|
2736
2773
|
enforce: "pre",
|
|
@@ -3135,22 +3172,6 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3135
3172
|
}
|
|
3136
3173
|
return isExistingDevPublicFile(pathname);
|
|
3137
3174
|
};
|
|
3138
|
-
server.middlewares.use((req, res, next) => {
|
|
3139
|
-
const blockReason = validateDevRequest({
|
|
3140
|
-
origin: req.headers.origin,
|
|
3141
|
-
host: req.headers.host,
|
|
3142
|
-
"x-forwarded-host": req.headers["x-forwarded-host"],
|
|
3143
|
-
"sec-fetch-site": req.headers["sec-fetch-site"],
|
|
3144
|
-
"sec-fetch-mode": req.headers["sec-fetch-mode"]
|
|
3145
|
-
}, nextConfig?.allowedDevOrigins);
|
|
3146
|
-
if (blockReason) {
|
|
3147
|
-
console.warn(`[vinext] Blocked dev request: ${blockReason} (${req.url})`);
|
|
3148
|
-
res.writeHead(403, { "Content-Type": "text/plain" });
|
|
3149
|
-
res.end("Forbidden");
|
|
3150
|
-
return;
|
|
3151
|
-
}
|
|
3152
|
-
next();
|
|
3153
|
-
});
|
|
3154
3175
|
server.middlewares.use((req, res, next) => {
|
|
3155
3176
|
if (!sendRepeatedSlashRedirect(req.url ?? "/", res)) next();
|
|
3156
3177
|
});
|
|
@@ -3241,13 +3262,14 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3241
3262
|
if (hasAppDir) server.middlewares.use((req, res, next) => {
|
|
3242
3263
|
const url = req.url ?? "/";
|
|
3243
3264
|
const [pathname] = url.split("?");
|
|
3244
|
-
if (url.startsWith("/@") || url.startsWith("/__vite") || url.startsWith("/node_modules") || url.includes(".") && !pathname.endsWith(".html")
|
|
3265
|
+
if (url.startsWith("/@") || url.startsWith("/__vite") || url.startsWith("/node_modules") || url.includes(".") && !pathname.endsWith(".html")) return next();
|
|
3245
3266
|
const _reqStart = now();
|
|
3267
|
+
const _reqWallStart = Date.now();
|
|
3246
3268
|
let _compileMs;
|
|
3247
3269
|
let _renderMs;
|
|
3248
3270
|
function _parseTiming(raw) {
|
|
3249
3271
|
const [handlerStart, inHandlerCompileMs, renderMs] = String(raw).split(",").map((v) => Number(v));
|
|
3250
|
-
if (!Number.isNaN(handlerStart) && !Number.isNaN(inHandlerCompileMs) && inHandlerCompileMs !== -1) _compileMs = Math.max(0, Math.round(handlerStart -
|
|
3272
|
+
if (!Number.isNaN(handlerStart) && !Number.isNaN(inHandlerCompileMs) && inHandlerCompileMs !== -1) _compileMs = Math.max(0, Math.round(handlerStart - _reqWallStart)) + inHandlerCompileMs;
|
|
3251
3273
|
if (!Number.isNaN(renderMs) && renderMs !== -1) _renderMs = renderMs;
|
|
3252
3274
|
}
|
|
3253
3275
|
const _origSetHeader = res.setHeader.bind(res);
|
|
@@ -3274,12 +3296,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3274
3296
|
return _origWriteHead(statusCode, ...args);
|
|
3275
3297
|
};
|
|
3276
3298
|
res.on("finish", () => {
|
|
3277
|
-
const logUrl = url.replace(/\.rsc(\?|$)/, "$1");
|
|
3278
3299
|
const totalMs = now() - _reqStart;
|
|
3279
3300
|
const resolvedRenderMs = _renderMs !== void 0 ? _renderMs : _compileMs !== void 0 ? Math.max(0, Math.round(totalMs - _compileMs)) : void 0;
|
|
3280
3301
|
logRequest({
|
|
3281
3302
|
method: req.method ?? "GET",
|
|
3282
|
-
url
|
|
3303
|
+
url,
|
|
3283
3304
|
status: res.statusCode,
|
|
3284
3305
|
totalMs,
|
|
3285
3306
|
compileMs: _compileMs,
|
|
@@ -3455,6 +3476,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3455
3476
|
removeForwardedMiddlewareContext(req);
|
|
3456
3477
|
for (const key of Object.keys(req.headers)) delete req.headers[key];
|
|
3457
3478
|
for (const [key, value] of nextRequestHeaders) req.headers[key] = value;
|
|
3479
|
+
const setCookies = nextRequestHeaders.getSetCookie();
|
|
3480
|
+
if (setCookies.length > 1) req.headers["set-cookie"] = setCookies;
|
|
3458
3481
|
};
|
|
3459
3482
|
const devRunMiddlewareAdapter = capturedMiddlewarePath ? async (_request, _ctx, opts) => {
|
|
3460
3483
|
const rawProto = process.env.VINEXT_TRUST_PROXY === "1" || (process.env.VINEXT_TRUSTED_HOSTS ?? "").split(",").some((h) => h.trim()) ? String(req.headers["x-forwarded-proto"] || "").split(",")[0].trim() : "";
|
|
@@ -3649,7 +3672,6 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3649
3672
|
const url = req.url ?? "/";
|
|
3650
3673
|
if (!hasPagesDir) return next();
|
|
3651
3674
|
if (url.startsWith("/@") || url.startsWith("/__vite") || url.startsWith("/node_modules")) return next();
|
|
3652
|
-
if (url.split("?")[0].endsWith(".rsc")) return next();
|
|
3653
3675
|
if (hasCloudflarePlugin) return next();
|
|
3654
3676
|
await pagesInstrumentationReady;
|
|
3655
3677
|
const traceHeaders = new Headers();
|
|
@@ -8,7 +8,6 @@ export type CloudflareProjectInfo = {
|
|
|
8
8
|
hasMDX: boolean;
|
|
9
9
|
/** The effective Next.js config sets `output: "export"`. */
|
|
10
10
|
isStaticExport?: boolean;
|
|
11
|
-
nativeModulesToStub: string[];
|
|
12
11
|
};
|
|
13
12
|
export type CloudflarePlatformSetupContext = {
|
|
14
13
|
root: string;
|
|
@@ -46,14 +45,13 @@ export declare function cssModulesConfigSource(indent?: string): string;
|
|
|
46
45
|
/** Generate vite.config.ts for App Router */
|
|
47
46
|
export declare function generateAppRouterViteConfig(info?: CloudflareProjectInfo, options?: CloudflareInitOptions, imagesBinding?: string, versionMetadataBinding?: string, serviceBinding?: boolean, assetsBinding?: string, assetsDirectory?: string, hasCssModules?: boolean): string;
|
|
48
47
|
/** Generate vite.config.ts for Pages Router */
|
|
49
|
-
export declare function generatePagesRouterViteConfig(
|
|
48
|
+
export declare function generatePagesRouterViteConfig(options?: CloudflareInitOptions, imagesBinding?: string, versionMetadataBinding?: string, serviceBinding?: boolean, hasCssModules?: boolean, assetsBinding?: string, assetsDirectory?: string): string;
|
|
50
49
|
export declare function updateViteConfigForCssModules(filePath: string, code: string): {
|
|
51
50
|
code: string;
|
|
52
51
|
preservedExistingGenerateScopedName: boolean;
|
|
53
52
|
};
|
|
54
53
|
export declare function updateViteConfigForCloudflare(filePath: string, code: string, options: {
|
|
55
54
|
isAppRouter: boolean;
|
|
56
|
-
nativeModulesToStub: string[];
|
|
57
55
|
cache?: CloudflareInitOptions;
|
|
58
56
|
assetsBinding?: string;
|
|
59
57
|
assetsDirectory?: string;
|