vinext 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/THIRD_PARTY_LICENSES.md +47 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -2
- package/dist/build/prerender.js +1 -1
- package/dist/build/report.d.ts +0 -14
- package/dist/build/report.js +1 -51
- package/dist/check.js +1 -1
- package/dist/cli.js +3 -0
- package/dist/client/dev-error-overlay.js +1 -1
- package/dist/client/navigation-runtime.d.ts +13 -1
- package/dist/client/navigation-runtime.js +1 -1
- package/dist/config/next-config.d.ts +19 -0
- package/dist/config/next-config.js +64 -1
- 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 -48
- 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 +33 -8
- package/dist/index.js +83 -70
- 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/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 +19 -4
- package/dist/server/app-bfcache-identity.js +1 -1
- package/dist/server/app-browser-entry.js +79 -63
- 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 +4 -4
- package/dist/server/app-browser-server-action-client.d.ts +2 -0
- package/dist/server/app-browser-server-action-client.js +4 -3
- 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 +2 -12
- 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 +42 -2
- package/dist/server/app-page-boundary-render.js +7 -6
- 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 -10
- package/dist/server/app-page-dispatch.js +84 -154
- package/dist/server/app-page-element-builder.d.ts +2 -2
- package/dist/server/app-page-element-builder.js +10 -9
- package/dist/server/app-page-execution.d.ts +17 -52
- package/dist/server/app-page-execution.js +99 -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 -12
- package/dist/server/app-page-render.js +89 -220
- 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 +67 -61
- 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 +2 -0
- package/dist/server/app-page-stream.js +2 -2
- 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-route-handler-cache.js +2 -2
- package/dist/server/app-route-handler-dispatch.js +14 -9
- package/dist/server/app-route-handler-execution.js +8 -3
- 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.js +17 -4
- package/dist/server/app-rsc-cache-busting.d.ts +2 -2
- package/dist/server/app-rsc-cache-busting.js +4 -4
- package/dist/server/app-rsc-error-handler.d.ts +2 -1
- package/dist/server/app-rsc-error-handler.js +9 -1
- package/dist/server/app-rsc-errors.d.ts +8 -0
- package/dist/server/app-rsc-errors.js +8 -1
- package/dist/server/app-rsc-handler.d.ts +5 -5
- package/dist/server/app-rsc-handler.js +30 -24
- package/dist/server/app-rsc-request-normalization.d.ts +0 -4
- package/dist/server/app-rsc-request-normalization.js +1 -4
- package/dist/server/app-rsc-response-finalizer.js +2 -2
- package/dist/server/app-rsc-response-stage.js +5 -3
- package/dist/server/app-server-action-execution.d.ts +3 -1
- package/dist/server/app-server-action-execution.js +7 -4
- package/dist/server/app-ssr-entry.d.ts +2 -0
- package/dist/server/app-ssr-entry.js +9 -8
- 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 +25 -3
- package/dist/server/app-worker-stages.js +45 -6
- package/dist/server/artifact-compatibility.d.ts +0 -1
- package/dist/server/artifact-compatibility.js +1 -10
- package/dist/server/cache-proof.d.ts +1 -115
- package/dist/server/cache-proof.js +1 -544
- package/dist/server/cacheability-request.js +13 -8
- package/dist/server/dev-server.js +4 -3
- package/dist/server/headers.d.ts +6 -3
- package/dist/server/headers.js +9 -5
- package/dist/server/isr-cache.d.ts +8 -2
- package/dist/server/isr-cache.js +26 -1
- package/dist/server/metadata-route-response.js +32 -15
- package/dist/server/multi-stage.d.ts +52 -11
- 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.js +52 -27
- package/dist/server/pages-page-handler.js +11 -20
- 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 +14 -12
- package/dist/server/pages-response-stage-entry.js +9 -3
- package/dist/server/prod-server.js +5 -1
- package/dist/server/request-pipeline.d.ts +6 -0
- package/dist/server/request-pipeline.js +21 -1
- package/dist/server/shared-cache-identity.d.ts +23 -0
- package/dist/server/shared-cache-identity.js +36 -0
- 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 +17 -20
- package/dist/shims/cache-request-state.js +16 -21
- package/dist/shims/cache-runtime.js +27 -11
- package/dist/shims/cache.d.ts +8 -7
- package/dist/shims/cache.js +17 -19
- package/dist/shims/cacheability-classification.d.ts +2 -0
- package/dist/shims/cdn-cache.d.ts +22 -5
- 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 +34 -24
- package/dist/shims/form.js +2 -2
- package/dist/shims/headers.d.ts +8 -23
- package/dist/shims/headers.js +17 -67
- package/dist/shims/internal/navigation-untracked.js +1 -1
- package/dist/shims/link.js +3 -1
- 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 +183 -29
- package/dist/shims/navigation.react-server.js +2 -2
- package/dist/shims/request-state-types.d.ts +2 -2
- package/dist/shims/slot.d.ts +12 -0
- package/dist/shims/slot.js +37 -9
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +2 -3
- package/dist/utils/cache-control-metadata.d.ts +5 -0
- package/dist/utils/cache-control-metadata.js +9 -1
- 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
|
@@ -29,11 +29,34 @@ const _isrCachePath = resolveEntryPath("../server/isr-cache.js", import.meta.url
|
|
|
29
29
|
const _revalidationRequestPath = resolveEntryPath("../server/revalidation-request.js", import.meta.url);
|
|
30
30
|
const _instrumentationRuntimePath = resolveEntryPath("../server/instrumentation-runtime.js", import.meta.url);
|
|
31
31
|
const _isolateSharedPromisePath = resolveEntryPath("../server/isolate-shared-promise.js", import.meta.url);
|
|
32
|
-
|
|
32
|
+
const GET_INITIAL_PROPS_NAME = /\bgetInitialProps\b/;
|
|
33
|
+
/**
|
|
34
|
+
* Whether a module's source names getInitialProps. Next.js serves a page
|
|
35
|
+
* without data functions as one static file only when neither it nor a
|
|
36
|
+
* custom _app defines getInitialProps, which it checks on the loaded modules:
|
|
37
|
+
* https://github.com/vercel/next.js/blob/canary/packages/next/src/build/utils.ts
|
|
38
|
+
* https://github.com/vercel/next.js/blob/canary/packages/next/src/build/index.ts
|
|
39
|
+
* The source is all the request stage has. A getInitialProps an imported
|
|
40
|
+
* wrapper attaches is only seen once the page renders.
|
|
41
|
+
*/
|
|
42
|
+
async function namesGetInitialProps(filePath) {
|
|
43
|
+
if (filePath === null) return false;
|
|
44
|
+
return GET_INITIAL_PROPS_NAME.test(await readFile(filePath, "utf8"));
|
|
45
|
+
}
|
|
46
|
+
async function getPagesRouteData(filePath, appRunsInitialProps) {
|
|
33
47
|
const source = await readFile(filePath, "utf8");
|
|
34
|
-
if (hasExportedName(source, "getStaticProps")) return
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
if (hasExportedName(source, "getStaticProps")) return {
|
|
49
|
+
dataKind: "static",
|
|
50
|
+
runsInitialProps: false
|
|
51
|
+
};
|
|
52
|
+
if (hasExportedName(source, "getServerSideProps")) return {
|
|
53
|
+
dataKind: "server",
|
|
54
|
+
runsInitialProps: false
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
dataKind: "none",
|
|
58
|
+
runsInitialProps: appRunsInitialProps || GET_INITIAL_PROPS_NAME.test(source)
|
|
59
|
+
};
|
|
37
60
|
}
|
|
38
61
|
/**
|
|
39
62
|
* Generate the request-only Pages Worker entry used by a multi-stage output.
|
|
@@ -43,9 +66,10 @@ async function generatePagesRequestEntry(pagesDir, nextConfig, fileMatcher, midd
|
|
|
43
66
|
const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
44
67
|
const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
45
68
|
const hasRequestAwareDocument = findFileWithExts(pagesDir, "_document", fileMatcher) !== null;
|
|
69
|
+
const appRunsInitialProps = await namesGetInitialProps(findFileWithExts(pagesDir, "_app", fileMatcher));
|
|
46
70
|
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)} }`;
|
|
71
|
+
const { dataKind, runsInitialProps } = await getPagesRouteData(route.filePath, appRunsInitialProps);
|
|
72
|
+
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
73
|
}));
|
|
50
74
|
const apiRouteEntries = apiRoutes.map((route) => ` { pattern: ${JSON.stringify(route.pattern)}, patternParts: ${JSON.stringify(route.patternParts)}, isDynamic: ${route.isDynamic}, params: ${JSON.stringify(route.params)} }`);
|
|
51
75
|
const i18nConfigJson = nextConfig?.i18n ? JSON.stringify({
|
|
@@ -210,9 +234,10 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
|
|
|
210
234
|
const pageImportInitializers = pageRoutes.map((r, i) => `page_${i} = await import(${JSON.stringify(r.filePath)});`);
|
|
211
235
|
const apiImports = apiRoutes.map((r, i) => instrumentationPath ? `let api_${i};` : `import * as api_${i} from ${JSON.stringify(r.filePath)};`);
|
|
212
236
|
const apiImportInitializers = apiRoutes.map((r, i) => `api_${i} = await import(${JSON.stringify(r.filePath)});`);
|
|
237
|
+
const appRunsInitialProps = await namesGetInitialProps(findFileWithExts(pagesDir, "_app", fileMatcher));
|
|
213
238
|
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)} }`;
|
|
239
|
+
const { dataKind, runsInitialProps } = await getPagesRouteData(r.filePath, appRunsInitialProps);
|
|
240
|
+
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
241
|
}));
|
|
217
242
|
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
243
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
package/dist/index.js
CHANGED
|
@@ -60,8 +60,6 @@ import { generateSsrEntry } from "./entries/app-ssr-entry.js";
|
|
|
60
60
|
import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VIRTUAL_CACHE_ADAPTERS, VIRTUAL_CDN_CACHE_ADAPTER, generateCacheAdaptersModule, generateCdnCacheAdapterModule } from "./cache/cache-adapters-virtual.js";
|
|
61
61
|
import { VIRTUAL_IMAGE_ADAPTERS, generateImageAdaptersModule } from "./image/image-adapters-virtual.js";
|
|
62
62
|
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
63
|
import { createRscScanGlobImportsPlugin, isRscScanGlobImportsAffected } from "./plugins/rsc-scan-glob-imports.js";
|
|
66
64
|
import { loadOrGenerateServerActionsEncryptionKey } from "./build/server-actions-encryption-key.js";
|
|
67
65
|
import { findOpenTelemetryPackages, mergeServerExternalPackages } from "./config/server-external-packages.js";
|
|
@@ -96,6 +94,7 @@ import { createRouteClientReferencesFallbackPlugin, createRscClientReferenceLoad
|
|
|
96
94
|
import { createRscReferenceValidationNormalizerPlugin } from "./plugins/rsc-reference-validation-normalizer.js";
|
|
97
95
|
import { createScanBuildCssPlugin } from "./plugins/scan-build-css.js";
|
|
98
96
|
import { createInstrumentationClientTransformPlugin, createInstrumentationServerTransformPlugin } from "./plugins/instrumentation-client.js";
|
|
97
|
+
import { createNextIntlCatalogPlugin } from "./plugins/next-intl-catalog.js";
|
|
99
98
|
import { createStyledJsxPlugin } from "./plugins/styled-jsx.js";
|
|
100
99
|
import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
|
|
101
100
|
import { isServerEnvironment } from "./plugins/environment.js";
|
|
@@ -155,7 +154,12 @@ const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
|
155
154
|
"react/jsx-runtime",
|
|
156
155
|
"react/jsx-dev-runtime"
|
|
157
156
|
]);
|
|
158
|
-
const PAGES_CLOUDFLARE_WORKER_OPTIONAL_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
157
|
+
const PAGES_CLOUDFLARE_WORKER_OPTIONAL_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
158
|
+
"use-sync-external-store/with-selector",
|
|
159
|
+
"vinext > @vitejs/plugin-rsc/react/rsc",
|
|
160
|
+
"vinext > @unpic/react",
|
|
161
|
+
"vinext > ipaddr.js"
|
|
162
|
+
]);
|
|
159
163
|
const APP_CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
160
164
|
"use-sync-external-store/shim",
|
|
161
165
|
"use-sync-external-store/shim/index.js",
|
|
@@ -499,6 +503,7 @@ function hasZeroOrOneAsterisk(value) {
|
|
|
499
503
|
}
|
|
500
504
|
function materializeTsconfigPathAliases(pathsConfig, baseUrl, projectRoot) {
|
|
501
505
|
const vite = {};
|
|
506
|
+
const viteExact = {};
|
|
502
507
|
const sass = [];
|
|
503
508
|
for (const [find, rawTargets] of Object.entries(pathsConfig)) {
|
|
504
509
|
const targets = Array.isArray(rawTargets) ? rawTargets.filter((value) => typeof value === "string") : typeof rawTargets === "string" ? [rawTargets] : [];
|
|
@@ -521,10 +526,11 @@ function materializeTsconfigPathAliases(pathsConfig, baseUrl, projectRoot) {
|
|
|
521
526
|
vite[aliasKey] = toViteAliasReplacement(path.resolve(baseUrl, targetDir), projectRoot);
|
|
522
527
|
continue;
|
|
523
528
|
}
|
|
524
|
-
|
|
529
|
+
viteExact[find] = toViteAliasReplacement(path.resolve(baseUrl, target), projectRoot);
|
|
525
530
|
}
|
|
526
531
|
return {
|
|
527
532
|
vite,
|
|
533
|
+
viteExact,
|
|
528
534
|
sass
|
|
529
535
|
};
|
|
530
536
|
}
|
|
@@ -561,6 +567,7 @@ function loadTsconfigPathAliases(configPath, projectRoot, seen = /* @__PURE__ */
|
|
|
561
567
|
const normalizedPath = tryRealpathSync(configPath) ?? configPath;
|
|
562
568
|
if (seen.has(normalizedPath)) return {
|
|
563
569
|
vite: {},
|
|
570
|
+
viteExact: {},
|
|
564
571
|
sass: []
|
|
565
572
|
};
|
|
566
573
|
seen.add(normalizedPath);
|
|
@@ -570,15 +577,18 @@ function loadTsconfigPathAliases(configPath, projectRoot, seen = /* @__PURE__ */
|
|
|
570
577
|
} catch {
|
|
571
578
|
return {
|
|
572
579
|
vite: {},
|
|
580
|
+
viteExact: {},
|
|
573
581
|
sass: []
|
|
574
582
|
};
|
|
575
583
|
}
|
|
576
584
|
if (!parsed) return {
|
|
577
585
|
vite: {},
|
|
586
|
+
viteExact: {},
|
|
578
587
|
sass: []
|
|
579
588
|
};
|
|
580
589
|
let aliases = {
|
|
581
590
|
vite: {},
|
|
591
|
+
viteExact: {},
|
|
582
592
|
sass: []
|
|
583
593
|
};
|
|
584
594
|
for (const extendsSpecifier of normalizeTsconfigExtends(parsed.extends)) {
|
|
@@ -590,6 +600,10 @@ function loadTsconfigPathAliases(configPath, projectRoot, seen = /* @__PURE__ */
|
|
|
590
600
|
...aliases.vite,
|
|
591
601
|
...parent.vite
|
|
592
602
|
},
|
|
603
|
+
viteExact: {
|
|
604
|
+
...aliases.viteExact,
|
|
605
|
+
...parent.viteExact
|
|
606
|
+
},
|
|
593
607
|
sass: mergeSassTsconfigPathAliases(aliases.sass, parent.sass)
|
|
594
608
|
};
|
|
595
609
|
}
|
|
@@ -604,6 +618,10 @@ function loadTsconfigPathAliases(configPath, projectRoot, seen = /* @__PURE__ */
|
|
|
604
618
|
...aliases.vite,
|
|
605
619
|
...own.vite
|
|
606
620
|
},
|
|
621
|
+
viteExact: {
|
|
622
|
+
...aliases.viteExact,
|
|
623
|
+
...own.viteExact
|
|
624
|
+
},
|
|
607
625
|
sass: mergeSassTsconfigPathAliases(aliases.sass, own.sass)
|
|
608
626
|
};
|
|
609
627
|
}
|
|
@@ -672,17 +690,20 @@ function resolveTsconfigAliases(projectRoot, configuredPath) {
|
|
|
672
690
|
if (_tsconfigAliasCache.has(cacheKey)) return _tsconfigAliasCache.get(cacheKey);
|
|
673
691
|
let aliases = {
|
|
674
692
|
vite: {},
|
|
693
|
+
viteExact: {},
|
|
675
694
|
sass: []
|
|
676
695
|
};
|
|
677
696
|
for (const candidate of configPath ? [configPath] : TSCONFIG_FILES.map((name) => path.join(projectRoot, name))) {
|
|
678
697
|
if (!fs.existsSync(candidate)) continue;
|
|
679
698
|
const materialized = loadTsconfigPathAliases(candidate, projectRoot);
|
|
680
699
|
aliases = {
|
|
681
|
-
|
|
682
|
-
|
|
700
|
+
...materialized,
|
|
701
|
+
vite: sortTsconfigAliasesBySpecificity(materialized.vite)
|
|
683
702
|
};
|
|
684
703
|
break;
|
|
685
704
|
}
|
|
705
|
+
aliases.vite = Object.fromEntries(Object.entries(aliases.vite).filter(([find]) => !_reactServerShims.has(find)));
|
|
706
|
+
aliases.viteExact = Object.fromEntries(Object.entries(aliases.viteExact).filter(([find]) => !_reactServerShims.has(find)));
|
|
686
707
|
_tsconfigAliasCache.set(cacheKey, aliases);
|
|
687
708
|
return aliases;
|
|
688
709
|
}
|
|
@@ -726,20 +747,38 @@ const tsconfigAliasCustomResolver = async function(updatedId, importer, options)
|
|
|
726
747
|
skipSelf: true
|
|
727
748
|
}) ?? { id: updatedId };
|
|
728
749
|
};
|
|
750
|
+
function aliasFindMatches(find, id) {
|
|
751
|
+
if (typeof find === "string") return id === find || id.startsWith(`${find}/`);
|
|
752
|
+
const { lastIndex } = find;
|
|
753
|
+
find.lastIndex = 0;
|
|
754
|
+
const matches = find.test(id);
|
|
755
|
+
find.lastIndex = lastIndex;
|
|
756
|
+
return matches;
|
|
757
|
+
}
|
|
729
758
|
/**
|
|
730
759
|
* Convert the merged alias map into Vite alias entries, attaching the
|
|
731
760
|
* stylesheet-scoping resolver to entries that came from tsconfig `paths`.
|
|
732
761
|
* Array order preserves the map's first-match ordering.
|
|
762
|
+
*
|
|
763
|
+
* Exact tsconfig keys come first as anchored RegExps: a string `find` would
|
|
764
|
+
* also match paths below the key, so `"@acme/pkg": ["./src/index.ts"]` would
|
|
765
|
+
* rewrite `@acme/pkg/runtime` to `./src/index.ts/runtime`. TypeScript and
|
|
766
|
+
* Next.js match such keys only against the exact specifier and prefer them over
|
|
767
|
+
* `*` patterns.
|
|
733
768
|
*/
|
|
734
|
-
function buildResolveAliasEntries(aliasMap, tsconfigPathAliases, explicitAliases) {
|
|
735
|
-
return Object.entries(
|
|
769
|
+
function buildResolveAliasEntries(aliasMap, tsconfigPathAliases, tsconfigExactPathAliases, explicitAliases) {
|
|
770
|
+
return [...Object.entries(tsconfigExactPathAliases).filter(([find]) => !Object.hasOwn(explicitAliases, find)).map(([find, replacement]) => ({
|
|
771
|
+
find: new RegExp(`^${escapeRegExp(find)}$`),
|
|
772
|
+
replacement,
|
|
773
|
+
customResolver: tsconfigAliasCustomResolver
|
|
774
|
+
})), ...Object.entries(aliasMap).map(([find, replacement]) => Object.hasOwn(tsconfigPathAliases, find) && !Object.hasOwn(explicitAliases, find) ? {
|
|
736
775
|
find,
|
|
737
776
|
replacement,
|
|
738
777
|
customResolver: tsconfigAliasCustomResolver
|
|
739
778
|
} : {
|
|
740
779
|
find,
|
|
741
780
|
replacement
|
|
742
|
-
});
|
|
781
|
+
})];
|
|
743
782
|
}
|
|
744
783
|
const ALIAS_CUSTOM_RESOLVER_DEPRECATION_RE = /`resolve\.alias` contains an alias with `customResolver` option/;
|
|
745
784
|
const VINEXT_FILTERED_ALIAS_DEPRECATION_WARN = Symbol.for("vinext.filteredAliasDeprecationWarn");
|
|
@@ -973,6 +1012,7 @@ function vinext(options = {}) {
|
|
|
973
1012
|
let resolvedServerExternalPackages = [];
|
|
974
1013
|
let registerNodeOpenTelemetryLoader = false;
|
|
975
1014
|
let pagesTsconfigAliases = {};
|
|
1015
|
+
let pagesTsconfigExactAliases = {};
|
|
976
1016
|
let pagesBundledPackages = /* @__PURE__ */ new Set();
|
|
977
1017
|
let isServeCommand = false;
|
|
978
1018
|
let buildEmptyOutDir;
|
|
@@ -1006,7 +1046,6 @@ function vinext(options = {}) {
|
|
|
1006
1046
|
const devForwardedMiddlewareContextKey = randomBytes(32).toString("hex");
|
|
1007
1047
|
let previewBuildCredentials;
|
|
1008
1048
|
const sassComposesLoader = createSassAwareFileSystemLoader();
|
|
1009
|
-
const rscClassificationManifests = /* @__PURE__ */ new Map();
|
|
1010
1049
|
let rscActionOwnerRoutes = null;
|
|
1011
1050
|
let rscActionOwnerSharedRoots = [];
|
|
1012
1051
|
let clientReferenceRoutes = null;
|
|
@@ -1027,6 +1066,7 @@ function vinext(options = {}) {
|
|
|
1027
1066
|
const shimsDir = path.resolve(__dirname, "shims");
|
|
1028
1067
|
const nextImageAliasTarget = toSlash(path.join(shimsDir, "image"));
|
|
1029
1068
|
const nextImageAliasTargetRE = new RegExp(`^${nextImageAliasTarget.split("/").map(escapeRegExp).join("[\\\\/]")}$`);
|
|
1069
|
+
let nextImageAliasedByUser = false;
|
|
1030
1070
|
const canonicalize = (p) => toSlash(tryRealpathSync(p) ?? p);
|
|
1031
1071
|
const pageTransformCanonicalPaths = /* @__PURE__ */ new Map();
|
|
1032
1072
|
const canonicalizePageTransformPath = (modulePath) => {
|
|
@@ -1041,11 +1081,6 @@ function vinext(options = {}) {
|
|
|
1041
1081
|
const relativePath = fileMatcher.stripExtension(canonicalId.slice(canonicalPagesDir.length));
|
|
1042
1082
|
return relativePath === "/api" || relativePath.startsWith("/api/");
|
|
1043
1083
|
};
|
|
1044
|
-
const dynamicShimPaths = new Set([
|
|
1045
|
-
resolveShimModulePath(shimsDir, "headers"),
|
|
1046
|
-
resolveShimModulePath(shimsDir, "server"),
|
|
1047
|
-
resolveShimModulePath(shimsDir, "cache")
|
|
1048
|
-
].map(canonicalize));
|
|
1049
1084
|
let nextShimMap = {};
|
|
1050
1085
|
let shimOptimizeDepsExclude = VINEXT_OPTIMIZE_DEPS_EXCLUDE;
|
|
1051
1086
|
const createShimRequirePlugin = () => esmExternalRequirePlugin({ external: [...shimOptimizeDepsExclude] });
|
|
@@ -1115,14 +1150,14 @@ function vinext(options = {}) {
|
|
|
1115
1150
|
rscPluginPromise = rscImport.then(async (mod) => {
|
|
1116
1151
|
const rsc = mod.default;
|
|
1117
1152
|
const plugins = rsc(rscPluginOptions);
|
|
1118
|
-
const
|
|
1153
|
+
const useCachePlugins = await createUseCacheCallablePlugin({
|
|
1119
1154
|
projectRoot: earlyBaseDir,
|
|
1120
1155
|
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href,
|
|
1121
1156
|
getEncryptionKey: () => serverActionsEncryptionKey
|
|
1122
1157
|
});
|
|
1123
1158
|
const useServerIndex = plugins.findIndex((plugin) => plugin.name === "rsc:use-server");
|
|
1124
1159
|
if (useServerIndex === -1) throw new Error("vinext: Failed to locate @vitejs/plugin-rsc use-server plugin.");
|
|
1125
|
-
plugins.splice(useServerIndex, 0,
|
|
1160
|
+
plugins.splice(useServerIndex, 0, ...useCachePlugins);
|
|
1126
1161
|
return plugins.map(scopeRscPlugin);
|
|
1127
1162
|
}).catch((cause) => {
|
|
1128
1163
|
throw new Error("vinext: Failed to load @vitejs/plugin-rsc.", { cause });
|
|
@@ -1401,6 +1436,7 @@ function vinext(options = {}) {
|
|
|
1401
1436
|
getPagesDir: () => hasPagesDir ? pagesDir : null,
|
|
1402
1437
|
getAliases: () => nextConfig?.aliases ?? {},
|
|
1403
1438
|
getTsconfigAliases: () => pagesTsconfigAliases,
|
|
1439
|
+
getTsconfigExactAliases: () => pagesTsconfigExactAliases,
|
|
1404
1440
|
getBundledPackages: () => pagesBundledPackages,
|
|
1405
1441
|
isEnabled: () => !hasCloudflarePlugin && !hasNitroPlugin
|
|
1406
1442
|
}),
|
|
@@ -1433,6 +1469,7 @@ function vinext(options = {}) {
|
|
|
1433
1469
|
buildLifecycleEnabled = env.command === "build" && !internalOptions.__skipBuildLifecycle && (buildLifecycleInvocation !== void 0 || claimViteCliBuildInvocation());
|
|
1434
1470
|
const userResolve = config.resolve;
|
|
1435
1471
|
let tsconfigPathAliases = {};
|
|
1472
|
+
let tsconfigExactPathAliases = {};
|
|
1436
1473
|
let sassTsconfigPathAliases = [];
|
|
1437
1474
|
const swcHelpersAlias = resolveSwcHelpersAlias(root);
|
|
1438
1475
|
const mode = env?.mode ?? "development";
|
|
@@ -1504,10 +1541,12 @@ function vinext(options = {}) {
|
|
|
1504
1541
|
const configuredTsconfigPath = isUnknownRecord(nextConfig.typescript) ? typeof nextConfig.typescript.tsconfigPath === "string" ? nextConfig.typescript.tsconfigPath : void 0 : void 0;
|
|
1505
1542
|
const resolvedTsconfigAliases = resolveTsconfigAliases(root, configuredTsconfigPath);
|
|
1506
1543
|
tsconfigPathAliases = resolvedTsconfigAliases.vite;
|
|
1544
|
+
tsconfigExactPathAliases = resolvedTsconfigAliases.viteExact;
|
|
1507
1545
|
pagesTsconfigAliases = tsconfigPathAliases;
|
|
1546
|
+
pagesTsconfigExactAliases = tsconfigExactPathAliases;
|
|
1508
1547
|
sassTsconfigPathAliases = resolvedTsconfigAliases.sass;
|
|
1509
1548
|
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 }));
|
|
1549
|
+
if (Object.keys(tsconfigPathAliases).length > 0 || Object.keys(tsconfigExactPathAliases).length > 0) config.customLogger = suppressAliasCustomResolverDeprecationWarning(config.customLogger ?? createLogger(config.logLevel, { allowClearScreen: config.clearScreen }));
|
|
1511
1550
|
if (rscCompatibilityId === void 0) {
|
|
1512
1551
|
const sharedRscCompatibilityId = process.env.__VINEXT_SHARED_RSC_COMPATIBILITY_ID;
|
|
1513
1552
|
rscCompatibilityId = sharedRscCompatibilityId && sharedRscCompatibilityId.length > 0 ? sharedRscCompatibilityId : createRscCompatibilityId(nextConfig);
|
|
@@ -1586,6 +1625,7 @@ function vinext(options = {}) {
|
|
|
1586
1625
|
defines["process.env.__NEXT_VERSION"] = JSON.stringify(getVinextVersion());
|
|
1587
1626
|
defines["process.env.__NEXT_APP_SHELLS"] = JSON.stringify(nextConfig.appShells);
|
|
1588
1627
|
defines["process.env.__NEXT_CACHE_COMPONENTS"] = JSON.stringify(nextConfig.cacheComponents ?? false);
|
|
1628
|
+
defines["process.env.__NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS"] = JSON.stringify(nextConfig.cachedNavigations);
|
|
1589
1629
|
for (const [key, value] of Object.entries(nextConfig.compilerDefine)) {
|
|
1590
1630
|
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
1631
|
defines[key] = value;
|
|
@@ -1680,6 +1720,11 @@ function vinext(options = {}) {
|
|
|
1680
1720
|
find,
|
|
1681
1721
|
replacement
|
|
1682
1722
|
}));
|
|
1723
|
+
const tsconfigOverridingAliases = {
|
|
1724
|
+
...nextConfig.aliases,
|
|
1725
|
+
...nextShimMap,
|
|
1726
|
+
"vinext/server/pages-client-assets": _pagesClientAssetsPath
|
|
1727
|
+
};
|
|
1683
1728
|
if (config.resolve) {
|
|
1684
1729
|
config.resolve = { ...config.resolve };
|
|
1685
1730
|
delete config.resolve.alias;
|
|
@@ -1754,13 +1799,8 @@ function vinext(options = {}) {
|
|
|
1754
1799
|
alias: [...userAliasEntries, ...buildResolveAliasEntries({
|
|
1755
1800
|
...swcHelpersAlias ? { "@swc/helpers/_": swcHelpersAlias } : {},
|
|
1756
1801
|
...tsconfigPathAliases,
|
|
1757
|
-
...
|
|
1758
|
-
|
|
1759
|
-
"vinext/server/pages-client-assets": _pagesClientAssetsPath
|
|
1760
|
-
}, tsconfigPathAliases, {
|
|
1761
|
-
...nextConfig.aliases,
|
|
1762
|
-
...nextShimMap
|
|
1763
|
-
})],
|
|
1802
|
+
...tsconfigOverridingAliases
|
|
1803
|
+
}, tsconfigPathAliases, tsconfigExactPathAliases, tsconfigOverridingAliases)],
|
|
1764
1804
|
dedupe: [
|
|
1765
1805
|
"react",
|
|
1766
1806
|
"react-dom",
|
|
@@ -2120,6 +2160,8 @@ function vinext(options = {}) {
|
|
|
2120
2160
|
};
|
|
2121
2161
|
}
|
|
2122
2162
|
sassComposesLoader.setResolvedConfig(config);
|
|
2163
|
+
const nextImageAlias = config.resolve?.alias?.find(({ find }) => aliasFindMatches(find, "next/image"));
|
|
2164
|
+
nextImageAliasedByUser = nextImageAlias !== void 0 && (nextImageAlias.customResolver !== void 0 || toSlash(nextImageAlias.replacement) !== nextImageAliasTarget);
|
|
2123
2165
|
if (config.command === "build" && hasAppDir && hasPagesDir) {
|
|
2124
2166
|
const [appRoutes, pageRoutes, apiRoutes] = await Promise.all([
|
|
2125
2167
|
appRouter(appDir, nextConfig?.pageExtensions, fileMatcher),
|
|
@@ -2191,7 +2233,7 @@ function vinext(options = {}) {
|
|
|
2191
2233
|
},
|
|
2192
2234
|
resolveId: {
|
|
2193
2235
|
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) {
|
|
2236
|
+
handler(id, importer, options) {
|
|
2195
2237
|
if (nextImageAliasTargetRE.test(id)) return this.environment?.name === "rsc" ? RESOLVED_NEXT_IMAGE_RSC : void 0;
|
|
2196
2238
|
const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
|
|
2197
2239
|
if (cleanId === "vinext/server/app-rsc-combined-handler") {
|
|
@@ -2209,8 +2251,14 @@ function vinext(options = {}) {
|
|
|
2209
2251
|
return _appRscHandlerPath;
|
|
2210
2252
|
}
|
|
2211
2253
|
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/"))
|
|
2254
|
+
if (cleanId === "vinext/shims/image" && this.environment?.name !== "rsc" && !nextImageAliasedByUser) return this.resolve("next/image", importer, { skipSelf: true });
|
|
2255
|
+
if (cleanId.startsWith("vinext/shims/")) {
|
|
2256
|
+
const shimPath = resolveShimModulePath(_shimsDir, stripJsExtension(stripViteModuleQuery(cleanId.slice(13))));
|
|
2257
|
+
return this.resolve(shimPath, importer, {
|
|
2258
|
+
...options,
|
|
2259
|
+
skipSelf: true
|
|
2260
|
+
});
|
|
2261
|
+
}
|
|
2214
2262
|
if (cleanId === VIRTUAL_WORKER_ENTRY) return RESOLVED_WORKER_ENTRY;
|
|
2215
2263
|
if (selectedMultiStageOutput && (cleanId === "vinext/server/app-router-entry" || cleanId === "vinext/server/pages-router-entry")) return RESOLVED_WORKER_ENTRY;
|
|
2216
2264
|
if (cleanId.endsWith("/" + VIRTUAL_WORKER_ENTRY)) return RESOLVED_WORKER_ENTRY;
|
|
@@ -2271,7 +2319,10 @@ function vinext(options = {}) {
|
|
|
2271
2319
|
const reactServerShim = _reactServerShims.get(cleanId);
|
|
2272
2320
|
if (reactServerShim !== void 0) {
|
|
2273
2321
|
const shimName = this.environment?.name === "rsc" ? `${reactServerShim}.react-server` : reactServerShim;
|
|
2274
|
-
return resolveShimModulePath(_shimsDir, shimName)
|
|
2322
|
+
return this.resolve(resolveShimModulePath(_shimsDir, shimName), importer, {
|
|
2323
|
+
...options,
|
|
2324
|
+
skipSelf: true
|
|
2325
|
+
});
|
|
2275
2326
|
}
|
|
2276
2327
|
}
|
|
2277
2328
|
},
|
|
@@ -2341,7 +2392,6 @@ function vinext(options = {}) {
|
|
|
2341
2392
|
const globalErrorPath = findFileWithExts(appDir, "global-error", fileMatcher);
|
|
2342
2393
|
const globalNotFoundPath = nextConfig?.globalNotFound ? findFileWithExts(appDir, "global-not-found", fileMatcher) : null;
|
|
2343
2394
|
if (id !== RESOLVED_APP_REQUEST_ENTRY) {
|
|
2344
|
-
rscClassificationManifests.set(id, collectRouteClassificationManifest(routes));
|
|
2345
2395
|
rscActionOwnerRoutes = this.environment.config.command === "build" && hasServerActions ? routes : null;
|
|
2346
2396
|
rscActionOwnerSharedRoots = [globalErrorPath, globalNotFoundPath].filter((path) => path !== null);
|
|
2347
2397
|
clientReferenceRoutes = this.environment.config.command === "build" ? routes : null;
|
|
@@ -2431,45 +2481,6 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2431
2481
|
}
|
|
2432
2482
|
if (id.startsWith("\0virtual:vinext-google-fonts?")) return generateGoogleFontsVirtualModule(id, _fontGoogleShimPath);
|
|
2433
2483
|
}
|
|
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
2484
|
}
|
|
2474
2485
|
},
|
|
2475
2486
|
{
|
|
@@ -2731,6 +2742,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2731
2742
|
asyncHooksStubPlugin,
|
|
2732
2743
|
createInstrumentationClientTransformPlugin(() => instrumentationClientPath, () => nextConfig.instrumentationClientRouteManifest),
|
|
2733
2744
|
createInstrumentationServerTransformPlugin(() => instrumentationPath, () => nextConfig.instrumentationServerValueInjections),
|
|
2745
|
+
createNextIntlCatalogPlugin(() => root, () => nextConfig.nextIntlCatalogLoader),
|
|
2734
2746
|
{
|
|
2735
2747
|
name: "vinext:instrumentation-client-inject",
|
|
2736
2748
|
enforce: "pre",
|
|
@@ -3243,11 +3255,12 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3243
3255
|
const [pathname] = url.split("?");
|
|
3244
3256
|
if (url.startsWith("/@") || url.startsWith("/__vite") || url.startsWith("/node_modules") || url.includes(".") && !pathname.endsWith(".html") && !pathname.endsWith(".rsc")) return next();
|
|
3245
3257
|
const _reqStart = now();
|
|
3258
|
+
const _reqWallStart = Date.now();
|
|
3246
3259
|
let _compileMs;
|
|
3247
3260
|
let _renderMs;
|
|
3248
3261
|
function _parseTiming(raw) {
|
|
3249
3262
|
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 -
|
|
3263
|
+
if (!Number.isNaN(handlerStart) && !Number.isNaN(inHandlerCompileMs) && inHandlerCompileMs !== -1) _compileMs = Math.max(0, Math.round(handlerStart - _reqWallStart)) + inHandlerCompileMs;
|
|
3251
3264
|
if (!Number.isNaN(renderMs) && renderMs !== -1) _renderMs = renderMs;
|
|
3252
3265
|
}
|
|
3253
3266
|
const _origSetHeader = res.setHeader.bind(res);
|
|
@@ -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;
|