vinext 1.0.0-beta.11 → 1.0.0-beta.13
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 +39 -12
- package/dist/build/action-owner-manifest.js +23 -5
- package/dist/build/lifecycle.d.ts +42 -0
- package/dist/build/lifecycle.js +246 -0
- package/dist/build/nitro-route-rules.js +1 -1
- package/dist/build/pages-client-assets-module.d.ts +0 -3
- package/dist/build/pages-client-assets-module.js +1 -13
- package/dist/build/precompress.js +1 -1
- package/dist/build/prerender-paths.d.ts +1 -1
- package/dist/build/prerender-paths.js +6 -6
- package/dist/build/prerender-server-pool.js +1 -1
- package/dist/build/prerender.d.ts +1 -1
- package/dist/build/prerender.js +5 -5
- package/dist/build/preview-credentials.d.ts +1 -1
- package/dist/build/preview-credentials.js +2 -2
- package/dist/build/report.js +1 -1
- package/dist/build/run-prerender.d.ts +2 -2
- package/dist/build/run-prerender.js +5 -5
- package/dist/build/standalone.js +2 -2
- package/dist/cli-args.d.ts +5 -13
- package/dist/cli-args.js +2 -45
- package/dist/cli-dev-config.d.ts +6 -2
- package/dist/cli-dev-config.js +160 -3
- package/dist/cli.js +104 -439
- package/dist/config/config-matchers.js +1 -1
- package/dist/config/next-config.d.ts +2 -2
- package/dist/config/next-config.js +5 -5
- package/dist/config/prerender.d.ts +3 -0
- package/dist/config/prerender.js +8 -2
- package/dist/entries/app-browser-entry.js +1 -1
- package/dist/entries/app-rsc-entry.d.ts +2 -0
- package/dist/entries/app-rsc-entry.js +25 -5
- package/dist/entries/pages-client-entry.d.ts +1 -0
- package/dist/entries/pages-client-entry.js +17 -2
- package/dist/index.d.ts +6 -8
- package/dist/index.js +282 -105
- package/dist/init-cloudflare.d.ts +3 -2
- package/dist/init-cloudflare.js +117 -5
- package/dist/init-platform.d.ts +2 -0
- package/dist/init-platform.js +9 -3
- package/dist/init.d.ts +7 -5
- package/dist/init.js +41 -22
- package/dist/plugins/dynamic-preload-metadata.js +1 -1
- package/dist/plugins/extensionless-dynamic-import.js +2 -2
- package/dist/plugins/fonts.js +1 -1
- package/dist/plugins/ignore-dynamic-requests.js +1 -1
- package/dist/plugins/import-meta-url.js +1 -1
- package/dist/plugins/instrumentation-client.js +1 -1
- package/dist/plugins/og-assets.js +32 -13
- package/dist/plugins/og-harfbuzz.d.ts +24 -0
- package/dist/plugins/og-harfbuzz.js +260 -0
- package/dist/plugins/optimize-imports.js +1 -1
- package/dist/plugins/require-condition-resolution.js +2 -2
- package/dist/plugins/require-context.js +2 -2
- package/dist/plugins/typeof-window.js +1 -1
- package/dist/plugins/use-cache-callable.d.ts +0 -2
- package/dist/plugins/use-cache-callable.js +40 -22
- package/dist/plugins/worker-image-imports.js +1 -1
- package/dist/routing/app-route-graph.js +1 -1
- package/dist/routing/app-router.js +1 -1
- package/dist/routing/pages-router.js +1 -1
- package/dist/server/app-action-forwarding.js +1 -1
- package/dist/server/app-browser-entry.js +1 -0
- package/dist/server/app-browser-error.js +1 -1
- package/dist/server/app-elements-wire.js +2 -2
- package/dist/server/app-middleware.js +1 -1
- package/dist/server/app-optimistic-routing.js +1 -1
- package/dist/server/app-page-cache-finalizer.d.ts +1 -0
- package/dist/server/app-page-cache-finalizer.js +14 -2
- package/dist/server/app-page-dispatch.js +1 -1
- package/dist/server/app-page-element-builder.js +3 -2
- package/dist/server/app-page-probe.js +3 -3
- package/dist/server/app-page-render.js +1 -0
- package/dist/server/app-page-request.d.ts +2 -0
- package/dist/server/app-page-request.js +16 -12
- package/dist/server/app-request-stage-dispatch.js +1 -1
- package/dist/server/app-request-stage-independent-entry.js +2 -2
- package/dist/server/app-route-handler-dispatch.d.ts +1 -0
- package/dist/server/app-route-handler-dispatch.js +3 -2
- package/dist/server/app-route-handler-execution.d.ts +1 -0
- package/dist/server/app-route-handler-execution.js +2 -2
- package/dist/server/app-route-handler-runtime.js +1 -1
- package/dist/server/app-router-entry.js +2 -2
- package/dist/server/app-rsc-handler.d.ts +9 -2
- package/dist/server/app-rsc-handler.js +30 -10
- package/dist/server/app-rsc-response-stage.js +6 -3
- package/dist/server/app-rsc-route-matching.js +1 -1
- package/dist/server/app-server-action-execution.js +35 -6
- package/dist/server/app-ssr-entry.js +7 -2
- package/dist/server/app-ssr-stream.js +25 -6
- package/dist/server/app-worker-stages.d.ts +4 -1
- package/dist/server/app-worker-stages.js +4 -4
- package/dist/server/artifact-compatibility.js +1 -1
- package/dist/server/client-reuse-manifest.js +1 -1
- package/dist/server/dev-lockfile.d.ts +1 -1
- package/dist/server/dev-lockfile.js +4 -1
- package/dist/server/dev-server.d.ts +1 -1
- package/dist/server/dev-server.js +28 -6
- package/dist/server/dev-stack-sourcemap.js +1 -1
- package/dist/server/html.d.ts +0 -20
- package/dist/server/html.js +16 -1
- package/dist/server/instrumentation.d.ts +4 -9
- package/dist/server/instrumentation.js +10 -15
- package/dist/server/isr-cache.js +3 -3
- package/dist/server/metadata-route-response.d.ts +1 -0
- package/dist/server/metadata-route-response.js +65 -0
- package/dist/server/middleware-runtime.js +3 -3
- package/dist/server/pages-asset-tags.d.ts +1 -0
- package/dist/server/pages-asset-tags.js +37 -2
- package/dist/server/pages-client-assets.d.ts +7 -0
- package/dist/server/pages-data-route.js +1 -1
- package/dist/server/pages-dev-hydration.d.ts +6 -0
- package/dist/server/pages-dev-hydration.js +19 -7
- package/dist/server/pages-document-initial-props.d.ts +1 -0
- package/dist/server/pages-document-initial-props.js +1 -1
- package/dist/server/pages-page-data.js +2 -2
- package/dist/server/pages-page-handler.js +5 -2
- package/dist/server/pages-page-response.d.ts +1 -0
- package/dist/server/pages-page-response.js +3 -2
- package/dist/server/pages-request-pipeline.js +3 -3
- package/dist/server/pages-request-stage-entry.js +3 -3
- package/dist/server/pages-revalidate.js +1 -1
- package/dist/server/prerender-route-params.js +1 -1
- package/dist/server/prod-server.js +19 -13
- package/dist/server/request-pipeline.js +2 -2
- package/dist/server/rsc-stream-hints.d.ts +12 -0
- package/dist/server/rsc-stream-hints.js +70 -35
- package/dist/server/seed-cache.js +3 -4
- package/dist/server/socket-error-backstop.js +1 -1
- package/dist/shims/cache-callable-runtime.d.ts +38 -0
- package/dist/shims/cache-callable-runtime.js +162 -11
- package/dist/shims/cache-runtime.d.ts +6 -8
- package/dist/shims/cache-runtime.js +89 -24
- package/dist/shims/constants.js +1 -1
- package/dist/shims/dynamic-preload-chunks.js +6 -2
- package/dist/shims/font-local.js +1 -1
- package/dist/shims/form.js +1 -1
- package/dist/shims/head.js +1 -1
- package/dist/shims/headers.js +2 -2
- package/dist/shims/image-config.js +2 -0
- package/dist/shims/internal/app-page-props-cache-key.d.ts +29 -0
- package/dist/shims/internal/app-page-props-cache-key.js +53 -1
- package/dist/shims/internal/format-url-object.d.ts +7 -0
- package/dist/shims/internal/format-url-object.js +53 -0
- package/dist/shims/internal/normalize-router-href.d.ts +15 -0
- package/dist/shims/internal/normalize-router-href.js +41 -0
- package/dist/shims/internal/pages-data-target.d.ts +4 -1
- package/dist/shims/internal/pages-data-target.js +28 -35
- package/dist/shims/internal/route-pattern-for-warning.d.ts +2 -2
- package/dist/shims/internal/route-pattern-for-warning.js +3 -3
- package/dist/shims/link.js +31 -92
- package/dist/shims/metadata.js +5 -4
- package/dist/shims/navigation.js +2 -2
- package/dist/shims/router-state.js +1 -1
- package/dist/shims/router.d.ts +8 -7
- package/dist/shims/router.js +312 -148
- package/dist/shims/script-nonce-context.d.ts +4 -1
- package/dist/shims/script-nonce-context.js +15 -6
- package/dist/shims/server.js +3 -3
- package/dist/utils/built-asset-url.js +1 -1
- package/dist/utils/client-runtime-metadata.d.ts +6 -0
- package/dist/utils/client-runtime-metadata.js +16 -0
- package/dist/utils/lazy-chunks.js +1 -1
- package/dist/utils/project.d.ts +1 -11
- package/dist/utils/project.js +20 -29
- package/dist/utils/react-version.d.ts +3 -1
- package/dist/utils/react-version.js +19 -1
- package/dist/utils/vite-cli-invocation.d.ts +21 -0
- package/dist/utils/vite-cli-invocation.js +144 -0
- package/package.json +10 -2
package/dist/index.js
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import path, { toSlash } from "./deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { detectPackageManager, formatMissingCloudflarePluginError, hasWranglerConfig } from "./utils/project.js";
|
|
3
|
-
import {
|
|
3
|
+
import { claimViteCliBuildInvocation, getViteCliInvocation, isViteCliConfigFile } from "./utils/vite-cli-invocation.js";
|
|
4
|
+
import { VINEXT_DEV_CLI_LIFECYCLE, applyDevServerDefaults, claimViteCliDevInvocation, createDevServerLifecyclePlugin, reserveViteCliDevInvocation } from "./cli-dev-config.js";
|
|
5
|
+
import { isUnknownRecord } from "./utils/record.js";
|
|
6
|
+
import { getReactUpgradeDeps } from "./utils/react-version.js";
|
|
7
|
+
import { loadDotenv } from "./config/dotenv.js";
|
|
8
|
+
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
|
|
4
9
|
import { buildViteResolveExtensions, createValidFileMatcher, findFileWithExts, normalizeViteResolveExtensions } from "./routing/file-matcher.js";
|
|
10
|
+
import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
|
|
11
|
+
import { encodeMiddlewareRequestHeaders } from "./utils/middleware-request-headers.js";
|
|
12
|
+
import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
|
|
13
|
+
import { resolveAssetsDir } from "./utils/asset-prefix.js";
|
|
14
|
+
import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
|
|
15
|
+
import { VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
|
|
16
|
+
import { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
|
|
5
17
|
import { hasBasePath, stripBasePath } from "./utils/base-path.js";
|
|
18
|
+
import { appRouteGraph, appRouter, invalidateAppRouteCache, matchAppRoute } from "./routing/app-router.js";
|
|
19
|
+
import { generateRouteTypes } from "./typegen.js";
|
|
6
20
|
import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./routing/pages-router.js";
|
|
7
21
|
import { resolveRuntimeEntryModule } from "./entries/runtime-entry-module.js";
|
|
8
|
-
import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
|
|
9
22
|
import { INTERNAL_HEADERS, NEXTJS_DEPLOYMENT_ID_HEADER, VINEXT_INTERNAL_HEADERS, VINEXT_TIMING_HEADER } from "./server/headers.js";
|
|
10
|
-
import { encodeMiddlewareRequestHeaders } from "./utils/middleware-request-headers.js";
|
|
11
23
|
import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
|
|
12
|
-
import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
|
|
13
24
|
import { validateMiddlewareMatcherPatterns } from "./server/middleware-matcher-pattern.js";
|
|
14
25
|
import { methodNotAllowedResponse } from "./server/http-error-responses.js";
|
|
15
26
|
import { isOpenRedirectShaped } from "./server/open-redirect.js";
|
|
@@ -19,12 +30,9 @@ import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentat
|
|
|
19
30
|
import { findMiddlewareFile, isProxyFile, runMiddleware } from "./server/middleware.js";
|
|
20
31
|
import { extractMiddlewareMatcherConfig, extractMiddlewareMatcherConfigValue, hasExportedName } from "./build/report.js";
|
|
21
32
|
import { generatePagesRequestEntry, generatePagesResponseEntry, generateServerEntry } from "./entries/pages-server-entry.js";
|
|
22
|
-
import { generateClientEntry } from "./entries/pages-client-entry.js";
|
|
23
|
-
import { appRouteGraph, appRouter, invalidateAppRouteCache, matchAppRoute } from "./routing/app-router.js";
|
|
24
|
-
import { isUnknownRecord } from "./utils/record.js";
|
|
33
|
+
import { compileClientMiddlewareMatchers, generateClientEntry } from "./entries/pages-client-entry.js";
|
|
25
34
|
import { logRequest, now } from "./server/request-log.js";
|
|
26
35
|
import { encodeUrlParserIgnoredCharacters, isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname, shouldAddTrailingSlashToPagesDataPath, urlParserCreatesPagesDataPath } from "./server/pages-data-route.js";
|
|
27
|
-
import { resolveAssetsDir } from "./utils/asset-prefix.js";
|
|
28
36
|
import { getPagesPreviewModeId } from "./server/pages-preview.js";
|
|
29
37
|
import { createSSRHandler } from "./server/dev-server.js";
|
|
30
38
|
import { handleApiRoute } from "./server/api-handler.js";
|
|
@@ -45,12 +53,12 @@ import { VIRTUAL_IMAGE_ADAPTERS, generateImageAdaptersModule } from "./image/ima
|
|
|
45
53
|
import { generateBrowserEntry, toLinkPrefetchRoutes } from "./entries/app-browser-entry.js";
|
|
46
54
|
import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
|
|
47
55
|
import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
|
|
48
|
-
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
|
|
49
|
-
import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
|
|
50
|
-
import { VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
|
|
51
|
-
import { loadDotenv } from "./config/dotenv.js";
|
|
52
56
|
import { findOpenTelemetryPackages, mergeServerExternalPackages } from "./config/server-external-packages.js";
|
|
53
57
|
import { precompressAssets } from "./build/precompress.js";
|
|
58
|
+
import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY, normalizeVinextPrerenderConfig } from "./config/prerender.js";
|
|
59
|
+
import { PAGES_CLIENT_ASSETS_MODULE, buildPagesClientAssetsModule, writePagesClientAssetsModuleIfMissing } from "./build/pages-client-assets-module.js";
|
|
60
|
+
import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
|
|
61
|
+
import { VINEXT_BUILD_LIFECYCLE_CONFIG, createBuildLifecyclePlugins } from "./build/lifecycle.js";
|
|
54
62
|
import { ensureAssetsIgnore } from "./build/assets-ignore.js";
|
|
55
63
|
import { emitNextClientRuntimeManifests } from "./build/next-client-runtime-manifests.js";
|
|
56
64
|
import { collectInlineCssManifest, injectInlineCssManifestGlobal } from "./build/inline-css.js";
|
|
@@ -79,18 +87,16 @@ import { validateMiddlewareModuleExports } from "./plugins/middleware-export-val
|
|
|
79
87
|
import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
|
|
80
88
|
import { augmentSsrManifestFromBundle, relativeWithinRoot, tryRealpathSync } from "./build/ssr-manifest.js";
|
|
81
89
|
import { createDynamicPreloadMetadataPlugin } from "./plugins/dynamic-preload-metadata.js";
|
|
90
|
+
import { createOgHarfbuzzPlugin } from "./plugins/og-harfbuzz.js";
|
|
82
91
|
import { createOgAssetsPlugin, createOgInlineFetchAssetsPlugin } from "./plugins/og-assets.js";
|
|
83
92
|
import { createUseCacheCallablePlugin } from "./plugins/use-cache-callable.js";
|
|
84
|
-
import { generateRouteTypes } from "./typegen.js";
|
|
85
93
|
import { SSR_EXTERNAL_REACT_ENTRIES, VINEXT_OPTIMIZE_DEPS_EXCLUDE, mergeOptimizeDepsExclude } from "./plugins/rsc-client-shim-excludes.js";
|
|
86
94
|
import { createServerExternalsManifestPlugin } from "./plugins/server-externals-manifest.js";
|
|
87
95
|
import { createTransitiveExternalsPlugin } from "./plugins/transitive-externals.js";
|
|
88
96
|
import public_shim_map_default from "./shims/public-shim-map.json.js";
|
|
89
97
|
import { VINEXT_CLIENT_ENTRY_MANIFEST } from "./utils/client-entry-manifest.js";
|
|
90
98
|
import { computeClientRuntimeMetadata } from "./utils/client-runtime-metadata.js";
|
|
91
|
-
import { PAGES_CLIENT_ASSETS_MODULE, buildPagesClientAssetsModule, setPagesClientAssetsBuildMetadata, takePagesClientAssetsBuildMetadata, writePagesClientAssetsModuleIfMissing } from "./build/pages-client-assets-module.js";
|
|
92
99
|
import { readPrerenderSecret, readServerRuntimeOutputDirs } from "./build/server-manifest.js";
|
|
93
|
-
import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
|
|
94
100
|
import { createModuleDependencyCache } from "./build/module-dependency-cache.js";
|
|
95
101
|
import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
|
|
96
102
|
import { markCssUrlAssetReferences, restoreDedupedCssAssetReferences } from "./build/css-url-assets.js";
|
|
@@ -111,15 +117,15 @@ import { publicFilePathVariants } from "./utils/public-file-path.js";
|
|
|
111
117
|
import { scanPublicFileRoutes } from "./utils/public-routes.js";
|
|
112
118
|
import { createIgnoreDynamicRequestsPlugin } from "./plugins/ignore-dynamic-requests.js";
|
|
113
119
|
import { assertSupportedViteVersion, getDepOptimizeNodeEnvOptions, serializeViteDefine } from "./utils/vite-version.js";
|
|
114
|
-
import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY, normalizeVinextPrerenderConfig } from "./config/prerender.js";
|
|
115
120
|
import { staticExportApp, staticExportPages } from "./build/static-export.js";
|
|
116
121
|
import { createRequire } from "node:module";
|
|
117
122
|
import fs from "node:fs";
|
|
118
|
-
import { createIdResolver, createLogger, parseAst, transformWithOxc } from "vite";
|
|
123
|
+
import { createIdResolver, createLogger, isRunnableDevEnvironment, parseAst, transformWithOxc } from "vite";
|
|
119
124
|
import { pathToFileURL } from "node:url";
|
|
125
|
+
import { execFileSync } from "node:child_process";
|
|
120
126
|
import { createHash, randomBytes } from "node:crypto";
|
|
121
|
-
import commonjs from "vite-plugin-commonjs";
|
|
122
127
|
import MagicString from "magic-string";
|
|
128
|
+
import commonjs from "vite-plugin-commonjs";
|
|
123
129
|
//#region src/index.ts
|
|
124
130
|
const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_EXCLUDE = Object.freeze(["vinext/server/fetch-handler", "vinext/server/pages-router-entry"]);
|
|
125
131
|
const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
@@ -133,6 +139,30 @@ const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
|
133
139
|
const OPTIONAL_OPTIMIZE_DEPS_WARNING_RE = /Failed to resolve dependency: .*use-sync-external-store\/with-selector.*present in .* 'optimizeDeps\.include'/;
|
|
134
140
|
const VINEXT_FILTERED_OPTIMIZE_DEPS_WARN = Symbol.for("vinext.filteredOptimizeDepsWarn");
|
|
135
141
|
const ANSI_ESCAPE_RE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
|
|
142
|
+
const RSC_ENVIRONMENTS = /* @__PURE__ */ new Set([
|
|
143
|
+
"rsc",
|
|
144
|
+
"ssr",
|
|
145
|
+
"client"
|
|
146
|
+
]);
|
|
147
|
+
function scopeRscPlugin(plugin) {
|
|
148
|
+
const applyToEnvironment = plugin.applyToEnvironment;
|
|
149
|
+
return {
|
|
150
|
+
...plugin,
|
|
151
|
+
applyToEnvironment(environment) {
|
|
152
|
+
if (!RSC_ENVIRONMENTS.has(environment.name)) return false;
|
|
153
|
+
return applyToEnvironment?.(environment) ?? true;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const earlyViteCliInvocation = getViteCliInvocation();
|
|
158
|
+
const viteCliBuildConfigNodeEnv = earlyViteCliInvocation?.command === "build" && process.env.NODE_ENV === "test" ? "test" : void 0;
|
|
159
|
+
if (earlyViteCliInvocation) {
|
|
160
|
+
if (!process.env.NODE_ENV) Reflect.set(process.env, "NODE_ENV", earlyViteCliInvocation.command === "build" ? viteCliBuildConfigNodeEnv ?? "production" : earlyViteCliInvocation.mode === "test" ? "test" : "development");
|
|
161
|
+
loadDotenv({
|
|
162
|
+
root: earlyViteCliInvocation.root,
|
|
163
|
+
mode: earlyViteCliInvocation.mode
|
|
164
|
+
});
|
|
165
|
+
}
|
|
136
166
|
installSocketErrorBackstop();
|
|
137
167
|
function hasServerOnlyMarkerImport(code) {
|
|
138
168
|
if (!code.includes("server-only")) return false;
|
|
@@ -187,6 +217,7 @@ function resolveShimModulePath(shimsDir, moduleName) {
|
|
|
187
217
|
}
|
|
188
218
|
return path.join(shimsDir, `${moduleName}.js`);
|
|
189
219
|
}
|
|
220
|
+
const PATCHED_SERVER_PACKAGES = ["@vercel/og"];
|
|
190
221
|
function isVercelOgImport(id) {
|
|
191
222
|
return id === "@vercel/og" || id === "@vercel/og.js";
|
|
192
223
|
}
|
|
@@ -316,7 +347,7 @@ function createDevPagesModuleDependencyReader(root, resolve) {
|
|
|
316
347
|
if (typeof specifier !== "string") continue;
|
|
317
348
|
const resolved = await resolve(specifier, cleanModulePath, { skipSelf: true });
|
|
318
349
|
if (!resolved?.id) continue;
|
|
319
|
-
if (isStylesheetSpecifier(specifier)) {
|
|
350
|
+
if (isStylesheetSpecifier(specifier) || isStylesheetSpecifier(resolved.id)) {
|
|
320
351
|
const asset = resolvedStylesheetToDevManifestAsset(root, resolved.id);
|
|
321
352
|
if (asset) dependencies.push({
|
|
322
353
|
type: "stylesheet",
|
|
@@ -799,7 +830,9 @@ function createServerEnvironmentFileNameResolver(config, outputRoot) {
|
|
|
799
830
|
};
|
|
800
831
|
}
|
|
801
832
|
function vinext(options = {}) {
|
|
833
|
+
const internalOptions = options;
|
|
802
834
|
const { supportsNativeTypeofWindowFolding: useNativeTypeofWindowFolding } = assertSupportedViteVersion();
|
|
835
|
+
const reservedDevCliInvocation = reserveViteCliDevInvocation();
|
|
803
836
|
const prerenderConfig = normalizeVinextPrerenderConfig(options.prerender);
|
|
804
837
|
const cacheAdapterBuildOutputs = [options.cache?.data?.output, options.cache?.cdn?.output].filter((output) => output !== void 0);
|
|
805
838
|
let root;
|
|
@@ -820,10 +853,7 @@ function vinext(options = {}) {
|
|
|
820
853
|
let hasCloudflarePlugin = false;
|
|
821
854
|
let matchedMultiStageOutput;
|
|
822
855
|
let selectedMultiStageOutput;
|
|
823
|
-
const isMultiStageServerEnvironment = (environment) =>
|
|
824
|
-
if (environment.name === "client") return Boolean(environment.config.build.ssr);
|
|
825
|
-
return isServerEnvironment(environment) && (!hasAppDir || environment.name !== "ssr");
|
|
826
|
-
};
|
|
856
|
+
const isMultiStageServerEnvironment = (environment) => isServerEnvironment(environment) && (!hasAppDir || environment.name === "rsc");
|
|
827
857
|
let warnedInlineNextConfigOverride = false;
|
|
828
858
|
let hasNitroPlugin = false;
|
|
829
859
|
let nitroHostRuntime = "node";
|
|
@@ -832,6 +862,12 @@ function vinext(options = {}) {
|
|
|
832
862
|
let pagesTsconfigAliases = {};
|
|
833
863
|
let pagesBundledPackages = /* @__PURE__ */ new Set();
|
|
834
864
|
let isServeCommand = false;
|
|
865
|
+
let buildEmptyOutDir;
|
|
866
|
+
let buildLifecycleEnabled = false;
|
|
867
|
+
let hasPlainPagesBuildEnvironments = false;
|
|
868
|
+
let originalPlainPagesEnvironments;
|
|
869
|
+
let buildLifecycleInvocation;
|
|
870
|
+
let reactUpgradeChecked = false;
|
|
835
871
|
let pagesOptimizeEntries = [];
|
|
836
872
|
const importMetaUrlCapability = createImportMetaUrlPlugin({
|
|
837
873
|
getRoot: () => root,
|
|
@@ -842,7 +878,7 @@ function vinext(options = {}) {
|
|
|
842
878
|
});
|
|
843
879
|
const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
|
|
844
880
|
const resolvePagesClientAssetsOutputDir = (environmentName, outputDir) => !selectedMultiStageOutput && !hasAppDir && environmentName === "ssr" ? path.dirname(outputDir) : outputDir;
|
|
845
|
-
let pagesClientAssetsModule = null;
|
|
881
|
+
let pagesClientAssetsModule = internalOptions.__pagesClientAssetsModule ?? null;
|
|
846
882
|
let devPublicFileRoutes = null;
|
|
847
883
|
let publicDirConflictOptions = null;
|
|
848
884
|
let copyPublicDirIntoStaticExportBasePath = false;
|
|
@@ -850,6 +886,7 @@ function vinext(options = {}) {
|
|
|
850
886
|
let rscCompatibilityId;
|
|
851
887
|
let draftModeSecret = getPagesPreviewModeId();
|
|
852
888
|
const prerenderSecret = process.env.__VINEXT_SHARED_PRERENDER_SECRET ?? randomBytes(32).toString("hex");
|
|
889
|
+
let revalidateSecret = process.env.__VINEXT_SHARED_REVALIDATE_SECRET;
|
|
853
890
|
let previewBuildCredentials;
|
|
854
891
|
const sassComposesLoader = createSassAwareFileSystemLoader();
|
|
855
892
|
const rscClassificationManifests = /* @__PURE__ */ new Map();
|
|
@@ -930,7 +967,8 @@ function vinext(options = {}) {
|
|
|
930
967
|
});
|
|
931
968
|
}
|
|
932
969
|
const autoRsc = options.rsc !== false;
|
|
933
|
-
const
|
|
970
|
+
const earlyRoot = earlyViteCliInvocation?.root ?? process.cwd();
|
|
971
|
+
const earlyBaseDir = path.resolve(earlyRoot, options.appDir ?? ".");
|
|
934
972
|
const earlyAppDirExists = !options.disableAppRouter && (fs.existsSync(path.join(earlyBaseDir, "app")) || fs.existsSync(path.join(earlyBaseDir, "src", "app")));
|
|
935
973
|
let resolvedReactPath = null;
|
|
936
974
|
let resolvedRscPath = null;
|
|
@@ -952,14 +990,12 @@ function vinext(options = {}) {
|
|
|
952
990
|
} });
|
|
953
991
|
const useCachePlugin = await createUseCacheCallablePlugin({
|
|
954
992
|
projectRoot: earlyBaseDir,
|
|
955
|
-
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href
|
|
956
|
-
getAppDir: () => appDir,
|
|
957
|
-
matchesPageExtension: (fileName) => fileMatcher.extensionRegex.test(fileName)
|
|
993
|
+
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href
|
|
958
994
|
});
|
|
959
995
|
const useServerIndex = plugins.findIndex((plugin) => plugin.name === "rsc:use-server");
|
|
960
996
|
if (useServerIndex === -1) throw new Error("vinext: Failed to locate @vitejs/plugin-rsc use-server plugin.");
|
|
961
997
|
plugins.splice(useServerIndex, 0, useCachePlugin);
|
|
962
|
-
return plugins;
|
|
998
|
+
return plugins.map(scopeRscPlugin);
|
|
963
999
|
}).catch((cause) => {
|
|
964
1000
|
throw new Error("vinext: Failed to load @vitejs/plugin-rsc.", { cause });
|
|
965
1001
|
});
|
|
@@ -968,8 +1004,6 @@ function vinext(options = {}) {
|
|
|
968
1004
|
manualUseCachePluginPromise = createUseCacheCallablePlugin({
|
|
969
1005
|
projectRoot: earlyBaseDir,
|
|
970
1006
|
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href,
|
|
971
|
-
getAppDir: () => appDir,
|
|
972
|
-
matchesPageExtension: (fileName) => fileMatcher.extensionRegex.test(fileName),
|
|
973
1007
|
allowMissingRsc: true
|
|
974
1008
|
});
|
|
975
1009
|
}
|
|
@@ -1106,7 +1140,59 @@ function vinext(options = {}) {
|
|
|
1106
1140
|
transformBundledCommonJsDependencies = previous;
|
|
1107
1141
|
}
|
|
1108
1142
|
};
|
|
1143
|
+
const buildLifecyclePlugins = createBuildLifecyclePlugins({
|
|
1144
|
+
isEnabled: (builder) => buildLifecycleEnabled && builder.config.build.write !== false && !builder.config.build.lib && (buildLifecycleInvocation !== void 0 || !builder.config.build.watch && !builder.config.build.ssr && getBuildBundlerOptions(builder.config.build)?.input === void 0),
|
|
1145
|
+
onComplete: () => buildLifecycleInvocation?.onComplete?.(),
|
|
1146
|
+
shouldDeferPostBuild: () => buildLifecycleInvocation !== void 0,
|
|
1147
|
+
shouldPrepare: (config) => buildLifecycleEnabled && config.build?.write !== false && !config.build?.lib && (buildLifecycleInvocation !== void 0 || !config.build?.watch && !config.build?.ssr && getBuildBundlerOptions(config.build)?.input === void 0),
|
|
1148
|
+
onPrepare: () => {
|
|
1149
|
+
if (!hasAppDir || reactUpgradeChecked) return;
|
|
1150
|
+
reactUpgradeChecked = true;
|
|
1151
|
+
const reactUpgrade = getReactUpgradeDeps(root);
|
|
1152
|
+
if (reactUpgrade.length === 0) return;
|
|
1153
|
+
const [packageManager, ...packageManagerArgs] = detectPackageManager(root).replace(/ -D$/, "").split(" ");
|
|
1154
|
+
console.log(" Upgrading React for RSC compatibility...");
|
|
1155
|
+
execFileSync(packageManager, [...packageManagerArgs, ...reactUpgrade], {
|
|
1156
|
+
cwd: root,
|
|
1157
|
+
stdio: "inherit",
|
|
1158
|
+
shell: process.platform === "win32"
|
|
1159
|
+
});
|
|
1160
|
+
},
|
|
1161
|
+
shouldBuildPlainPages: () => !hasAppDir && !hasCloudflarePlugin && !hasNitroPlugin,
|
|
1162
|
+
createContext: () => ({
|
|
1163
|
+
cacheConfig: options.cache ?? null,
|
|
1164
|
+
configNodeEnv: viteCliBuildConfigNodeEnv,
|
|
1165
|
+
createPagesOnlyPlugins: (pagesClientAssetsModule) => vinext({
|
|
1166
|
+
...options,
|
|
1167
|
+
disableAppRouter: true,
|
|
1168
|
+
precompress: false,
|
|
1169
|
+
prerender: void 0,
|
|
1170
|
+
__skipBuildLifecycle: true,
|
|
1171
|
+
__pagesClientAssetsModule: pagesClientAssetsModule
|
|
1172
|
+
}),
|
|
1173
|
+
emptyOutDir: buildEmptyOutDir,
|
|
1174
|
+
hasAppDir,
|
|
1175
|
+
hasPagesDir,
|
|
1176
|
+
nextConfig,
|
|
1177
|
+
prerenderConfig,
|
|
1178
|
+
prerenderConcurrency: prerenderConfig?.concurrency,
|
|
1179
|
+
prerenderSecret,
|
|
1180
|
+
previewBuildCredentials,
|
|
1181
|
+
revalidateSecret,
|
|
1182
|
+
root,
|
|
1183
|
+
routeRootConfig: {
|
|
1184
|
+
appDir: options.appDir,
|
|
1185
|
+
disableAppRouter: options.disableAppRouter,
|
|
1186
|
+
rscOutDir: options.rscOutDir,
|
|
1187
|
+
ssrOutDir: options.ssrOutDir
|
|
1188
|
+
},
|
|
1189
|
+
rscBuildIdentity,
|
|
1190
|
+
rscCompatibilityId,
|
|
1191
|
+
skipHybridPagesBundle: hasCloudflarePlugin
|
|
1192
|
+
})
|
|
1193
|
+
});
|
|
1109
1194
|
const plugins = [
|
|
1195
|
+
buildLifecyclePlugins[0],
|
|
1110
1196
|
createStyledJsxPlugin(earlyBaseDir),
|
|
1111
1197
|
mdxProxyPlugin,
|
|
1112
1198
|
reactPluginPromise,
|
|
@@ -1173,6 +1259,7 @@ function vinext(options = {}) {
|
|
|
1173
1259
|
}),
|
|
1174
1260
|
dataUrlCssPlugin(),
|
|
1175
1261
|
createCssModuleImportCompatibilityPlugin(),
|
|
1262
|
+
createDevServerLifecyclePlugin({}, (config) => config[VINEXT_DEV_CLI_LIFECYCLE] === true),
|
|
1176
1263
|
{
|
|
1177
1264
|
name: "vinext:config",
|
|
1178
1265
|
enforce: "pre",
|
|
@@ -1186,8 +1273,14 @@ function vinext(options = {}) {
|
|
|
1186
1273
|
},
|
|
1187
1274
|
[VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY]: options.cache ?? null,
|
|
1188
1275
|
async config(config, env) {
|
|
1276
|
+
hasPlainPagesBuildEnvironments = false;
|
|
1277
|
+
originalPlainPagesEnvironments = void 0;
|
|
1278
|
+
buildEmptyOutDir = typeof config.build?.emptyOutDir === "boolean" ? config.build.emptyOutDir : void 0;
|
|
1189
1279
|
isServeCommand = env.command === "serve";
|
|
1190
|
-
root = toSlash(config.root ??
|
|
1280
|
+
root = path.resolve(toSlash(process.cwd()), config.root ?? ".");
|
|
1281
|
+
const devCliLifecycleEnabled = env.command === "serve" && env.isPreview !== true && claimViteCliDevInvocation(root, config["__vinextDevRestart"] === true, reservedDevCliInvocation && config.configFile === false);
|
|
1282
|
+
buildLifecycleInvocation = config[VINEXT_BUILD_LIFECYCLE_CONFIG];
|
|
1283
|
+
buildLifecycleEnabled = env.command === "build" && !internalOptions.__skipBuildLifecycle && (buildLifecycleInvocation !== void 0 || claimViteCliBuildInvocation());
|
|
1191
1284
|
const userResolve = config.resolve;
|
|
1192
1285
|
let tsconfigPathAliases = {};
|
|
1193
1286
|
let sassTsconfigPathAliases = [];
|
|
@@ -1204,8 +1297,11 @@ function vinext(options = {}) {
|
|
|
1204
1297
|
if (env?.command === "build" || env?.isPreview === true) resolvedNodeEnv = "production";
|
|
1205
1298
|
else if (mode === "test") resolvedNodeEnv = "test";
|
|
1206
1299
|
else resolvedNodeEnv = "development";
|
|
1207
|
-
if (process.env.NODE_ENV !== resolvedNodeEnv) Reflect.set(process.env, "NODE_ENV", resolvedNodeEnv);
|
|
1208
|
-
if (env?.command === "build")
|
|
1300
|
+
if (!(process.env.NODE_ENV === "test" && viteCliBuildConfigNodeEnv === "test") && process.env.NODE_ENV !== resolvedNodeEnv) Reflect.set(process.env, "NODE_ENV", resolvedNodeEnv);
|
|
1301
|
+
if (env?.command === "build") {
|
|
1302
|
+
previewBuildCredentials = getPreviewBuildCredentials() ?? createPreviewBuildCredentials();
|
|
1303
|
+
if (buildLifecycleEnabled) revalidateSecret ??= randomBytes(32).toString("hex");
|
|
1304
|
+
}
|
|
1209
1305
|
draftModeSecret = previewBuildCredentials?.id ?? getPagesPreviewModeId();
|
|
1210
1306
|
let baseDir;
|
|
1211
1307
|
if (options.appDir) {
|
|
@@ -1245,6 +1341,7 @@ function vinext(options = {}) {
|
|
|
1245
1341
|
buildId: sharedBuildId
|
|
1246
1342
|
};
|
|
1247
1343
|
}
|
|
1344
|
+
if (env?.command === "build" && earlyViteCliInvocation?.command === "build") Reflect.set(process.env, "NODE_ENV", "production");
|
|
1248
1345
|
const configuredTsconfigPath = isUnknownRecord(nextConfig.typescript) ? typeof nextConfig.typescript.tsconfigPath === "string" ? nextConfig.typescript.tsconfigPath : void 0 : void 0;
|
|
1249
1346
|
const resolvedTsconfigAliases = resolveTsconfigAliases(root, configuredTsconfigPath);
|
|
1250
1347
|
tsconfigPathAliases = resolvedTsconfigAliases.vite;
|
|
@@ -1401,7 +1498,7 @@ function vinext(options = {}) {
|
|
|
1401
1498
|
resolvedServerExternalPackages = nextServerExternal;
|
|
1402
1499
|
const isMultiEnv = hasAppDir || hasCloudflarePlugin || hasNitroPlugin;
|
|
1403
1500
|
const hasBuildInput = getBuildBundlerOptions(config.build)?.input !== void 0;
|
|
1404
|
-
const shouldInjectPlainPagesEnvironments = !hasAppDir && !hasCloudflarePlugin && !isSSR && !hasBuildInput;
|
|
1501
|
+
const shouldInjectPlainPagesEnvironments = !hasAppDir && !hasCloudflarePlugin && !isSSR && !hasBuildInput && !config.build?.lib;
|
|
1405
1502
|
const hasClientBuildEnvironment = hasAppDir || hasCloudflarePlugin || hasNitroPlugin || shouldInjectPlainPagesEnvironments;
|
|
1406
1503
|
const clientAssetsDir = resolveAssetsDir(nextConfig.assetPrefix ?? "");
|
|
1407
1504
|
clientAssetsInlineLimit = config.build?.assetsInlineLimit ?? 0;
|
|
@@ -1421,6 +1518,11 @@ function vinext(options = {}) {
|
|
|
1421
1518
|
}
|
|
1422
1519
|
const viteConfig = {
|
|
1423
1520
|
appType: "custom",
|
|
1521
|
+
...devCliLifecycleEnabled ? { [VINEXT_DEV_CLI_LIFECYCLE]: true } : {},
|
|
1522
|
+
...!hasAppDir && hasCloudflarePlugin ? { builder: {
|
|
1523
|
+
...config.builder,
|
|
1524
|
+
sharedConfigBuild: true
|
|
1525
|
+
} } : {},
|
|
1424
1526
|
build: {
|
|
1425
1527
|
ssrEmitAssets: true,
|
|
1426
1528
|
cssTarget: [
|
|
@@ -1454,7 +1556,10 @@ function vinext(options = {}) {
|
|
|
1454
1556
|
},
|
|
1455
1557
|
hmr: devHmrConfig
|
|
1456
1558
|
},
|
|
1457
|
-
...hasCloudflarePlugin || hasNitroPlugin ? {} : config.ssr?.external === true ? { ssr: {
|
|
1559
|
+
...hasCloudflarePlugin || hasNitroPlugin ? {} : config.ssr?.external === true ? { ssr: {
|
|
1560
|
+
external: true,
|
|
1561
|
+
noExternal: [...PATCHED_SERVER_PACKAGES]
|
|
1562
|
+
} } : { ssr: {
|
|
1458
1563
|
external: [
|
|
1459
1564
|
"react",
|
|
1460
1565
|
"react-dom",
|
|
@@ -1550,6 +1655,7 @@ function vinext(options = {}) {
|
|
|
1550
1655
|
}
|
|
1551
1656
|
};
|
|
1552
1657
|
pagesOptimizeEntries = !hasAppDir ? [...hasPagesDir ? [toRelativeFileEntry(root, pagesDir) + "/**/*.{tsx,ts,jsx,js}"] : [], ...[instrumentationPath, instrumentationClientPath].flatMap((entry) => entry ? [toRelativeFileEntry(root, entry)] : [])] : [];
|
|
1658
|
+
if (env.command === "serve" && !hasAppDir && !hasCloudflarePlugin && !shouldInjectPlainPagesEnvironments) viteConfig.optimizeDeps.include = [.../* @__PURE__ */ new Set([...incomingInclude, "react-dom/client"])];
|
|
1553
1659
|
if (hasAppDir) {
|
|
1554
1660
|
const appEntries = [`${path.relative(root, appDir)}/**/*.{tsx,ts,jsx,js}`];
|
|
1555
1661
|
const explicitInstrumentationEntries = [instrumentationPath, instrumentationClientPath].flatMap((entry) => entry ? [toRelativeFileEntry(root, entry)] : []);
|
|
@@ -1566,7 +1672,7 @@ function vinext(options = {}) {
|
|
|
1566
1672
|
...env?.command === "serve" && _canExternalizeAppRscHandler ? ["vinext/server/app-rsc-combined-handler", "vinext/server/app-rsc-handler"] : [],
|
|
1567
1673
|
...userSsrExternal
|
|
1568
1674
|
],
|
|
1569
|
-
|
|
1675
|
+
noExternal: userSsrExternal === true ? [...PATCHED_SERVER_PACKAGES] : true
|
|
1570
1676
|
} },
|
|
1571
1677
|
optimizeDeps: {
|
|
1572
1678
|
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE),
|
|
@@ -1589,7 +1695,7 @@ function vinext(options = {}) {
|
|
|
1589
1695
|
"ipaddr.js",
|
|
1590
1696
|
...externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []
|
|
1591
1697
|
],
|
|
1592
|
-
|
|
1698
|
+
noExternal: userSsrExternal === true ? [...PATCHED_SERVER_PACKAGES] : true
|
|
1593
1699
|
} },
|
|
1594
1700
|
optimizeDeps: {
|
|
1595
1701
|
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], userSsrExternal === true || externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []),
|
|
@@ -1631,6 +1737,7 @@ function vinext(options = {}) {
|
|
|
1631
1737
|
} else if (hasCloudflarePlugin) viteConfig.environments = { client: {
|
|
1632
1738
|
consumer: "client",
|
|
1633
1739
|
optimizeDeps: {
|
|
1740
|
+
include: ["react-dom/client"],
|
|
1634
1741
|
...pagesOptimizeEntries.length > 0 ? { entries: pagesOptimizeEntries } : {},
|
|
1635
1742
|
...depOptimizeNodeEnvOptions
|
|
1636
1743
|
},
|
|
@@ -1645,49 +1752,55 @@ function vinext(options = {}) {
|
|
|
1645
1752
|
})
|
|
1646
1753
|
}
|
|
1647
1754
|
} };
|
|
1648
|
-
else if (shouldInjectPlainPagesEnvironments)
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
resolve: {
|
|
1669
|
-
external: [
|
|
1670
|
-
"react",
|
|
1671
|
-
"react-dom",
|
|
1672
|
-
"react-dom/server",
|
|
1673
|
-
"ipaddr.js",
|
|
1674
|
-
...nextServerExternal
|
|
1675
|
-
],
|
|
1676
|
-
noExternal: true
|
|
1677
|
-
},
|
|
1678
|
-
optimizeDeps: {
|
|
1679
|
-
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], Object.keys(nextShimMap)),
|
|
1680
|
-
...depOptimizeNodeEnvOptions
|
|
1755
|
+
else if (shouldInjectPlainPagesEnvironments) {
|
|
1756
|
+
const plainPagesEnvironments = {
|
|
1757
|
+
client: {
|
|
1758
|
+
consumer: "client",
|
|
1759
|
+
optimizeDeps: {
|
|
1760
|
+
include: ["react-dom/client"],
|
|
1761
|
+
...pagesOptimizeEntries.length > 0 ? { entries: pagesOptimizeEntries } : {},
|
|
1762
|
+
...depOptimizeNodeEnvOptions
|
|
1763
|
+
},
|
|
1764
|
+
build: {
|
|
1765
|
+
outDir: "dist/client",
|
|
1766
|
+
manifest: true,
|
|
1767
|
+
ssrManifest: true,
|
|
1768
|
+
assetsInlineLimit: clientAssetsInlineLimit,
|
|
1769
|
+
...withBuildBundlerOptions({
|
|
1770
|
+
input: { index: VIRTUAL_CLIENT_ENTRY },
|
|
1771
|
+
output: getClientOutputConfig(clientAssetsDir),
|
|
1772
|
+
treeshake: getClientTreeshakeConfig()
|
|
1773
|
+
})
|
|
1774
|
+
}
|
|
1681
1775
|
},
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1776
|
+
ssr: {
|
|
1777
|
+
resolve: {
|
|
1778
|
+
external: [
|
|
1779
|
+
"react",
|
|
1780
|
+
"react-dom",
|
|
1781
|
+
"react-dom/server",
|
|
1782
|
+
"ipaddr.js",
|
|
1783
|
+
...nextServerExternal
|
|
1784
|
+
],
|
|
1785
|
+
noExternal: true
|
|
1786
|
+
},
|
|
1787
|
+
optimizeDeps: {
|
|
1788
|
+
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], Object.keys(nextShimMap)),
|
|
1789
|
+
...depOptimizeNodeEnvOptions
|
|
1790
|
+
},
|
|
1791
|
+
build: {
|
|
1792
|
+
outDir: "dist/server",
|
|
1793
|
+
...withBuildBundlerOptions({
|
|
1794
|
+
input: { index: hasNitroPlugin ? VIRTUAL_WORKER_ENTRY : VIRTUAL_SERVER_ENTRY },
|
|
1795
|
+
output: { entryFileNames: "entry.js" }
|
|
1796
|
+
})
|
|
1797
|
+
}
|
|
1688
1798
|
}
|
|
1689
|
-
}
|
|
1690
|
-
|
|
1799
|
+
};
|
|
1800
|
+
originalPlainPagesEnvironments = config.environments;
|
|
1801
|
+
viteConfig.environments = plainPagesEnvironments;
|
|
1802
|
+
hasPlainPagesBuildEnvironments = env.command === "build";
|
|
1803
|
+
}
|
|
1691
1804
|
if (pagesOptimizeEntries.length > 0 && !hasCloudflarePlugin) viteConfig.optimizeDeps = {
|
|
1692
1805
|
...viteConfig.optimizeDeps,
|
|
1693
1806
|
entries: pagesOptimizeEntries
|
|
@@ -1719,6 +1832,12 @@ function vinext(options = {}) {
|
|
|
1719
1832
|
return null;
|
|
1720
1833
|
},
|
|
1721
1834
|
async configResolved(config) {
|
|
1835
|
+
if (isServeCommand && !config["__vinextDevCliLifecycle"] && config.configFile && isViteCliConfigFile(config.configFile, config.inlineConfig)) {
|
|
1836
|
+
if (claimViteCliDevInvocation(config.root, false, true)) {
|
|
1837
|
+
config[VINEXT_DEV_CLI_LIFECYCLE] = true;
|
|
1838
|
+
if (!config.server.middlewareMode) applyDevServerDefaults(config.server, {});
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1722
1841
|
if (isServeCommand && hasCloudflarePlugin && hasPagesDir && !hasAppDir) suppressOptionalOptimizeDepsWarnings(config.logger);
|
|
1723
1842
|
if (config.worker?.rolldownOptions) {
|
|
1724
1843
|
const workerFileNames = `${resolveAssetsDir(nextConfig.assetPrefix ?? "")}/workers/[name]-[hash].js`;
|
|
@@ -1913,7 +2032,10 @@ function vinext(options = {}) {
|
|
|
1913
2032
|
}
|
|
1914
2033
|
if (id === RESOLVED_CLIENT_ENTRY) return await generateClientEntry$1();
|
|
1915
2034
|
if (id === RESOLVED_PAGES_CLIENT_ASSETS) {
|
|
1916
|
-
const metadata = {
|
|
2035
|
+
const metadata = {
|
|
2036
|
+
clientEntry: DEV_PAGES_CLIENT_ENTRY,
|
|
2037
|
+
crossOrigin: nextConfig?.crossOrigin ?? ""
|
|
2038
|
+
};
|
|
1917
2039
|
const ssrManifest = {};
|
|
1918
2040
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
1919
2041
|
const pagesRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
@@ -1952,6 +2074,7 @@ function vinext(options = {}) {
|
|
|
1952
2074
|
clientTraceMetadata: nextConfig?.clientTraceMetadata,
|
|
1953
2075
|
nodeOpenTelemetryLoader: registerNodeOpenTelemetryLoader,
|
|
1954
2076
|
assetPrefix: nextConfig?.assetPrefix,
|
|
2077
|
+
crossOrigin: nextConfig?.crossOrigin,
|
|
1955
2078
|
expireTime: nextConfig?.expireTime,
|
|
1956
2079
|
reactMaxHeadersLength: nextConfig?.reactMaxHeadersLength,
|
|
1957
2080
|
cacheMaxMemorySize: nextConfig?.cacheMaxMemorySize,
|
|
@@ -2118,6 +2241,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2118
2241
|
transform: {
|
|
2119
2242
|
filter: { id: /virtual:|\.[cm]?[jt]sx?(?:\?|$)/ },
|
|
2120
2243
|
handler(code, id) {
|
|
2244
|
+
const environment = this.environment;
|
|
2245
|
+
if (!isServeCommand && (!environment || !isMultiStageServerEnvironment(environment))) return null;
|
|
2121
2246
|
const transformed = matchedMultiStageOutput?.transformHostEntry?.({
|
|
2122
2247
|
code,
|
|
2123
2248
|
id
|
|
@@ -2360,6 +2485,18 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2360
2485
|
return `http://localhost:${typeof address === "object" && address ? address.port : server.config.server.port ?? 3e3}`;
|
|
2361
2486
|
};
|
|
2362
2487
|
let cachedSSRHandler = null;
|
|
2488
|
+
const devPageRouteDataKinds = /* @__PURE__ */ new Map();
|
|
2489
|
+
function classifyDevPageFile(filePath) {
|
|
2490
|
+
const cached = devPageRouteDataKinds.get(filePath);
|
|
2491
|
+
if (cached) return cached;
|
|
2492
|
+
let dataKind = "none";
|
|
2493
|
+
try {
|
|
2494
|
+
const source = fs.readFileSync(filePath, "utf8");
|
|
2495
|
+
dataKind = hasExportedName(source, "getStaticProps") ? "static" : hasExportedName(source, "getServerSideProps") ? "server" : "none";
|
|
2496
|
+
} catch {}
|
|
2497
|
+
devPageRouteDataKinds.set(filePath, dataKind);
|
|
2498
|
+
return dataKind;
|
|
2499
|
+
}
|
|
2363
2500
|
function getPagesRunner() {
|
|
2364
2501
|
if (!pagesRunner) {
|
|
2365
2502
|
const env = server.environments["ssr"] ?? Object.values(server.environments).find((e) => e !== server.environments["rsc"]) ?? Object.values(server.environments)[0];
|
|
@@ -2413,6 +2550,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2413
2550
|
}
|
|
2414
2551
|
pagesRunner?.clearCache();
|
|
2415
2552
|
}
|
|
2553
|
+
function invalidatePagesHydrationProxies() {
|
|
2554
|
+
const graph = server.environments.client?.moduleGraph;
|
|
2555
|
+
if (!graph) return;
|
|
2556
|
+
for (const mod of graph.idToModuleMap.values()) if (mod.id?.includes("?html-proxy&index=")) graph.invalidateModule(mod);
|
|
2557
|
+
}
|
|
2416
2558
|
function invalidateAppRoutingModules() {
|
|
2417
2559
|
invalidateAppRouteCache();
|
|
2418
2560
|
invalidateMetadataFileCache();
|
|
@@ -2524,13 +2666,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2524
2666
|
if (hasAppDir) invalidateRscEntryModule();
|
|
2525
2667
|
if (hasCloudflarePlugin && hasPagesDir && !hasAppDir) invalidatePagesServerEntry();
|
|
2526
2668
|
};
|
|
2669
|
+
function invalidatePagesMiddlewareMatcher(filePath) {
|
|
2670
|
+
if (!hasPagesDir || !middlewarePath || toSlash(filePath) !== middlewarePath) return;
|
|
2671
|
+
cachedSSRHandler = null;
|
|
2672
|
+
server.ws.send({ type: "full-reload" });
|
|
2673
|
+
}
|
|
2527
2674
|
server.watcher.on("add", (filePath) => {
|
|
2675
|
+
invalidatePagesMiddlewareMatcher(filePath);
|
|
2528
2676
|
updatePublicFileRoute(filePath, true);
|
|
2529
2677
|
let routeChanged = false;
|
|
2530
2678
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
2531
2679
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
2532
2680
|
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2533
2681
|
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2682
|
+
devPageRouteDataKinds.delete(toSlash(filePath));
|
|
2534
2683
|
invalidateRouteCache(pagesDir);
|
|
2535
2684
|
routeChanged = true;
|
|
2536
2685
|
}
|
|
@@ -2541,23 +2690,37 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2541
2690
|
}
|
|
2542
2691
|
if (routeChanged) {
|
|
2543
2692
|
invalidatePagesServerEntry();
|
|
2693
|
+
if (hasPagesDir) invalidatePagesHydrationProxies();
|
|
2544
2694
|
if (!hasAppDir) server.ws.send({ type: "full-reload" });
|
|
2545
2695
|
invalidateHybridClientEntries();
|
|
2546
2696
|
revalidateHybridRoutes();
|
|
2547
2697
|
}
|
|
2548
2698
|
});
|
|
2549
2699
|
server.watcher.on("change", (filePath) => {
|
|
2700
|
+
invalidatePagesMiddlewareMatcher(filePath);
|
|
2701
|
+
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2702
|
+
const pageFile = toSlash(filePath);
|
|
2703
|
+
const previousKind = devPageRouteDataKinds.get(pageFile);
|
|
2704
|
+
devPageRouteDataKinds.delete(pageFile);
|
|
2705
|
+
if (previousKind !== void 0 && previousKind !== classifyDevPageFile(pageFile)) {
|
|
2706
|
+
cachedSSRHandler = null;
|
|
2707
|
+
invalidatePagesHydrationProxies();
|
|
2708
|
+
server.ws.send({ type: "full-reload" });
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2550
2711
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
2551
2712
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
2552
2713
|
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2553
2714
|
});
|
|
2554
2715
|
server.watcher.on("unlink", (filePath) => {
|
|
2716
|
+
invalidatePagesMiddlewareMatcher(filePath);
|
|
2555
2717
|
updatePublicFileRoute(filePath, false);
|
|
2556
2718
|
let routeChanged = false;
|
|
2557
2719
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
2558
2720
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
2559
2721
|
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2560
2722
|
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2723
|
+
devPageRouteDataKinds.delete(toSlash(filePath));
|
|
2561
2724
|
invalidateRouteCache(pagesDir);
|
|
2562
2725
|
routeChanged = true;
|
|
2563
2726
|
}
|
|
@@ -2568,6 +2731,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2568
2731
|
}
|
|
2569
2732
|
if (routeChanged) {
|
|
2570
2733
|
invalidatePagesServerEntry();
|
|
2734
|
+
if (hasPagesDir) invalidatePagesHydrationProxies();
|
|
2571
2735
|
if (!hasAppDir) server.ws.send({ type: "full-reload" });
|
|
2572
2736
|
invalidateHybridClientEntries();
|
|
2573
2737
|
revalidateHybridRoutes();
|
|
@@ -2668,7 +2832,14 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2668
2832
|
restore();
|
|
2669
2833
|
return false;
|
|
2670
2834
|
};
|
|
2671
|
-
const pagesInstrumentationReady =
|
|
2835
|
+
const pagesInstrumentationReady = (async () => {
|
|
2836
|
+
if (!instrumentationPath || hasAppDir && hasCloudflarePlugin) return;
|
|
2837
|
+
if (hasAppDir) {
|
|
2838
|
+
const environment = server.environments["rsc"];
|
|
2839
|
+
if (!isRunnableDevEnvironment(environment)) return;
|
|
2840
|
+
return runInstrumentation(environment.runner, instrumentationPath);
|
|
2841
|
+
} else return runInstrumentation(getPagesRunner(), instrumentationPath);
|
|
2842
|
+
})();
|
|
2672
2843
|
pagesInstrumentationReady.catch(() => {});
|
|
2673
2844
|
if (hasAppDir) server.middlewares.use((req, res, next) => {
|
|
2674
2845
|
const url = req.url ?? "/";
|
|
@@ -2917,18 +3088,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2917
3088
|
const getDevApiRoutes = () => devApiRoutesPromise ??= apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
2918
3089
|
let devAppRoutesPromise = null;
|
|
2919
3090
|
const getDevAppRoutes = () => devAppRoutesPromise ??= hasAppDir && appDir ? appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : Promise.resolve([]);
|
|
2920
|
-
const
|
|
2921
|
-
const classifyDevPageRoute = (route) => {
|
|
2922
|
-
const cached = devPageRouteDataKinds.get(route.filePath);
|
|
2923
|
-
if (cached) return cached;
|
|
2924
|
-
let dataKind = "none";
|
|
2925
|
-
try {
|
|
2926
|
-
const source = fs.readFileSync(route.filePath, "utf8");
|
|
2927
|
-
dataKind = hasExportedName(source, "getStaticProps") ? "static" : hasExportedName(source, "getServerSideProps") ? "server" : "none";
|
|
2928
|
-
} catch {}
|
|
2929
|
-
devPageRouteDataKinds.set(route.filePath, dataKind);
|
|
2930
|
-
return dataKind;
|
|
2931
|
-
};
|
|
3091
|
+
const classifyDevPageRoute = (route) => classifyDevPageFile(route.filePath);
|
|
2932
3092
|
const pipelineDeps = {
|
|
2933
3093
|
basePath: bp,
|
|
2934
3094
|
trailingSlash: nextConfig?.trailingSlash ?? false,
|
|
@@ -3065,7 +3225,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3065
3225
|
}
|
|
3066
3226
|
if (!cachedSSRHandler || cachedSSRHandler.routes !== routes) cachedSSRHandler = {
|
|
3067
3227
|
routes,
|
|
3068
|
-
handler: createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false, middlewarePath !== null, (nextConfig?.rewrites.beforeFiles.length ?? 0) > 0 || (nextConfig?.rewrites.afterFiles.length ?? 0) > 0 || (nextConfig?.rewrites.fallback.length ?? 0) > 0, nextConfig?.clientTraceMetadata, nextConfig?.htmlLimitedBots, nextConfig?.reactStrictMode === true, nextConfig?.expireTime, nextConfig?.crossOrigin, devBuildId)
|
|
3228
|
+
handler: createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false, middlewarePath !== null, (nextConfig?.rewrites.beforeFiles.length ?? 0) > 0 || (nextConfig?.rewrites.afterFiles.length ?? 0) > 0 || (nextConfig?.rewrites.fallback.length ?? 0) > 0, nextConfig?.clientTraceMetadata, nextConfig?.htmlLimitedBots, nextConfig?.reactStrictMode === true, nextConfig?.expireTime, nextConfig?.crossOrigin, devBuildId, middlewarePath ? compileClientMiddlewareMatchers(extractMiddlewareMatcherConfig(middlewarePath)) : void 0, classifyDevPageRoute)
|
|
3069
3229
|
};
|
|
3070
3230
|
flushStagedHeaders();
|
|
3071
3231
|
flushRequestHeaders();
|
|
@@ -3262,8 +3422,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3262
3422
|
const serverDefines = { ...nextConfig.compilerDefineServer };
|
|
3263
3423
|
serverDefines["process.env.NEXT_RUNTIME"] = JSON.stringify("nodejs");
|
|
3264
3424
|
serverDefines["process.env.NEXT_PHASE"] = "globalThis.__VINEXT_NEXT_PHASE";
|
|
3265
|
-
|
|
3266
|
-
if (sharedRevalidateSecret) serverDefines["process.env.__VINEXT_REVALIDATE_SECRET"] = JSON.stringify(sharedRevalidateSecret);
|
|
3425
|
+
if (revalidateSecret) serverDefines["process.env.__VINEXT_REVALIDATE_SECRET"] = JSON.stringify(revalidateSecret);
|
|
3267
3426
|
if (previewBuildCredentials) {
|
|
3268
3427
|
serverDefines["process.env.__VINEXT_PREVIEW_MODE_ID"] = JSON.stringify(previewBuildCredentials.id);
|
|
3269
3428
|
serverDefines["process.env.__VINEXT_PREVIEW_MODE_SIGNING_KEY"] = JSON.stringify(previewBuildCredentials.signingKey);
|
|
@@ -3438,7 +3597,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3438
3597
|
sequential: true,
|
|
3439
3598
|
order: "post",
|
|
3440
3599
|
handler() {
|
|
3441
|
-
if (buildIdWritten) return;
|
|
3600
|
+
if (buildIdWritten || !isServerEnvironment(this.environment)) return;
|
|
3442
3601
|
buildIdWritten = true;
|
|
3443
3602
|
const outDir = path.join(root, "dist", "server");
|
|
3444
3603
|
fs.mkdirSync(outDir, { recursive: true });
|
|
@@ -3645,17 +3804,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3645
3804
|
clientEntry: runtimeMetadata.clientEntryFile ?? void 0,
|
|
3646
3805
|
appBootstrapPreinitModules: runtimeMetadata.appBootstrapPreinitModules,
|
|
3647
3806
|
ssrManifest,
|
|
3807
|
+
cssGraph: runtimeMetadata.cssGraph,
|
|
3648
3808
|
lazyChunks: runtimeMetadata.lazyChunks ?? void 0,
|
|
3649
|
-
dynamicPreloads: runtimeMetadata.dynamicPreloads ?? void 0
|
|
3809
|
+
dynamicPreloads: runtimeMetadata.dynamicPreloads ?? void 0,
|
|
3810
|
+
crossOrigin: nextConfig.crossOrigin ?? ""
|
|
3650
3811
|
});
|
|
3651
|
-
const buildSession = process.env.__VINEXT_PAGES_CLIENT_ASSETS_BUILD_SESSION;
|
|
3652
|
-
if (hasAppDir && hasPagesDir && buildSession) setPagesClientAssetsBuildMetadata(buildSession, pagesClientAssetsModule);
|
|
3653
|
-
}
|
|
3654
|
-
if (pagesClientAssetsModule === null) {
|
|
3655
|
-
if (pagesClientAssetsOutputDirs.size === 0) return;
|
|
3656
|
-
const buildSession = process.env.__VINEXT_PAGES_CLIENT_ASSETS_BUILD_SESSION;
|
|
3657
|
-
if (buildSession) pagesClientAssetsModule = takePagesClientAssetsBuildMetadata(buildSession);
|
|
3658
3812
|
}
|
|
3813
|
+
if (pagesClientAssetsModule === null && pagesClientAssetsOutputDirs.size === 0) return;
|
|
3659
3814
|
if (pagesClientAssetsModule === null) {
|
|
3660
3815
|
const emptyModule = buildPagesClientAssetsModule({});
|
|
3661
3816
|
for (const outputDir of pagesClientAssetsOutputDirs) writePagesClientAssetsModuleIfMissing(outputDir, emptyModule);
|
|
@@ -3727,6 +3882,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3727
3882
|
}
|
|
3728
3883
|
},
|
|
3729
3884
|
createWasmModuleImportPlugin(),
|
|
3885
|
+
createOgHarfbuzzPlugin(),
|
|
3730
3886
|
{
|
|
3731
3887
|
name: "vinext:og-font-patch",
|
|
3732
3888
|
enforce: "pre",
|
|
@@ -3827,6 +3983,27 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3827
3983
|
plugins.push(createRscReferenceValidationNormalizerPlugin());
|
|
3828
3984
|
plugins.push(createRscClientReferenceLoadersPlugin());
|
|
3829
3985
|
} else if (manualUseCachePluginPromise) plugins.push(manualUseCachePluginPromise);
|
|
3986
|
+
plugins.push({
|
|
3987
|
+
name: "vinext:plain-pages-build-config",
|
|
3988
|
+
apply: "build",
|
|
3989
|
+
enforce: "post",
|
|
3990
|
+
config: {
|
|
3991
|
+
order: "post",
|
|
3992
|
+
handler(config) {
|
|
3993
|
+
if (!hasPlainPagesBuildEnvironments) return;
|
|
3994
|
+
if (config.build?.watch || config.build?.ssr || config.build?.lib || getBuildBundlerOptions(config.build)?.input !== void 0) {
|
|
3995
|
+
for (const name of ["client", "ssr"]) if (originalPlainPagesEnvironments?.[name]) config.environments[name] = originalPlainPagesEnvironments[name];
|
|
3996
|
+
else delete config.environments?.[name];
|
|
3997
|
+
return;
|
|
3998
|
+
}
|
|
3999
|
+
return { builder: {
|
|
4000
|
+
...config.builder,
|
|
4001
|
+
sharedConfigBuild: true
|
|
4002
|
+
} };
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
4005
|
+
});
|
|
4006
|
+
plugins.push(buildLifecyclePlugins[1]);
|
|
3830
4007
|
return plugins;
|
|
3831
4008
|
}
|
|
3832
4009
|
/**
|