vinext 0.1.7 → 0.2.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 +51 -30
- package/dist/build/inject-pregenerated-paths.d.ts +4 -0
- package/dist/build/inject-pregenerated-paths.js +18 -0
- package/dist/build/layout-classification.js +1 -1
- package/dist/build/nitro-route-rules.js +1 -1
- package/dist/build/pages-client-assets-module.d.ts +11 -0
- package/dist/build/pages-client-assets-module.js +27 -0
- package/dist/build/prerender.d.ts +2 -1
- package/dist/build/prerender.js +13 -6
- package/dist/build/report.d.ts +13 -2
- package/dist/build/report.js +99 -2
- package/dist/build/run-prerender.d.ts +7 -0
- package/dist/build/run-prerender.js +10 -1
- package/dist/build/standalone.js +2 -0
- package/dist/cache/cache-adapters-virtual.js +3 -3
- package/dist/check.d.ts +18 -0
- package/dist/check.js +77 -19
- package/dist/cli-args.d.ts +1 -2
- package/dist/cli-args.js +1 -1
- package/dist/cli-dev-config.d.ts +12 -0
- package/dist/cli-dev-config.js +23 -0
- package/dist/cli.js +113 -97
- package/dist/{server → client}/dev-error-overlay-store.d.ts +1 -1
- package/dist/{server → client}/dev-error-overlay-store.js +1 -1
- package/dist/{server → client}/dev-error-overlay.d.ts +1 -1
- package/dist/{server → client}/dev-error-overlay.js +2 -2
- package/dist/client/navigation-runtime.d.ts +2 -0
- package/dist/client/navigation-runtime.js +3 -1
- package/dist/client/window-next.d.ts +2 -1
- package/dist/cloudflare/index.d.ts +2 -2
- package/dist/cloudflare/index.js +2 -2
- package/dist/config/config-matchers.js +14 -10
- package/dist/config/next-config.d.ts +6 -3
- package/dist/config/next-config.js +47 -1
- package/dist/config/prerender.d.ts +34 -0
- package/dist/config/prerender.js +55 -0
- package/dist/config/server-external-packages.d.ts +4 -0
- package/dist/config/server-external-packages.js +91 -0
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +89 -15
- package/dist/entries/app-rsc-manifest.js +10 -0
- package/dist/entries/pages-client-entry.d.ts +3 -0
- package/dist/entries/pages-client-entry.js +16 -1
- package/dist/entries/pages-server-entry.js +6 -2
- package/dist/image/image-adapters-virtual.d.ts +59 -0
- package/dist/image/image-adapters-virtual.js +59 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +211 -118
- package/dist/init-cloudflare.d.ts +43 -0
- package/dist/init-cloudflare.js +839 -0
- package/dist/init-platform.d.ts +40 -0
- package/dist/init-platform.js +195 -0
- package/dist/init.d.ts +16 -38
- package/dist/init.js +208 -97
- package/dist/node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.js +294 -0
- package/dist/node_modules/.pnpm/process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js +94 -0
- package/dist/{cloudflare → packages/cloudflare}/src/cache/cdn-adapter.runtime.js +1 -1
- package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.d.ts +2 -2
- package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.js +1 -1
- package/dist/packages/cloudflare/src/deploy-config.js +150 -0
- package/dist/packages/cloudflare/src/deploy-help.js +55 -0
- package/dist/packages/cloudflare/src/deploy.js +276 -0
- package/dist/{cloudflare → packages/cloudflare/src}/tpr.d.ts +4 -41
- package/dist/{cloudflare → packages/cloudflare/src}/tpr.js +18 -15
- package/dist/plugins/ast-scope.d.ts +16 -0
- package/dist/plugins/ast-scope.js +62 -0
- package/dist/plugins/ast-utils.d.ts +27 -1
- package/dist/plugins/ast-utils.js +32 -1
- package/dist/plugins/css-module-imports.d.ts +14 -0
- package/dist/plugins/css-module-imports.js +59 -0
- package/dist/plugins/extensionless-dynamic-import.js +2 -2
- package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
- package/dist/plugins/ignore-dynamic-requests.js +530 -0
- package/dist/plugins/middleware-server-only.d.ts +8 -6
- package/dist/plugins/middleware-server-only.js +8 -7
- package/dist/plugins/optimize-imports.js +1 -1
- package/dist/plugins/typeof-window.d.ts +1 -1
- package/dist/plugins/typeof-window.js +28 -56
- package/dist/routing/app-route-graph.d.ts +29 -4
- package/dist/routing/app-route-graph.js +182 -40
- package/dist/routing/app-router.d.ts +5 -0
- package/dist/routing/app-router.js +5 -0
- package/dist/routing/file-matcher.d.ts +8 -0
- package/dist/routing/file-matcher.js +10 -1
- package/dist/routing/pages-router.js +2 -2
- package/dist/server/api-handler.js +9 -14
- package/dist/server/app-browser-action-result.d.ts +4 -1
- package/dist/server/app-browser-action-result.js +8 -1
- package/dist/server/app-browser-entry.js +194 -190
- package/dist/server/app-browser-history-controller.d.ts +2 -1
- package/dist/server/app-browser-history-controller.js +6 -2
- package/dist/server/app-browser-interception-context.d.ts +1 -0
- package/dist/server/app-browser-interception-context.js +4 -2
- package/dist/server/app-browser-navigation-controller.d.ts +2 -0
- package/dist/server/app-browser-navigation-controller.js +60 -31
- package/dist/server/app-browser-server-action-client.d.ts +32 -0
- package/dist/server/app-browser-server-action-client.js +127 -0
- package/dist/server/app-browser-state.d.ts +11 -1
- package/dist/server/app-browser-state.js +25 -8
- package/dist/server/app-browser-visible-commit.d.ts +6 -1
- package/dist/server/app-browser-visible-commit.js +43 -25
- package/dist/server/app-elements-wire.d.ts +9 -2
- package/dist/server/app-elements-wire.js +8 -1
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +4 -3
- package/dist/server/app-fallback-renderer.d.ts +5 -2
- package/dist/server/app-fallback-renderer.js +15 -7
- package/dist/server/app-hydration-cache-publication.d.ts +11 -0
- package/dist/server/app-hydration-cache-publication.js +43 -0
- package/dist/server/app-middleware.d.ts +4 -3
- package/dist/server/app-middleware.js +8 -3
- package/dist/server/app-optimistic-routing.js +11 -4
- package/dist/server/app-page-boundary-render.d.ts +3 -0
- package/dist/server/app-page-boundary-render.js +14 -3
- package/dist/server/app-page-cache-finalizer.d.ts +1 -0
- package/dist/server/app-page-cache-finalizer.js +10 -3
- package/dist/server/app-page-cache-render.d.ts +1 -0
- package/dist/server/app-page-cache-render.js +8 -4
- package/dist/server/app-page-cache.d.ts +1 -0
- package/dist/server/app-page-cache.js +5 -2
- package/dist/server/app-page-dispatch.d.ts +33 -4
- package/dist/server/app-page-dispatch.js +63 -90
- package/dist/server/app-page-element-builder.d.ts +9 -2
- package/dist/server/app-page-element-builder.js +114 -23
- package/dist/server/app-page-head.d.ts +16 -1
- package/dist/server/app-page-head.js +44 -22
- package/dist/server/app-page-params.d.ts +2 -1
- package/dist/server/app-page-params.js +8 -1
- package/dist/server/app-page-ppr-runtime.d.ts +7 -0
- package/dist/server/app-page-ppr-runtime.js +70 -0
- package/dist/server/app-page-probe.d.ts +1 -0
- package/dist/server/app-page-probe.js +6 -1
- package/dist/server/app-page-render-identity.d.ts +1 -0
- package/dist/server/app-page-render-identity.js +1 -1
- package/dist/server/app-page-render.d.ts +4 -1
- package/dist/server/app-page-render.js +26 -3
- package/dist/server/app-page-request.d.ts +22 -1
- package/dist/server/app-page-request.js +92 -15
- package/dist/server/app-page-route-wiring.d.ts +14 -2
- package/dist/server/app-page-route-wiring.js +61 -25
- package/dist/server/app-page-search-params-observation.d.ts +4 -2
- package/dist/server/app-page-search-params-observation.js +11 -7
- package/dist/server/app-page-segment-state.d.ts +2 -1
- package/dist/server/app-page-segment-state.js +3 -1
- package/dist/server/app-page-stream.d.ts +5 -0
- package/dist/server/app-page-stream.js +3 -1
- package/dist/server/app-ppr-fallback-shell-render.d.ts +4 -3
- package/dist/server/app-route-handler-dispatch.js +1 -0
- package/dist/server/app-route-handler-execution.js +7 -2
- package/dist/server/app-route-handler-response.js +1 -0
- package/dist/server/app-route-handler-runtime.js +1 -1
- package/dist/server/app-route-module-loader.d.ts +2 -0
- package/dist/server/app-route-module-loader.js +1 -0
- package/dist/server/app-router-entry.js +16 -8
- package/dist/server/app-rsc-errors.js +7 -1
- package/dist/server/app-rsc-handler.d.ts +3 -1
- package/dist/server/app-rsc-handler.js +67 -39
- package/dist/server/app-rsc-request-normalization.d.ts +3 -2
- package/dist/server/app-rsc-request-normalization.js +6 -3
- package/dist/server/app-rsc-route-matching.d.ts +7 -0
- package/dist/server/app-rsc-route-matching.js +36 -3
- package/dist/server/app-segment-config.d.ts +12 -0
- package/dist/server/app-segment-config.js +91 -5
- package/dist/server/app-server-action-execution.d.ts +5 -0
- package/dist/server/app-server-action-execution.js +94 -33
- package/dist/server/app-ssr-entry.d.ts +3 -0
- package/dist/server/app-ssr-entry.js +19 -8
- package/dist/server/app-ssr-stream.d.ts +7 -3
- package/dist/server/app-ssr-stream.js +10 -6
- package/dist/server/app-static-generation.d.ts +1 -0
- package/dist/server/app-static-generation.js +1 -0
- package/dist/server/app-visited-response-cache.d.ts +6 -0
- package/dist/server/app-visited-response-cache.js +3 -1
- package/dist/server/client-trace-metadata.js +26 -0
- package/dist/server/default-global-not-found-module.d.ts +14 -0
- package/dist/server/default-global-not-found-module.js +14 -0
- package/dist/server/dev-route-files.js +4 -0
- package/dist/server/dev-server.js +19 -18
- package/dist/server/dev-stack-sourcemap.d.ts +1 -1
- package/dist/server/dev-stack-sourcemap.js +1 -1
- package/dist/server/fetch-handler.d.ts +2 -0
- package/dist/server/fetch-handler.js +18 -0
- package/dist/server/headers.d.ts +5 -15
- package/dist/server/headers.js +4 -15
- package/dist/server/image-optimization.d.ts +51 -1
- package/dist/server/image-optimization.js +52 -2
- package/dist/server/implicit-tags.js +1 -1
- package/dist/server/isr-cache.d.ts +1 -1
- package/dist/server/isr-cache.js +2 -2
- package/dist/server/metadata-routes.d.ts +3 -1
- package/dist/server/metadata-routes.js +12 -2
- package/dist/server/middleware-runtime.js +6 -1
- package/dist/server/navigation-planner.d.ts +1 -0
- package/dist/server/navigation-planner.js +14 -3
- package/dist/server/pages-api-route.js +2 -2
- package/dist/server/pages-asset-tags.d.ts +4 -6
- package/dist/server/pages-asset-tags.js +12 -12
- package/dist/server/pages-client-assets.d.ts +12 -0
- package/dist/server/pages-client-assets.js +10 -0
- package/dist/server/pages-node-compat.d.ts +8 -1
- package/dist/server/pages-node-compat.js +32 -4
- package/dist/server/pages-page-data.d.ts +24 -1
- package/dist/server/pages-page-data.js +45 -24
- package/dist/server/pages-page-handler.d.ts +2 -1
- package/dist/server/pages-page-handler.js +19 -12
- package/dist/server/pages-page-response.d.ts +7 -0
- package/dist/server/pages-page-response.js +4 -1
- package/dist/server/pages-request-pipeline.d.ts +2 -0
- package/dist/server/pages-request-pipeline.js +25 -1
- package/dist/server/pages-router-entry.d.ts +30 -0
- package/dist/server/pages-router-entry.js +108 -0
- package/dist/server/prerender-manifest.d.ts +3 -1
- package/dist/server/prerender-route-params.js +1 -1
- package/dist/server/prod-server.d.ts +1 -1
- package/dist/server/prod-server.js +48 -26
- package/dist/server/request-pipeline.js +1 -0
- package/dist/server/seed-cache.js +4 -4
- package/dist/server/worker-utils.d.ts +2 -1
- package/dist/server/worker-utils.js +7 -1
- package/dist/shims/app-router-scroll-state.d.ts +1 -0
- package/dist/shims/app-router-scroll-state.js +1 -0
- package/dist/shims/app-router-scroll.js +2 -1
- package/dist/shims/cache.js +19 -15
- package/dist/shims/cdn-cache.js +1 -1
- package/dist/shims/dynamic-preload-chunks.js +2 -1
- package/dist/shims/error-boundary.d.ts +19 -1
- package/dist/shims/error-boundary.js +11 -1
- package/dist/shims/form.d.ts +3 -1
- package/dist/shims/form.js +37 -43
- package/dist/shims/headers.d.ts +9 -1
- package/dist/shims/headers.js +31 -6
- package/dist/shims/image.js +75 -14
- package/dist/shims/internal/app-route-detection.d.ts +2 -17
- package/dist/shims/internal/app-route-detection.js +4 -17
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +23 -0
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +51 -0
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +2 -15
- package/dist/shims/internal/hybrid-client-route-owner.js +9 -60
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +9 -5
- package/dist/shims/internal/pages-data-fetch-dedup.js +73 -14
- package/dist/shims/internal/pages-data-target.d.ts +10 -9
- package/dist/shims/internal/pages-data-target.js +91 -12
- package/dist/shims/internal/pages-router-components.d.ts +7 -0
- package/dist/shims/internal/pages-router-components.js +13 -0
- package/dist/shims/layout-segment-context.d.ts +4 -1
- package/dist/shims/layout-segment-context.js +18 -4
- package/dist/shims/link.js +70 -37
- package/dist/shims/metadata.d.ts +3 -2
- package/dist/shims/metadata.js +8 -4
- package/dist/shims/navigation.d.ts +5 -1
- package/dist/shims/navigation.js +45 -10
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/root-params.d.ts +15 -1
- package/dist/shims/root-params.js +21 -1
- package/dist/shims/router.d.ts +5 -7
- package/dist/shims/router.js +374 -94
- package/dist/shims/server.js +3 -2
- package/dist/shims/slot.js +3 -6
- package/dist/typegen.js +6 -5
- package/dist/utils/client-runtime-metadata.d.ts +2 -18
- package/dist/utils/client-runtime-metadata.js +31 -22
- package/dist/utils/dev-stack-sourcemap-endpoint.d.ts +4 -0
- package/dist/{server → utils}/dev-stack-sourcemap-endpoint.js +1 -1
- package/dist/utils/domain-locale.d.ts +6 -3
- package/dist/{server → utils}/middleware-request-headers.d.ts +1 -1
- package/dist/{server → utils}/middleware-request-headers.js +2 -2
- package/dist/utils/path.d.ts +2 -1
- package/dist/utils/path.js +1 -1
- package/dist/utils/project.d.ts +52 -2
- package/dist/utils/project.js +230 -5
- package/dist/utils/protocol-headers.d.ts +17 -0
- package/dist/utils/protocol-headers.js +17 -0
- package/dist/utils/react-version.d.ts +4 -0
- package/dist/utils/react-version.js +44 -0
- package/package.json +53 -4
- package/dist/deploy.d.ts +0 -190
- package/dist/deploy.js +0 -1033
- package/dist/server/dev-stack-sourcemap-endpoint.d.ts +0 -4
- /package/dist/{cloudflare → packages/cloudflare}/src/utils/cache-control-metadata.js +0 -0
package/dist/index.js
CHANGED
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
import { detectPackageManager } from "./utils/project.js";
|
|
2
|
-
import { normalizePathSeparators, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
|
|
1
|
+
import { detectPackageManager, formatMissingCloudflarePluginError, hasWranglerConfig } from "./utils/project.js";
|
|
3
2
|
import { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
|
|
4
3
|
import { escapeRegExp } from "./utils/regex.js";
|
|
4
|
+
import { normalizePathSeparators, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
|
|
5
5
|
import { buildViteResolveExtensions, createValidFileMatcher, findFileWithExts, normalizeViteResolveExtensions } from "./routing/file-matcher.js";
|
|
6
6
|
import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./routing/pages-router.js";
|
|
7
|
-
import {
|
|
7
|
+
import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
|
|
8
|
+
import { INTERNAL_HEADERS, NEXTJS_DEPLOYMENT_ID_HEADER, VINEXT_INTERNAL_HEADERS, VINEXT_TIMING_HEADER } from "./server/headers.js";
|
|
8
9
|
import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
|
|
9
10
|
import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
|
|
10
11
|
import { isOpenRedirectShaped } from "./server/open-redirect.js";
|
|
11
12
|
import { filterInternalHeaders, normalizeTrailingSlash } from "./server/request-pipeline.js";
|
|
12
13
|
import { findMiddlewareFile, isProxyFile, runMiddleware } from "./server/middleware.js";
|
|
13
14
|
import { generateServerEntry } from "./entries/pages-server-entry.js";
|
|
15
|
+
import { extractMiddlewareMatcherConfig } from "./build/report.js";
|
|
14
16
|
import { generateClientEntry } from "./entries/pages-client-entry.js";
|
|
15
17
|
import { appRouteGraph, appRouter, invalidateAppRouteCache, matchAppRoute } from "./routing/app-router.js";
|
|
16
18
|
import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
|
|
17
19
|
import { isUnknownRecord } from "./utils/record.js";
|
|
18
20
|
import { logRequest, now } from "./server/request-log.js";
|
|
21
|
+
import { resolvePagesI18nRequest } from "./server/pages-i18n.js";
|
|
22
|
+
import { isNextDataPathname, parseNextDataPathname } from "./server/pages-data-route.js";
|
|
19
23
|
import { createSSRHandler } from "./server/dev-server.js";
|
|
20
24
|
import { handleApiRoute } from "./server/api-handler.js";
|
|
21
25
|
import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath, resolveDevImageRedirect } from "./server/image-optimization.js";
|
|
22
26
|
import { installSocketErrorBackstop } from "./server/socket-error-backstop.js";
|
|
23
|
-
import { scanMetadataFiles } from "./server/metadata-routes.js";
|
|
27
|
+
import { invalidateMetadataFileCache, scanMetadataFiles } from "./server/metadata-routes.js";
|
|
24
28
|
import { shouldInvalidateAppRouteFile } from "./server/dev-route-files.js";
|
|
25
29
|
import { createDirectRunner } from "./server/dev-module-runner.js";
|
|
26
30
|
import { validateDevRequest } from "./server/dev-origin-check.js";
|
|
27
31
|
import { generateRscEntry } from "./entries/app-rsc-entry.js";
|
|
28
32
|
import { generateSsrEntry } from "./entries/app-ssr-entry.js";
|
|
29
33
|
import { VIRTUAL_CACHE_ADAPTERS, generateCacheAdaptersModule } from "./cache/cache-adapters-virtual.js";
|
|
34
|
+
import { VIRTUAL_IMAGE_ADAPTERS, generateImageAdaptersModule } from "./image/image-adapters-virtual.js";
|
|
30
35
|
import { generateBrowserEntry, isLinkPrefetchRoute, toDocumentOnlyAppRoute, toLinkPrefetchRoute } from "./entries/app-browser-entry.js";
|
|
31
36
|
import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
|
|
32
37
|
import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
|
|
@@ -35,7 +40,7 @@ import { resolveAssetsDir } from "./utils/asset-prefix.js";
|
|
|
35
40
|
import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
|
|
36
41
|
import { getDepOptimizeNodeEnvOptions, getViteMajorVersion, serializeViteDefine } from "./utils/vite-version.js";
|
|
37
42
|
import { createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
|
|
38
|
-
import {
|
|
43
|
+
import { mergeServerExternalPackages } from "./config/server-external-packages.js";
|
|
39
44
|
import { precompressAssets } from "./build/precompress.js";
|
|
40
45
|
import { ensureAssetsIgnore } from "./build/assets-ignore.js";
|
|
41
46
|
import { emitNextClientRuntimeManifests } from "./build/next-client-runtime-manifests.js";
|
|
@@ -48,6 +53,7 @@ import { renderVinextBuiltUrl } from "./utils/built-asset-url.js";
|
|
|
48
53
|
import { asyncHooksStubPlugin } from "./plugins/async-hooks-stub.js";
|
|
49
54
|
import { clientReferenceDedupPlugin } from "./plugins/client-reference-dedup.js";
|
|
50
55
|
import { dataUrlCssPlugin } from "./plugins/css-data-url.js";
|
|
56
|
+
import { createCssModuleImportCompatibilityPlugin } from "./plugins/css-module-imports.js";
|
|
51
57
|
import { createRscClientReferenceLoadersPlugin } from "./plugins/rsc-client-reference-loaders.js";
|
|
52
58
|
import { createInstrumentationClientTransformPlugin } from "./plugins/instrumentation-client.js";
|
|
53
59
|
import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
|
|
@@ -61,8 +67,8 @@ import { generateRouteTypes } from "./typegen.js";
|
|
|
61
67
|
import { SSR_EXTERNAL_REACT_ENTRIES, VINEXT_OPTIMIZE_DEPS_EXCLUDE, mergeOptimizeDepsExclude } from "./plugins/rsc-client-shim-excludes.js";
|
|
62
68
|
import { createServerExternalsManifestPlugin } from "./plugins/server-externals-manifest.js";
|
|
63
69
|
import { VINEXT_CLIENT_ENTRY_MANIFEST } from "./utils/client-entry-manifest.js";
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
70
|
+
import { computeClientRuntimeMetadata } from "./utils/client-runtime-metadata.js";
|
|
71
|
+
import { PAGES_CLIENT_ASSETS_MODULE, buildPagesClientAssetsModule, setPagesClientAssetsBuildMetadata, takePagesClientAssetsBuildMetadata, writePagesClientAssetsModuleIfMissing } from "./build/pages-client-assets-module.js";
|
|
66
72
|
import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
|
|
67
73
|
import { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassTildeImporter } from "./plugins/sass.js";
|
|
68
74
|
import { createClientAssetFileNames, createClientCodeSplittingConfig, createClientFileNameConfig, createClientManualChunks, createClientOutputConfig, createRscFrameworkChunkOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfigForVite, withBuildBundlerOptions } from "./build/client-build-config.js";
|
|
@@ -76,6 +82,8 @@ import { createWasmModuleImportPlugin } from "./plugins/wasm-module-import.js";
|
|
|
76
82
|
import { getTypeofWindowReplacement, replaceTypeofWindow } from "./plugins/typeof-window.js";
|
|
77
83
|
import { hasMdxFiles } from "./utils/mdx-scan.js";
|
|
78
84
|
import { scanPublicFileRoutes } from "./utils/public-routes.js";
|
|
85
|
+
import { createIgnoreDynamicRequestsPlugin } from "./plugins/ignore-dynamic-requests.js";
|
|
86
|
+
import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, normalizeVinextPrerenderConfig } from "./config/prerender.js";
|
|
79
87
|
import { staticExportApp, staticExportPages } from "./build/static-export.js";
|
|
80
88
|
import { createRequire } from "node:module";
|
|
81
89
|
import fs from "node:fs";
|
|
@@ -85,7 +93,6 @@ import { pathToFileURL } from "node:url";
|
|
|
85
93
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
86
94
|
import commonjs from "vite-plugin-commonjs";
|
|
87
95
|
import MagicString from "magic-string";
|
|
88
|
-
import tsconfigPaths from "vite-tsconfig-paths";
|
|
89
96
|
//#region src/index.ts
|
|
90
97
|
installSocketErrorBackstop();
|
|
91
98
|
function getCacheDirPrefix(cacheDir) {
|
|
@@ -138,6 +145,11 @@ function resolveOptionalDependency(projectRoot, specifier) {
|
|
|
138
145
|
} catch {}
|
|
139
146
|
return null;
|
|
140
147
|
}
|
|
148
|
+
async function loadVite7TsconfigPathsPlugin(projectRoot) {
|
|
149
|
+
const resolvedPath = resolveOptionalDependency(projectRoot, "vite-tsconfig-paths");
|
|
150
|
+
if (!resolvedPath) throw new Error("[vinext] Vite 7 requires the optional peer dependency vite-tsconfig-paths for tsconfig path alias support. Install vite-tsconfig-paths or upgrade to Vite 8.");
|
|
151
|
+
return (await import(pathToFileURL(resolvedPath).href)).default();
|
|
152
|
+
}
|
|
141
153
|
function resolveShimModulePath(shimsDir, moduleName) {
|
|
142
154
|
for (const ext of [
|
|
143
155
|
".ts",
|
|
@@ -230,6 +242,20 @@ function toViteAliasReplacement(absolutePath, projectRoot) {
|
|
|
230
242
|
}
|
|
231
243
|
return normalizedPath;
|
|
232
244
|
}
|
|
245
|
+
function resolveSwcHelpersAlias(root) {
|
|
246
|
+
const rootRequire = createRequire(path.join(root, "package.json"));
|
|
247
|
+
const resolvers = [];
|
|
248
|
+
try {
|
|
249
|
+
const nextPackageJson = rootRequire.resolve("next/package.json");
|
|
250
|
+
const realNextPackageJson = tryRealpathSync(nextPackageJson) ?? nextPackageJson;
|
|
251
|
+
resolvers.push(createRequire(realNextPackageJson));
|
|
252
|
+
} catch {}
|
|
253
|
+
resolvers.push(rootRequire, createRequire(import.meta.url));
|
|
254
|
+
for (const resolver of resolvers) try {
|
|
255
|
+
const packageJsonPath = resolver.resolve("@swc/helpers/package.json");
|
|
256
|
+
return normalizePathSeparators(path.join(path.dirname(packageJsonPath), "_"));
|
|
257
|
+
} catch {}
|
|
258
|
+
}
|
|
233
259
|
function loadTsconfigPathAliases(configPath, projectRoot, seen = /* @__PURE__ */ new Set()) {
|
|
234
260
|
const normalizedPath = tryRealpathSync(configPath) ?? configPath;
|
|
235
261
|
if (seen.has(normalizedPath)) return {};
|
|
@@ -293,19 +319,27 @@ function resolveTsconfigAliases(projectRoot) {
|
|
|
293
319
|
_tsconfigAliasCache.set(projectRoot, aliases);
|
|
294
320
|
return aliases;
|
|
295
321
|
}
|
|
322
|
+
const VIRTUAL_WORKER_ENTRY = "virtual:vinext-worker-entry";
|
|
323
|
+
const RESOLVED_WORKER_ENTRY = "\0virtual:vinext-worker-entry";
|
|
296
324
|
const VIRTUAL_SERVER_ENTRY = "virtual:vinext-server-entry";
|
|
297
325
|
const RESOLVED_SERVER_ENTRY = "\0virtual:vinext-server-entry";
|
|
298
326
|
const VIRTUAL_CLIENT_ENTRY = "virtual:vinext-client-entry";
|
|
299
327
|
const RESOLVED_CLIENT_ENTRY = "\0virtual:vinext-client-entry";
|
|
328
|
+
const VIRTUAL_PAGES_CLIENT_ASSETS = "virtual:vinext-pages-client-assets";
|
|
329
|
+
const RESOLVED_PAGES_CLIENT_ASSETS = "\0virtual:vinext-pages-client-assets";
|
|
300
330
|
const VIRTUAL_RSC_ENTRY = "virtual:vinext-rsc-entry";
|
|
301
331
|
const RESOLVED_RSC_ENTRY = "\0virtual:vinext-rsc-entry";
|
|
302
332
|
const VIRTUAL_APP_SSR_ENTRY = "virtual:vinext-app-ssr-entry";
|
|
303
333
|
const RESOLVED_APP_SSR_ENTRY = "\0virtual:vinext-app-ssr-entry";
|
|
304
334
|
const VIRTUAL_APP_BROWSER_ENTRY = "virtual:vinext-app-browser-entry";
|
|
305
335
|
const RESOLVED_APP_BROWSER_ENTRY = "\0virtual:vinext-app-browser-entry";
|
|
336
|
+
const VIRTUAL_APP_CAPABILITIES = "virtual:vinext-app-capabilities";
|
|
337
|
+
const RESOLVED_APP_CAPABILITIES = "\0virtual:vinext-app-capabilities";
|
|
306
338
|
const RESOLVED_ROOT_PARAMS = "\0virtual:vinext-root-params";
|
|
307
339
|
/** Virtual module that registers config-driven cache adapters (see VinextOptions.cache). */
|
|
308
340
|
const RESOLVED_CACHE_ADAPTERS = "\0" + VIRTUAL_CACHE_ADAPTERS;
|
|
341
|
+
/** Virtual module that registers the config-driven image optimizer (see VinextOptions.images). */
|
|
342
|
+
const RESOLVED_IMAGE_ADAPTERS = "\0" + VIRTUAL_IMAGE_ADAPTERS;
|
|
309
343
|
/** Virtual module for composed instrumentation-client bootstrap. */
|
|
310
344
|
const VIRTUAL_INSTRUMENTATION_CLIENT = "private-next-instrumentation-client";
|
|
311
345
|
const RESOLVED_INSTRUMENTATION_CLIENT = `${VIRTUAL_INSTRUMENTATION_CLIENT}.mjs`;
|
|
@@ -331,8 +365,11 @@ function createStaticImageAsset(imagePath) {
|
|
|
331
365
|
* the `id.startsWith(_shimsDir)` checks would never match.
|
|
332
366
|
*/
|
|
333
367
|
const _shimsDir = normalizePathSeparators(path.resolve(__dirname, "shims")) + "/";
|
|
368
|
+
const _serverDir = normalizePathSeparators(path.resolve(__dirname, "server"));
|
|
334
369
|
const _fontGoogleShimPath = resolveShimModulePath(_shimsDir, "font-google");
|
|
335
|
-
const
|
|
370
|
+
const _appBrowserServerActionClientPath = resolveShimModulePath(_serverDir, "app-browser-server-action-client");
|
|
371
|
+
const _appRscHandlerPath = resolveShimModulePath(_serverDir, "app-rsc-handler");
|
|
372
|
+
const _pagesClientAssetsPath = resolveShimModulePath(_serverDir, "pages-client-assets");
|
|
336
373
|
const _canExternalizeAppRscHandler = _appRscHandlerPath.endsWith(".js");
|
|
337
374
|
function isValidExportIdentifier(name) {
|
|
338
375
|
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
@@ -432,6 +469,7 @@ function getClientOutputConfigForVite(viteMajorVersion, assetsDir, preserveAppRo
|
|
|
432
469
|
} : createClientOutputConfig(manualChunks, assetsDir);
|
|
433
470
|
}
|
|
434
471
|
function vinext(options = {}) {
|
|
472
|
+
const prerenderConfig = normalizeVinextPrerenderConfig(options.prerender);
|
|
435
473
|
const viteMajorVersion = getViteMajorVersion();
|
|
436
474
|
let root;
|
|
437
475
|
let pagesDir;
|
|
@@ -449,6 +487,8 @@ function vinext(options = {}) {
|
|
|
449
487
|
let hasCloudflarePlugin = false;
|
|
450
488
|
let warnedInlineNextConfigOverride = false;
|
|
451
489
|
let hasNitroPlugin = false;
|
|
490
|
+
const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
|
|
491
|
+
let pagesClientAssetsModule = null;
|
|
452
492
|
let rscCompatibilityId;
|
|
453
493
|
const draftModeSecret = randomUUID();
|
|
454
494
|
const sassComposesLoader = createSassAwareFileSystemLoader();
|
|
@@ -494,7 +534,9 @@ function vinext(options = {}) {
|
|
|
494
534
|
const appPrefetchRoutes = hasAppDir ? (await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher)).map((route) => isLinkPrefetchRoute(route) ? toLinkPrefetchRoute(route) : toDocumentOnlyAppRoute(route)) : [];
|
|
495
535
|
return generateClientEntry(pagesDir, nextConfig, fileMatcher, {
|
|
496
536
|
appPrefetchRoutes,
|
|
497
|
-
instrumentationClientPath
|
|
537
|
+
instrumentationClientPath,
|
|
538
|
+
middlewareMatcher: middlewarePath ? extractMiddlewareMatcherConfig(middlewarePath) : void 0,
|
|
539
|
+
reactPreamble: options.react !== false
|
|
498
540
|
});
|
|
499
541
|
}
|
|
500
542
|
async function writeRouteTypes() {
|
|
@@ -531,6 +573,13 @@ function vinext(options = {}) {
|
|
|
531
573
|
throw new Error("vinext: Failed to load @vitejs/plugin-rsc.", { cause });
|
|
532
574
|
});
|
|
533
575
|
}
|
|
576
|
+
async function resolveHasServerActions(config) {
|
|
577
|
+
if (config.command !== "build" || !rscPluginModulePromise) return true;
|
|
578
|
+
const { getPluginApi } = await rscPluginModulePromise;
|
|
579
|
+
const pluginApi = getPluginApi(config);
|
|
580
|
+
if (!pluginApi || pluginApi.manager.isScanBuild) return true;
|
|
581
|
+
return Object.keys(pluginApi.manager.serverReferenceMetaMap).length > 0;
|
|
582
|
+
}
|
|
534
583
|
const reactOptions = options.react && options.react !== true ? options.react : void 0;
|
|
535
584
|
let reactPluginPromise = null;
|
|
536
585
|
if (options.react !== false) {
|
|
@@ -576,8 +625,9 @@ function vinext(options = {}) {
|
|
|
576
625
|
return mdxDelegatePromise;
|
|
577
626
|
}
|
|
578
627
|
const plugins = [
|
|
579
|
-
...viteMajorVersion >= 8 ? [] : [
|
|
628
|
+
...viteMajorVersion >= 8 ? [] : [loadVite7TsconfigPathsPlugin(earlyBaseDir)],
|
|
580
629
|
reactPluginPromise,
|
|
630
|
+
createIgnoreDynamicRequestsPlugin(() => nextConfig?.turbopackTranspilePackages ?? []),
|
|
581
631
|
commonjs(),
|
|
582
632
|
...viteMajorVersion >= 8 ? [{
|
|
583
633
|
name: "vinext:jsx-in-js",
|
|
@@ -606,17 +656,24 @@ function vinext(options = {}) {
|
|
|
606
656
|
createMiddlewareServerOnlyPlugin({
|
|
607
657
|
getMiddlewarePath: () => middlewarePath,
|
|
608
658
|
getCanonicalMiddlewarePath: () => middlewarePath ? tryRealpathSync(middlewarePath) ?? middlewarePath : null,
|
|
659
|
+
isNeutralServerModule: (id) => {
|
|
660
|
+
const canonicalId = canonicalizePageTransformPath(id);
|
|
661
|
+
return isWithinPagesDirectory(canonicalId) && isApiPage(canonicalId);
|
|
662
|
+
},
|
|
609
663
|
serverOnlyShimPath: resolveShimModulePath(shimsDir, "server-only")
|
|
610
664
|
}),
|
|
611
665
|
dataUrlCssPlugin(),
|
|
666
|
+
createCssModuleImportCompatibilityPlugin(),
|
|
612
667
|
{
|
|
613
668
|
name: "vinext:config",
|
|
614
669
|
enforce: "pre",
|
|
670
|
+
[VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY]: prerenderConfig,
|
|
615
671
|
async config(config, env) {
|
|
616
672
|
root = normalizePathSeparators(config.root ?? process.cwd());
|
|
617
673
|
const userResolve = config.resolve;
|
|
618
674
|
const shouldEnableNativeTsconfigPaths = viteMajorVersion >= 8 && userResolve?.tsconfigPaths === void 0;
|
|
619
675
|
const tsconfigPathAliases = resolveTsconfigAliases(root);
|
|
676
|
+
const swcHelpersAlias = resolveSwcHelpersAlias(root);
|
|
620
677
|
const mode = env?.mode ?? "development";
|
|
621
678
|
const dotenvVars = loadEnv(mode, config.envDir ?? root, "");
|
|
622
679
|
for (const [key, value] of Object.entries(dotenvVars)) if (process.env[key] === void 0) process.env[key] = value;
|
|
@@ -681,6 +738,8 @@ function vinext(options = {}) {
|
|
|
681
738
|
defines[`process.env.${key}`] = JSON.stringify(value);
|
|
682
739
|
}
|
|
683
740
|
defines["process.env.__NEXT_ROUTER_BASEPATH"] = JSON.stringify(nextConfig.basePath);
|
|
741
|
+
defines["process.env.__VINEXT_HAS_PAGES_ROUTER"] = JSON.stringify(String(hasPagesDir));
|
|
742
|
+
defines["process.env.__NEXT_CLIENT_ROUTER_DYNAMIC_STALETIME"] = JSON.stringify(String(nextConfig.staleTimes.dynamic));
|
|
684
743
|
defines["process.env.__NEXT_CLIENT_ROUTER_STATIC_STALETIME"] = JSON.stringify(String(nextConfig.staleTimes.static));
|
|
685
744
|
defines["process.env.__VINEXT_PREFETCH_INLINING"] = JSON.stringify(nextConfig.prefetchInlining ? "true" : "false");
|
|
686
745
|
defines["process.env.__NEXT_GESTURE_TRANSITION"] = JSON.stringify(nextConfig.gestureTransition);
|
|
@@ -716,6 +775,7 @@ function vinext(options = {}) {
|
|
|
716
775
|
}
|
|
717
776
|
defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_SVG"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowSVG ?? false));
|
|
718
777
|
defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_LOCAL_IP"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowLocalIP ?? false));
|
|
778
|
+
defines["process.env.__VINEXT_IMAGE_UNOPTIMIZED"] = JSON.stringify(String(nextConfig.images?.unoptimized === true));
|
|
719
779
|
defines["process.env.__VINEXT_BUILD_ID"] = JSON.stringify(nextConfig.buildId);
|
|
720
780
|
defines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify(rscCompatibilityId);
|
|
721
781
|
defines["process.env.__VINEXT_DEPLOYMENT_ID"] = JSON.stringify(nextConfig.deploymentId ?? "");
|
|
@@ -782,7 +842,7 @@ function vinext(options = {}) {
|
|
|
782
842
|
"vinext/cache": path.resolve(__dirname, "cache"),
|
|
783
843
|
"vinext/instrumentation": path.resolve(__dirname, "server", "instrumentation"),
|
|
784
844
|
"vinext/instrumentation-client": path.resolve(__dirname, "client", "instrumentation-client"),
|
|
785
|
-
"vinext/dev-error-overlay": path.resolve(__dirname, "
|
|
845
|
+
"vinext/dev-error-overlay": path.resolve(__dirname, "client", "dev-error-overlay"),
|
|
786
846
|
"vinext/html": path.resolve(__dirname, "server", "html"),
|
|
787
847
|
...clientInjectModule === null ? { "private-next-instrumentation-client": instrumentationClientPath ?? INSTRUMENTATION_CLIENT_EMPTY_MODULE } : {}
|
|
788
848
|
}).flatMap(([k, v]) => k.startsWith("next/") ? [[k, v], [`${k}.js`, v]] : [[k, v]]));
|
|
@@ -800,6 +860,8 @@ function vinext(options = {}) {
|
|
|
800
860
|
hasUserMdxPlugin = pluginsFlat.some((p) => p && typeof p === "object" && "name" in p && typeof p.name === "string" && (p.name === "@mdx-js/rollup" || p.name === "mdx"));
|
|
801
861
|
if (!hasUserMdxPlugin && hasMdxFiles(root, hasAppDir ? appDir : null, hasPagesDir ? pagesDir : null)) await ensureMdxDelegate("detected");
|
|
802
862
|
const isSSR = !!config.build?.ssr;
|
|
863
|
+
const serverTranspilePackages = [...nextConfig?.turbopackTranspilePackages ?? [], ...nextConfig?.optimizePackageImports ?? []];
|
|
864
|
+
const nextServerExternal = mergeServerExternalPackages(nextConfig?.serverExternalPackages, serverTranspilePackages);
|
|
803
865
|
const isMultiEnv = hasAppDir || hasCloudflarePlugin || hasNitroPlugin;
|
|
804
866
|
const hasBuildInput = getBuildBundlerOptions(config.build)?.input !== void 0;
|
|
805
867
|
const shouldInjectPlainPagesEnvironments = !hasAppDir && !hasCloudflarePlugin && !isSSR && !hasBuildInput;
|
|
@@ -850,15 +912,19 @@ function vinext(options = {}) {
|
|
|
850
912
|
"react",
|
|
851
913
|
"react-dom",
|
|
852
914
|
"react-dom/server",
|
|
853
|
-
"ipaddr.js"
|
|
915
|
+
"ipaddr.js",
|
|
916
|
+
...Array.isArray(config.ssr?.external) ? config.ssr.external : [],
|
|
917
|
+
...nextServerExternal
|
|
854
918
|
],
|
|
855
919
|
noExternal: true
|
|
856
920
|
} },
|
|
857
921
|
resolve: {
|
|
858
922
|
alias: {
|
|
923
|
+
...swcHelpersAlias ? { "@swc/helpers/_": swcHelpersAlias } : {},
|
|
859
924
|
...tsconfigPathAliases,
|
|
860
925
|
...nextConfig.aliases,
|
|
861
|
-
...nextShimMap
|
|
926
|
+
...nextShimMap,
|
|
927
|
+
"vinext/server/pages-client-assets": _pagesClientAssetsPath
|
|
862
928
|
},
|
|
863
929
|
dedupe: [
|
|
864
930
|
"react",
|
|
@@ -895,7 +961,6 @@ function vinext(options = {}) {
|
|
|
895
961
|
...cssModulesOverride
|
|
896
962
|
}
|
|
897
963
|
};
|
|
898
|
-
const nextServerExternal = nextConfig?.serverExternalPackages ?? [];
|
|
899
964
|
const userSsrExternal = Array.isArray(config.ssr?.external) ? [...config.ssr.external, ...nextServerExternal] : config.ssr?.external === true ? true : nextServerExternal;
|
|
900
965
|
const externalizeSsrReactInDev = env.command === "serve" && !hasCloudflarePlugin && !hasNitroPlugin;
|
|
901
966
|
const incomingExclude = config.optimizeDeps?.exclude ?? [];
|
|
@@ -1031,7 +1096,8 @@ function vinext(options = {}) {
|
|
|
1031
1096
|
"react",
|
|
1032
1097
|
"react-dom",
|
|
1033
1098
|
"react-dom/server",
|
|
1034
|
-
"ipaddr.js"
|
|
1099
|
+
"ipaddr.js",
|
|
1100
|
+
...nextServerExternal
|
|
1035
1101
|
],
|
|
1036
1102
|
noExternal: true
|
|
1037
1103
|
},
|
|
@@ -1102,7 +1168,7 @@ function vinext(options = {}) {
|
|
|
1102
1168
|
resolveId: {
|
|
1103
1169
|
filter: { id: /(?:next\/|vinext\/(?:shims\/|server\/app-rsc-handler)|virtual:vinext-|@vercel\/og(?:\.js)?$)/ },
|
|
1104
1170
|
handler(id, importer) {
|
|
1105
|
-
const cleanId = id.startsWith("\0") ? id.slice(1) : id;
|
|
1171
|
+
const cleanId = normalizePathSeparators(id.startsWith("\0") ? id.slice(1) : id);
|
|
1106
1172
|
if (cleanId === "vinext/server/app-rsc-handler") {
|
|
1107
1173
|
if (_canExternalizeAppRscHandler && this.environment?.name === "rsc" && this.environment.config?.command === "serve") return {
|
|
1108
1174
|
id: _appRscHandlerPath,
|
|
@@ -1112,20 +1178,24 @@ function vinext(options = {}) {
|
|
|
1112
1178
|
}
|
|
1113
1179
|
if (isVercelOgImport(cleanId) && !isVinextOgShimImporter(importer)) return resolveShimModulePath(_shimsDir, "og");
|
|
1114
1180
|
if (cleanId.startsWith("vinext/shims/")) return resolveShimModulePath(_shimsDir, stripJsExtension(stripViteModuleQuery(cleanId.slice(13))));
|
|
1181
|
+
if (cleanId === VIRTUAL_WORKER_ENTRY) return RESOLVED_WORKER_ENTRY;
|
|
1182
|
+
if (cleanId.endsWith("/virtual:vinext-worker-entry")) return RESOLVED_WORKER_ENTRY;
|
|
1115
1183
|
if (cleanId === VIRTUAL_SERVER_ENTRY) return RESOLVED_SERVER_ENTRY;
|
|
1116
1184
|
if (cleanId === VIRTUAL_CLIENT_ENTRY) return RESOLVED_CLIENT_ENTRY;
|
|
1117
|
-
if (cleanId.endsWith("/virtual:vinext-server-entry")
|
|
1118
|
-
if (cleanId.endsWith("/virtual:vinext-client-entry")
|
|
1185
|
+
if (cleanId.endsWith("/virtual:vinext-server-entry")) return RESOLVED_SERVER_ENTRY;
|
|
1186
|
+
if (cleanId.endsWith("/virtual:vinext-client-entry")) return RESOLVED_CLIENT_ENTRY;
|
|
1119
1187
|
if (cleanId === VIRTUAL_RSC_ENTRY) return RESOLVED_RSC_ENTRY;
|
|
1120
1188
|
if (cleanId === VIRTUAL_APP_SSR_ENTRY) return RESOLVED_APP_SSR_ENTRY;
|
|
1121
1189
|
if (cleanId === VIRTUAL_APP_BROWSER_ENTRY) return RESOLVED_APP_BROWSER_ENTRY;
|
|
1190
|
+
if (cleanId === VIRTUAL_APP_CAPABILITIES) return RESOLVED_APP_CAPABILITIES;
|
|
1122
1191
|
if (cleanId === "next/root-params" || cleanId === "next/root-params.js") return RESOLVED_ROOT_PARAMS;
|
|
1123
|
-
if (cleanId === "virtual:vinext-cache-adapters" || cleanId.endsWith("/virtual:vinext-cache-adapters")
|
|
1192
|
+
if (cleanId === "virtual:vinext-cache-adapters" || cleanId.endsWith("/virtual:vinext-cache-adapters")) return RESOLVED_CACHE_ADAPTERS;
|
|
1193
|
+
if (cleanId === "virtual:vinext-image-adapters" || cleanId.endsWith("/virtual:vinext-image-adapters")) return RESOLVED_IMAGE_ADAPTERS;
|
|
1124
1194
|
if (cleanId.startsWith("virtual:vinext-google-fonts?")) return RESOLVED_VIRTUAL_GOOGLE_FONTS + cleanId.slice(VIRTUAL_GOOGLE_FONTS.length);
|
|
1125
|
-
if (cleanId.endsWith("/virtual:vinext-rsc-entry")
|
|
1126
|
-
if (cleanId.endsWith("/virtual:vinext-app-ssr-entry")
|
|
1127
|
-
if (cleanId.endsWith("/virtual:vinext-app-browser-entry")
|
|
1128
|
-
if (cleanId.includes("/virtual:vinext-google-fonts?")
|
|
1195
|
+
if (cleanId.endsWith("/virtual:vinext-rsc-entry")) return RESOLVED_RSC_ENTRY;
|
|
1196
|
+
if (cleanId.endsWith("/virtual:vinext-app-ssr-entry")) return RESOLVED_APP_SSR_ENTRY;
|
|
1197
|
+
if (cleanId.endsWith("/virtual:vinext-app-browser-entry")) return RESOLVED_APP_BROWSER_ENTRY;
|
|
1198
|
+
if (cleanId.includes("/virtual:vinext-google-fonts?")) {
|
|
1129
1199
|
const queryIndex = cleanId.indexOf(VIRTUAL_GOOGLE_FONTS + "?");
|
|
1130
1200
|
return RESOLVED_VIRTUAL_GOOGLE_FONTS + cleanId.slice(queryIndex + VIRTUAL_GOOGLE_FONTS.length);
|
|
1131
1201
|
}
|
|
@@ -1134,19 +1204,16 @@ function vinext(options = {}) {
|
|
|
1134
1204
|
}
|
|
1135
1205
|
},
|
|
1136
1206
|
async load(id) {
|
|
1207
|
+
if (id === RESOLVED_WORKER_ENTRY) return `export { default } from ${JSON.stringify(hasAppDir ? "vinext/server/app-router-entry" : "vinext/server/pages-router-entry")};`;
|
|
1137
1208
|
if (id === RESOLVED_SERVER_ENTRY) return await generateServerEntry$1();
|
|
1138
1209
|
if (id === RESOLVED_CLIENT_ENTRY) return await generateClientEntry$1();
|
|
1210
|
+
if (id === RESOLVED_PAGES_CLIENT_ASSETS) return "export default { clientEntry: '/@id/__x00__virtual:vinext-client-entry' };";
|
|
1139
1211
|
if (id === RESOLVED_RSC_ENTRY && hasAppDir) {
|
|
1140
1212
|
const routes = await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher);
|
|
1141
1213
|
const metaRoutes = scanMetadataFiles(appDir);
|
|
1142
|
-
|
|
1143
|
-
if (this.environment?.config.command === "build" && rscPluginModulePromise) {
|
|
1144
|
-
const { getPluginApi } = await rscPluginModulePromise;
|
|
1145
|
-
const pluginApi = getPluginApi(this.environment.config);
|
|
1146
|
-
if (pluginApi && !pluginApi.manager.isScanBuild) hasServerActions = Object.keys(pluginApi.manager.serverReferenceMetaMap).length > 0;
|
|
1147
|
-
}
|
|
1214
|
+
const hasServerActions = await resolveHasServerActions(this.environment.config);
|
|
1148
1215
|
const globalErrorPath = findFileWithExts(appDir, "global-error", fileMatcher);
|
|
1149
|
-
const globalNotFoundPath = findFileWithExts(appDir, "global-not-found", fileMatcher);
|
|
1216
|
+
const globalNotFoundPath = nextConfig?.globalNotFound ? findFileWithExts(appDir, "global-not-found", fileMatcher) : null;
|
|
1150
1217
|
rscClassificationManifest = collectRouteClassificationManifest(routes);
|
|
1151
1218
|
return generateRscEntry(appDir, routes, middlewarePath, metaRoutes, globalErrorPath, nextConfig?.basePath, nextConfig?.trailingSlash, {
|
|
1152
1219
|
redirects: nextConfig?.redirects,
|
|
@@ -1163,13 +1230,18 @@ function vinext(options = {}) {
|
|
|
1163
1230
|
reactMaxHeadersLength: nextConfig?.reactMaxHeadersLength,
|
|
1164
1231
|
cacheMaxMemorySize: nextConfig?.cacheMaxMemorySize,
|
|
1165
1232
|
inlineCss: nextConfig?.inlineCss,
|
|
1233
|
+
globalNotFound: nextConfig?.globalNotFound,
|
|
1166
1234
|
cacheComponents: nextConfig?.cacheComponents,
|
|
1167
1235
|
hasServerActions,
|
|
1168
1236
|
i18n: nextConfig?.i18n,
|
|
1169
1237
|
imageConfig: {
|
|
1170
1238
|
deviceSizes: nextConfig?.images?.deviceSizes,
|
|
1171
1239
|
imageSizes: nextConfig?.images?.imageSizes,
|
|
1172
|
-
qualities: nextConfig?.images?.qualities
|
|
1240
|
+
qualities: nextConfig?.images?.qualities,
|
|
1241
|
+
dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,
|
|
1242
|
+
dangerouslyAllowLocalIP: nextConfig?.images?.dangerouslyAllowLocalIP,
|
|
1243
|
+
contentDispositionType: nextConfig?.images?.contentDispositionType,
|
|
1244
|
+
contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy
|
|
1173
1245
|
},
|
|
1174
1246
|
hasPagesDir,
|
|
1175
1247
|
publicFiles: scanPublicFileRoutes(root),
|
|
@@ -1179,6 +1251,7 @@ function vinext(options = {}) {
|
|
|
1179
1251
|
}
|
|
1180
1252
|
if (id === RESOLVED_ROOT_PARAMS) return generateRootParamsModule((hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : []).flatMap((route) => route.rootParamNames ?? []));
|
|
1181
1253
|
if (id === RESOLVED_CACHE_ADAPTERS) return generateCacheAdaptersModule(options.cache);
|
|
1254
|
+
if (id === RESOLVED_IMAGE_ADAPTERS) return generateImageAdaptersModule(options.images);
|
|
1182
1255
|
if (id === RESOLVED_APP_SSR_ENTRY && hasAppDir) return generateSsrEntry(hasPagesDir);
|
|
1183
1256
|
if (id === RESOLVED_APP_BROWSER_ENTRY && hasAppDir) {
|
|
1184
1257
|
const graph = await appRouteGraph(appDir, nextConfig?.pageExtensions, fileMatcher);
|
|
@@ -1194,6 +1267,13 @@ function vinext(options = {}) {
|
|
|
1194
1267
|
}))] : [];
|
|
1195
1268
|
return generateBrowserEntry(graph.routes, graph.routeManifest, pagesPrefetchRoutes, nextConfig.rewrites);
|
|
1196
1269
|
}
|
|
1270
|
+
if (id === RESOLVED_APP_CAPABILITIES && hasAppDir) {
|
|
1271
|
+
const hasServerActions = await resolveHasServerActions(this.environment.config);
|
|
1272
|
+
return `
|
|
1273
|
+
export const hasServerActions = ${JSON.stringify(hasServerActions)};
|
|
1274
|
+
export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.stringify(_appBrowserServerActionClientPath)})` : "null"};
|
|
1275
|
+
`;
|
|
1276
|
+
}
|
|
1197
1277
|
if (id.startsWith("\0virtual:vinext-google-fonts?")) return generateGoogleFontsVirtualModule(id, _fontGoogleShimPath);
|
|
1198
1278
|
},
|
|
1199
1279
|
// @vitejs/plugin-rsc runs the RSC environment build in two phases:
|
|
@@ -1231,6 +1311,28 @@ function vinext(options = {}) {
|
|
|
1231
1311
|
}
|
|
1232
1312
|
}
|
|
1233
1313
|
},
|
|
1314
|
+
{
|
|
1315
|
+
name: "vinext:pages-client-assets-resolver",
|
|
1316
|
+
sharedDuringBuild: true,
|
|
1317
|
+
resolveId: {
|
|
1318
|
+
filter: { id: /virtual:vinext-pages-client-assets$/ },
|
|
1319
|
+
handler(id) {
|
|
1320
|
+
const cleanId = normalizePathSeparators(id.startsWith("\0") ? id.slice(1) : id);
|
|
1321
|
+
if (cleanId !== VIRTUAL_PAGES_CLIENT_ASSETS && !cleanId.endsWith("/virtual:vinext-pages-client-assets")) return;
|
|
1322
|
+
if (this.environment?.config.command !== "build") return RESOLVED_PAGES_CLIENT_ASSETS;
|
|
1323
|
+
const buildRoot = this.environment.config.root ?? process.cwd();
|
|
1324
|
+
const environmentOutDir = path.resolve(buildRoot, this.environment.config.build.outDir);
|
|
1325
|
+
const sidecarDir = !hasAppDir && this.environment.name === "ssr" ? path.dirname(environmentOutDir) : environmentOutDir;
|
|
1326
|
+
let externalId = normalizePathSeparators(path.relative(environmentOutDir, path.join(sidecarDir, PAGES_CLIENT_ASSETS_MODULE)));
|
|
1327
|
+
if (!externalId.startsWith(".")) externalId = `./${externalId}`;
|
|
1328
|
+
pagesClientAssetsOutputDirs.add(sidecarDir);
|
|
1329
|
+
return {
|
|
1330
|
+
id: externalId,
|
|
1331
|
+
external: true
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
},
|
|
1234
1336
|
{
|
|
1235
1337
|
name: "vinext:css-url-assets-mark",
|
|
1236
1338
|
enforce: "pre",
|
|
@@ -1251,11 +1353,14 @@ function vinext(options = {}) {
|
|
|
1251
1353
|
}
|
|
1252
1354
|
},
|
|
1253
1355
|
{
|
|
1254
|
-
name: "vinext:
|
|
1356
|
+
name: "vinext:css-url-assets-defaults",
|
|
1255
1357
|
apply: "build",
|
|
1256
|
-
configEnvironment(name) {
|
|
1257
|
-
if (name
|
|
1258
|
-
|
|
1358
|
+
configEnvironment(name, config) {
|
|
1359
|
+
if (name === "client") return { build: { assetsInlineLimit: clientAssetsInlineLimit } };
|
|
1360
|
+
if (!hasAppDir || name !== "rsc" && name !== "ssr") return null;
|
|
1361
|
+
const output = getBuildBundlerOptions(config.build)?.output;
|
|
1362
|
+
if (Array.isArray(output) || output?.assetFileNames !== void 0) return null;
|
|
1363
|
+
return { build: { ...withBuildBundlerOptions(viteMajorVersion, { output: { assetFileNames: createClientAssetFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? "")) } }) } };
|
|
1259
1364
|
}
|
|
1260
1365
|
},
|
|
1261
1366
|
{
|
|
@@ -1338,6 +1443,7 @@ function vinext(options = {}) {
|
|
|
1338
1443
|
}
|
|
1339
1444
|
}
|
|
1340
1445
|
},
|
|
1446
|
+
createCssModuleImportCompatibilityPlugin({ compiledMdx: true }),
|
|
1341
1447
|
{
|
|
1342
1448
|
name: "vinext:react-canary",
|
|
1343
1449
|
enforce: "pre",
|
|
@@ -1427,6 +1533,7 @@ function vinext(options = {}) {
|
|
|
1427
1533
|
}
|
|
1428
1534
|
function invalidateAppRoutingModules() {
|
|
1429
1535
|
invalidateAppRouteCache();
|
|
1536
|
+
invalidateMetadataFileCache();
|
|
1430
1537
|
invalidateRscEntryModule();
|
|
1431
1538
|
invalidateRootParamsModule();
|
|
1432
1539
|
}
|
|
@@ -1797,11 +1904,15 @@ function vinext(options = {}) {
|
|
|
1797
1904
|
hadBasePath: true,
|
|
1798
1905
|
isDataReq,
|
|
1799
1906
|
isDataRequest,
|
|
1907
|
+
hasMiddleware: capturedMiddlewarePath !== null,
|
|
1800
1908
|
rawSearch: url.includes("?") ? url.slice(url.indexOf("?")) : "",
|
|
1801
1909
|
runMiddleware: devRunMiddlewareAdapter,
|
|
1802
|
-
matchPageRoute: (resolvedPathname) => {
|
|
1803
|
-
const m = matchRoute(resolvedPathname, devPageRoutes);
|
|
1804
|
-
return m ? { route: {
|
|
1910
|
+
matchPageRoute: (resolvedPathname, request) => {
|
|
1911
|
+
const m = matchRoute(nextConfig?.i18n ? resolvePagesI18nRequest(resolvedPathname, nextConfig.i18n, request.headers, new URL(request.url).hostname, bp, nextConfig.trailingSlash ?? false).url : resolvedPathname, devPageRoutes);
|
|
1912
|
+
return m ? { route: {
|
|
1913
|
+
isDynamic: m.route.isDynamic,
|
|
1914
|
+
pattern: m.route.pattern
|
|
1915
|
+
} } : null;
|
|
1805
1916
|
},
|
|
1806
1917
|
proxyExternal: async (currentRequest, externalUrl) => {
|
|
1807
1918
|
const externalMethod = req.method ?? "GET";
|
|
@@ -1988,7 +2099,7 @@ function vinext(options = {}) {
|
|
|
1988
2099
|
handler(code, id) {
|
|
1989
2100
|
const cacheDirPrefix = getCacheDirPrefix(this.environment.config.cacheDir);
|
|
1990
2101
|
if (normalizePathSeparators(id).startsWith(cacheDirPrefix)) return null;
|
|
1991
|
-
return replaceTypeofWindow(code, getTypeofWindowReplacement(this.environment));
|
|
2102
|
+
return replaceTypeofWindow(code, getTypeofWindowReplacement(this.environment), id);
|
|
1992
2103
|
}
|
|
1993
2104
|
}
|
|
1994
2105
|
},
|
|
@@ -2242,29 +2353,6 @@ function vinext(options = {}) {
|
|
|
2242
2353
|
createOgInlineFetchAssetsPlugin(),
|
|
2243
2354
|
createOgAssetsPlugin(),
|
|
2244
2355
|
createServerExternalsManifestPlugin(),
|
|
2245
|
-
{
|
|
2246
|
-
name: "vinext:image-config",
|
|
2247
|
-
apply: "build",
|
|
2248
|
-
enforce: "post",
|
|
2249
|
-
writeBundle: {
|
|
2250
|
-
sequential: true,
|
|
2251
|
-
order: "post",
|
|
2252
|
-
handler(options) {
|
|
2253
|
-
if (this.environment?.name !== "rsc") return;
|
|
2254
|
-
const outDir = options.dir;
|
|
2255
|
-
if (!outDir) return;
|
|
2256
|
-
const imageConfig = {
|
|
2257
|
-
deviceSizes: nextConfig?.images?.deviceSizes,
|
|
2258
|
-
imageSizes: nextConfig?.images?.imageSizes,
|
|
2259
|
-
qualities: nextConfig?.images?.qualities,
|
|
2260
|
-
dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,
|
|
2261
|
-
contentDispositionType: nextConfig?.images?.contentDispositionType,
|
|
2262
|
-
contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy
|
|
2263
|
-
};
|
|
2264
|
-
fs.writeFileSync(path.join(outDir, "image-config.json"), JSON.stringify(imageConfig));
|
|
2265
|
-
}
|
|
2266
|
-
}
|
|
2267
|
-
},
|
|
2268
2356
|
(() => {
|
|
2269
2357
|
let buildIdWritten = false;
|
|
2270
2358
|
return {
|
|
@@ -2437,6 +2525,65 @@ function vinext(options = {}) {
|
|
|
2437
2525
|
}
|
|
2438
2526
|
};
|
|
2439
2527
|
})(),
|
|
2528
|
+
{
|
|
2529
|
+
name: "vinext:pages-client-assets",
|
|
2530
|
+
apply: "build",
|
|
2531
|
+
enforce: "post",
|
|
2532
|
+
sharedDuringBuild: true,
|
|
2533
|
+
closeBundle: {
|
|
2534
|
+
sequential: true,
|
|
2535
|
+
order: "post",
|
|
2536
|
+
handler() {
|
|
2537
|
+
const envConfig = this.environment.config;
|
|
2538
|
+
if (this.environment.name === "client") {
|
|
2539
|
+
const buildRoot = envConfig.root ?? process.cwd();
|
|
2540
|
+
const clientDir = path.resolve(buildRoot, envConfig.build.outDir);
|
|
2541
|
+
const runtimeMetadata = computeClientRuntimeMetadata({
|
|
2542
|
+
clientDir,
|
|
2543
|
+
assetBase: envConfig.base ?? "/",
|
|
2544
|
+
assetPrefix: nextConfig.assetPrefix,
|
|
2545
|
+
includeClientEntry: !hasAppDir ? true : hasPagesDir ? "pages-client-entry" : false
|
|
2546
|
+
});
|
|
2547
|
+
let ssrManifest;
|
|
2548
|
+
const ssrManifestPath = path.join(clientDir, ".vite", "ssr-manifest.json");
|
|
2549
|
+
if (fs.existsSync(ssrManifestPath)) try {
|
|
2550
|
+
ssrManifest = JSON.parse(fs.readFileSync(ssrManifestPath, "utf-8"));
|
|
2551
|
+
} catch {}
|
|
2552
|
+
pagesClientAssetsModule = buildPagesClientAssetsModule({
|
|
2553
|
+
clientEntry: runtimeMetadata.clientEntryFile ?? void 0,
|
|
2554
|
+
appBootstrapPreinitModules: runtimeMetadata.appBootstrapPreinitModules,
|
|
2555
|
+
ssrManifest,
|
|
2556
|
+
lazyChunks: runtimeMetadata.lazyChunks ?? void 0,
|
|
2557
|
+
dynamicPreloads: runtimeMetadata.dynamicPreloads ?? void 0
|
|
2558
|
+
});
|
|
2559
|
+
const buildSession = process.env.__VINEXT_PAGES_CLIENT_ASSETS_BUILD_SESSION;
|
|
2560
|
+
if (hasAppDir && hasPagesDir && buildSession) setPagesClientAssetsBuildMetadata(buildSession, pagesClientAssetsModule);
|
|
2561
|
+
}
|
|
2562
|
+
if (pagesClientAssetsModule === null) {
|
|
2563
|
+
if (pagesClientAssetsOutputDirs.size === 0) return;
|
|
2564
|
+
const buildSession = process.env.__VINEXT_PAGES_CLIENT_ASSETS_BUILD_SESSION;
|
|
2565
|
+
if (buildSession) pagesClientAssetsModule = takePagesClientAssetsBuildMetadata(buildSession);
|
|
2566
|
+
}
|
|
2567
|
+
if (pagesClientAssetsModule === null) {
|
|
2568
|
+
const emptyModule = buildPagesClientAssetsModule({});
|
|
2569
|
+
for (const outputDir of pagesClientAssetsOutputDirs) writePagesClientAssetsModuleIfMissing(outputDir, emptyModule);
|
|
2570
|
+
return;
|
|
2571
|
+
}
|
|
2572
|
+
for (const outputDir of pagesClientAssetsOutputDirs) {
|
|
2573
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
2574
|
+
fs.writeFileSync(path.join(outputDir, PAGES_CLIENT_ASSETS_MODULE), pagesClientAssetsModule);
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
},
|
|
2578
|
+
buildApp() {
|
|
2579
|
+
if (pagesClientAssetsModule === null) return Promise.resolve();
|
|
2580
|
+
for (const outputDir of pagesClientAssetsOutputDirs) {
|
|
2581
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
2582
|
+
fs.writeFileSync(path.join(outputDir, PAGES_CLIENT_ASSETS_MODULE), pagesClientAssetsModule);
|
|
2583
|
+
}
|
|
2584
|
+
return Promise.resolve();
|
|
2585
|
+
}
|
|
2586
|
+
},
|
|
2440
2587
|
{
|
|
2441
2588
|
name: "vinext:inline-css-manifest",
|
|
2442
2589
|
apply: "build",
|
|
@@ -2470,61 +2617,7 @@ function vinext(options = {}) {
|
|
|
2470
2617
|
const envConfig = this.environment?.config;
|
|
2471
2618
|
if (!envConfig) return;
|
|
2472
2619
|
const buildRoot = envConfig.root ?? process.cwd();
|
|
2473
|
-
const
|
|
2474
|
-
if (!fs.existsSync(distDir)) return;
|
|
2475
|
-
const clientDir = path.resolve(buildRoot, "dist", "client");
|
|
2476
|
-
const runtimeMetadata = computeClientRuntimeMetadata({
|
|
2477
|
-
clientDir,
|
|
2478
|
-
assetBase: envConfig.base ?? "/",
|
|
2479
|
-
assetPrefix: nextConfig.assetPrefix,
|
|
2480
|
-
includeClientEntry: !hasAppDir ? true : hasPagesDir ? "pages-client-entry" : false
|
|
2481
|
-
});
|
|
2482
|
-
const lazyChunksData = runtimeMetadata.lazyChunks ?? null;
|
|
2483
|
-
const dynamicPreloadsData = runtimeMetadata.dynamicPreloads ?? null;
|
|
2484
|
-
let clientEntryFile = runtimeMetadata.clientEntryFile ?? null;
|
|
2485
|
-
let ssrManifestData = null;
|
|
2486
|
-
const ssrManifestPath = path.join(clientDir, ".vite", "ssr-manifest.json");
|
|
2487
|
-
if (fs.existsSync(ssrManifestPath)) try {
|
|
2488
|
-
ssrManifestData = JSON.parse(fs.readFileSync(ssrManifestPath, "utf-8"));
|
|
2489
|
-
} catch {}
|
|
2490
|
-
if (hasAppDir) {
|
|
2491
|
-
const workerEntry = path.resolve(distDir, "server", "index.js");
|
|
2492
|
-
if (fs.existsSync(workerEntry)) {
|
|
2493
|
-
const script = buildRuntimeGlobalsScript({
|
|
2494
|
-
clientEntryFile,
|
|
2495
|
-
ssrManifest: ssrManifestData,
|
|
2496
|
-
lazyChunks: lazyChunksData,
|
|
2497
|
-
dynamicPreloads: dynamicPreloadsData
|
|
2498
|
-
});
|
|
2499
|
-
if (script) {
|
|
2500
|
-
const code = fs.readFileSync(workerEntry, "utf-8");
|
|
2501
|
-
fs.writeFileSync(workerEntry, script + "\n" + code);
|
|
2502
|
-
}
|
|
2503
|
-
}
|
|
2504
|
-
} else {
|
|
2505
|
-
let workerOutDir = null;
|
|
2506
|
-
for (const entry of fs.readdirSync(distDir)) {
|
|
2507
|
-
const candidate = path.join(distDir, entry);
|
|
2508
|
-
if (entry === "client") continue;
|
|
2509
|
-
if (fs.statSync(candidate).isDirectory() && fs.existsSync(path.join(candidate, "wrangler.json"))) {
|
|
2510
|
-
workerOutDir = candidate;
|
|
2511
|
-
break;
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
if (!workerOutDir) return;
|
|
2515
|
-
const workerEntry = path.join(workerOutDir, "index.js");
|
|
2516
|
-
if (!fs.existsSync(workerEntry)) return;
|
|
2517
|
-
const script = buildRuntimeGlobalsScript({
|
|
2518
|
-
clientEntryFile,
|
|
2519
|
-
ssrManifest: ssrManifestData,
|
|
2520
|
-
lazyChunks: lazyChunksData,
|
|
2521
|
-
dynamicPreloads: dynamicPreloadsData
|
|
2522
|
-
});
|
|
2523
|
-
if (script) {
|
|
2524
|
-
const code = fs.readFileSync(workerEntry, "utf-8");
|
|
2525
|
-
fs.writeFileSync(workerEntry, script + "\n" + code);
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2620
|
+
const clientDir = path.resolve(buildRoot, envConfig.build.outDir);
|
|
2528
2621
|
const headersPath = path.join(clientDir, "_headers");
|
|
2529
2622
|
if (!fs.existsSync(headersPath)) {
|
|
2530
2623
|
const headersContent = [
|