vinext 1.2.1 → 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 +12 -9
- 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/pages-client-assets-module.js +1 -1
- package/dist/build/prerender-paths.js +5 -2
- 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/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 +183 -255
- 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 +239 -83
- package/dist/init.js +17 -0
- package/dist/plugins/optimize-imports.d.ts +25 -2
- package/dist/plugins/optimize-imports.js +106 -20
- package/dist/plugins/rsc-client-reference-loaders.d.ts +45 -1
- package/dist/plugins/rsc-client-reference-loaders.js +336 -18
- package/dist/plugins/use-cache-callable.d.ts +5 -0
- package/dist/plugins/use-cache-callable.js +30 -8
- package/dist/plugins/worker-image-imports.d.ts +1 -0
- package/dist/plugins/worker-image-imports.js +1 -1
- 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/app-action-forwarding.d.ts +8 -0
- package/dist/server/app-action-forwarding.js +15 -1
- package/dist/server/app-browser-entry.js +147 -60
- 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-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-state.d.ts +2 -2
- 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 +2 -0
- package/dist/server/app-page-render.js +3 -1
- 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 +11 -7
- package/dist/server/app-prerender-static-params.js +3 -2
- package/dist/server/app-render-dependency.js +42 -2
- package/dist/server/app-request-stage-independent-entry.js +2 -2
- package/dist/server/app-response-stage-entry.js +3 -3
- 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 +20 -3
- 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 +2 -2
- 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 +146 -130
- 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 +3 -1
- 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 +50 -56
- package/dist/server/app-ssr-entry.d.ts +6 -0
- package/dist/server/app-ssr-entry.js +16 -7
- package/dist/server/app-ssr-stream.d.ts +7 -0
- package/dist/server/app-ssr-stream.js +13 -1
- package/dist/server/config-headers.js +12 -3
- 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/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 +26 -13
- package/dist/server/navigation-planner.d.ts +2 -2
- 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/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-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-request-pipeline.d.ts +6 -1
- package/dist/server/pages-request-pipeline.js +31 -35
- package/dist/server/pages-request-stage-entry.js +16 -6
- package/dist/server/pages-response-stage-entry.js +1 -1
- package/dist/server/pages-revalidate.js +1 -0
- package/dist/server/pages-router-entry.js +1 -1
- package/dist/server/prod-server.d.ts +2 -2
- package/dist/server/prod-server.js +71 -33
- 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/server-reference-loader.js +10 -1
- package/dist/server/static-file-cache.js +15 -3
- 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/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 +31 -14
- package/dist/shims/internal/hybrid-client-route-owner.js +8 -8
- package/dist/shims/link.js +5 -3
- package/dist/shims/navigation.d.ts +1 -1
- package/dist/shims/navigation.js +17 -5
- package/dist/shims/og.js +35 -10
- package/dist/shims/request-context.d.ts +13 -0
- package/dist/shims/router.js +19 -40
- package/dist/shims/server.d.ts +31 -4
- package/dist/shims/server.js +58 -10
- 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/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/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/public-routes.d.ts +2 -0
- package/dist/utils/public-routes.js +18 -7
- package/package.json +1 -1
- 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,5 +1,6 @@
|
|
|
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";
|
|
5
6
|
import { TRIVIA_PATTERN, hasImportAttributes, isTypeOnlyImport, parseModuleRecord, parseProgram } from "./plugins/ast-utils.js";
|
|
@@ -7,6 +8,7 @@ import { claimViteCliBuildInvocation, getViteCliInvocation, isViteCliConfigFile
|
|
|
7
8
|
import { VINEXT_DEV_CLI_LIFECYCLE, applyDevServerDefaults, claimViteCliDevInvocation, createDevServerLifecyclePlugin, reserveViteCliDevInvocation } from "./cli-dev-config.js";
|
|
8
9
|
import { isUnknownRecord } from "./utils/record.js";
|
|
9
10
|
import { getReactUpgradeDeps, reactUpgradeRequiredMessage } from "./utils/react-version.js";
|
|
11
|
+
import { resolvePluginReactPath } from "./utils/plugin-react-version.js";
|
|
10
12
|
import { loadDotenv } from "./config/dotenv.js";
|
|
11
13
|
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
|
|
12
14
|
import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
|
|
@@ -28,14 +30,14 @@ import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./rout
|
|
|
28
30
|
import { resolveRuntimeEntryModule } from "./entries/runtime-entry-module.js";
|
|
29
31
|
import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
|
|
30
32
|
import { validateMiddlewareMatcherPatterns } from "./server/middleware-matcher-pattern.js";
|
|
31
|
-
import { resolvePagesI18nRequest, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
|
|
33
|
+
import { resolvePagesI18nRequest, shouldRestoreLocaleRootTrailingSlash, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
|
|
32
34
|
import { encodeUrlParserIgnoredCharacters, isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname, shouldAddTrailingSlashToPagesDataPath, urlParserCreatesPagesDataPath } from "./server/pages-data-route.js";
|
|
33
35
|
import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
|
|
34
36
|
import { findMiddlewareFile, isProxyFile, runMiddleware } from "./server/middleware.js";
|
|
35
37
|
import { extractMiddlewareMatcherConfig, extractMiddlewareMatcherConfigValue, hasExportedName } from "./build/report.js";
|
|
36
38
|
import { generatePagesRequestEntry, generatePagesResponseEntry, generateServerEntry } from "./entries/pages-server-entry.js";
|
|
37
39
|
import { compileClientMiddlewareMatchers, generateClientEntry } from "./entries/pages-client-entry.js";
|
|
38
|
-
import { isPathInside, isPathInsideOrEqual, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
|
|
40
|
+
import { canonicalizeFilePath, isPathInside, isPathInsideOrEqual, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
|
|
39
41
|
import { logRequest, now } from "./server/request-log.js";
|
|
40
42
|
import { getPagesPreviewModeId } from "./server/pages-preview.js";
|
|
41
43
|
import { createSSRHandler } from "./server/dev-server.js";
|
|
@@ -49,16 +51,18 @@ import { installSocketErrorBackstop } from "./server/socket-error-backstop.js";
|
|
|
49
51
|
import { invalidateMetadataFileCache, scanMetadataFiles } from "./server/metadata-routes.js";
|
|
50
52
|
import { shouldInvalidateAppRouteFile } from "./server/dev-route-files.js";
|
|
51
53
|
import { createDirectRunner } from "./server/dev-module-runner.js";
|
|
54
|
+
import { rootBoundaryFiles, rootBoundaryRouteFiles } from "./entries/app-rsc-manifest.js";
|
|
52
55
|
import { validateDevRequest } from "./server/dev-origin-check.js";
|
|
53
56
|
import { createActionOwnerManifestPlugin } from "./plugins/action-owner-manifest.js";
|
|
54
57
|
import { generateAppRequestRscEntry, generateAppResponseRscEntry, generateRscEntry } from "./entries/app-rsc-entry.js";
|
|
55
58
|
import { generateSsrEntry } from "./entries/app-ssr-entry.js";
|
|
56
59
|
import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VIRTUAL_CACHE_ADAPTERS, VIRTUAL_CDN_CACHE_ADAPTER, generateCacheAdaptersModule, generateCdnCacheAdapterModule } from "./cache/cache-adapters-virtual.js";
|
|
57
60
|
import { VIRTUAL_IMAGE_ADAPTERS, generateImageAdaptersModule } from "./image/image-adapters-virtual.js";
|
|
58
|
-
import { generateBrowserEntry, toLinkPrefetchRoutes } from "./entries/app-browser-entry.js";
|
|
61
|
+
import { generateBrowserEntry, generateBrowserRouteManifestModule, toHashedRouteHandlerRoutes, toLinkPrefetchRoutes } from "./entries/app-browser-entry.js";
|
|
59
62
|
import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
|
|
60
63
|
import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
|
|
61
64
|
import { createRscScanGlobImportsPlugin, isRscScanGlobImportsAffected } from "./plugins/rsc-scan-glob-imports.js";
|
|
65
|
+
import { loadOrGenerateServerActionsEncryptionKey } from "./build/server-actions-encryption-key.js";
|
|
62
66
|
import { findOpenTelemetryPackages, mergeServerExternalPackages } from "./config/server-external-packages.js";
|
|
63
67
|
import { precompressAssets } from "./build/precompress.js";
|
|
64
68
|
import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY, normalizeVinextPrerenderConfig } from "./config/prerender.js";
|
|
@@ -67,7 +71,8 @@ import { PAGES_CLIENT_ASSETS_MODULE, buildPagesClientAssetsModule, collectClient
|
|
|
67
71
|
import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
|
|
68
72
|
import { VINEXT_BUILD_LIFECYCLE_CONFIG, createBuildLifecyclePlugins } from "./build/lifecycle.js";
|
|
69
73
|
import { ensureAssetsIgnore } from "./build/assets-ignore.js";
|
|
70
|
-
import {
|
|
74
|
+
import { registerNitroPublicFiles } from "./build/nitro-public-files.js";
|
|
75
|
+
import { emitNextClientRuntimeManifests, getPagesManifestPage } from "./build/next-client-runtime-manifests.js";
|
|
71
76
|
import { collectInlineCssManifest, injectInlineCssManifestGlobal } from "./build/inline-css.js";
|
|
72
77
|
import { readTrustedRevalidationHostname } from "./server/revalidation-host.js";
|
|
73
78
|
import { sealForwardedMiddlewareContext } from "./server/forwarded-middleware-context.js";
|
|
@@ -83,7 +88,9 @@ import { asyncHooksStubPlugin } from "./plugins/async-hooks-stub.js";
|
|
|
83
88
|
import { clientReferenceDedupPlugin } from "./plugins/client-reference-dedup.js";
|
|
84
89
|
import { dataUrlCssPlugin } from "./plugins/css-data-url.js";
|
|
85
90
|
import { createCssModuleImportCompatibilityPlugin } from "./plugins/css-module-imports.js";
|
|
86
|
-
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";
|
|
87
94
|
import { createRscReferenceValidationNormalizerPlugin } from "./plugins/rsc-reference-validation-normalizer.js";
|
|
88
95
|
import { createScanBuildCssPlugin } from "./plugins/scan-build-css.js";
|
|
89
96
|
import { createInstrumentationClientTransformPlugin, createInstrumentationServerTransformPlugin } from "./plugins/instrumentation-client.js";
|
|
@@ -107,14 +114,12 @@ import { createTransitiveExternalsPlugin } from "./plugins/transitive-externals.
|
|
|
107
114
|
import public_shim_map_default from "./shims/public-shim-map.json.js";
|
|
108
115
|
import { computeClientRuntimeMetadata } from "./utils/client-runtime-metadata.js";
|
|
109
116
|
import { readPrerenderSecret, readServerRuntimeOutputDirs } from "./build/server-manifest.js";
|
|
110
|
-
import { createModuleDependencyCache } from "./build/module-dependency-cache.js";
|
|
117
|
+
import { ModuleDependencyStore, createModuleDependencyCache } from "./build/module-dependency-cache.js";
|
|
111
118
|
import { markCssUrlAssetReferences, restoreDedupedCssAssetReferences } from "./build/css-url-assets.js";
|
|
112
119
|
import { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter, createSassTsconfigPathImporters } from "./plugins/sass.js";
|
|
113
|
-
import { assertClientOutDirIsSeparate, createClientAssetFileNames, createClientCodeSplittingConfig, createClientFileNameConfig, createClientManualChunks, createMultiStageChunkFileNames, createMultiStageCodeSplittingConfig, createRscFrameworkChunkOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfig, withBuildBundlerOptions } from "./build/client-build-config.js";
|
|
114
120
|
import { EXPORT_ALL_CANDIDATE_FILTER, hasExportAllCandidate, stripServerExports, validatePageExports } from "./plugins/strip-server-exports.js";
|
|
115
121
|
import { removeConsoleCalls } from "./plugins/remove-console.js";
|
|
116
122
|
import { createImportMetaUrlPlugin } from "./plugins/import-meta-url.js";
|
|
117
|
-
import { createWorkerImageImportsPlugin } from "./plugins/worker-image-imports.js";
|
|
118
123
|
import { SERVER_ONLY_SPECIFIER_RE, createWorkerServerOnlyImportsPlugin } from "./plugins/worker-server-only-imports.js";
|
|
119
124
|
import { createWorkerUseServerPlugins } from "./plugins/worker-use-server.js";
|
|
120
125
|
import { createRequireContextPlugin } from "./plugins/require-context.js";
|
|
@@ -126,7 +131,7 @@ import { createWasmModuleImportPlugin } from "./plugins/wasm-module-import.js";
|
|
|
126
131
|
import { consumerEnvironmentConditionFilter, getTypeofWindowReplacement, mayFoldChangeScannedImports, replaceConsumerEnvironmentConditions } from "./plugins/typeof-window.js";
|
|
127
132
|
import { hasMdxFiles, loadMdxEsmReader, pageExtensionsIncludeMdx } from "./utils/mdx-scan.js";
|
|
128
133
|
import { publicFileRouteKey } from "./utils/public-file-path.js";
|
|
129
|
-
import { scanPublicFileRoutes } from "./utils/public-routes.js";
|
|
134
|
+
import { scanPublicFileRoutes, scanPublicFiles } from "./utils/public-routes.js";
|
|
130
135
|
import { createIgnoreDynamicRequestsPlugin } from "./plugins/ignore-dynamic-requests.js";
|
|
131
136
|
import { assertPluginRscVersion, needsAppReactServerDom } from "./utils/plugin-rsc-version.js";
|
|
132
137
|
import { assertSupportedViteVersion, getDepOptimizeNodeEnvOptions, serializeViteDefine } from "./utils/vite-version.js";
|
|
@@ -185,13 +190,17 @@ function scopeRscPlugin(plugin) {
|
|
|
185
190
|
};
|
|
186
191
|
}
|
|
187
192
|
const earlyViteCliInvocation = getViteCliInvocation();
|
|
193
|
+
let earlyDotenv;
|
|
188
194
|
const viteCliBuildConfigNodeEnv = earlyViteCliInvocation?.command === "build" && process.env.NODE_ENV === "test" ? "test" : void 0;
|
|
189
195
|
if (earlyViteCliInvocation) {
|
|
190
196
|
if (!process.env.NODE_ENV) Reflect.set(process.env, "NODE_ENV", earlyViteCliInvocation.command === "build" ? viteCliBuildConfigNodeEnv ?? "production" : earlyViteCliInvocation.mode === "test" ? "test" : "development");
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
197
|
+
earlyDotenv = {
|
|
198
|
+
dir: path.resolve(earlyViteCliInvocation.root),
|
|
199
|
+
env: loadDotenv({
|
|
200
|
+
root: earlyViteCliInvocation.root,
|
|
201
|
+
mode: earlyViteCliInvocation.mode
|
|
202
|
+
}).loadedEnv
|
|
203
|
+
};
|
|
195
204
|
}
|
|
196
205
|
installSocketErrorBackstop();
|
|
197
206
|
const INVALID_SERVER_ONLY_ID_PREFIX = "\0vinext:invalid-server-only:";
|
|
@@ -391,23 +400,35 @@ async function collectDevPagesAppStylesheetAssets(appFilePath, getModuleDependen
|
|
|
391
400
|
await visitModule(appFilePath);
|
|
392
401
|
return stylesheetAssets;
|
|
393
402
|
}
|
|
394
|
-
function createDevPagesModuleDependencyReader(root, resolve) {
|
|
395
|
-
return createModuleDependencyCache(collectModuleDependencies);
|
|
403
|
+
function createDevPagesModuleDependencyReader(root, resolve, store) {
|
|
404
|
+
return createModuleDependencyCache((modulePath) => store.read(modulePath, collectModuleDependencies));
|
|
396
405
|
async function collectModuleDependencies(modulePath) {
|
|
406
|
+
const dependencies = [];
|
|
407
|
+
const entry = {
|
|
408
|
+
dependencies,
|
|
409
|
+
resolvedFiles: [],
|
|
410
|
+
cacheable: true
|
|
411
|
+
};
|
|
397
412
|
const cleanModulePath = stripViteModuleQuery(modulePath);
|
|
398
|
-
if (!path.isAbsolute(cleanModulePath) || !fs.existsSync(cleanModulePath)) return
|
|
413
|
+
if (!path.isAbsolute(cleanModulePath) || !fs.existsSync(cleanModulePath)) return entry;
|
|
399
414
|
let code;
|
|
400
415
|
try {
|
|
401
416
|
code = fs.readFileSync(cleanModulePath, "utf-8");
|
|
402
417
|
} catch {
|
|
403
|
-
return
|
|
418
|
+
return {
|
|
419
|
+
...entry,
|
|
420
|
+
cacheable: false
|
|
421
|
+
};
|
|
404
422
|
}
|
|
405
423
|
const record = parseModuleRecord(code, parserLanguageForScript(cleanModulePath));
|
|
406
|
-
if (!record) return
|
|
407
|
-
const dependencies = [];
|
|
424
|
+
if (!record) return entry;
|
|
408
425
|
for (const specifier of runtimeStaticDependencySpecifiers(code, record, parserLanguageForScript(cleanModulePath))) {
|
|
409
426
|
const resolved = await resolve(specifier, cleanModulePath, { skipSelf: false });
|
|
410
|
-
if (!resolved?.id)
|
|
427
|
+
if (!resolved?.id) {
|
|
428
|
+
entry.cacheable = false;
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
entry.resolvedFiles.push(stripViteModuleQuery(resolved.id));
|
|
411
432
|
if (isStylesheetSpecifier(specifier) || isStylesheetSpecifier(resolved.id)) {
|
|
412
433
|
const asset = resolvedStylesheetToDevManifestAsset(root, resolved.id);
|
|
413
434
|
if (asset) dependencies.push({
|
|
@@ -419,7 +440,7 @@ function createDevPagesModuleDependencyReader(root, resolve) {
|
|
|
419
440
|
id: resolved.id
|
|
420
441
|
});
|
|
421
442
|
}
|
|
422
|
-
return
|
|
443
|
+
return entry;
|
|
423
444
|
}
|
|
424
445
|
}
|
|
425
446
|
const TSCONFIG_FILES = ["tsconfig.json", "jsconfig.json"];
|
|
@@ -762,13 +783,18 @@ const VIRTUAL_APP_SSR_ENTRY = "virtual:vinext-app-ssr-entry";
|
|
|
762
783
|
const RESOLVED_APP_SSR_ENTRY = "\0" + VIRTUAL_APP_SSR_ENTRY;
|
|
763
784
|
const VIRTUAL_APP_BROWSER_ENTRY = "virtual:vinext-app-browser-entry";
|
|
764
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;
|
|
765
788
|
const VIRTUAL_APP_CAPABILITIES = "virtual:vinext-app-capabilities";
|
|
766
789
|
const RESOLVED_APP_CAPABILITIES = "\0" + VIRTUAL_APP_CAPABILITIES;
|
|
767
790
|
const RESOLVED_ROOT_PARAMS = "\0virtual:vinext-root-params";
|
|
791
|
+
const RESOLVED_NEXT_IMAGE_RSC = "\0virtual:vinext-next-image-rsc";
|
|
768
792
|
const APP_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("app-request-stage-independent-entry");
|
|
769
793
|
const APP_RESPONSE_STAGE_ENTRY = resolveRuntimeEntryModule("app-response-stage-entry");
|
|
770
794
|
const PAGES_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("pages-request-stage-entry");
|
|
771
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");
|
|
772
798
|
const WORKER_ROUTER_ENTRIES = /* @__PURE__ */ new Set([resolveRuntimeEntryModule("app-router-entry"), resolveRuntimeEntryModule("pages-router-entry")]);
|
|
773
799
|
/** Virtual module that registers config-driven cache adapters (see VinextOptions.cache). */
|
|
774
800
|
const RESOLVED_CACHE_ADAPTERS = "\0" + VIRTUAL_CACHE_ADAPTERS;
|
|
@@ -883,13 +909,8 @@ const clientManualChunks = createClientManualChunks(_shimsDir);
|
|
|
883
909
|
const clientCodeSplittingConfig = createClientCodeSplittingConfig(clientManualChunks);
|
|
884
910
|
const appClientManualChunks = createClientManualChunks(_shimsDir, true);
|
|
885
911
|
const appClientCodeSplittingConfig = createClientCodeSplittingConfig(appClientManualChunks);
|
|
886
|
-
function getClientOutputConfig(
|
|
887
|
-
|
|
888
|
-
return {
|
|
889
|
-
...createClientFileNameConfig(assetsDir),
|
|
890
|
-
assetFileNames: createClientAssetFileNames(assetsDir),
|
|
891
|
-
codeSplitting
|
|
892
|
-
};
|
|
912
|
+
function getClientOutputConfig(preserveAppRouteBoundaries = false) {
|
|
913
|
+
return { codeSplitting: preserveAppRouteBoundaries ? appClientCodeSplittingConfig : clientCodeSplittingConfig };
|
|
893
914
|
}
|
|
894
915
|
function createServerEnvironmentFileNameResolver(config, outputRoot) {
|
|
895
916
|
const resolvedOutputRoot = path.resolve(config.root, outputRoot);
|
|
@@ -928,6 +949,10 @@ function vinext(options = {}) {
|
|
|
928
949
|
let clientInjectModule = null;
|
|
929
950
|
let globalNotFoundCssIsolationPath = null;
|
|
930
951
|
let clientAssetsInlineLimit = 0;
|
|
952
|
+
let clientOutputFileNamesAssetsDir = null;
|
|
953
|
+
let plainPagesSsrFileNamesAssetsDir = null;
|
|
954
|
+
let topLevelFileNames = {};
|
|
955
|
+
let environmentFileNames = {};
|
|
931
956
|
let hasCloudflarePlugin = false;
|
|
932
957
|
let matchedMultiStageOutput;
|
|
933
958
|
let selectedMultiStageOutput;
|
|
@@ -935,6 +960,8 @@ function vinext(options = {}) {
|
|
|
935
960
|
let warnedInlineNextConfigOverride = false;
|
|
936
961
|
let hasNitroPlugin = false;
|
|
937
962
|
let nitroHostRuntime = "node";
|
|
963
|
+
let nitroPublicFiles = false;
|
|
964
|
+
let nitroPublicDir = "public";
|
|
938
965
|
let resolvedServerExternalPackages = [];
|
|
939
966
|
let registerNodeOpenTelemetryLoader = false;
|
|
940
967
|
let pagesTsconfigAliases = {};
|
|
@@ -956,6 +983,7 @@ function vinext(options = {}) {
|
|
|
956
983
|
});
|
|
957
984
|
const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
|
|
958
985
|
const pagesClientAssetsExternalTargets = /* @__PURE__ */ new Map();
|
|
986
|
+
const devPagesModuleDependencyStores = /* @__PURE__ */ new Map();
|
|
959
987
|
const resolvePagesClientAssetsOutputDir = (environmentName, outputDir) => !selectedMultiStageOutput && !hasAppDir && !hasCloudflarePlugin && environmentName === "ssr" ? path.dirname(outputDir) : outputDir;
|
|
960
988
|
let pagesClientAssetsModule = internalOptions.__pagesClientAssetsModule ?? null;
|
|
961
989
|
let clientBuildFiles = [];
|
|
@@ -973,6 +1001,9 @@ function vinext(options = {}) {
|
|
|
973
1001
|
const rscClassificationManifests = /* @__PURE__ */ new Map();
|
|
974
1002
|
let rscActionOwnerRoutes = null;
|
|
975
1003
|
let rscActionOwnerSharedRoots = [];
|
|
1004
|
+
let clientReferenceRoutes = null;
|
|
1005
|
+
let clientReferenceAlwaysRenderedFiles = [];
|
|
1006
|
+
let clientReferenceRoutelessFiles = [];
|
|
976
1007
|
const serverEntryKindsByEnvironment = /* @__PURE__ */ new Map();
|
|
977
1008
|
const serverRuntimeOutputDirs = /* @__PURE__ */ new Set();
|
|
978
1009
|
function recordServerEntryLoad(environmentName, id) {
|
|
@@ -985,6 +1016,8 @@ function vinext(options = {}) {
|
|
|
985
1016
|
entries.add(id);
|
|
986
1017
|
}
|
|
987
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("[\\\\/]")}$`);
|
|
988
1021
|
const canonicalize = (p) => toSlash(tryRealpathSync(p) ?? p);
|
|
989
1022
|
const pageTransformCanonicalPaths = /* @__PURE__ */ new Map();
|
|
990
1023
|
const canonicalizePageTransformPath = (modulePath) => {
|
|
@@ -1032,9 +1065,10 @@ function vinext(options = {}) {
|
|
|
1032
1065
|
* __NEXT_DATA__ to determine which page to hydrate.
|
|
1033
1066
|
*/
|
|
1034
1067
|
async function generateClientEntry$1() {
|
|
1035
|
-
const
|
|
1068
|
+
const appRoutes = hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : [];
|
|
1036
1069
|
return generateClientEntry(pagesDir, nextConfig, fileMatcher, {
|
|
1037
|
-
appPrefetchRoutes,
|
|
1070
|
+
appPrefetchRoutes: toLinkPrefetchRoutes(appRoutes),
|
|
1071
|
+
appRouteHandlers: toHashedRouteHandlerRoutes(appRoutes),
|
|
1038
1072
|
instrumentationClientPath,
|
|
1039
1073
|
middlewareMatcher: middlewarePath ? extractMiddlewareMatcherConfig(middlewarePath) : void 0,
|
|
1040
1074
|
reactPreamble: options.react !== false
|
|
@@ -1051,28 +1085,29 @@ function vinext(options = {}) {
|
|
|
1051
1085
|
const earlyRoot = earlyViteCliInvocation?.root ?? process.cwd();
|
|
1052
1086
|
const earlyBaseDir = path.resolve(earlyRoot, options.appDir ?? ".");
|
|
1053
1087
|
const earlyAppDirExists = !options.disableAppRouter && (fs.existsSync(path.join(earlyBaseDir, "app")) || fs.existsSync(path.join(earlyBaseDir, "src", "app")));
|
|
1054
|
-
let resolvedReactPath = null;
|
|
1055
1088
|
let resolvedRscPath = null;
|
|
1056
1089
|
let rscPluginModulePromise = null;
|
|
1057
|
-
resolvedReactPath = resolveOptionalDependency(earlyBaseDir, "@vitejs/plugin-react");
|
|
1058
1090
|
resolvedRscPath = resolveOptionalDependency(earlyBaseDir, "@vitejs/plugin-rsc");
|
|
1059
1091
|
const rscVersion = earlyAppDirExists && resolvedRscPath ? assertPluginRscVersion(resolvedRscPath) : null;
|
|
1060
1092
|
let rscPluginPromise = null;
|
|
1061
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;
|
|
1062
1100
|
if (earlyAppDirExists && autoRsc) {
|
|
1063
1101
|
if (!resolvedRscPath) throw new Error("vinext: App Router detected but @vitejs/plugin-rsc is not installed.\nRun: " + detectPackageManager(process.cwd()) + " @vitejs/plugin-rsc");
|
|
1064
1102
|
const rscImport = import(pathToFileURL(resolvedRscPath).href);
|
|
1065
1103
|
rscPluginModulePromise = rscImport;
|
|
1066
1104
|
rscPluginPromise = rscImport.then(async (mod) => {
|
|
1067
1105
|
const rsc = mod.default;
|
|
1068
|
-
const plugins = rsc(
|
|
1069
|
-
rsc: VIRTUAL_RSC_ENTRY,
|
|
1070
|
-
ssr: VIRTUAL_APP_SSR_ENTRY,
|
|
1071
|
-
client: VIRTUAL_APP_BROWSER_ENTRY
|
|
1072
|
-
} });
|
|
1106
|
+
const plugins = rsc(rscPluginOptions);
|
|
1073
1107
|
const useCachePlugin = await createUseCacheCallablePlugin({
|
|
1074
1108
|
projectRoot: earlyBaseDir,
|
|
1075
|
-
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href
|
|
1109
|
+
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href,
|
|
1110
|
+
getEncryptionKey: () => serverActionsEncryptionKey
|
|
1076
1111
|
});
|
|
1077
1112
|
const useServerIndex = plugins.findIndex((plugin) => plugin.name === "rsc:use-server");
|
|
1078
1113
|
if (useServerIndex === -1) throw new Error("vinext: Failed to locate @vitejs/plugin-rsc use-server plugin.");
|
|
@@ -1101,6 +1136,7 @@ function vinext(options = {}) {
|
|
|
1101
1136
|
let reactPluginPromise = null;
|
|
1102
1137
|
let reactCompilerPluginPromise = null;
|
|
1103
1138
|
if (options.react !== false) {
|
|
1139
|
+
const resolvedReactPath = resolvePluginReactPath(earlyBaseDir);
|
|
1104
1140
|
if (!resolvedReactPath) throw new Error("vinext: @vitejs/plugin-react is not installed.\nRun: " + detectPackageManager(process.cwd()) + " @vitejs/plugin-react");
|
|
1105
1141
|
const allReactPlugins = import(pathToFileURL(resolvedReactPath).href).catch((cause) => {
|
|
1106
1142
|
throw new Error("vinext: Failed to load @vitejs/plugin-react.", { cause });
|
|
@@ -1378,6 +1414,7 @@ function vinext(options = {}) {
|
|
|
1378
1414
|
originalPlainPagesEnvironments = void 0;
|
|
1379
1415
|
buildEmptyOutDir = typeof config.build?.emptyOutDir === "boolean" ? config.build.emptyOutDir : void 0;
|
|
1380
1416
|
isServeCommand = env.command === "serve";
|
|
1417
|
+
const ipaddrSsrExternal = env.command === "serve" ? ["ipaddr.js"] : [];
|
|
1381
1418
|
root = path.resolve(toSlash(process.cwd()), config.root ?? ".");
|
|
1382
1419
|
if (env.command === "build") assertClientOutDirIsSeparate(root, options);
|
|
1383
1420
|
const devCliLifecycleEnabled = env.command === "serve" && env.isPreview !== true && claimViteCliDevInvocation(root, config["__vinextDevRestart"] === true, reservedDevCliInvocation && config.configFile === false);
|
|
@@ -1388,13 +1425,15 @@ function vinext(options = {}) {
|
|
|
1388
1425
|
let sassTsconfigPathAliases = [];
|
|
1389
1426
|
const swcHelpersAlias = resolveSwcHelpersAlias(root);
|
|
1390
1427
|
const mode = env?.mode ?? "development";
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
mode
|
|
1396
|
-
});
|
|
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;
|
|
1397
1432
|
}
|
|
1433
|
+
if (envDir) loadDotenv({
|
|
1434
|
+
root: envDir,
|
|
1435
|
+
mode
|
|
1436
|
+
});
|
|
1398
1437
|
let resolvedNodeEnv;
|
|
1399
1438
|
if (env?.command === "build" || env?.isPreview === true) resolvedNodeEnv = "production";
|
|
1400
1439
|
else if (mode === "test") resolvedNodeEnv = "test";
|
|
@@ -1443,6 +1482,13 @@ function vinext(options = {}) {
|
|
|
1443
1482
|
buildId: sharedBuildId
|
|
1444
1483
|
};
|
|
1445
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
|
+
}
|
|
1446
1492
|
if (env?.command === "build" && earlyViteCliInvocation?.command === "build") Reflect.set(process.env, "NODE_ENV", "production");
|
|
1447
1493
|
const configuredTsconfigPath = isUnknownRecord(nextConfig.typescript) ? typeof nextConfig.typescript.tsconfigPath === "string" ? nextConfig.typescript.tsconfigPath : void 0 : void 0;
|
|
1448
1494
|
const resolvedTsconfigAliases = resolveTsconfigAliases(root, configuredTsconfigPath);
|
|
@@ -1520,9 +1566,9 @@ function vinext(options = {}) {
|
|
|
1520
1566
|
defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_SVG"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowSVG ?? false));
|
|
1521
1567
|
defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_LOCAL_IP"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowLocalIP ?? false));
|
|
1522
1568
|
defines["process.env.__VINEXT_IMAGE_UNOPTIMIZED"] = JSON.stringify(String(nextConfig.images?.unoptimized === true));
|
|
1523
|
-
defines["process.env.__VINEXT_BUILD_ID"] =
|
|
1524
|
-
defines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify(
|
|
1525
|
-
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("");
|
|
1526
1572
|
defines["process.env.__VINEXT_DEPLOYMENT_ID"] = JSON.stringify(nextConfig.deploymentId ?? "");
|
|
1527
1573
|
defines["process.env.NEXT_DEPLOYMENT_ID"] = nextConfig.deploymentId ? JSON.stringify(nextConfig.deploymentId) : "false";
|
|
1528
1574
|
defines["process.env.NEXT_RUNTIME"] = "\"\"";
|
|
@@ -1608,6 +1654,10 @@ function vinext(options = {}) {
|
|
|
1608
1654
|
const hasClientBuildEnvironment = hasAppDir || hasCloudflarePlugin || hasNitroPlugin || shouldInjectPlainPagesEnvironments;
|
|
1609
1655
|
const clientAssetsDir = resolveAssetsDir(nextConfig.assetPrefix ?? "");
|
|
1610
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)]));
|
|
1611
1661
|
const devHmrConfig = config.server?.hmr === false ? false : {
|
|
1612
1662
|
...typeof config.server?.hmr === "object" ? config.server.hmr : {},
|
|
1613
1663
|
overlay: false
|
|
@@ -1652,7 +1702,7 @@ function vinext(options = {}) {
|
|
|
1652
1702
|
};
|
|
1653
1703
|
})(),
|
|
1654
1704
|
...!isSSR && !isMultiEnv ? { treeshake: getClientTreeshakeConfig() } : {},
|
|
1655
|
-
...!isSSR && !isMultiEnv ? { output: getClientOutputConfig(
|
|
1705
|
+
...!isSSR && !isMultiEnv ? { output: getClientOutputConfig() } : {}
|
|
1656
1706
|
})
|
|
1657
1707
|
},
|
|
1658
1708
|
worker: { plugins: () => [
|
|
@@ -1682,7 +1732,7 @@ function vinext(options = {}) {
|
|
|
1682
1732
|
"react",
|
|
1683
1733
|
"react-dom",
|
|
1684
1734
|
"react-dom/server",
|
|
1685
|
-
|
|
1735
|
+
...ipaddrSsrExternal,
|
|
1686
1736
|
...Array.isArray(config.ssr?.external) ? config.ssr.external : [],
|
|
1687
1737
|
...nextServerExternal
|
|
1688
1738
|
],
|
|
@@ -1867,7 +1917,7 @@ function vinext(options = {}) {
|
|
|
1867
1917
|
...hasCloudflarePlugin || hasNitroPlugin ? {} : { resolve: {
|
|
1868
1918
|
external: userSsrExternal === true ? true : [
|
|
1869
1919
|
...userSsrExternal,
|
|
1870
|
-
|
|
1920
|
+
...ipaddrSsrExternal,
|
|
1871
1921
|
...externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []
|
|
1872
1922
|
],
|
|
1873
1923
|
noExternal: userSsrExternal === true ? [...PATCHED_SERVER_PACKAGES] : true
|
|
@@ -1905,7 +1955,7 @@ function vinext(options = {}) {
|
|
|
1905
1955
|
assetsInlineLimit: clientAssetsInlineLimit,
|
|
1906
1956
|
...withBuildBundlerOptions({
|
|
1907
1957
|
input: appClientInput,
|
|
1908
|
-
output: getClientOutputConfig(
|
|
1958
|
+
output: getClientOutputConfig(true),
|
|
1909
1959
|
treeshake: getClientTreeshakeConfig()
|
|
1910
1960
|
})
|
|
1911
1961
|
}
|
|
@@ -1925,7 +1975,7 @@ function vinext(options = {}) {
|
|
|
1925
1975
|
assetsInlineLimit: clientAssetsInlineLimit,
|
|
1926
1976
|
...withBuildBundlerOptions({
|
|
1927
1977
|
input: { index: VIRTUAL_CLIENT_ENTRY },
|
|
1928
|
-
output: getClientOutputConfig(
|
|
1978
|
+
output: getClientOutputConfig(),
|
|
1929
1979
|
treeshake: getClientTreeshakeConfig()
|
|
1930
1980
|
})
|
|
1931
1981
|
}
|
|
@@ -1946,7 +1996,7 @@ function vinext(options = {}) {
|
|
|
1946
1996
|
assetsInlineLimit: clientAssetsInlineLimit,
|
|
1947
1997
|
...withBuildBundlerOptions({
|
|
1948
1998
|
input: { index: VIRTUAL_CLIENT_ENTRY },
|
|
1949
|
-
output: getClientOutputConfig(
|
|
1999
|
+
output: getClientOutputConfig(),
|
|
1950
2000
|
treeshake: getClientTreeshakeConfig()
|
|
1951
2001
|
})
|
|
1952
2002
|
}
|
|
@@ -1957,7 +2007,7 @@ function vinext(options = {}) {
|
|
|
1957
2007
|
"react",
|
|
1958
2008
|
"react-dom",
|
|
1959
2009
|
"react-dom/server",
|
|
1960
|
-
|
|
2010
|
+
...ipaddrSsrExternal,
|
|
1961
2011
|
...nextServerExternal
|
|
1962
2012
|
],
|
|
1963
2013
|
noExternal: true
|
|
@@ -2031,16 +2081,14 @@ function vinext(options = {}) {
|
|
|
2031
2081
|
Object.assign(config, { logger: createOptionalOptimizeDepsLogger(config.logger, optionalWarnings) });
|
|
2032
2082
|
}
|
|
2033
2083
|
if (config.worker?.rolldownOptions) {
|
|
2034
|
-
const workerFileNames =
|
|
2084
|
+
const workerFileNames = createWorkerFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? ""), config.root);
|
|
2035
2085
|
const workerOutputs = config.worker.rolldownOptions.output;
|
|
2036
2086
|
config.worker.rolldownOptions.output = Array.isArray(workerOutputs) ? (workerOutputs.length > 0 ? workerOutputs : [{}]).map((output) => ({
|
|
2037
2087
|
...output,
|
|
2038
|
-
|
|
2039
|
-
chunkFileNames: workerFileNames
|
|
2088
|
+
...workerFileNames
|
|
2040
2089
|
})) : {
|
|
2041
2090
|
...workerOutputs,
|
|
2042
|
-
|
|
2043
|
-
chunkFileNames: workerFileNames
|
|
2091
|
+
...workerFileNames
|
|
2044
2092
|
};
|
|
2045
2093
|
}
|
|
2046
2094
|
sassComposesLoader.setResolvedConfig(config);
|
|
@@ -2114,8 +2162,9 @@ function vinext(options = {}) {
|
|
|
2114
2162
|
}
|
|
2115
2163
|
},
|
|
2116
2164
|
resolveId: {
|
|
2117
|
-
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}`) },
|
|
2118
2166
|
handler(id, importer) {
|
|
2167
|
+
if (nextImageAliasTargetRE.test(id)) return this.environment?.name === "rsc" ? RESOLVED_NEXT_IMAGE_RSC : void 0;
|
|
2119
2168
|
const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
|
|
2120
2169
|
if (cleanId === "vinext/server/app-rsc-combined-handler") {
|
|
2121
2170
|
if (_canExternalizeAppRscHandler && this.environment?.name === "rsc" && this.environment.config?.command === "serve") return {
|
|
@@ -2132,6 +2181,7 @@ function vinext(options = {}) {
|
|
|
2132
2181
|
return _appRscHandlerPath;
|
|
2133
2182
|
}
|
|
2134
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 });
|
|
2135
2185
|
if (cleanId.startsWith("vinext/shims/")) return resolveShimModulePath(_shimsDir, stripJsExtension(stripViteModuleQuery(cleanId.slice(13))));
|
|
2136
2186
|
if (cleanId === VIRTUAL_WORKER_ENTRY) return RESOLVED_WORKER_ENTRY;
|
|
2137
2187
|
if (selectedMultiStageOutput && (cleanId === "vinext/server/app-router-entry" || cleanId === "vinext/server/pages-router-entry")) return RESOLVED_WORKER_ENTRY;
|
|
@@ -2174,6 +2224,7 @@ function vinext(options = {}) {
|
|
|
2174
2224
|
if (cleanId === VIRTUAL_APP_RESPONSE_ENTRY) return RESOLVED_APP_RESPONSE_ENTRY;
|
|
2175
2225
|
if (cleanId === VIRTUAL_APP_SSR_ENTRY) return RESOLVED_APP_SSR_ENTRY;
|
|
2176
2226
|
if (cleanId === VIRTUAL_APP_BROWSER_ENTRY) return RESOLVED_APP_BROWSER_ENTRY;
|
|
2227
|
+
if (cleanId === VIRTUAL_APP_ROUTE_MANIFEST) return RESOLVED_APP_ROUTE_MANIFEST;
|
|
2177
2228
|
if (cleanId === VIRTUAL_APP_CAPABILITIES) return RESOLVED_APP_CAPABILITIES;
|
|
2178
2229
|
if (cleanId === "next/root-params" || cleanId === "next/root-params.js") return RESOLVED_ROOT_PARAMS;
|
|
2179
2230
|
if (cleanId === "virtual:vinext-cache-adapters" || cleanId.endsWith("/virtual:vinext-cache-adapters")) return RESOLVED_CACHE_ADAPTERS;
|
|
@@ -2207,7 +2258,8 @@ function vinext(options = {}) {
|
|
|
2207
2258
|
].join("\n");
|
|
2208
2259
|
const entry = hasAppDir ? "vinext/server/app-router-entry" : "vinext/server/pages-router-entry";
|
|
2209
2260
|
if (!hasAppDir && hasNitroPlugin) return [
|
|
2210
|
-
`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;"],
|
|
2211
2263
|
"export default { fetch(request, env, ctx) {",
|
|
2212
2264
|
` return worker.fetch(request, env, { ...ctx, hostRuntime: ${JSON.stringify(nitroHostRuntime)} });`,
|
|
2213
2265
|
"} };"
|
|
@@ -2238,7 +2290,12 @@ function vinext(options = {}) {
|
|
|
2238
2290
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
2239
2291
|
const pagesRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
2240
2292
|
const moduleFilePaths = [...appFilePath ? [appFilePath] : [], ...pagesRoutes.map((route) => route.filePath)];
|
|
2241
|
-
|
|
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);
|
|
2242
2299
|
for (const moduleFilePath of moduleFilePaths) {
|
|
2243
2300
|
const stylesheetAssets = await collectDevPagesAppStylesheetAssets(moduleFilePath, getModuleDependencies);
|
|
2244
2301
|
if (stylesheetAssets.length > 0) ssrManifest[toSlash(moduleFilePath)] = stylesheetAssets;
|
|
@@ -2259,6 +2316,9 @@ function vinext(options = {}) {
|
|
|
2259
2316
|
rscClassificationManifests.set(id, collectRouteClassificationManifest(routes));
|
|
2260
2317
|
rscActionOwnerRoutes = this.environment.config.command === "build" && hasServerActions ? routes : null;
|
|
2261
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] : []];
|
|
2262
2322
|
}
|
|
2263
2323
|
return (id === RESOLVED_APP_REQUEST_ENTRY ? generateAppRequestRscEntry : id === RESOLVED_APP_RESPONSE_ENTRY ? generateAppResponseRscEntry : generateRscEntry)(appDir, routes, middlewarePath, metaRoutes, globalErrorPath, nextConfig?.basePath, nextConfig?.trailingSlash, {
|
|
2264
2324
|
redirects: nextConfig?.redirects,
|
|
@@ -2273,6 +2333,7 @@ function vinext(options = {}) {
|
|
|
2273
2333
|
nodeOpenTelemetryLoader: registerNodeOpenTelemetryLoader,
|
|
2274
2334
|
assetPrefix: nextConfig?.assetPrefix,
|
|
2275
2335
|
crossOrigin: nextConfig?.crossOrigin,
|
|
2336
|
+
skipProxyUrlNormalize: nextConfig?.skipProxyUrlNormalize,
|
|
2276
2337
|
skipTrailingSlashRedirect: nextConfig?.skipTrailingSlashRedirect,
|
|
2277
2338
|
expireTime: nextConfig?.expireTime,
|
|
2278
2339
|
reactMaxHeadersLength: nextConfig?.reactMaxHeadersLength,
|
|
@@ -2302,27 +2363,31 @@ function vinext(options = {}) {
|
|
|
2302
2363
|
devForwardedMiddlewareContextKey: isServeCommand && this.environment.config.consumer === "server" ? devForwardedMiddlewareContextKey : void 0
|
|
2303
2364
|
}, instrumentationPath);
|
|
2304
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");
|
|
2305
2371
|
if (id === RESOLVED_ROOT_PARAMS) return generateRootParamsModule((hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : []).flatMap((route) => route.rootParamNames ?? []));
|
|
2306
2372
|
if (id === RESOLVED_CACHE_ADAPTERS) return generateCacheAdaptersModule(options.cache);
|
|
2307
2373
|
if (id === RESOLVED_CDN_CACHE_ADAPTER) return generateCdnCacheAdapterModule(options.cache);
|
|
2308
2374
|
if (id === RESOLVED_IMAGE_ADAPTERS) return generateImageAdaptersModule(options.images);
|
|
2309
2375
|
if (id === RESOLVED_APP_SSR_ENTRY && hasAppDir) {
|
|
2310
2376
|
recordServerEntryLoad(this.environment?.name, id);
|
|
2311
|
-
return generateSsrEntry(hasPagesDir);
|
|
2377
|
+
return generateSsrEntry(hasPagesDir, nitroPublicFiles ? NITRO_PUBLIC_FILES_ENTRY : null);
|
|
2312
2378
|
}
|
|
2313
2379
|
if (id === RESOLVED_APP_BROWSER_ENTRY && hasAppDir) {
|
|
2314
2380
|
const graph = await appRouteGraph(appDir, nextConfig?.pageExtensions, fileMatcher);
|
|
2315
|
-
const pagesPrefetchRoutes = hasPagesDir ?
|
|
2381
|
+
const pagesPrefetchRoutes = hasPagesDir ? (await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher)).map((route) => ({
|
|
2316
2382
|
canPrefetchLoadingShell: false,
|
|
2317
2383
|
isDynamic: route.isDynamic,
|
|
2318
2384
|
patternParts: [...route.patternParts]
|
|
2319
|
-
}))
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
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);
|
|
2326
2391
|
}
|
|
2327
2392
|
if (id === RESOLVED_APP_CAPABILITIES && hasAppDir) {
|
|
2328
2393
|
const hasServerActions = await resolveHasServerActions(this.environment.config);
|
|
@@ -2488,12 +2553,36 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2488
2553
|
name: "vinext:css-url-assets-defaults",
|
|
2489
2554
|
apply: "build",
|
|
2490
2555
|
configEnvironment(name, config) {
|
|
2491
|
-
if (name === "client")
|
|
2492
|
-
|
|
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;
|
|
2493
2571
|
const output = getBuildBundlerOptions(config.build)?.output;
|
|
2494
|
-
if (Array.isArray(output)
|
|
2495
|
-
const
|
|
2496
|
-
|
|
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 }) } };
|
|
2497
2586
|
}
|
|
2498
2587
|
},
|
|
2499
2588
|
{
|
|
@@ -2672,6 +2761,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2672
2761
|
},
|
|
2673
2762
|
configureServer(server) {
|
|
2674
2763
|
installSocketErrorBackstop({ runningServer: true });
|
|
2764
|
+
devPagesModuleDependencyStores.clear();
|
|
2675
2765
|
const devBuildId = nextConfig?.buildId ?? process.env.__VINEXT_BUILD_ID ?? "development";
|
|
2676
2766
|
server.middlewares.use((req, _res, next) => {
|
|
2677
2767
|
req.__vinextOriginalEncodedUrl ??= req.url;
|
|
@@ -2747,6 +2837,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2747
2837
|
}
|
|
2748
2838
|
pagesRunner?.clearCache();
|
|
2749
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
|
+
}
|
|
2750
2854
|
function invalidatePagesClientAssetsModule() {
|
|
2751
2855
|
for (const env of Object.values(server.environments)) {
|
|
2752
2856
|
const mod = env.moduleGraph.getModuleById(RESOLVED_PAGES_CLIENT_ASSETS);
|
|
@@ -2759,11 +2863,18 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2759
2863
|
if (!graph) return;
|
|
2760
2864
|
for (const mod of graph.idToModuleMap.values()) if (mod.id?.includes("?html-proxy&index=")) graph.invalidateModule(mod);
|
|
2761
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
|
+
}
|
|
2762
2872
|
function invalidateAppRoutingModules() {
|
|
2763
2873
|
invalidateAppRouteCache();
|
|
2764
2874
|
invalidateMetadataFileCache();
|
|
2765
2875
|
invalidateRscEntryModule();
|
|
2766
2876
|
invalidateRootParamsModule();
|
|
2877
|
+
invalidateAppRouteManifestModule();
|
|
2767
2878
|
}
|
|
2768
2879
|
let hybridRouteValidation = Promise.resolve();
|
|
2769
2880
|
let hybridRouteValidationError = null;
|
|
@@ -2876,6 +2987,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2876
2987
|
server.ws.send({ type: "full-reload" });
|
|
2877
2988
|
}
|
|
2878
2989
|
server.watcher.on("add", (filePath) => {
|
|
2990
|
+
invalidatePagesModuleDependencies(filePath, "create");
|
|
2879
2991
|
invalidatePagesMiddlewareMatcher(filePath);
|
|
2880
2992
|
updatePublicFileRoute(filePath, true);
|
|
2881
2993
|
let routeChanged = false;
|
|
@@ -2901,6 +3013,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2901
3013
|
}
|
|
2902
3014
|
});
|
|
2903
3015
|
server.watcher.on("change", (filePath) => {
|
|
3016
|
+
invalidatePagesModuleDependencies(filePath, "update");
|
|
2904
3017
|
invalidatePagesMiddlewareMatcher(filePath);
|
|
2905
3018
|
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2906
3019
|
const pageFile = toSlash(filePath);
|
|
@@ -2917,6 +3030,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2917
3030
|
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2918
3031
|
});
|
|
2919
3032
|
server.watcher.on("unlink", (filePath) => {
|
|
3033
|
+
invalidatePagesModuleDependencies(filePath, "delete");
|
|
2920
3034
|
invalidatePagesMiddlewareMatcher(filePath);
|
|
2921
3035
|
updatePublicFileRoute(filePath, false);
|
|
2922
3036
|
let routeChanged = false;
|
|
@@ -3329,6 +3443,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3329
3443
|
dataNotFoundResponse,
|
|
3330
3444
|
rawSearch: url.includes("?") ? url.slice(url.indexOf("?")) : "",
|
|
3331
3445
|
configMatchPathname,
|
|
3446
|
+
restoreLocaleRootTrailingSlash: shouldRestoreLocaleRootTrailingSlash(canonicalOriginalUrl.split("?")[0], nextConfig ?? {}),
|
|
3332
3447
|
runMiddleware: devRunMiddlewareAdapter,
|
|
3333
3448
|
matchApiRoute: async (apiUrl) => {
|
|
3334
3449
|
const devApiRoutes = await getDevApiRoutes();
|
|
@@ -3373,7 +3488,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3373
3488
|
}) : new Response("Invalid image optimization parameters", { status: 400 });
|
|
3374
3489
|
}
|
|
3375
3490
|
const isRetrievalMethod = req.method === "GET" || req.method === "HEAD";
|
|
3376
|
-
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;
|
|
3377
3492
|
if (!isRetrievalMethod) return isExistingDevPublicFile(normalizePathnameForRouteMatch(requestPathname)) ? methodNotAllowedResponse("GET, HEAD") : false;
|
|
3378
3493
|
return serveRewrittenViteFilesystemRoute(req, res, requestPathname, stagedHeaders);
|
|
3379
3494
|
}
|
|
@@ -3673,12 +3788,15 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3673
3788
|
},
|
|
3674
3789
|
{
|
|
3675
3790
|
name: "vinext:compiler-define-server",
|
|
3676
|
-
configEnvironment(name) {
|
|
3677
|
-
if (name === "client") return null;
|
|
3791
|
+
configEnvironment(name, config) {
|
|
3792
|
+
if (name === "client" || config.consumer === "client") return null;
|
|
3678
3793
|
const serverDefines = { ...nextConfig.compilerDefineServer };
|
|
3679
3794
|
serverDefines["process.env.NEXT_RUNTIME"] = JSON.stringify("nodejs");
|
|
3680
3795
|
serverDefines["process.env.NEXT_PHASE"] = "globalThis.__VINEXT_NEXT_PHASE";
|
|
3681
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);
|
|
3682
3800
|
if (previewBuildCredentials) {
|
|
3683
3801
|
serverDefines["process.env.__VINEXT_PREVIEW_MODE_ID"] = JSON.stringify(previewBuildCredentials.id);
|
|
3684
3802
|
serverDefines["process.env.__VINEXT_PREVIEW_MODE_SIGNING_KEY"] = JSON.stringify(previewBuildCredentials.signingKey);
|
|
@@ -3896,11 +4014,25 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3896
4014
|
},
|
|
3897
4015
|
{
|
|
3898
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
|
+
},
|
|
3899
4030
|
nitro: { setup: (nitro) => {
|
|
3900
4031
|
nitroBuildDir = nitro.options.buildDir ? path.resolve(root, nitro.options.buildDir) : void 0;
|
|
3901
4032
|
nitroHostRuntime = nitro.options.exportConditions?.includes("workerd") ? "worker" : "node";
|
|
3902
4033
|
if (!nextConfig) return;
|
|
3903
4034
|
if (!hasAppDir && !hasPagesDir) return;
|
|
4035
|
+
nitroPublicFiles = registerNitroPublicFiles(nitro.options, NITRO_PUBLIC_FILES_PLUGIN, () => scanPublicFiles(root, nitroPublicDir));
|
|
3904
4036
|
if (resolvedServerExternalPackages.length > 0) nitro.options.traceDeps = [.../* @__PURE__ */ new Set([...nitro.options.traceDeps ?? [], ...resolvedServerExternalPackages])];
|
|
3905
4037
|
} }
|
|
3906
4038
|
},
|
|
@@ -3936,15 +4068,17 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3936
4068
|
writeBundle: {
|
|
3937
4069
|
sequential: true,
|
|
3938
4070
|
order: "post",
|
|
3939
|
-
handler(outputOptions) {
|
|
4071
|
+
async handler(outputOptions) {
|
|
3940
4072
|
const clientDir = outputOptions.dir;
|
|
3941
4073
|
if (!clientDir) return;
|
|
3942
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() : [];
|
|
3943
4076
|
emitNextClientRuntimeManifests({
|
|
3944
4077
|
clientDir,
|
|
3945
4078
|
assetsSubdir: resolveAssetsDir(nextConfig.assetPrefix),
|
|
3946
4079
|
buildId: nextConfig.buildId,
|
|
3947
|
-
rewrites: nextConfig.rewrites
|
|
4080
|
+
rewrites: nextConfig.rewrites,
|
|
4081
|
+
pages: pageRoutes.map((route) => getPagesManifestPage(pagesDir, route.filePath, fileMatcher))
|
|
3948
4082
|
});
|
|
3949
4083
|
}
|
|
3950
4084
|
}
|
|
@@ -4046,6 +4180,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
4046
4180
|
appBootstrapPreinitModules: runtimeMetadata.appBootstrapPreinitModules,
|
|
4047
4181
|
ssrManifest,
|
|
4048
4182
|
cssGraph: runtimeMetadata.cssGraph,
|
|
4183
|
+
sharedChunks: runtimeMetadata.sharedChunks,
|
|
4049
4184
|
lazyChunks: runtimeMetadata.lazyChunks ?? void 0,
|
|
4050
4185
|
dynamicPreloads: runtimeMetadata.dynamicPreloads ?? void 0,
|
|
4051
4186
|
crossOrigin: nextConfig.crossOrigin ?? "",
|
|
@@ -4247,14 +4382,35 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
4247
4382
|
onComplete() {
|
|
4248
4383
|
rscActionOwnerRoutes = null;
|
|
4249
4384
|
rscActionOwnerSharedRoots = [];
|
|
4385
|
+
clientReferenceRoutes = null;
|
|
4386
|
+
clientReferenceAlwaysRenderedFiles = [];
|
|
4387
|
+
clientReferenceRoutelessFiles = [];
|
|
4250
4388
|
}
|
|
4251
4389
|
}));
|
|
4252
4390
|
plugins.push(createScanBuildCssPlugin());
|
|
4253
4391
|
}
|
|
4254
4392
|
if (rscPluginPromise) {
|
|
4255
4393
|
plugins.push(createRscReferenceValidationNormalizerPlugin());
|
|
4256
|
-
plugins.push(createRscClientReferenceLoadersPlugin(
|
|
4257
|
-
|
|
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
|
+
}
|
|
4258
4414
|
plugins.push({
|
|
4259
4415
|
name: "vinext:plain-pages-build-config",
|
|
4260
4416
|
apply: "build",
|