vinext 1.2.0 → 1.3.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 +13 -10
- package/dist/build/client-build-config.d.ts +64 -3
- package/dist/build/client-build-config.js +131 -4
- package/dist/build/client-reference-groups.d.ts +163 -0
- package/dist/build/client-reference-groups.js +534 -0
- package/dist/build/module-dependency-cache.d.ts +31 -0
- package/dist/build/module-dependency-cache.js +51 -1
- package/dist/build/next-client-runtime-manifests.d.ts +10 -1
- package/dist/build/next-client-runtime-manifests.js +19 -4
- package/dist/build/nitro-public-files.d.ts +24 -0
- package/dist/build/nitro-public-files.js +60 -0
- package/dist/build/output-root-externals.d.ts +21 -0
- package/dist/build/output-root-externals.js +40 -0
- package/dist/build/pages-client-assets-module.js +1 -1
- package/dist/build/prerender-paths.js +6 -3
- package/dist/build/prerender.js +1 -1
- package/dist/build/server-actions-encryption-key.d.ts +23 -0
- package/dist/build/server-actions-encryption-key.js +101 -0
- package/dist/build/ssr-manifest.d.ts +3 -0
- package/dist/build/ssr-manifest.js +10 -1
- package/dist/check.js +5 -6
- package/dist/cli-dev-config.js +3 -3
- package/dist/cli.js +1 -1
- package/dist/client/client-rewrite-params.d.ts +9 -0
- package/dist/client/client-rewrite-params.js +20 -0
- package/dist/client/dev-error-overlay.js +2 -1
- package/dist/client/navigation-runtime.d.ts +25 -2
- package/dist/client/navigation-runtime.js +42 -11
- package/dist/client/vinext-next-data.d.ts +0 -1
- package/dist/config/config-matchers.d.ts +15 -40
- package/dist/config/config-matchers.js +195 -262
- package/dist/config/config-source.d.ts +34 -0
- package/dist/config/config-source.js +141 -0
- package/dist/config/header-params.d.ts +29 -0
- package/dist/config/header-params.js +106 -0
- package/dist/config/next-config.d.ts +7 -5
- package/dist/config/next-config.js +120 -7
- package/dist/entries/app-browser-entry.d.ts +14 -1
- package/dist/entries/app-browser-entry.js +26 -36
- package/dist/entries/app-rsc-entry.d.ts +2 -0
- package/dist/entries/app-rsc-entry.js +92 -57
- package/dist/entries/app-rsc-manifest.d.ts +10 -0
- package/dist/entries/app-rsc-manifest.js +20 -1
- package/dist/entries/app-ssr-entry.d.ts +4 -1
- package/dist/entries/app-ssr-entry.js +9 -2
- package/dist/entries/pages-client-entry.d.ts +1 -0
- package/dist/entries/pages-client-entry.js +6 -6
- package/dist/entries/pages-server-entry.js +17 -14
- package/dist/index.d.ts +11 -0
- package/dist/index.js +350 -175
- package/dist/init.d.ts +1 -1
- package/dist/init.js +103 -6
- package/dist/plugins/ast-utils.d.ts +53 -2
- package/dist/plugins/ast-utils.js +90 -2
- package/dist/plugins/cloudflare-dev-module-urls.d.ts +41 -0
- package/dist/plugins/cloudflare-dev-module-urls.js +271 -0
- package/dist/plugins/commonjs-esm-facade.js +2 -2
- package/dist/plugins/css-module-imports.js +13 -20
- package/dist/plugins/dynamic-preload-metadata.js +2 -3
- package/dist/plugins/extensionless-dynamic-import.js +2 -3
- package/dist/plugins/fonts.d.ts +1 -1
- package/dist/plugins/fonts.js +3 -3
- package/dist/plugins/ignore-dynamic-requests.js +2 -3
- package/dist/plugins/import-meta-url.js +3 -4
- package/dist/plugins/instrumentation-client.js +3 -2
- package/dist/plugins/middleware-export-validation.js +2 -3
- package/dist/plugins/og-harfbuzz.js +2 -3
- package/dist/plugins/optimize-imports.d.ts +25 -2
- package/dist/plugins/optimize-imports.js +109 -24
- package/dist/plugins/pages-node-externals.js +2 -3
- package/dist/plugins/remove-console.js +2 -18
- package/dist/plugins/require-condition-resolution.js +3 -3
- package/dist/plugins/require-context.js +2 -3
- package/dist/plugins/rsc-client-reference-loaders.d.ts +45 -1
- package/dist/plugins/rsc-client-reference-loaders.js +336 -18
- package/dist/plugins/strip-server-exports.js +3 -4
- package/dist/plugins/styled-jsx.js +2 -3
- package/dist/plugins/use-cache-callable.d.ts +26 -2
- package/dist/plugins/use-cache-callable.js +101 -36
- package/dist/plugins/worker-image-imports.d.ts +1 -0
- package/dist/plugins/worker-image-imports.js +31 -34
- package/dist/plugins/worker-use-server.js +38 -14
- package/dist/routing/app-route-graph.d.ts +1 -1
- package/dist/routing/browser-route-manifest.d.ts +43 -0
- package/dist/routing/browser-route-manifest.js +195 -0
- package/dist/routing/hashed-route-patterns.d.ts +4 -0
- package/dist/routing/hashed-route-patterns.js +22 -0
- package/dist/routing/optimistic-route-trie.d.ts +27 -0
- package/dist/routing/optimistic-route-trie.js +102 -0
- package/dist/routing/route-validation.d.ts +6 -1
- package/dist/routing/route-validation.js +26 -10
- package/dist/server/api-handler.js +1 -1
- package/dist/server/app-action-forwarding.d.ts +8 -0
- package/dist/server/app-action-forwarding.js +17 -3
- package/dist/server/app-browser-entry.js +149 -62
- package/dist/server/app-browser-error.d.ts +3 -1
- package/dist/server/app-browser-error.js +7 -2
- package/dist/server/app-browser-interception-context.d.ts +2 -2
- package/dist/server/app-browser-interception-context.js +1 -1
- package/dist/server/app-browser-mpa-navigation.d.ts +1 -0
- package/dist/server/app-browser-mpa-navigation.js +6 -5
- package/dist/server/app-browser-navigation-controller.d.ts +17 -6
- package/dist/server/app-browser-navigation-controller.js +88 -26
- package/dist/server/app-browser-prefetch-response.js +2 -2
- package/dist/server/app-browser-state.d.ts +2 -2
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-supplemental-refresh.js +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +4 -4
- package/dist/server/app-client-reference-preloader.d.ts +23 -0
- package/dist/server/app-client-reference-preloader.js +30 -7
- package/dist/server/app-fallback-renderer.js +2 -1
- package/dist/server/app-middleware.d.ts +6 -0
- package/dist/server/app-middleware.js +8 -10
- package/dist/server/app-optimistic-routing.d.ts +8 -10
- package/dist/server/app-optimistic-routing.js +4 -95
- package/dist/server/app-page-boundary-render.js +8 -1
- package/dist/server/app-page-cache-render.js +1 -0
- package/dist/server/app-page-dispatch.js +3 -1
- package/dist/server/app-page-render.js +4 -2
- package/dist/server/app-page-rsc-render-status.d.ts +1 -0
- package/dist/server/app-page-rsc-render-status.js +1 -0
- package/dist/server/app-page-search-params-observation.d.ts +1 -4
- package/dist/server/app-page-search-params-observation.js +8 -10
- package/dist/server/app-page-stream.d.ts +7 -0
- package/dist/server/app-page-stream.js +1 -0
- package/dist/server/app-pages-bridge.d.ts +2 -1
- package/dist/server/app-pages-bridge.js +12 -8
- package/dist/server/app-prerender-endpoints.js +1 -1
- package/dist/server/app-prerender-static-params.js +3 -2
- package/dist/server/app-render-abort-error.d.ts +19 -0
- package/dist/server/app-render-abort-error.js +31 -1
- package/dist/server/app-render-dependency.js +42 -2
- package/dist/server/app-request-stage-independent-entry.js +7 -7
- package/dist/server/app-response-stage-entry.js +5 -5
- package/dist/server/app-route-handler-dispatch.js +3 -1
- package/dist/server/app-route-handler-execution.d.ts +2 -0
- package/dist/server/app-route-handler-execution.js +9 -2
- package/dist/server/app-route-handler-middleware-context.d.ts +2 -1
- package/dist/server/app-route-handler-middleware-context.js +3 -3
- package/dist/server/app-route-handler-response.d.ts +2 -1
- package/dist/server/app-route-handler-response.js +2 -2
- package/dist/server/app-route-handler-runtime.d.ts +2 -0
- package/dist/server/app-route-handler-runtime.js +21 -4
- package/dist/server/app-route-module-loader.js +7 -6
- package/dist/server/app-route-tree.d.ts +20 -0
- package/dist/server/app-route-tree.js +18 -0
- package/dist/server/app-router-entry.js +7 -7
- package/dist/server/app-rsc-cache-busting.d.ts +16 -0
- package/dist/server/app-rsc-cache-busting.js +29 -12
- package/dist/server/app-rsc-combined-handler.js +8 -1
- package/dist/server/app-rsc-errors.d.ts +7 -0
- package/dist/server/app-rsc-errors.js +9 -2
- package/dist/server/app-rsc-handler.d.ts +4 -1
- package/dist/server/app-rsc-handler.js +151 -135
- package/dist/server/app-rsc-request-normalization.js +3 -3
- package/dist/server/app-rsc-response-finalizer.d.ts +5 -0
- package/dist/server/app-rsc-response-finalizer.js +4 -1
- package/dist/server/app-rsc-response-stage.js +5 -3
- package/dist/server/app-rsc-route-matching.d.ts +1 -0
- package/dist/server/app-rsc-route-matching.js +1 -1
- package/dist/server/app-server-action-execution.d.ts +23 -6
- package/dist/server/app-server-action-execution.js +51 -57
- package/dist/server/app-ssr-entry.d.ts +6 -0
- package/dist/server/app-ssr-entry.js +21 -11
- package/dist/server/app-ssr-stream.d.ts +7 -0
- package/dist/server/app-ssr-stream.js +13 -1
- package/dist/server/app-visited-response-cache.js +2 -2
- package/dist/server/config-headers.js +13 -4
- package/dist/server/defer-until-stream-consumed.d.ts +2 -1
- package/dist/server/defer-until-stream-consumed.js +3 -1
- package/dist/server/dev-server.js +1 -1
- package/dist/server/image-optimization.js +1 -0
- package/dist/server/isolate-shared-promise.d.ts +10 -0
- package/dist/server/isolate-shared-promise.js +33 -0
- package/dist/server/isr-cache.js +3 -2
- package/dist/server/metadata-route-response.js +2 -2
- package/dist/server/middleware-matcher-pattern.d.ts +0 -1
- package/dist/server/middleware-matcher-pattern.js +11 -140
- package/dist/server/middleware-matcher.js +5 -6
- package/dist/server/middleware-response-headers.d.ts +31 -0
- package/dist/server/middleware-response-headers.js +57 -1
- package/dist/server/middleware-runtime.js +30 -17
- package/dist/server/navigation-planner.d.ts +2 -2
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/nitro-public-files-plugin.d.ts +38 -0
- package/dist/server/nitro-public-files-plugin.js +106 -0
- package/dist/server/nitro-public-files.d.ts +21 -0
- package/dist/server/nitro-public-files.js +39 -0
- package/dist/server/open-redirect.d.ts +11 -4
- package/dist/server/open-redirect.js +11 -4
- package/dist/server/pages-api-route.js +2 -2
- package/dist/server/pages-asset-tags.d.ts +5 -0
- package/dist/server/pages-asset-tags.js +9 -2
- package/dist/server/pages-client-assets.d.ts +4 -1
- package/dist/server/pages-data-route.js +2 -1
- package/dist/server/pages-i18n.d.ts +18 -0
- package/dist/server/pages-i18n.js +18 -2
- package/dist/server/pages-node-compat.d.ts +5 -3
- package/dist/server/pages-node-compat.js +35 -16
- package/dist/server/pages-page-data.js +1 -1
- package/dist/server/pages-page-handler.js +1 -1
- package/dist/server/pages-page-response.js +1 -1
- package/dist/server/pages-request-pipeline.d.ts +6 -1
- package/dist/server/pages-request-pipeline.js +35 -39
- package/dist/server/pages-request-stage-entry.js +20 -10
- package/dist/server/pages-response-stage-entry.js +1 -1
- package/dist/server/pages-revalidate.js +3 -2
- package/dist/server/pages-router-entry.js +2 -2
- package/dist/server/prod-server.d.ts +2 -2
- package/dist/server/prod-server.js +74 -36
- package/dist/server/proxy-trust.d.ts +6 -0
- package/dist/server/proxy-trust.js +12 -6
- package/dist/server/request-pipeline.d.ts +5 -0
- package/dist/server/request-pipeline.js +12 -1
- package/dist/server/rsc-stream-hints.d.ts +1 -1
- package/dist/server/rsc-stream-hints.js +21 -3
- package/dist/server/server-reference-loader.js +10 -1
- package/dist/server/static-file-cache.js +15 -3
- package/dist/server/worker-image-optimization.js +19 -6
- package/dist/server/worker-utils.js +1 -1
- package/dist/shims/cache-handler.js +3 -2
- package/dist/shims/cache-request-state.d.ts +40 -3
- package/dist/shims/cache-request-state.js +70 -5
- package/dist/shims/cache-runtime.js +47 -19
- package/dist/shims/cache.d.ts +2 -2
- package/dist/shims/cache.js +17 -8
- package/dist/shims/cdn-purge-routes.d.ts +24 -0
- package/dist/shims/cdn-purge-routes.js +77 -0
- package/dist/shims/dynamic.js +17 -4
- package/dist/shims/form.js +8 -3
- package/dist/shims/head.js +1 -1
- package/dist/shims/headers.js +2 -2
- package/dist/shims/image-props.d.ts +93 -0
- package/dist/shims/image-props.js +323 -0
- package/dist/shims/image.d.ts +4 -18
- package/dist/shims/image.js +4 -319
- package/dist/shims/internal/headers-state.d.ts +7 -0
- package/dist/shims/internal/headers-state.js +14 -2
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +4 -1
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +32 -15
- package/dist/shims/internal/hybrid-client-route-owner.js +9 -8
- package/dist/shims/link-prefetch.js +5 -4
- package/dist/shims/link.js +7 -5
- package/dist/shims/navigation.d.ts +1 -1
- package/dist/shims/navigation.js +21 -10
- package/dist/shims/og.js +35 -10
- package/dist/shims/request-context.d.ts +13 -0
- package/dist/shims/router.js +28 -52
- package/dist/shims/server.d.ts +42 -8
- package/dist/shims/server.js +99 -15
- package/dist/shims/thenable-params.d.ts +6 -1
- package/dist/shims/thenable-params.js +11 -2
- package/dist/shims/unified-request-context.d.ts +5 -0
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/url-utils.d.ts +7 -0
- package/dist/shims/url-utils.js +12 -3
- package/dist/utils/asset-prefix.d.ts +7 -0
- package/dist/utils/asset-prefix.js +10 -1
- package/dist/utils/client-build-manifest.js +12 -5
- package/dist/utils/client-runtime-metadata.d.ts +1 -0
- package/dist/utils/client-runtime-metadata.js +15 -2
- package/dist/utils/domain-locale.js +1 -1
- package/dist/utils/lazy-chunks.d.ts +4 -0
- package/dist/utils/manifest-paths.d.ts +14 -0
- package/dist/utils/manifest-paths.js +22 -1
- package/dist/utils/path-to-regexp.d.ts +21 -0
- package/dist/{server/middleware-path-to-regexp.js → utils/path-to-regexp.js} +14 -11
- package/dist/utils/plugin-react-version.d.ts +15 -0
- package/dist/utils/plugin-react-version.js +64 -0
- package/dist/utils/plugin-rsc-version.d.ts +2 -0
- package/dist/utils/plugin-rsc-version.js +28 -2
- package/dist/utils/public-routes.d.ts +2 -0
- package/dist/utils/public-routes.js +18 -7
- package/dist/utils/react-version.d.ts +7 -0
- package/dist/utils/react-version.js +39 -16
- package/package.json +6 -6
- package/dist/build/nitro-route-rules.d.ts +0 -47
- package/dist/build/nitro-route-rules.js +0 -79
- package/dist/plugins/cache-flight-codec.d.ts +0 -19
- package/dist/plugins/cache-flight-codec.js +0 -68
- package/dist/server/middleware-path-to-regexp.d.ts +0 -13
- package/dist/utils/regex-safety.d.ts +0 -17
- package/dist/utils/regex-safety.js +0 -789
package/dist/index.js
CHANGED
|
@@ -1,40 +1,43 @@
|
|
|
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 { escapeRegExp } from "./utils/regex.js";
|
|
3
4
|
import { buildViteResolveExtensions, createValidFileMatcher, findFileWithExts, normalizeViteResolveExtensions } from "./routing/file-matcher.js";
|
|
4
5
|
import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
|
|
6
|
+
import { TRIVIA_PATTERN, hasImportAttributes, isTypeOnlyImport, parseModuleRecord, parseProgram } from "./plugins/ast-utils.js";
|
|
5
7
|
import { claimViteCliBuildInvocation, getViteCliInvocation, isViteCliConfigFile } from "./utils/vite-cli-invocation.js";
|
|
6
8
|
import { VINEXT_DEV_CLI_LIFECYCLE, applyDevServerDefaults, claimViteCliDevInvocation, createDevServerLifecyclePlugin, reserveViteCliDevInvocation } from "./cli-dev-config.js";
|
|
7
9
|
import { isUnknownRecord } from "./utils/record.js";
|
|
8
|
-
import { getReactUpgradeDeps } from "./utils/react-version.js";
|
|
10
|
+
import { getReactUpgradeDeps, reactUpgradeRequiredMessage } from "./utils/react-version.js";
|
|
11
|
+
import { resolvePluginReactPath } from "./utils/plugin-react-version.js";
|
|
9
12
|
import { loadDotenv } from "./config/dotenv.js";
|
|
10
13
|
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
|
|
11
14
|
import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
|
|
12
15
|
import { encodeMiddlewareRequestHeaders } from "./utils/middleware-request-headers.js";
|
|
16
|
+
import { hasBasePath, stripBasePath } from "./utils/base-path.js";
|
|
17
|
+
import { INTERNAL_HEADERS, NEXTJS_DEPLOYMENT_ID_HEADER, VINEXT_INTERNAL_HEADERS, VINEXT_TIMING_HEADER } from "./server/headers.js";
|
|
18
|
+
import { methodNotAllowedResponse, notFoundStaticAssetResponse } from "./server/http-error-responses.js";
|
|
19
|
+
import { isOpenRedirectShaped, sendRepeatedSlashRedirect } from "./server/open-redirect.js";
|
|
20
|
+
import { canonicalizeRequestUrlPathname, filterInternalHeaders, normalizeTrailingSlash } from "./server/request-pipeline.js";
|
|
13
21
|
import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
|
|
14
22
|
import { omitUnusedBuildSourcemap } from "./plugins/transform-result.js";
|
|
15
23
|
import { assetPrefixPathname, isNextStaticPath, resolveAssetsDir } from "./utils/asset-prefix.js";
|
|
16
24
|
import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
|
|
17
25
|
import { VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, findNextConfigPath, lightningCssFeatureNamesToMask, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
|
|
18
26
|
import { normalizePathnameForRouteMatch, normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
|
|
19
|
-
import { hasBasePath, stripBasePath } from "./utils/base-path.js";
|
|
20
27
|
import { appRouteGraph, appRouter, invalidateAppRouteCache, matchAppRoute } from "./routing/app-router.js";
|
|
21
28
|
import { generateRouteTypes } from "./typegen.js";
|
|
22
29
|
import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./routing/pages-router.js";
|
|
23
30
|
import { resolveRuntimeEntryModule } from "./entries/runtime-entry-module.js";
|
|
24
|
-
import { INTERNAL_HEADERS, NEXTJS_DEPLOYMENT_ID_HEADER, VINEXT_INTERNAL_HEADERS, VINEXT_TIMING_HEADER } from "./server/headers.js";
|
|
25
31
|
import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
|
|
26
32
|
import { validateMiddlewareMatcherPatterns } from "./server/middleware-matcher-pattern.js";
|
|
27
|
-
import {
|
|
28
|
-
import { isOpenRedirectShaped, sendRepeatedSlashRedirect } from "./server/open-redirect.js";
|
|
29
|
-
import { canonicalizeRequestUrlPathname, filterInternalHeaders, normalizeTrailingSlash } from "./server/request-pipeline.js";
|
|
30
|
-
import { resolvePagesI18nRequest, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
|
|
33
|
+
import { resolvePagesI18nRequest, shouldRestoreLocaleRootTrailingSlash, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
|
|
31
34
|
import { encodeUrlParserIgnoredCharacters, isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname, shouldAddTrailingSlashToPagesDataPath, urlParserCreatesPagesDataPath } from "./server/pages-data-route.js";
|
|
32
35
|
import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
|
|
33
36
|
import { findMiddlewareFile, isProxyFile, runMiddleware } from "./server/middleware.js";
|
|
34
37
|
import { extractMiddlewareMatcherConfig, extractMiddlewareMatcherConfigValue, hasExportedName } from "./build/report.js";
|
|
35
38
|
import { generatePagesRequestEntry, generatePagesResponseEntry, generateServerEntry } from "./entries/pages-server-entry.js";
|
|
36
39
|
import { compileClientMiddlewareMatchers, generateClientEntry } from "./entries/pages-client-entry.js";
|
|
37
|
-
import { isPathInside, isPathInsideOrEqual, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
|
|
40
|
+
import { canonicalizeFilePath, isPathInside, isPathInsideOrEqual, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
|
|
38
41
|
import { logRequest, now } from "./server/request-log.js";
|
|
39
42
|
import { getPagesPreviewModeId } from "./server/pages-preview.js";
|
|
40
43
|
import { createSSRHandler } from "./server/dev-server.js";
|
|
@@ -43,20 +46,23 @@ import { handleApiRoute } from "./server/api-handler.js";
|
|
|
43
46
|
import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath, resolveDevImageRedirect } from "./server/image-optimization.js";
|
|
44
47
|
import { CACHEABILITY_MANIFEST_MODULE, CACHEABILITY_REQUEST_PROJECTION_MODULE } from "./server/cacheability-manifest.js";
|
|
45
48
|
import { PREGENERATED_CONCRETE_PATHS_MODULE } from "./server/pregenerated-concrete-paths.js";
|
|
49
|
+
import { rewriteOutputRootExternals } from "./build/output-root-externals.js";
|
|
46
50
|
import { installSocketErrorBackstop } from "./server/socket-error-backstop.js";
|
|
47
51
|
import { invalidateMetadataFileCache, scanMetadataFiles } from "./server/metadata-routes.js";
|
|
48
52
|
import { shouldInvalidateAppRouteFile } from "./server/dev-route-files.js";
|
|
49
53
|
import { createDirectRunner } from "./server/dev-module-runner.js";
|
|
54
|
+
import { rootBoundaryFiles, rootBoundaryRouteFiles } from "./entries/app-rsc-manifest.js";
|
|
50
55
|
import { validateDevRequest } from "./server/dev-origin-check.js";
|
|
51
56
|
import { createActionOwnerManifestPlugin } from "./plugins/action-owner-manifest.js";
|
|
52
57
|
import { generateAppRequestRscEntry, generateAppResponseRscEntry, generateRscEntry } from "./entries/app-rsc-entry.js";
|
|
53
58
|
import { generateSsrEntry } from "./entries/app-ssr-entry.js";
|
|
54
59
|
import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VIRTUAL_CACHE_ADAPTERS, VIRTUAL_CDN_CACHE_ADAPTER, generateCacheAdaptersModule, generateCdnCacheAdapterModule } from "./cache/cache-adapters-virtual.js";
|
|
55
60
|
import { VIRTUAL_IMAGE_ADAPTERS, generateImageAdaptersModule } from "./image/image-adapters-virtual.js";
|
|
56
|
-
import { generateBrowserEntry, toLinkPrefetchRoutes } from "./entries/app-browser-entry.js";
|
|
61
|
+
import { generateBrowserEntry, generateBrowserRouteManifestModule, toHashedRouteHandlerRoutes, toLinkPrefetchRoutes } from "./entries/app-browser-entry.js";
|
|
57
62
|
import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
|
|
58
63
|
import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
|
|
59
64
|
import { createRscScanGlobImportsPlugin, isRscScanGlobImportsAffected } from "./plugins/rsc-scan-glob-imports.js";
|
|
65
|
+
import { loadOrGenerateServerActionsEncryptionKey } from "./build/server-actions-encryption-key.js";
|
|
60
66
|
import { findOpenTelemetryPackages, mergeServerExternalPackages } from "./config/server-external-packages.js";
|
|
61
67
|
import { precompressAssets } from "./build/precompress.js";
|
|
62
68
|
import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY, normalizeVinextPrerenderConfig } from "./config/prerender.js";
|
|
@@ -65,7 +71,8 @@ import { PAGES_CLIENT_ASSETS_MODULE, buildPagesClientAssetsModule, collectClient
|
|
|
65
71
|
import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
|
|
66
72
|
import { VINEXT_BUILD_LIFECYCLE_CONFIG, createBuildLifecyclePlugins } from "./build/lifecycle.js";
|
|
67
73
|
import { ensureAssetsIgnore } from "./build/assets-ignore.js";
|
|
68
|
-
import {
|
|
74
|
+
import { registerNitroPublicFiles } from "./build/nitro-public-files.js";
|
|
75
|
+
import { emitNextClientRuntimeManifests, getPagesManifestPage } from "./build/next-client-runtime-manifests.js";
|
|
69
76
|
import { collectInlineCssManifest, injectInlineCssManifestGlobal } from "./build/inline-css.js";
|
|
70
77
|
import { readTrustedRevalidationHostname } from "./server/revalidation-host.js";
|
|
71
78
|
import { sealForwardedMiddlewareContext } from "./server/forwarded-middleware-context.js";
|
|
@@ -81,7 +88,9 @@ import { asyncHooksStubPlugin } from "./plugins/async-hooks-stub.js";
|
|
|
81
88
|
import { clientReferenceDedupPlugin } from "./plugins/client-reference-dedup.js";
|
|
82
89
|
import { dataUrlCssPlugin } from "./plugins/css-data-url.js";
|
|
83
90
|
import { createCssModuleImportCompatibilityPlugin } from "./plugins/css-module-imports.js";
|
|
84
|
-
import {
|
|
91
|
+
import { createWorkerImageImportsPlugin } from "./plugins/worker-image-imports.js";
|
|
92
|
+
import { assertClientOutDirIsSeparate, createClientAssetFileNames, createClientCodeSplittingConfig, createClientManualChunks, createClientOutputFileNameDefaults, createMultiStageChunkFileNames, createMultiStageCodeSplittingConfig, createRscFrameworkChunkOutputConfig, createWorkerFileNames, findUnsupportedClientOutputFileNames, getBuildBundlerOptions, getClientTreeshakeConfig, getOutputFileNames, withBuildBundlerOptions } from "./build/client-build-config.js";
|
|
93
|
+
import { createRouteClientReferencesFallbackPlugin, createRscClientReferenceLoadersPlugin } from "./plugins/rsc-client-reference-loaders.js";
|
|
85
94
|
import { createRscReferenceValidationNormalizerPlugin } from "./plugins/rsc-reference-validation-normalizer.js";
|
|
86
95
|
import { createScanBuildCssPlugin } from "./plugins/scan-build-css.js";
|
|
87
96
|
import { createInstrumentationClientTransformPlugin, createInstrumentationServerTransformPlugin } from "./plugins/instrumentation-client.js";
|
|
@@ -90,6 +99,7 @@ import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjec
|
|
|
90
99
|
import { isServerEnvironment } from "./plugins/environment.js";
|
|
91
100
|
import { createMiddlewareServerOnlyPlugin } from "./plugins/middleware-server-only.js";
|
|
92
101
|
import { createPagesNodeExternalsPlugin } from "./plugins/pages-node-externals.js";
|
|
102
|
+
import { createCloudflareDevModuleUrlsPlugin } from "./plugins/cloudflare-dev-module-urls.js";
|
|
93
103
|
import { validateMiddlewareModuleExports } from "./plugins/middleware-export-validation.js";
|
|
94
104
|
import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
|
|
95
105
|
import { augmentSsrManifestFromBundle, relativeWithinRoot, tryRealpathSync } from "./build/ssr-manifest.js";
|
|
@@ -98,21 +108,18 @@ import { createTransformCache } from "./plugins/transform-cache.js";
|
|
|
98
108
|
import { createOgHarfbuzzPlugin } from "./plugins/og-harfbuzz.js";
|
|
99
109
|
import { createOgAssetsPlugin, createOgInlineFetchAssetsPlugin } from "./plugins/og-assets.js";
|
|
100
110
|
import { createUseCacheCallablePlugin } from "./plugins/use-cache-callable.js";
|
|
101
|
-
import { cacheFlightCodecPlugin } from "./plugins/cache-flight-codec.js";
|
|
102
111
|
import { SSR_EXTERNAL_REACT_ENTRIES, VINEXT_OPTIMIZE_DEPS_EXCLUDE, mergeOptimizeDepsExclude } from "./plugins/rsc-client-shim-excludes.js";
|
|
103
112
|
import { createServerExternalsManifestPlugin } from "./plugins/server-externals-manifest.js";
|
|
104
113
|
import { createTransitiveExternalsPlugin } from "./plugins/transitive-externals.js";
|
|
105
114
|
import public_shim_map_default from "./shims/public-shim-map.json.js";
|
|
106
115
|
import { computeClientRuntimeMetadata } from "./utils/client-runtime-metadata.js";
|
|
107
116
|
import { readPrerenderSecret, readServerRuntimeOutputDirs } from "./build/server-manifest.js";
|
|
108
|
-
import { createModuleDependencyCache } from "./build/module-dependency-cache.js";
|
|
117
|
+
import { ModuleDependencyStore, createModuleDependencyCache } from "./build/module-dependency-cache.js";
|
|
109
118
|
import { markCssUrlAssetReferences, restoreDedupedCssAssetReferences } from "./build/css-url-assets.js";
|
|
110
119
|
import { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter, createSassTsconfigPathImporters } from "./plugins/sass.js";
|
|
111
|
-
import { assertClientOutDirIsSeparate, createClientAssetFileNames, createClientCodeSplittingConfig, createClientFileNameConfig, createClientManualChunks, createMultiStageChunkFileNames, createMultiStageCodeSplittingConfig, createRscFrameworkChunkOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfig, withBuildBundlerOptions } from "./build/client-build-config.js";
|
|
112
120
|
import { EXPORT_ALL_CANDIDATE_FILTER, hasExportAllCandidate, stripServerExports, validatePageExports } from "./plugins/strip-server-exports.js";
|
|
113
121
|
import { removeConsoleCalls } from "./plugins/remove-console.js";
|
|
114
122
|
import { createImportMetaUrlPlugin } from "./plugins/import-meta-url.js";
|
|
115
|
-
import { createWorkerImageImportsPlugin } from "./plugins/worker-image-imports.js";
|
|
116
123
|
import { SERVER_ONLY_SPECIFIER_RE, createWorkerServerOnlyImportsPlugin } from "./plugins/worker-server-only-imports.js";
|
|
117
124
|
import { createWorkerUseServerPlugins } from "./plugins/worker-use-server.js";
|
|
118
125
|
import { createRequireContextPlugin } from "./plugins/require-context.js";
|
|
@@ -124,16 +131,15 @@ import { createWasmModuleImportPlugin } from "./plugins/wasm-module-import.js";
|
|
|
124
131
|
import { consumerEnvironmentConditionFilter, getTypeofWindowReplacement, mayFoldChangeScannedImports, replaceConsumerEnvironmentConditions } from "./plugins/typeof-window.js";
|
|
125
132
|
import { hasMdxFiles, loadMdxEsmReader, pageExtensionsIncludeMdx } from "./utils/mdx-scan.js";
|
|
126
133
|
import { publicFileRouteKey } from "./utils/public-file-path.js";
|
|
127
|
-
import { scanPublicFileRoutes } from "./utils/public-routes.js";
|
|
134
|
+
import { scanPublicFileRoutes, scanPublicFiles } from "./utils/public-routes.js";
|
|
128
135
|
import { createIgnoreDynamicRequestsPlugin } from "./plugins/ignore-dynamic-requests.js";
|
|
129
|
-
import { assertPluginRscVersion } from "./utils/plugin-rsc-version.js";
|
|
136
|
+
import { assertPluginRscVersion, needsAppReactServerDom } from "./utils/plugin-rsc-version.js";
|
|
130
137
|
import { assertSupportedViteVersion, getDepOptimizeNodeEnvOptions, serializeViteDefine } from "./utils/vite-version.js";
|
|
131
138
|
import { staticExportApp, staticExportPages } from "./build/static-export.js";
|
|
132
139
|
import { createRequire } from "node:module";
|
|
133
140
|
import fs from "node:fs";
|
|
134
141
|
import { pathToFileURL } from "node:url";
|
|
135
|
-
import { createIdResolver, createLogger, isRunnableDevEnvironment,
|
|
136
|
-
import { execFileSync } from "node:child_process";
|
|
142
|
+
import { createIdResolver, createLogger, isRunnableDevEnvironment, transformWithOxc } from "vite";
|
|
137
143
|
import { createHash, randomBytes } from "node:crypto";
|
|
138
144
|
import MagicString from "magic-string";
|
|
139
145
|
import commonjs from "vite-plugin-commonjs";
|
|
@@ -146,6 +152,7 @@ const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
|
146
152
|
"react/jsx-runtime",
|
|
147
153
|
"react/jsx-dev-runtime"
|
|
148
154
|
]);
|
|
155
|
+
const PAGES_CLOUDFLARE_WORKER_OPTIONAL_OPTIMIZE_DEPS_INCLUDE = Object.freeze(["use-sync-external-store/with-selector", "vinext > @vitejs/plugin-rsc/react/rsc"]);
|
|
149
156
|
const APP_CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
150
157
|
"use-sync-external-store/shim",
|
|
151
158
|
"use-sync-external-store/shim/index.js",
|
|
@@ -183,13 +190,17 @@ function scopeRscPlugin(plugin) {
|
|
|
183
190
|
};
|
|
184
191
|
}
|
|
185
192
|
const earlyViteCliInvocation = getViteCliInvocation();
|
|
193
|
+
let earlyDotenv;
|
|
186
194
|
const viteCliBuildConfigNodeEnv = earlyViteCliInvocation?.command === "build" && process.env.NODE_ENV === "test" ? "test" : void 0;
|
|
187
195
|
if (earlyViteCliInvocation) {
|
|
188
196
|
if (!process.env.NODE_ENV) Reflect.set(process.env, "NODE_ENV", earlyViteCliInvocation.command === "build" ? viteCliBuildConfigNodeEnv ?? "production" : earlyViteCliInvocation.mode === "test" ? "test" : "development");
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
197
|
+
earlyDotenv = {
|
|
198
|
+
dir: path.resolve(earlyViteCliInvocation.root),
|
|
199
|
+
env: loadDotenv({
|
|
200
|
+
root: earlyViteCliInvocation.root,
|
|
201
|
+
mode: earlyViteCliInvocation.mode
|
|
202
|
+
}).loadedEnv
|
|
203
|
+
};
|
|
193
204
|
}
|
|
194
205
|
installSocketErrorBackstop();
|
|
195
206
|
const INVALID_SERVER_ONLY_ID_PREFIX = "\0vinext:invalid-server-only:";
|
|
@@ -199,9 +210,13 @@ function createServerOnlyClientImportError(importer) {
|
|
|
199
210
|
}
|
|
200
211
|
function hasServerOnlyMarkerImport(code) {
|
|
201
212
|
if (!code.includes("server-only")) return false;
|
|
213
|
+
const record = parseModuleRecord(code, "js");
|
|
214
|
+
if (!record) return false;
|
|
215
|
+
if (record.staticImports.some((statement) => statement.moduleRequest.value === "server-only")) return true;
|
|
216
|
+
if (!code.includes("require")) return false;
|
|
202
217
|
let ast;
|
|
203
218
|
try {
|
|
204
|
-
ast =
|
|
219
|
+
ast = parseProgram(code);
|
|
205
220
|
} catch {
|
|
206
221
|
return false;
|
|
207
222
|
}
|
|
@@ -209,9 +224,6 @@ function hasServerOnlyMarkerImport(code) {
|
|
|
209
224
|
if (!node) return false;
|
|
210
225
|
if (Array.isArray(node)) return node.some((child) => walk(child));
|
|
211
226
|
if (typeof node !== "object") return false;
|
|
212
|
-
if (node.type === "ImportDeclaration") {
|
|
213
|
-
if (node.source?.value === "server-only") return true;
|
|
214
|
-
}
|
|
215
227
|
if (node.type === "CallExpression") {
|
|
216
228
|
const call = node;
|
|
217
229
|
if (call.callee?.type === "Identifier" && call.callee.name === "require" && call.arguments?.[0]?.type === "Literal" && call.arguments[0].value === "server-only") return true;
|
|
@@ -300,24 +312,16 @@ function isolateMdxStylesheetImports(code) {
|
|
|
300
312
|
}
|
|
301
313
|
function isolateGlobalNotFoundStylesheetImports(code, id) {
|
|
302
314
|
if (isMdxModuleId(id)) return isolateMdxStylesheetImports(code);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
ast = parseAst(code, { lang: parserLanguageForScript(id) });
|
|
306
|
-
} catch {
|
|
307
|
-
return null;
|
|
308
|
-
}
|
|
315
|
+
const record = parseModuleRecord(code, parserLanguageForScript(id));
|
|
316
|
+
if (!record) return null;
|
|
309
317
|
let output = null;
|
|
310
|
-
for (const statement of
|
|
311
|
-
if (statement.
|
|
312
|
-
|
|
313
|
-
if (
|
|
314
|
-
|
|
315
|
-
const specifier = source?.value;
|
|
316
|
-
if (typeof specifier !== "string" || !isStylesheetSpecifier(specifier)) continue;
|
|
317
|
-
const range = source;
|
|
318
|
-
if (typeof range.start !== "number" || typeof range.end !== "number") continue;
|
|
318
|
+
for (const statement of record.staticImports) {
|
|
319
|
+
if (statement.entries.length > 0 || isTypeOnlyImport(code, statement)) continue;
|
|
320
|
+
const source = statement.moduleRequest;
|
|
321
|
+
if (hasImportAttributes(code, source.end, statement.end)) continue;
|
|
322
|
+
if (!isStylesheetSpecifier(source.value)) continue;
|
|
319
323
|
output ??= new MagicString(code);
|
|
320
|
-
output.overwrite(
|
|
324
|
+
output.overwrite(source.start, source.end, JSON.stringify(source.value + GLOBAL_NOT_FOUND_CSS_QUERY));
|
|
321
325
|
}
|
|
322
326
|
return output ? toMagicStringTransformResult(output) : null;
|
|
323
327
|
}
|
|
@@ -330,8 +334,46 @@ function commonjsTransformFilter(id, transformProjectLocalCommonJs = false, tran
|
|
|
330
334
|
if (transformBundledDependencies && isBundledCommonJsDependency(cleanId)) return true;
|
|
331
335
|
if (/\.c[jt]s$/i.test(cleanId) && !cleanId.includes("node_modules")) return transformProjectLocalCommonJs;
|
|
332
336
|
}
|
|
333
|
-
|
|
334
|
-
|
|
337
|
+
const EMPTY_EXPORT_PRESCAN = new RegExp(String.raw`\bexport${TRIVIA_PATTERN}*\{${TRIVIA_PATTERN}*\}`);
|
|
338
|
+
/**
|
|
339
|
+
* Sources of a module's static imports and re-exports, in source order.
|
|
340
|
+
* Type-only declarations and declarations with import attributes are skipped.
|
|
341
|
+
*/
|
|
342
|
+
function runtimeStaticDependencySpecifiers(code, record, lang) {
|
|
343
|
+
const dependencies = [];
|
|
344
|
+
for (const statement of record.staticImports) {
|
|
345
|
+
if (isTypeOnlyImport(code, statement)) continue;
|
|
346
|
+
if (hasImportAttributes(code, statement.moduleRequest.end, statement.end)) continue;
|
|
347
|
+
dependencies.push({
|
|
348
|
+
start: statement.start,
|
|
349
|
+
specifier: statement.moduleRequest.value
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
for (const statement of record.staticExports) {
|
|
353
|
+
const source = statement.entries[0]?.moduleRequest;
|
|
354
|
+
if (!source || statement.entries.every((entry) => entry.isType)) continue;
|
|
355
|
+
if (hasImportAttributes(code, source.end, statement.end)) continue;
|
|
356
|
+
dependencies.push({
|
|
357
|
+
start: statement.start,
|
|
358
|
+
specifier: source.value
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
if (EMPTY_EXPORT_PRESCAN.test(code)) {
|
|
362
|
+
let program = null;
|
|
363
|
+
try {
|
|
364
|
+
program = parseProgram(code, { lang });
|
|
365
|
+
} catch {}
|
|
366
|
+
for (const statement of program?.body ?? []) {
|
|
367
|
+
if (statement.type !== "ExportNamedDeclaration" || !statement.source) continue;
|
|
368
|
+
if (statement.specifiers.length > 0 || statement.exportKind === "type") continue;
|
|
369
|
+
if (statement.attributes.length > 0) continue;
|
|
370
|
+
dependencies.push({
|
|
371
|
+
start: statement.start,
|
|
372
|
+
specifier: statement.source.value
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return dependencies.sort((a, b) => a.start - b.start).map(({ specifier }) => specifier);
|
|
335
377
|
}
|
|
336
378
|
function resolvedStylesheetToDevManifestAsset(root, resolvedId) {
|
|
337
379
|
const cleanId = stripViteModuleQuery(resolvedId);
|
|
@@ -358,28 +400,35 @@ async function collectDevPagesAppStylesheetAssets(appFilePath, getModuleDependen
|
|
|
358
400
|
await visitModule(appFilePath);
|
|
359
401
|
return stylesheetAssets;
|
|
360
402
|
}
|
|
361
|
-
function createDevPagesModuleDependencyReader(root, resolve) {
|
|
362
|
-
return createModuleDependencyCache(collectModuleDependencies);
|
|
403
|
+
function createDevPagesModuleDependencyReader(root, resolve, store) {
|
|
404
|
+
return createModuleDependencyCache((modulePath) => store.read(modulePath, collectModuleDependencies));
|
|
363
405
|
async function collectModuleDependencies(modulePath) {
|
|
406
|
+
const dependencies = [];
|
|
407
|
+
const entry = {
|
|
408
|
+
dependencies,
|
|
409
|
+
resolvedFiles: [],
|
|
410
|
+
cacheable: true
|
|
411
|
+
};
|
|
364
412
|
const cleanModulePath = stripViteModuleQuery(modulePath);
|
|
365
|
-
if (!path.isAbsolute(cleanModulePath) || !fs.existsSync(cleanModulePath)) return
|
|
366
|
-
let
|
|
413
|
+
if (!path.isAbsolute(cleanModulePath) || !fs.existsSync(cleanModulePath)) return entry;
|
|
414
|
+
let code;
|
|
367
415
|
try {
|
|
368
|
-
|
|
416
|
+
code = fs.readFileSync(cleanModulePath, "utf-8");
|
|
369
417
|
} catch {
|
|
370
|
-
return
|
|
418
|
+
return {
|
|
419
|
+
...entry,
|
|
420
|
+
cacheable: false
|
|
421
|
+
};
|
|
371
422
|
}
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
if (
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const resolved = await resolve(specifier, cleanModulePath, { skipSelf: true });
|
|
382
|
-
if (!resolved?.id) continue;
|
|
423
|
+
const record = parseModuleRecord(code, parserLanguageForScript(cleanModulePath));
|
|
424
|
+
if (!record) return entry;
|
|
425
|
+
for (const specifier of runtimeStaticDependencySpecifiers(code, record, parserLanguageForScript(cleanModulePath))) {
|
|
426
|
+
const resolved = await resolve(specifier, cleanModulePath, { skipSelf: false });
|
|
427
|
+
if (!resolved?.id) {
|
|
428
|
+
entry.cacheable = false;
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
entry.resolvedFiles.push(stripViteModuleQuery(resolved.id));
|
|
383
432
|
if (isStylesheetSpecifier(specifier) || isStylesheetSpecifier(resolved.id)) {
|
|
384
433
|
const asset = resolvedStylesheetToDevManifestAsset(root, resolved.id);
|
|
385
434
|
if (asset) dependencies.push({
|
|
@@ -391,7 +440,7 @@ function createDevPagesModuleDependencyReader(root, resolve) {
|
|
|
391
440
|
id: resolved.id
|
|
392
441
|
});
|
|
393
442
|
}
|
|
394
|
-
return
|
|
443
|
+
return entry;
|
|
395
444
|
}
|
|
396
445
|
}
|
|
397
446
|
const TSCONFIG_FILES = ["tsconfig.json", "jsconfig.json"];
|
|
@@ -721,6 +770,11 @@ const VIRTUAL_CACHEABILITY_REQUEST_PROJECTION = "virtual:vinext-cacheability-req
|
|
|
721
770
|
const RESOLVED_CACHEABILITY_REQUEST_PROJECTION = "\0" + VIRTUAL_CACHEABILITY_REQUEST_PROJECTION;
|
|
722
771
|
const VIRTUAL_PREGENERATED_CONCRETE_PATHS = "virtual:vinext-pregenerated-concrete-paths";
|
|
723
772
|
const RESOLVED_PREGENERATED_CONCRETE_PATHS = "\0" + VIRTUAL_PREGENERATED_CONCRETE_PATHS;
|
|
773
|
+
const OUTPUT_ROOT_SERVER_EXTERNALS = /* @__PURE__ */ new Map([
|
|
774
|
+
[VIRTUAL_CACHEABILITY_MANIFEST, CACHEABILITY_MANIFEST_MODULE],
|
|
775
|
+
[VIRTUAL_CACHEABILITY_REQUEST_PROJECTION, CACHEABILITY_REQUEST_PROJECTION_MODULE],
|
|
776
|
+
[VIRTUAL_PREGENERATED_CONCRETE_PATHS, PREGENERATED_CONCRETE_PATHS_MODULE]
|
|
777
|
+
]);
|
|
724
778
|
const VIRTUAL_APP_REQUEST_ENTRY = "virtual:vinext-app-request-entry";
|
|
725
779
|
const RESOLVED_APP_REQUEST_ENTRY = "\0" + VIRTUAL_APP_REQUEST_ENTRY;
|
|
726
780
|
const VIRTUAL_APP_RESPONSE_ENTRY = "virtual:vinext-app-response-entry";
|
|
@@ -729,13 +783,18 @@ const VIRTUAL_APP_SSR_ENTRY = "virtual:vinext-app-ssr-entry";
|
|
|
729
783
|
const RESOLVED_APP_SSR_ENTRY = "\0" + VIRTUAL_APP_SSR_ENTRY;
|
|
730
784
|
const VIRTUAL_APP_BROWSER_ENTRY = "virtual:vinext-app-browser-entry";
|
|
731
785
|
const RESOLVED_APP_BROWSER_ENTRY = "\0" + VIRTUAL_APP_BROWSER_ENTRY;
|
|
786
|
+
const VIRTUAL_APP_ROUTE_MANIFEST = "virtual:vinext-app-route-manifest";
|
|
787
|
+
const RESOLVED_APP_ROUTE_MANIFEST = "\0" + VIRTUAL_APP_ROUTE_MANIFEST;
|
|
732
788
|
const VIRTUAL_APP_CAPABILITIES = "virtual:vinext-app-capabilities";
|
|
733
789
|
const RESOLVED_APP_CAPABILITIES = "\0" + VIRTUAL_APP_CAPABILITIES;
|
|
734
790
|
const RESOLVED_ROOT_PARAMS = "\0virtual:vinext-root-params";
|
|
791
|
+
const RESOLVED_NEXT_IMAGE_RSC = "\0virtual:vinext-next-image-rsc";
|
|
735
792
|
const APP_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("app-request-stage-independent-entry");
|
|
736
793
|
const APP_RESPONSE_STAGE_ENTRY = resolveRuntimeEntryModule("app-response-stage-entry");
|
|
737
794
|
const PAGES_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("pages-request-stage-entry");
|
|
738
795
|
const PAGES_RESPONSE_STAGE_ENTRY = resolveRuntimeEntryModule("pages-response-stage-entry");
|
|
796
|
+
const NITRO_PUBLIC_FILES_ENTRY = resolveRuntimeEntryModule("nitro-public-files");
|
|
797
|
+
const NITRO_PUBLIC_FILES_PLUGIN = resolveRuntimeEntryModule("nitro-public-files-plugin");
|
|
739
798
|
const WORKER_ROUTER_ENTRIES = /* @__PURE__ */ new Set([resolveRuntimeEntryModule("app-router-entry"), resolveRuntimeEntryModule("pages-router-entry")]);
|
|
740
799
|
/** Virtual module that registers config-driven cache adapters (see VinextOptions.cache). */
|
|
741
800
|
const RESOLVED_CACHE_ADAPTERS = "\0" + VIRTUAL_CACHE_ADAPTERS;
|
|
@@ -850,13 +909,8 @@ const clientManualChunks = createClientManualChunks(_shimsDir);
|
|
|
850
909
|
const clientCodeSplittingConfig = createClientCodeSplittingConfig(clientManualChunks);
|
|
851
910
|
const appClientManualChunks = createClientManualChunks(_shimsDir, true);
|
|
852
911
|
const appClientCodeSplittingConfig = createClientCodeSplittingConfig(appClientManualChunks);
|
|
853
|
-
function getClientOutputConfig(
|
|
854
|
-
|
|
855
|
-
return {
|
|
856
|
-
...createClientFileNameConfig(assetsDir),
|
|
857
|
-
assetFileNames: createClientAssetFileNames(assetsDir),
|
|
858
|
-
codeSplitting
|
|
859
|
-
};
|
|
912
|
+
function getClientOutputConfig(preserveAppRouteBoundaries = false) {
|
|
913
|
+
return { codeSplitting: preserveAppRouteBoundaries ? appClientCodeSplittingConfig : clientCodeSplittingConfig };
|
|
860
914
|
}
|
|
861
915
|
function createServerEnvironmentFileNameResolver(config, outputRoot) {
|
|
862
916
|
const resolvedOutputRoot = path.resolve(config.root, outputRoot);
|
|
@@ -895,6 +949,10 @@ function vinext(options = {}) {
|
|
|
895
949
|
let clientInjectModule = null;
|
|
896
950
|
let globalNotFoundCssIsolationPath = null;
|
|
897
951
|
let clientAssetsInlineLimit = 0;
|
|
952
|
+
let clientOutputFileNamesAssetsDir = null;
|
|
953
|
+
let plainPagesSsrFileNamesAssetsDir = null;
|
|
954
|
+
let topLevelFileNames = {};
|
|
955
|
+
let environmentFileNames = {};
|
|
898
956
|
let hasCloudflarePlugin = false;
|
|
899
957
|
let matchedMultiStageOutput;
|
|
900
958
|
let selectedMultiStageOutput;
|
|
@@ -902,6 +960,8 @@ function vinext(options = {}) {
|
|
|
902
960
|
let warnedInlineNextConfigOverride = false;
|
|
903
961
|
let hasNitroPlugin = false;
|
|
904
962
|
let nitroHostRuntime = "node";
|
|
963
|
+
let nitroPublicFiles = false;
|
|
964
|
+
let nitroPublicDir = "public";
|
|
905
965
|
let resolvedServerExternalPackages = [];
|
|
906
966
|
let registerNodeOpenTelemetryLoader = false;
|
|
907
967
|
let pagesTsconfigAliases = {};
|
|
@@ -912,7 +972,7 @@ function vinext(options = {}) {
|
|
|
912
972
|
let hasPlainPagesBuildEnvironments = false;
|
|
913
973
|
let originalPlainPagesEnvironments;
|
|
914
974
|
let buildLifecycleInvocation;
|
|
915
|
-
let
|
|
975
|
+
let reactVersionChecked = false;
|
|
916
976
|
let pagesOptimizeEntries = [];
|
|
917
977
|
const importMetaUrlCapability = createImportMetaUrlPlugin({
|
|
918
978
|
getRoot: () => root,
|
|
@@ -922,6 +982,8 @@ function vinext(options = {}) {
|
|
|
922
982
|
}
|
|
923
983
|
});
|
|
924
984
|
const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
|
|
985
|
+
const pagesClientAssetsExternalTargets = /* @__PURE__ */ new Map();
|
|
986
|
+
const devPagesModuleDependencyStores = /* @__PURE__ */ new Map();
|
|
925
987
|
const resolvePagesClientAssetsOutputDir = (environmentName, outputDir) => !selectedMultiStageOutput && !hasAppDir && !hasCloudflarePlugin && environmentName === "ssr" ? path.dirname(outputDir) : outputDir;
|
|
926
988
|
let pagesClientAssetsModule = internalOptions.__pagesClientAssetsModule ?? null;
|
|
927
989
|
let clientBuildFiles = [];
|
|
@@ -939,6 +1001,9 @@ function vinext(options = {}) {
|
|
|
939
1001
|
const rscClassificationManifests = /* @__PURE__ */ new Map();
|
|
940
1002
|
let rscActionOwnerRoutes = null;
|
|
941
1003
|
let rscActionOwnerSharedRoots = [];
|
|
1004
|
+
let clientReferenceRoutes = null;
|
|
1005
|
+
let clientReferenceAlwaysRenderedFiles = [];
|
|
1006
|
+
let clientReferenceRoutelessFiles = [];
|
|
942
1007
|
const serverEntryKindsByEnvironment = /* @__PURE__ */ new Map();
|
|
943
1008
|
const serverRuntimeOutputDirs = /* @__PURE__ */ new Set();
|
|
944
1009
|
function recordServerEntryLoad(environmentName, id) {
|
|
@@ -951,6 +1016,8 @@ function vinext(options = {}) {
|
|
|
951
1016
|
entries.add(id);
|
|
952
1017
|
}
|
|
953
1018
|
const shimsDir = path.resolve(__dirname, "shims");
|
|
1019
|
+
const nextImageAliasTarget = toSlash(path.join(shimsDir, "image"));
|
|
1020
|
+
const nextImageAliasTargetRE = new RegExp(`^${nextImageAliasTarget.split("/").map(escapeRegExp).join("[\\\\/]")}$`);
|
|
954
1021
|
const canonicalize = (p) => toSlash(tryRealpathSync(p) ?? p);
|
|
955
1022
|
const pageTransformCanonicalPaths = /* @__PURE__ */ new Map();
|
|
956
1023
|
const canonicalizePageTransformPath = (modulePath) => {
|
|
@@ -998,9 +1065,10 @@ function vinext(options = {}) {
|
|
|
998
1065
|
* __NEXT_DATA__ to determine which page to hydrate.
|
|
999
1066
|
*/
|
|
1000
1067
|
async function generateClientEntry$1() {
|
|
1001
|
-
const
|
|
1068
|
+
const appRoutes = hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : [];
|
|
1002
1069
|
return generateClientEntry(pagesDir, nextConfig, fileMatcher, {
|
|
1003
|
-
appPrefetchRoutes,
|
|
1070
|
+
appPrefetchRoutes: toLinkPrefetchRoutes(appRoutes),
|
|
1071
|
+
appRouteHandlers: toHashedRouteHandlerRoutes(appRoutes),
|
|
1004
1072
|
instrumentationClientPath,
|
|
1005
1073
|
middlewareMatcher: middlewarePath ? extractMiddlewareMatcherConfig(middlewarePath) : void 0,
|
|
1006
1074
|
reactPreamble: options.react !== false
|
|
@@ -1017,32 +1085,33 @@ function vinext(options = {}) {
|
|
|
1017
1085
|
const earlyRoot = earlyViteCliInvocation?.root ?? process.cwd();
|
|
1018
1086
|
const earlyBaseDir = path.resolve(earlyRoot, options.appDir ?? ".");
|
|
1019
1087
|
const earlyAppDirExists = !options.disableAppRouter && (fs.existsSync(path.join(earlyBaseDir, "app")) || fs.existsSync(path.join(earlyBaseDir, "src", "app")));
|
|
1020
|
-
let resolvedReactPath = null;
|
|
1021
1088
|
let resolvedRscPath = null;
|
|
1022
1089
|
let rscPluginModulePromise = null;
|
|
1023
|
-
resolvedReactPath = resolveOptionalDependency(earlyBaseDir, "@vitejs/plugin-react");
|
|
1024
1090
|
resolvedRscPath = resolveOptionalDependency(earlyBaseDir, "@vitejs/plugin-rsc");
|
|
1025
1091
|
const rscVersion = earlyAppDirExists && resolvedRscPath ? assertPluginRscVersion(resolvedRscPath) : null;
|
|
1026
1092
|
let rscPluginPromise = null;
|
|
1027
1093
|
let manualUseCachePluginPromise = null;
|
|
1094
|
+
const rscPluginOptions = { entries: {
|
|
1095
|
+
rsc: VIRTUAL_RSC_ENTRY,
|
|
1096
|
+
ssr: VIRTUAL_APP_SSR_ENTRY,
|
|
1097
|
+
client: VIRTUAL_APP_BROWSER_ENTRY
|
|
1098
|
+
} };
|
|
1099
|
+
let serverActionsEncryptionKey;
|
|
1028
1100
|
if (earlyAppDirExists && autoRsc) {
|
|
1029
1101
|
if (!resolvedRscPath) throw new Error("vinext: App Router detected but @vitejs/plugin-rsc is not installed.\nRun: " + detectPackageManager(process.cwd()) + " @vitejs/plugin-rsc");
|
|
1030
1102
|
const rscImport = import(pathToFileURL(resolvedRscPath).href);
|
|
1031
1103
|
rscPluginModulePromise = rscImport;
|
|
1032
1104
|
rscPluginPromise = rscImport.then(async (mod) => {
|
|
1033
1105
|
const rsc = mod.default;
|
|
1034
|
-
const plugins = rsc(
|
|
1035
|
-
rsc: VIRTUAL_RSC_ENTRY,
|
|
1036
|
-
ssr: VIRTUAL_APP_SSR_ENTRY,
|
|
1037
|
-
client: VIRTUAL_APP_BROWSER_ENTRY
|
|
1038
|
-
} });
|
|
1106
|
+
const plugins = rsc(rscPluginOptions);
|
|
1039
1107
|
const useCachePlugin = await createUseCacheCallablePlugin({
|
|
1040
1108
|
projectRoot: earlyBaseDir,
|
|
1041
|
-
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href
|
|
1109
|
+
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href,
|
|
1110
|
+
getEncryptionKey: () => serverActionsEncryptionKey
|
|
1042
1111
|
});
|
|
1043
1112
|
const useServerIndex = plugins.findIndex((plugin) => plugin.name === "rsc:use-server");
|
|
1044
1113
|
if (useServerIndex === -1) throw new Error("vinext: Failed to locate @vitejs/plugin-rsc use-server plugin.");
|
|
1045
|
-
plugins.splice(useServerIndex, 0,
|
|
1114
|
+
plugins.splice(useServerIndex, 0, useCachePlugin);
|
|
1046
1115
|
return plugins.map(scopeRscPlugin);
|
|
1047
1116
|
}).catch((cause) => {
|
|
1048
1117
|
throw new Error("vinext: Failed to load @vitejs/plugin-rsc.", { cause });
|
|
@@ -1067,6 +1136,7 @@ function vinext(options = {}) {
|
|
|
1067
1136
|
let reactPluginPromise = null;
|
|
1068
1137
|
let reactCompilerPluginPromise = null;
|
|
1069
1138
|
if (options.react !== false) {
|
|
1139
|
+
const resolvedReactPath = resolvePluginReactPath(earlyBaseDir);
|
|
1070
1140
|
if (!resolvedReactPath) throw new Error("vinext: @vitejs/plugin-react is not installed.\nRun: " + detectPackageManager(process.cwd()) + " @vitejs/plugin-react");
|
|
1071
1141
|
const allReactPlugins = import(pathToFileURL(resolvedReactPath).href).catch((cause) => {
|
|
1072
1142
|
throw new Error("vinext: Failed to load @vitejs/plugin-react.", { cause });
|
|
@@ -1214,17 +1284,13 @@ function vinext(options = {}) {
|
|
|
1214
1284
|
shouldDeferPostBuild: () => buildLifecycleInvocation !== void 0,
|
|
1215
1285
|
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),
|
|
1216
1286
|
onPrepare: () => {
|
|
1217
|
-
if (!hasAppDir ||
|
|
1218
|
-
|
|
1287
|
+
if (!hasAppDir || reactVersionChecked) return;
|
|
1288
|
+
reactVersionChecked = true;
|
|
1219
1289
|
const reactUpgrade = getReactUpgradeDeps(root);
|
|
1290
|
+
const needsAppRsdw = rscVersion !== null && needsAppReactServerDom(process.cwd(), rscVersion);
|
|
1291
|
+
if (needsAppRsdw && !reactUpgrade.includes("react-server-dom-webpack@latest")) reactUpgrade.push("react-server-dom-webpack@latest");
|
|
1220
1292
|
if (reactUpgrade.length === 0) return;
|
|
1221
|
-
|
|
1222
|
-
console.log(" Upgrading React for RSC compatibility...");
|
|
1223
|
-
execFileSync(packageManager, [...packageManagerArgs, ...reactUpgrade], {
|
|
1224
|
-
cwd: root,
|
|
1225
|
-
stdio: "inherit",
|
|
1226
|
-
shell: process.platform === "win32"
|
|
1227
|
-
});
|
|
1293
|
+
throw new Error(reactUpgradeRequiredMessage(detectPackageManager(root).replace(/ -D$/, ""), reactUpgrade, needsAppRsdw ? rscVersion : void 0));
|
|
1228
1294
|
},
|
|
1229
1295
|
shouldBuildPlainPages: () => !hasAppDir && !hasCloudflarePlugin && !hasNitroPlugin,
|
|
1230
1296
|
createContext: () => ({
|
|
@@ -1348,6 +1414,7 @@ function vinext(options = {}) {
|
|
|
1348
1414
|
originalPlainPagesEnvironments = void 0;
|
|
1349
1415
|
buildEmptyOutDir = typeof config.build?.emptyOutDir === "boolean" ? config.build.emptyOutDir : void 0;
|
|
1350
1416
|
isServeCommand = env.command === "serve";
|
|
1417
|
+
const ipaddrSsrExternal = env.command === "serve" ? ["ipaddr.js"] : [];
|
|
1351
1418
|
root = path.resolve(toSlash(process.cwd()), config.root ?? ".");
|
|
1352
1419
|
if (env.command === "build") assertClientOutDirIsSeparate(root, options);
|
|
1353
1420
|
const devCliLifecycleEnabled = env.command === "serve" && env.isPreview !== true && claimViteCliDevInvocation(root, config["__vinextDevRestart"] === true, reservedDevCliInvocation && config.configFile === false);
|
|
@@ -1358,13 +1425,15 @@ function vinext(options = {}) {
|
|
|
1358
1425
|
let sassTsconfigPathAliases = [];
|
|
1359
1426
|
const swcHelpersAlias = resolveSwcHelpersAlias(root);
|
|
1360
1427
|
const mode = env?.mode ?? "development";
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
mode
|
|
1366
|
-
});
|
|
1428
|
+
const envDir = config.envDir === false ? void 0 : config.envDir ? path.resolve(root, config.envDir) : root;
|
|
1429
|
+
if (earlyDotenv && envDir !== earlyDotenv.dir) {
|
|
1430
|
+
for (const [key, value] of Object.entries(earlyDotenv.env)) if (process.env[key] === value) Reflect.deleteProperty(process.env, key);
|
|
1431
|
+
earlyDotenv = void 0;
|
|
1367
1432
|
}
|
|
1433
|
+
if (envDir) loadDotenv({
|
|
1434
|
+
root: envDir,
|
|
1435
|
+
mode
|
|
1436
|
+
});
|
|
1368
1437
|
let resolvedNodeEnv;
|
|
1369
1438
|
if (env?.command === "build" || env?.isPreview === true) resolvedNodeEnv = "production";
|
|
1370
1439
|
else if (mode === "test") resolvedNodeEnv = "test";
|
|
@@ -1413,6 +1482,13 @@ function vinext(options = {}) {
|
|
|
1413
1482
|
buildId: sharedBuildId
|
|
1414
1483
|
};
|
|
1415
1484
|
}
|
|
1485
|
+
if (rscPluginPromise) {
|
|
1486
|
+
serverActionsEncryptionKey = loadOrGenerateServerActionsEncryptionKey({
|
|
1487
|
+
root,
|
|
1488
|
+
isBuild: env.command === "build"
|
|
1489
|
+
});
|
|
1490
|
+
rscPluginOptions.defineEncryptionKey = `process.env.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY || ${JSON.stringify(serverActionsEncryptionKey)}`;
|
|
1491
|
+
}
|
|
1416
1492
|
if (env?.command === "build" && earlyViteCliInvocation?.command === "build") Reflect.set(process.env, "NODE_ENV", "production");
|
|
1417
1493
|
const configuredTsconfigPath = isUnknownRecord(nextConfig.typescript) ? typeof nextConfig.typescript.tsconfigPath === "string" ? nextConfig.typescript.tsconfigPath : void 0 : void 0;
|
|
1418
1494
|
const resolvedTsconfigAliases = resolveTsconfigAliases(root, configuredTsconfigPath);
|
|
@@ -1490,9 +1566,9 @@ function vinext(options = {}) {
|
|
|
1490
1566
|
defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_SVG"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowSVG ?? false));
|
|
1491
1567
|
defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_LOCAL_IP"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowLocalIP ?? false));
|
|
1492
1568
|
defines["process.env.__VINEXT_IMAGE_UNOPTIMIZED"] = JSON.stringify(String(nextConfig.images?.unoptimized === true));
|
|
1493
|
-
defines["process.env.__VINEXT_BUILD_ID"] =
|
|
1494
|
-
defines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify(
|
|
1495
|
-
defines["process.env.__VINEXT_RSC_BUILD_IDENTITY"] = JSON.stringify(
|
|
1569
|
+
defines["process.env.__VINEXT_BUILD_ID"] = "undefined";
|
|
1570
|
+
defines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify("");
|
|
1571
|
+
defines["process.env.__VINEXT_RSC_BUILD_IDENTITY"] = JSON.stringify("");
|
|
1496
1572
|
defines["process.env.__VINEXT_DEPLOYMENT_ID"] = JSON.stringify(nextConfig.deploymentId ?? "");
|
|
1497
1573
|
defines["process.env.NEXT_DEPLOYMENT_ID"] = nextConfig.deploymentId ? JSON.stringify(nextConfig.deploymentId) : "false";
|
|
1498
1574
|
defines["process.env.NEXT_RUNTIME"] = "\"\"";
|
|
@@ -1578,6 +1654,10 @@ function vinext(options = {}) {
|
|
|
1578
1654
|
const hasClientBuildEnvironment = hasAppDir || hasCloudflarePlugin || hasNitroPlugin || shouldInjectPlainPagesEnvironments;
|
|
1579
1655
|
const clientAssetsDir = resolveAssetsDir(nextConfig.assetPrefix ?? "");
|
|
1580
1656
|
clientAssetsInlineLimit = config.build?.assetsInlineLimit ?? 0;
|
|
1657
|
+
clientOutputFileNamesAssetsDir = !isSSR && !isMultiEnv || hasAppDir || hasCloudflarePlugin || shouldInjectPlainPagesEnvironments ? clientAssetsDir : null;
|
|
1658
|
+
plainPagesSsrFileNamesAssetsDir = !isMultiEnv && shouldInjectPlainPagesEnvironments ? clientAssetsDir : null;
|
|
1659
|
+
topLevelFileNames = getOutputFileNames(getBuildBundlerOptions(config.build)?.output);
|
|
1660
|
+
environmentFileNames = Object.fromEntries(Object.entries(config.environments ?? {}).map(([environmentName, environment]) => [environmentName, getOutputFileNames(getBuildBundlerOptions(environment?.build)?.output)]));
|
|
1581
1661
|
const devHmrConfig = config.server?.hmr === false ? false : {
|
|
1582
1662
|
...typeof config.server?.hmr === "object" ? config.server.hmr : {},
|
|
1583
1663
|
overlay: false
|
|
@@ -1622,7 +1702,7 @@ function vinext(options = {}) {
|
|
|
1622
1702
|
};
|
|
1623
1703
|
})(),
|
|
1624
1704
|
...!isSSR && !isMultiEnv ? { treeshake: getClientTreeshakeConfig() } : {},
|
|
1625
|
-
...!isSSR && !isMultiEnv ? { output: getClientOutputConfig(
|
|
1705
|
+
...!isSSR && !isMultiEnv ? { output: getClientOutputConfig() } : {}
|
|
1626
1706
|
})
|
|
1627
1707
|
},
|
|
1628
1708
|
worker: { plugins: () => [
|
|
@@ -1652,7 +1732,7 @@ function vinext(options = {}) {
|
|
|
1652
1732
|
"react",
|
|
1653
1733
|
"react-dom",
|
|
1654
1734
|
"react-dom/server",
|
|
1655
|
-
|
|
1735
|
+
...ipaddrSsrExternal,
|
|
1656
1736
|
...Array.isArray(config.ssr?.external) ? config.ssr.external : [],
|
|
1657
1737
|
...nextServerExternal
|
|
1658
1738
|
],
|
|
@@ -1837,7 +1917,7 @@ function vinext(options = {}) {
|
|
|
1837
1917
|
...hasCloudflarePlugin || hasNitroPlugin ? {} : { resolve: {
|
|
1838
1918
|
external: userSsrExternal === true ? true : [
|
|
1839
1919
|
...userSsrExternal,
|
|
1840
|
-
|
|
1920
|
+
...ipaddrSsrExternal,
|
|
1841
1921
|
...externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []
|
|
1842
1922
|
],
|
|
1843
1923
|
noExternal: userSsrExternal === true ? [...PATCHED_SERVER_PACKAGES] : true
|
|
@@ -1875,7 +1955,7 @@ function vinext(options = {}) {
|
|
|
1875
1955
|
assetsInlineLimit: clientAssetsInlineLimit,
|
|
1876
1956
|
...withBuildBundlerOptions({
|
|
1877
1957
|
input: appClientInput,
|
|
1878
|
-
output: getClientOutputConfig(
|
|
1958
|
+
output: getClientOutputConfig(true),
|
|
1879
1959
|
treeshake: getClientTreeshakeConfig()
|
|
1880
1960
|
})
|
|
1881
1961
|
}
|
|
@@ -1895,7 +1975,7 @@ function vinext(options = {}) {
|
|
|
1895
1975
|
assetsInlineLimit: clientAssetsInlineLimit,
|
|
1896
1976
|
...withBuildBundlerOptions({
|
|
1897
1977
|
input: { index: VIRTUAL_CLIENT_ENTRY },
|
|
1898
|
-
output: getClientOutputConfig(
|
|
1978
|
+
output: getClientOutputConfig(),
|
|
1899
1979
|
treeshake: getClientTreeshakeConfig()
|
|
1900
1980
|
})
|
|
1901
1981
|
}
|
|
@@ -1916,7 +1996,7 @@ function vinext(options = {}) {
|
|
|
1916
1996
|
assetsInlineLimit: clientAssetsInlineLimit,
|
|
1917
1997
|
...withBuildBundlerOptions({
|
|
1918
1998
|
input: { index: VIRTUAL_CLIENT_ENTRY },
|
|
1919
|
-
output: getClientOutputConfig(
|
|
1999
|
+
output: getClientOutputConfig(),
|
|
1920
2000
|
treeshake: getClientTreeshakeConfig()
|
|
1921
2001
|
})
|
|
1922
2002
|
}
|
|
@@ -1927,7 +2007,7 @@ function vinext(options = {}) {
|
|
|
1927
2007
|
"react",
|
|
1928
2008
|
"react-dom",
|
|
1929
2009
|
"react-dom/server",
|
|
1930
|
-
|
|
2010
|
+
...ipaddrSsrExternal,
|
|
1931
2011
|
...nextServerExternal
|
|
1932
2012
|
],
|
|
1933
2013
|
noExternal: true
|
|
@@ -1990,9 +2070,10 @@ function vinext(options = {}) {
|
|
|
1990
2070
|
const optionalWarnings = /* @__PURE__ */ new Set();
|
|
1991
2071
|
for (const [name, environment] of Object.entries(config.environments)) {
|
|
1992
2072
|
const optimizer = environment.optimizeDeps;
|
|
1993
|
-
const optionalIncludes = hasAppDir ? name === "client" && !optimizer.noDiscovery ? APP_CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE : [] : name !== "client" ?
|
|
2073
|
+
const optionalIncludes = hasAppDir ? name === "client" && !optimizer.noDiscovery ? APP_CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE : [] : name !== "client" ? PAGES_CLOUDFLARE_WORKER_OPTIONAL_OPTIMIZE_DEPS_INCLUDE : [];
|
|
1994
2074
|
for (const id of optionalIncludes) {
|
|
1995
|
-
|
|
2075
|
+
const depId = id.slice(id.lastIndexOf(">") + 1).trim();
|
|
2076
|
+
if (optimizer.include?.includes(id) || optimizer.include?.includes(depId) || optimizer.exclude?.some((excluded) => depId === excluded || depId.startsWith(`${excluded}/`))) continue;
|
|
1996
2077
|
(optimizer.include ??= []).push(id);
|
|
1997
2078
|
optionalWarnings.add(`Failed to resolve dependency: ${id}, present in ${name} 'optimizeDeps.include'`);
|
|
1998
2079
|
}
|
|
@@ -2000,16 +2081,14 @@ function vinext(options = {}) {
|
|
|
2000
2081
|
Object.assign(config, { logger: createOptionalOptimizeDepsLogger(config.logger, optionalWarnings) });
|
|
2001
2082
|
}
|
|
2002
2083
|
if (config.worker?.rolldownOptions) {
|
|
2003
|
-
const workerFileNames =
|
|
2084
|
+
const workerFileNames = createWorkerFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? ""), config.root);
|
|
2004
2085
|
const workerOutputs = config.worker.rolldownOptions.output;
|
|
2005
2086
|
config.worker.rolldownOptions.output = Array.isArray(workerOutputs) ? (workerOutputs.length > 0 ? workerOutputs : [{}]).map((output) => ({
|
|
2006
2087
|
...output,
|
|
2007
|
-
|
|
2008
|
-
chunkFileNames: workerFileNames
|
|
2088
|
+
...workerFileNames
|
|
2009
2089
|
})) : {
|
|
2010
2090
|
...workerOutputs,
|
|
2011
|
-
|
|
2012
|
-
chunkFileNames: workerFileNames
|
|
2091
|
+
...workerFileNames
|
|
2013
2092
|
};
|
|
2014
2093
|
}
|
|
2015
2094
|
sassComposesLoader.setResolvedConfig(config);
|
|
@@ -2083,8 +2162,9 @@ function vinext(options = {}) {
|
|
|
2083
2162
|
}
|
|
2084
2163
|
},
|
|
2085
2164
|
resolveId: {
|
|
2086
|
-
filter: { id: /(?:next\/|vinext\/(?:shims\/|server\/(?:app-rsc-(?:combined-)?handler|app-router-entry|pages-router-entry))|virtual:vinext-|@vercel\/og(?:\.js)?$)
|
|
2165
|
+
filter: { id: new RegExp(`${/(?:next\/|vinext\/(?:shims\/|server\/(?:app-rsc-(?:combined-)?handler|app-router-entry|pages-router-entry))|virtual:vinext-|@vercel\/og(?:\.js)?$)/.source}|${nextImageAliasTargetRE.source}`) },
|
|
2087
2166
|
handler(id, importer) {
|
|
2167
|
+
if (nextImageAliasTargetRE.test(id)) return this.environment?.name === "rsc" ? RESOLVED_NEXT_IMAGE_RSC : void 0;
|
|
2088
2168
|
const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
|
|
2089
2169
|
if (cleanId === "vinext/server/app-rsc-combined-handler") {
|
|
2090
2170
|
if (_canExternalizeAppRscHandler && this.environment?.name === "rsc" && this.environment.config?.command === "serve") return {
|
|
@@ -2101,6 +2181,7 @@ function vinext(options = {}) {
|
|
|
2101
2181
|
return _appRscHandlerPath;
|
|
2102
2182
|
}
|
|
2103
2183
|
if (isVercelOgImport(cleanId) && !isVinextOgShimImporter(importer)) return resolveShimModulePath(_shimsDir, "og");
|
|
2184
|
+
if (cleanId === "vinext/shims/image" && this.environment?.name !== "rsc") return this.resolve("next/image", importer, { skipSelf: true });
|
|
2104
2185
|
if (cleanId.startsWith("vinext/shims/")) return resolveShimModulePath(_shimsDir, stripJsExtension(stripViteModuleQuery(cleanId.slice(13))));
|
|
2105
2186
|
if (cleanId === VIRTUAL_WORKER_ENTRY) return RESOLVED_WORKER_ENTRY;
|
|
2106
2187
|
if (selectedMultiStageOutput && (cleanId === "vinext/server/app-router-entry" || cleanId === "vinext/server/pages-router-entry")) return RESOLVED_WORKER_ENTRY;
|
|
@@ -2120,21 +2201,21 @@ function vinext(options = {}) {
|
|
|
2120
2201
|
if (cleanId === VIRTUAL_RSC_ENTRY) return RESOLVED_RSC_ENTRY;
|
|
2121
2202
|
if (cleanId === VIRTUAL_CACHEABILITY_MANIFEST) {
|
|
2122
2203
|
if ((hasAppDir ? this.environment?.name === "rsc" : this.environment !== void 0 && isServerEnvironment(this.environment)) && this.environment.config?.command === "build") return {
|
|
2123
|
-
id:
|
|
2204
|
+
id: VIRTUAL_CACHEABILITY_MANIFEST,
|
|
2124
2205
|
external: true
|
|
2125
2206
|
};
|
|
2126
2207
|
return RESOLVED_CACHEABILITY_MANIFEST;
|
|
2127
2208
|
}
|
|
2128
2209
|
if (cleanId === VIRTUAL_CACHEABILITY_REQUEST_PROJECTION) {
|
|
2129
2210
|
if (hasAppDir && this.environment?.name === "rsc" && this.environment.config?.command === "build") return {
|
|
2130
|
-
id:
|
|
2211
|
+
id: VIRTUAL_CACHEABILITY_REQUEST_PROJECTION,
|
|
2131
2212
|
external: true
|
|
2132
2213
|
};
|
|
2133
2214
|
return RESOLVED_CACHEABILITY_REQUEST_PROJECTION;
|
|
2134
2215
|
}
|
|
2135
2216
|
if (cleanId === VIRTUAL_PREGENERATED_CONCRETE_PATHS) {
|
|
2136
2217
|
if ((hasAppDir ? this.environment?.name === "rsc" : this.environment !== void 0 && isServerEnvironment(this.environment)) && this.environment.config?.command === "build") return {
|
|
2137
|
-
id:
|
|
2218
|
+
id: VIRTUAL_PREGENERATED_CONCRETE_PATHS,
|
|
2138
2219
|
external: true
|
|
2139
2220
|
};
|
|
2140
2221
|
return RESOLVED_PREGENERATED_CONCRETE_PATHS;
|
|
@@ -2143,6 +2224,7 @@ function vinext(options = {}) {
|
|
|
2143
2224
|
if (cleanId === VIRTUAL_APP_RESPONSE_ENTRY) return RESOLVED_APP_RESPONSE_ENTRY;
|
|
2144
2225
|
if (cleanId === VIRTUAL_APP_SSR_ENTRY) return RESOLVED_APP_SSR_ENTRY;
|
|
2145
2226
|
if (cleanId === VIRTUAL_APP_BROWSER_ENTRY) return RESOLVED_APP_BROWSER_ENTRY;
|
|
2227
|
+
if (cleanId === VIRTUAL_APP_ROUTE_MANIFEST) return RESOLVED_APP_ROUTE_MANIFEST;
|
|
2146
2228
|
if (cleanId === VIRTUAL_APP_CAPABILITIES) return RESOLVED_APP_CAPABILITIES;
|
|
2147
2229
|
if (cleanId === "next/root-params" || cleanId === "next/root-params.js") return RESOLVED_ROOT_PARAMS;
|
|
2148
2230
|
if (cleanId === "virtual:vinext-cache-adapters" || cleanId.endsWith("/virtual:vinext-cache-adapters")) return RESOLVED_CACHE_ADAPTERS;
|
|
@@ -2176,7 +2258,8 @@ function vinext(options = {}) {
|
|
|
2176
2258
|
].join("\n");
|
|
2177
2259
|
const entry = hasAppDir ? "vinext/server/app-router-entry" : "vinext/server/pages-router-entry";
|
|
2178
2260
|
if (!hasAppDir && hasNitroPlugin) return [
|
|
2179
|
-
`import
|
|
2261
|
+
`import pagesWorker from ${JSON.stringify(entry)};`,
|
|
2262
|
+
...nitroPublicFiles ? [`import { withNitroPagesPublicFiles } from ${JSON.stringify(NITRO_PUBLIC_FILES_ENTRY)};`, "const worker = withNitroPagesPublicFiles(pagesWorker);"] : ["const worker = pagesWorker;"],
|
|
2180
2263
|
"export default { fetch(request, env, ctx) {",
|
|
2181
2264
|
` return worker.fetch(request, env, { ...ctx, hostRuntime: ${JSON.stringify(nitroHostRuntime)} });`,
|
|
2182
2265
|
"} };"
|
|
@@ -2207,7 +2290,12 @@ function vinext(options = {}) {
|
|
|
2207
2290
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
2208
2291
|
const pagesRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
2209
2292
|
const moduleFilePaths = [...appFilePath ? [appFilePath] : [], ...pagesRoutes.map((route) => route.filePath)];
|
|
2210
|
-
|
|
2293
|
+
let dependencyStore = devPagesModuleDependencyStores.get(this.environment.name);
|
|
2294
|
+
if (!dependencyStore) {
|
|
2295
|
+
dependencyStore = new ModuleDependencyStore();
|
|
2296
|
+
devPagesModuleDependencyStores.set(this.environment.name, dependencyStore);
|
|
2297
|
+
}
|
|
2298
|
+
const getModuleDependencies = createDevPagesModuleDependencyReader(root, this.resolve.bind(this), dependencyStore);
|
|
2211
2299
|
for (const moduleFilePath of moduleFilePaths) {
|
|
2212
2300
|
const stylesheetAssets = await collectDevPagesAppStylesheetAssets(moduleFilePath, getModuleDependencies);
|
|
2213
2301
|
if (stylesheetAssets.length > 0) ssrManifest[toSlash(moduleFilePath)] = stylesheetAssets;
|
|
@@ -2228,6 +2316,9 @@ function vinext(options = {}) {
|
|
|
2228
2316
|
rscClassificationManifests.set(id, collectRouteClassificationManifest(routes));
|
|
2229
2317
|
rscActionOwnerRoutes = this.environment.config.command === "build" && hasServerActions ? routes : null;
|
|
2230
2318
|
rscActionOwnerSharedRoots = [globalErrorPath, globalNotFoundPath].filter((path) => path !== null);
|
|
2319
|
+
clientReferenceRoutes = this.environment.config.command === "build" ? routes : null;
|
|
2320
|
+
clientReferenceAlwaysRenderedFiles = [...globalErrorPath ? [globalErrorPath] : [], ...rootBoundaryFiles(routes)];
|
|
2321
|
+
clientReferenceRoutelessFiles = [...rootBoundaryRouteFiles(routes), ...globalNotFoundPath ? [globalNotFoundPath] : []];
|
|
2231
2322
|
}
|
|
2232
2323
|
return (id === RESOLVED_APP_REQUEST_ENTRY ? generateAppRequestRscEntry : id === RESOLVED_APP_RESPONSE_ENTRY ? generateAppResponseRscEntry : generateRscEntry)(appDir, routes, middlewarePath, metaRoutes, globalErrorPath, nextConfig?.basePath, nextConfig?.trailingSlash, {
|
|
2233
2324
|
redirects: nextConfig?.redirects,
|
|
@@ -2242,6 +2333,7 @@ function vinext(options = {}) {
|
|
|
2242
2333
|
nodeOpenTelemetryLoader: registerNodeOpenTelemetryLoader,
|
|
2243
2334
|
assetPrefix: nextConfig?.assetPrefix,
|
|
2244
2335
|
crossOrigin: nextConfig?.crossOrigin,
|
|
2336
|
+
skipProxyUrlNormalize: nextConfig?.skipProxyUrlNormalize,
|
|
2245
2337
|
skipTrailingSlashRedirect: nextConfig?.skipTrailingSlashRedirect,
|
|
2246
2338
|
expireTime: nextConfig?.expireTime,
|
|
2247
2339
|
reactMaxHeadersLength: nextConfig?.reactMaxHeadersLength,
|
|
@@ -2271,27 +2363,31 @@ function vinext(options = {}) {
|
|
|
2271
2363
|
devForwardedMiddlewareContextKey: isServeCommand && this.environment.config.consumer === "server" ? devForwardedMiddlewareContextKey : void 0
|
|
2272
2364
|
}, instrumentationPath);
|
|
2273
2365
|
}
|
|
2366
|
+
if (id === RESOLVED_NEXT_IMAGE_RSC) return [
|
|
2367
|
+
`export { getImageProps, imageOptimizationUrl } from "vinext/shims/image-props";`,
|
|
2368
|
+
`export { default } from "vinext/shims/image";`,
|
|
2369
|
+
""
|
|
2370
|
+
].join("\n");
|
|
2274
2371
|
if (id === RESOLVED_ROOT_PARAMS) return generateRootParamsModule((hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : []).flatMap((route) => route.rootParamNames ?? []));
|
|
2275
2372
|
if (id === RESOLVED_CACHE_ADAPTERS) return generateCacheAdaptersModule(options.cache);
|
|
2276
2373
|
if (id === RESOLVED_CDN_CACHE_ADAPTER) return generateCdnCacheAdapterModule(options.cache);
|
|
2277
2374
|
if (id === RESOLVED_IMAGE_ADAPTERS) return generateImageAdaptersModule(options.images);
|
|
2278
2375
|
if (id === RESOLVED_APP_SSR_ENTRY && hasAppDir) {
|
|
2279
2376
|
recordServerEntryLoad(this.environment?.name, id);
|
|
2280
|
-
return generateSsrEntry(hasPagesDir);
|
|
2377
|
+
return generateSsrEntry(hasPagesDir, nitroPublicFiles ? NITRO_PUBLIC_FILES_ENTRY : null);
|
|
2281
2378
|
}
|
|
2282
2379
|
if (id === RESOLVED_APP_BROWSER_ENTRY && hasAppDir) {
|
|
2283
2380
|
const graph = await appRouteGraph(appDir, nextConfig?.pageExtensions, fileMatcher);
|
|
2284
|
-
const pagesPrefetchRoutes = hasPagesDir ?
|
|
2381
|
+
const pagesPrefetchRoutes = hasPagesDir ? (await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher)).map((route) => ({
|
|
2285
2382
|
canPrefetchLoadingShell: false,
|
|
2286
2383
|
isDynamic: route.isDynamic,
|
|
2287
2384
|
patternParts: [...route.patternParts]
|
|
2288
|
-
}))
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
return generateBrowserEntry(graph.routes, graph.routeManifest, pagesPrefetchRoutes, nextConfig.rewrites, nextConfig.i18n?.locales);
|
|
2385
|
+
})) : [];
|
|
2386
|
+
return generateBrowserEntry(graph.routes, pagesPrefetchRoutes, nextConfig.rewrites, nextConfig.i18n?.locales);
|
|
2387
|
+
}
|
|
2388
|
+
if (id === RESOLVED_APP_ROUTE_MANIFEST && hasAppDir) {
|
|
2389
|
+
const graph = await appRouteGraph(appDir, nextConfig?.pageExtensions, fileMatcher);
|
|
2390
|
+
return generateBrowserRouteManifestModule(graph.routeManifest);
|
|
2295
2391
|
}
|
|
2296
2392
|
if (id === RESOLVED_APP_CAPABILITIES && hasAppDir) {
|
|
2297
2393
|
const hasServerActions = await resolveHasServerActions(this.environment.config);
|
|
@@ -2370,15 +2466,19 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2370
2466
|
const buildRoot = this.environment.config.root ?? process.cwd();
|
|
2371
2467
|
const environmentOutDir = path.resolve(buildRoot, this.environment.config.build.outDir);
|
|
2372
2468
|
const sidecarDir = resolvePagesClientAssetsOutputDir(this.environment.name, environmentOutDir);
|
|
2373
|
-
|
|
2374
|
-
if (!externalId.startsWith(".")) externalId = `./${externalId}`;
|
|
2469
|
+
pagesClientAssetsExternalTargets.set(this.environment.name, /* @__PURE__ */ new Map([[VIRTUAL_PAGES_CLIENT_ASSETS, path.relative(environmentOutDir, path.join(sidecarDir, PAGES_CLIENT_ASSETS_MODULE))]]));
|
|
2375
2470
|
pagesClientAssetsOutputDirs.add(sidecarDir);
|
|
2376
2471
|
return {
|
|
2377
|
-
id:
|
|
2472
|
+
id: VIRTUAL_PAGES_CLIENT_ASSETS,
|
|
2378
2473
|
external: true
|
|
2379
2474
|
};
|
|
2380
2475
|
}
|
|
2381
2476
|
},
|
|
2477
|
+
renderChunk(code, chunk) {
|
|
2478
|
+
const targets = pagesClientAssetsExternalTargets.get(this.environment.name);
|
|
2479
|
+
if (!targets) return null;
|
|
2480
|
+
return rewriteOutputRootExternals(code, chunk.fileName, targets);
|
|
2481
|
+
},
|
|
2382
2482
|
outputOptions(output) {
|
|
2383
2483
|
const environment = this.environment;
|
|
2384
2484
|
if (!selectedMultiStageOutput || !environment || !isMultiStageServerEnvironment(environment)) return;
|
|
@@ -2453,12 +2553,36 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2453
2553
|
name: "vinext:css-url-assets-defaults",
|
|
2454
2554
|
apply: "build",
|
|
2455
2555
|
configEnvironment(name, config) {
|
|
2456
|
-
if (name === "client")
|
|
2457
|
-
|
|
2556
|
+
if (name === "client") {
|
|
2557
|
+
const output = getBuildBundlerOptions(config.build)?.output;
|
|
2558
|
+
const fileNameDefaults = clientOutputFileNamesAssetsDir ? createClientOutputFileNameDefaults(output, clientOutputFileNamesAssetsDir) : null;
|
|
2559
|
+
if (clientOutputFileNamesAssetsDir) {
|
|
2560
|
+
const unsupported = findUnsupportedClientOutputFileNames(output, clientOutputFileNamesAssetsDir);
|
|
2561
|
+
if (unsupported.length > 0) console.warn(`[vinext] Client output file names should stay under "${clientOutputFileNamesAssetsDir}/", include [hash], emit ".js" chunks and start asset basenames with "[name]." or "[name]-" and end them with [extname] so asset URLs, immutable caching, content types, CSS url() assets and script tags keep working: ` + unsupported.join("; "));
|
|
2562
|
+
}
|
|
2563
|
+
return { build: {
|
|
2564
|
+
assetsInlineLimit: clientAssetsInlineLimit,
|
|
2565
|
+
...fileNameDefaults && Object.keys(fileNameDefaults).length > 0 ? withBuildBundlerOptions({ output: fileNameDefaults }) : {}
|
|
2566
|
+
} };
|
|
2567
|
+
}
|
|
2568
|
+
const plainPagesSsrAssetsDir = name === "ssr" ? plainPagesSsrFileNamesAssetsDir : null;
|
|
2569
|
+
const isCloudflarePagesServer = hasCloudflarePlugin && !hasAppDir;
|
|
2570
|
+
if (!(hasAppDir && (name === "rsc" || name === "ssr")) && !plainPagesSsrAssetsDir && !isCloudflarePagesServer) return null;
|
|
2458
2571
|
const output = getBuildBundlerOptions(config.build)?.output;
|
|
2459
|
-
if (Array.isArray(output)
|
|
2460
|
-
const
|
|
2461
|
-
|
|
2572
|
+
if (Array.isArray(output)) return null;
|
|
2573
|
+
const ownFileNames = environmentFileNames[name] ?? {};
|
|
2574
|
+
const inheritsTopLevel = (key) => ownFileNames[key] === void 0 && topLevelFileNames[key] !== void 0 && output?.[key] === topLevelFileNames[key];
|
|
2575
|
+
const clientAssetFileNames = environmentFileNames.client?.assetFileNames;
|
|
2576
|
+
const serverAssetFileNames = ownFileNames.assetFileNames === void 0 && clientAssetFileNames !== void 0 ? clientAssetFileNames : output?.assetFileNames === void 0 ? createClientAssetFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? "")) : void 0;
|
|
2577
|
+
if (isCloudflarePagesServer) return serverAssetFileNames === void 0 ? null : { build: withBuildBundlerOptions({ output: { assetFileNames: serverAssetFileNames } }) };
|
|
2578
|
+
const serverChunkFileNames = output?.chunkFileNames === void 0 || inheritsTopLevel("chunkFileNames") ? plainPagesSsrAssetsDir ? `${plainPagesSsrAssetsDir}/chunks/[name]-[hash].js` : output?.chunkFileNames === void 0 ? void 0 : `${config.build?.assetsDir ?? "assets"}/[name]-[hash].js` : void 0;
|
|
2579
|
+
const serverFileNameDefaults = {
|
|
2580
|
+
...serverAssetFileNames !== void 0 ? { assetFileNames: serverAssetFileNames } : {},
|
|
2581
|
+
...serverChunkFileNames !== void 0 ? { chunkFileNames: serverChunkFileNames } : {},
|
|
2582
|
+
...inheritsTopLevel("entryFileNames") ? { entryFileNames: "[name].js" } : {}
|
|
2583
|
+
};
|
|
2584
|
+
if (Object.keys(serverFileNameDefaults).length === 0) return null;
|
|
2585
|
+
return { build: { ...withBuildBundlerOptions({ output: serverFileNameDefaults }) } };
|
|
2462
2586
|
}
|
|
2463
2587
|
},
|
|
2464
2588
|
{
|
|
@@ -2484,6 +2608,9 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2484
2608
|
{
|
|
2485
2609
|
name: "vinext:cacheability-manifest-asset",
|
|
2486
2610
|
apply: "build",
|
|
2611
|
+
renderChunk(code, chunk) {
|
|
2612
|
+
return rewriteOutputRootExternals(code, chunk.fileName, OUTPUT_ROOT_SERVER_EXTERNALS);
|
|
2613
|
+
},
|
|
2487
2614
|
generateBundle() {
|
|
2488
2615
|
if (!(hasAppDir ? this.environment?.name === "rsc" : this.environment !== void 0 && isServerEnvironment(this.environment))) return;
|
|
2489
2616
|
this.emitFile({
|
|
@@ -2634,6 +2761,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2634
2761
|
},
|
|
2635
2762
|
configureServer(server) {
|
|
2636
2763
|
installSocketErrorBackstop({ runningServer: true });
|
|
2764
|
+
devPagesModuleDependencyStores.clear();
|
|
2637
2765
|
const devBuildId = nextConfig?.buildId ?? process.env.__VINEXT_BUILD_ID ?? "development";
|
|
2638
2766
|
server.middlewares.use((req, _res, next) => {
|
|
2639
2767
|
req.__vinextOriginalEncodedUrl ??= req.url;
|
|
@@ -2648,7 +2776,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2648
2776
|
return new URL(resolved).origin;
|
|
2649
2777
|
} catch {}
|
|
2650
2778
|
const address = server.httpServer?.address();
|
|
2651
|
-
return `http://localhost:${typeof address === "object" && address ? address.port : server.config.server.port
|
|
2779
|
+
return `http://localhost:${typeof address === "object" && address ? address.port : server.config.server.port}`;
|
|
2652
2780
|
};
|
|
2653
2781
|
let cachedSSRHandler = null;
|
|
2654
2782
|
const devPageRouteDataKinds = /* @__PURE__ */ new Map();
|
|
@@ -2709,6 +2837,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2709
2837
|
}
|
|
2710
2838
|
pagesRunner?.clearCache();
|
|
2711
2839
|
}
|
|
2840
|
+
function invalidatePagesModuleDependencies(filePath, event) {
|
|
2841
|
+
if (devPagesModuleDependencyStores.size === 0) return;
|
|
2842
|
+
if (path.basename(filePath) === "tsconfig.json") {
|
|
2843
|
+
devPagesModuleDependencyStores.clear();
|
|
2844
|
+
return;
|
|
2845
|
+
}
|
|
2846
|
+
const files = /* @__PURE__ */ new Set([
|
|
2847
|
+
toSlash(filePath),
|
|
2848
|
+
canonicalizeFilePath(filePath),
|
|
2849
|
+
path.join(canonicalizeFilePath(path.dirname(filePath)), path.basename(filePath))
|
|
2850
|
+
]);
|
|
2851
|
+
const unmappedDelete = event === "delete" && (isScriptModuleId(filePath) || isStylesheetSpecifier(filePath));
|
|
2852
|
+
for (const store of devPagesModuleDependencyStores.values()) if (!store.invalidate([...files], event) && unmappedDelete) store.clear();
|
|
2853
|
+
}
|
|
2712
2854
|
function invalidatePagesClientAssetsModule() {
|
|
2713
2855
|
for (const env of Object.values(server.environments)) {
|
|
2714
2856
|
const mod = env.moduleGraph.getModuleById(RESOLVED_PAGES_CLIENT_ASSETS);
|
|
@@ -2721,11 +2863,18 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2721
2863
|
if (!graph) return;
|
|
2722
2864
|
for (const mod of graph.idToModuleMap.values()) if (mod.id?.includes("?html-proxy&index=")) graph.invalidateModule(mod);
|
|
2723
2865
|
}
|
|
2866
|
+
function invalidateAppRouteManifestModule() {
|
|
2867
|
+
for (const env of Object.values(server.environments)) {
|
|
2868
|
+
const mod = env.moduleGraph.getModuleById(RESOLVED_APP_ROUTE_MANIFEST);
|
|
2869
|
+
if (mod) env.moduleGraph.invalidateModule(mod);
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2724
2872
|
function invalidateAppRoutingModules() {
|
|
2725
2873
|
invalidateAppRouteCache();
|
|
2726
2874
|
invalidateMetadataFileCache();
|
|
2727
2875
|
invalidateRscEntryModule();
|
|
2728
2876
|
invalidateRootParamsModule();
|
|
2877
|
+
invalidateAppRouteManifestModule();
|
|
2729
2878
|
}
|
|
2730
2879
|
let hybridRouteValidation = Promise.resolve();
|
|
2731
2880
|
let hybridRouteValidationError = null;
|
|
@@ -2838,6 +2987,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2838
2987
|
server.ws.send({ type: "full-reload" });
|
|
2839
2988
|
}
|
|
2840
2989
|
server.watcher.on("add", (filePath) => {
|
|
2990
|
+
invalidatePagesModuleDependencies(filePath, "create");
|
|
2841
2991
|
invalidatePagesMiddlewareMatcher(filePath);
|
|
2842
2992
|
updatePublicFileRoute(filePath, true);
|
|
2843
2993
|
let routeChanged = false;
|
|
@@ -2863,6 +3013,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2863
3013
|
}
|
|
2864
3014
|
});
|
|
2865
3015
|
server.watcher.on("change", (filePath) => {
|
|
3016
|
+
invalidatePagesModuleDependencies(filePath, "update");
|
|
2866
3017
|
invalidatePagesMiddlewareMatcher(filePath);
|
|
2867
3018
|
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2868
3019
|
const pageFile = toSlash(filePath);
|
|
@@ -2879,6 +3030,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2879
3030
|
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2880
3031
|
});
|
|
2881
3032
|
server.watcher.on("unlink", (filePath) => {
|
|
3033
|
+
invalidatePagesModuleDependencies(filePath, "delete");
|
|
2882
3034
|
invalidatePagesMiddlewareMatcher(filePath);
|
|
2883
3035
|
updatePublicFileRoute(filePath, false);
|
|
2884
3036
|
let routeChanged = false;
|
|
@@ -3291,6 +3443,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3291
3443
|
dataNotFoundResponse,
|
|
3292
3444
|
rawSearch: url.includes("?") ? url.slice(url.indexOf("?")) : "",
|
|
3293
3445
|
configMatchPathname,
|
|
3446
|
+
restoreLocaleRootTrailingSlash: shouldRestoreLocaleRootTrailingSlash(canonicalOriginalUrl.split("?")[0], nextConfig ?? {}),
|
|
3294
3447
|
runMiddleware: devRunMiddlewareAdapter,
|
|
3295
3448
|
matchApiRoute: async (apiUrl) => {
|
|
3296
3449
|
const devApiRoutes = await getDevApiRoutes();
|
|
@@ -3335,7 +3488,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3335
3488
|
}) : new Response("Invalid image optimization parameters", { status: 400 });
|
|
3336
3489
|
}
|
|
3337
3490
|
const isRetrievalMethod = req.method === "GET" || req.method === "HEAD";
|
|
3338
|
-
if (phase === "direct" && isRetrievalMethod || requestPathname === "/" || requestPathname === "/api" || requestPathname.startsWith("/api/")) return false;
|
|
3491
|
+
if (!resolvedPathnameHasBasePath || phase === "direct" && isRetrievalMethod || requestPathname === "/" || requestPathname === "/api" || requestPathname.startsWith("/api/")) return false;
|
|
3339
3492
|
if (!isRetrievalMethod) return isExistingDevPublicFile(normalizePathnameForRouteMatch(requestPathname)) ? methodNotAllowedResponse("GET, HEAD") : false;
|
|
3340
3493
|
return serveRewrittenViteFilesystemRoute(req, res, requestPathname, stagedHeaders);
|
|
3341
3494
|
}
|
|
@@ -3635,12 +3788,15 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3635
3788
|
},
|
|
3636
3789
|
{
|
|
3637
3790
|
name: "vinext:compiler-define-server",
|
|
3638
|
-
configEnvironment(name) {
|
|
3639
|
-
if (name === "client") return null;
|
|
3791
|
+
configEnvironment(name, config) {
|
|
3792
|
+
if (name === "client" || config.consumer === "client") return null;
|
|
3640
3793
|
const serverDefines = { ...nextConfig.compilerDefineServer };
|
|
3641
3794
|
serverDefines["process.env.NEXT_RUNTIME"] = JSON.stringify("nodejs");
|
|
3642
3795
|
serverDefines["process.env.NEXT_PHASE"] = "globalThis.__VINEXT_NEXT_PHASE";
|
|
3643
3796
|
if (revalidateSecret) serverDefines["process.env.__VINEXT_REVALIDATE_SECRET"] = JSON.stringify(revalidateSecret);
|
|
3797
|
+
serverDefines["process.env.__VINEXT_BUILD_ID"] = JSON.stringify(nextConfig.buildId);
|
|
3798
|
+
if (rscCompatibilityId) serverDefines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify(rscCompatibilityId);
|
|
3799
|
+
if (rscBuildIdentity) serverDefines["process.env.__VINEXT_RSC_BUILD_IDENTITY"] = JSON.stringify(rscBuildIdentity);
|
|
3644
3800
|
if (previewBuildCredentials) {
|
|
3645
3801
|
serverDefines["process.env.__VINEXT_PREVIEW_MODE_ID"] = JSON.stringify(previewBuildCredentials.id);
|
|
3646
3802
|
serverDefines["process.env.__VINEXT_PREVIEW_MODE_SIGNING_KEY"] = JSON.stringify(previewBuildCredentials.signingKey);
|
|
@@ -3724,27 +3880,18 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3724
3880
|
},
|
|
3725
3881
|
async handler(code, id) {
|
|
3726
3882
|
const lang = id.endsWith(".ts") ? "ts" : "tsx";
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
ast = parseAst(code, { lang });
|
|
3730
|
-
} catch {
|
|
3731
|
-
return null;
|
|
3732
|
-
}
|
|
3883
|
+
const record = parseModuleRecord(code, lang);
|
|
3884
|
+
if (!record) return null;
|
|
3733
3885
|
const s = new MagicString(code);
|
|
3734
3886
|
let hasChanges = false;
|
|
3735
3887
|
const imageImports = /* @__PURE__ */ new Set();
|
|
3736
|
-
for (const
|
|
3737
|
-
|
|
3738
|
-
const importNode = node;
|
|
3739
|
-
const importPath = importNode.source?.value;
|
|
3740
|
-
if (typeof importPath !== "string") continue;
|
|
3888
|
+
for (const importNode of record.staticImports) {
|
|
3889
|
+
const importPath = importNode.moduleRequest.value;
|
|
3741
3890
|
if (!IMAGE_EXT_RE.test(importPath)) continue;
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
const varName = specifier.local?.name;
|
|
3747
|
-
if (!varName) continue;
|
|
3891
|
+
if (importNode.entries.length !== 1) continue;
|
|
3892
|
+
const [entry] = importNode.entries;
|
|
3893
|
+
if (entry.importName.kind !== "Default") continue;
|
|
3894
|
+
const varName = entry.localName.value;
|
|
3748
3895
|
const dir = path.dirname(id);
|
|
3749
3896
|
const resolvedImage = importPath.startsWith(".") ? path.resolve(dir, importPath) : (await this.resolve(importPath, id, { skipSelf: true }))?.id;
|
|
3750
3897
|
if (!resolvedImage) continue;
|
|
@@ -3866,24 +4013,27 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3866
4013
|
}
|
|
3867
4014
|
},
|
|
3868
4015
|
{
|
|
3869
|
-
name: "vinext:nitro-
|
|
3870
|
-
|
|
4016
|
+
name: "vinext:nitro-setup",
|
|
4017
|
+
configResolved(config) {
|
|
4018
|
+
nitroPublicDir = config.publicDir;
|
|
4019
|
+
},
|
|
4020
|
+
buildStart() {
|
|
4021
|
+
if (this.environment?.name !== "nitro" || this.environment.mode !== "build") return;
|
|
4022
|
+
const config = this.environment.getTopLevelConfig();
|
|
4023
|
+
const clientOutDir = config.environments.client?.build.outDir;
|
|
4024
|
+
if (!clientOutDir) return;
|
|
4025
|
+
fs.rmSync(path.resolve(config.root, clientOutDir, ".vite"), {
|
|
4026
|
+
recursive: true,
|
|
4027
|
+
force: true
|
|
4028
|
+
});
|
|
4029
|
+
},
|
|
4030
|
+
nitro: { setup: (nitro) => {
|
|
3871
4031
|
nitroBuildDir = nitro.options.buildDir ? path.resolve(root, nitro.options.buildDir) : void 0;
|
|
3872
4032
|
nitroHostRuntime = nitro.options.exportConditions?.includes("workerd") ? "worker" : "node";
|
|
3873
4033
|
if (!nextConfig) return;
|
|
3874
4034
|
if (!hasAppDir && !hasPagesDir) return;
|
|
4035
|
+
nitroPublicFiles = registerNitroPublicFiles(nitro.options, NITRO_PUBLIC_FILES_PLUGIN, () => scanPublicFiles(root, nitroPublicDir));
|
|
3875
4036
|
if (resolvedServerExternalPackages.length > 0) nitro.options.traceDeps = [.../* @__PURE__ */ new Set([...nitro.options.traceDeps ?? [], ...resolvedServerExternalPackages])];
|
|
3876
|
-
if (nitro.options.dev) return;
|
|
3877
|
-
const { collectNitroRouteRules, mergeNitroRouteRules } = await import("./build/nitro-route-rules.js");
|
|
3878
|
-
const generatedRouteRules = await collectNitroRouteRules({
|
|
3879
|
-
appDir: hasAppDir ? appDir : null,
|
|
3880
|
-
pagesDir: hasPagesDir ? pagesDir : null,
|
|
3881
|
-
pageExtensions: nextConfig.pageExtensions
|
|
3882
|
-
});
|
|
3883
|
-
if (Object.keys(generatedRouteRules).length === 0) return;
|
|
3884
|
-
const { routeRules, skippedRoutes } = mergeNitroRouteRules(nitro.options.routeRules, generatedRouteRules);
|
|
3885
|
-
nitro.options.routeRules = routeRules;
|
|
3886
|
-
if (skippedRoutes.length > 0) (nitro.logger?.warn ?? console.warn)(`[vinext] Skipping generated Nitro routeRules for routes with existing exact cache config: ${skippedRoutes.join(", ")}`);
|
|
3887
4037
|
} }
|
|
3888
4038
|
},
|
|
3889
4039
|
{
|
|
@@ -3918,15 +4068,17 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3918
4068
|
writeBundle: {
|
|
3919
4069
|
sequential: true,
|
|
3920
4070
|
order: "post",
|
|
3921
|
-
handler(outputOptions) {
|
|
4071
|
+
async handler(outputOptions) {
|
|
3922
4072
|
const clientDir = outputOptions.dir;
|
|
3923
4073
|
if (!clientDir) return;
|
|
3924
4074
|
if (!(this.environment?.name === "client")) return;
|
|
4075
|
+
const pageRoutes = hasPagesDir ? (await Promise.all([pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher), apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher)])).flat() : [];
|
|
3925
4076
|
emitNextClientRuntimeManifests({
|
|
3926
4077
|
clientDir,
|
|
3927
4078
|
assetsSubdir: resolveAssetsDir(nextConfig.assetPrefix),
|
|
3928
4079
|
buildId: nextConfig.buildId,
|
|
3929
|
-
rewrites: nextConfig.rewrites
|
|
4080
|
+
rewrites: nextConfig.rewrites,
|
|
4081
|
+
pages: pageRoutes.map((route) => getPagesManifestPage(pagesDir, route.filePath, fileMatcher))
|
|
3930
4082
|
});
|
|
3931
4083
|
}
|
|
3932
4084
|
}
|
|
@@ -4028,6 +4180,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
4028
4180
|
appBootstrapPreinitModules: runtimeMetadata.appBootstrapPreinitModules,
|
|
4029
4181
|
ssrManifest,
|
|
4030
4182
|
cssGraph: runtimeMetadata.cssGraph,
|
|
4183
|
+
sharedChunks: runtimeMetadata.sharedChunks,
|
|
4031
4184
|
lazyChunks: runtimeMetadata.lazyChunks ?? void 0,
|
|
4032
4185
|
dynamicPreloads: runtimeMetadata.dynamicPreloads ?? void 0,
|
|
4033
4186
|
crossOrigin: nextConfig.crossOrigin ?? "",
|
|
@@ -4229,14 +4382,35 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
4229
4382
|
onComplete() {
|
|
4230
4383
|
rscActionOwnerRoutes = null;
|
|
4231
4384
|
rscActionOwnerSharedRoots = [];
|
|
4385
|
+
clientReferenceRoutes = null;
|
|
4386
|
+
clientReferenceAlwaysRenderedFiles = [];
|
|
4387
|
+
clientReferenceRoutelessFiles = [];
|
|
4232
4388
|
}
|
|
4233
4389
|
}));
|
|
4234
4390
|
plugins.push(createScanBuildCssPlugin());
|
|
4235
4391
|
}
|
|
4236
4392
|
if (rscPluginPromise) {
|
|
4237
4393
|
plugins.push(createRscReferenceValidationNormalizerPlugin());
|
|
4238
|
-
plugins.push(createRscClientReferenceLoadersPlugin(
|
|
4239
|
-
|
|
4394
|
+
plugins.push(createRscClientReferenceLoadersPlugin({
|
|
4395
|
+
routes: {
|
|
4396
|
+
canonicalizeModuleId: canonicalize,
|
|
4397
|
+
getAlwaysRenderedFiles: () => clientReferenceAlwaysRenderedFiles,
|
|
4398
|
+
getRoutelessFiles: () => clientReferenceRoutelessFiles,
|
|
4399
|
+
getRoutes: () => clientReferenceRoutes,
|
|
4400
|
+
getSharedRoots: () => rscActionOwnerSharedRoots
|
|
4401
|
+
},
|
|
4402
|
+
grouping: options.disableNextLikeChunking ? void 0 : {
|
|
4403
|
+
isAlwaysLoadedClientModule(id) {
|
|
4404
|
+
const chunkName = appClientManualChunks(id);
|
|
4405
|
+
return chunkName === "framework" || chunkName === "vinext";
|
|
4406
|
+
},
|
|
4407
|
+
ownClientChunkGroups: /* @__PURE__ */ new Set([...appClientCodeSplittingConfig.groups, ...clientCodeSplittingConfig.groups])
|
|
4408
|
+
}
|
|
4409
|
+
}));
|
|
4410
|
+
} else {
|
|
4411
|
+
plugins.push(createRouteClientReferencesFallbackPlugin());
|
|
4412
|
+
if (manualUseCachePluginPromise) plugins.push(manualUseCachePluginPromise);
|
|
4413
|
+
}
|
|
4240
4414
|
plugins.push({
|
|
4241
4415
|
name: "vinext:plain-pages-build-config",
|
|
4242
4416
|
apply: "build",
|
|
@@ -4257,6 +4431,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
4257
4431
|
}
|
|
4258
4432
|
}
|
|
4259
4433
|
});
|
|
4434
|
+
plugins.push(createCloudflareDevModuleUrlsPlugin({ isEnabled: () => hasCloudflarePlugin }));
|
|
4260
4435
|
plugins.push(buildLifecyclePlugins[1]);
|
|
4261
4436
|
return plugins;
|
|
4262
4437
|
}
|