vinext 1.0.0-beta.9 → 1.0.1
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 +150 -92
- package/THIRD_PARTY_LICENSES.md +51 -0
- package/dist/_virtual/_rolldown/runtime.js +25 -0
- package/dist/build/action-owner-manifest.d.ts +8 -9
- package/dist/build/action-owner-manifest.js +23 -5
- package/dist/build/assets-ignore.d.ts +3 -4
- package/dist/build/clean-output.d.ts +2 -3
- package/dist/build/client-build-config.d.ts +40 -12
- package/dist/build/client-build-config.js +76 -6
- package/dist/build/css-url-assets.d.ts +4 -5
- package/dist/build/css-url-assets.js +5 -2
- package/dist/build/google-fonts/build-url.d.ts +3 -4
- package/dist/build/google-fonts/fallback-metrics.d.ts +3 -4
- package/dist/build/google-fonts/find-font-files-in-css.d.ts +2 -3
- package/dist/build/google-fonts/font-metadata.d.ts +2 -3
- package/dist/build/google-fonts/get-axes.d.ts +2 -3
- package/dist/build/google-fonts/sort-variants.d.ts +2 -3
- package/dist/build/google-fonts/validate.d.ts +2 -3
- package/dist/build/google-fonts/validate.js +8 -4
- package/dist/build/inject-pregenerated-paths.d.ts +2 -3
- package/dist/build/inject-pregenerated-paths.js +16 -14
- package/dist/build/inline-css.d.ts +3 -4
- package/dist/build/layout-classification-types.d.ts +4 -5
- package/dist/build/layout-classification.d.ts +7 -8
- package/dist/build/lifecycle.d.ts +42 -0
- package/dist/build/lifecycle.js +253 -0
- package/dist/build/module-dependency-cache.d.ts +2 -3
- package/dist/build/next-client-runtime-manifests.d.ts +4 -5
- package/dist/build/nitro-route-rules.d.ts +6 -7
- package/dist/build/nitro-route-rules.js +1 -1
- package/dist/build/pages-client-assets-module.d.ts +4 -8
- package/dist/build/pages-client-assets-module.js +7 -14
- package/dist/build/precompress.d.ts +2 -3
- package/dist/build/precompress.js +1 -1
- package/dist/build/prerender-cloudflare-loader.d.ts +4 -0
- package/dist/build/prerender-cloudflare-loader.js +49 -0
- package/dist/build/prerender-paths.d.ts +36 -11
- package/dist/build/prerender-paths.js +274 -102
- package/dist/build/prerender-phase.d.ts +2 -3
- package/dist/build/prerender-server-entry.js +11 -3
- package/dist/build/prerender-server-pool.d.ts +9 -6
- package/dist/build/prerender-server-pool.js +8 -5
- package/dist/build/prerender.d.ts +73 -16
- package/dist/build/prerender.js +272 -80
- package/dist/build/preview-credentials.d.ts +5 -6
- package/dist/build/preview-credentials.js +2 -2
- package/dist/build/public-dir-conflict.d.ts +5 -6
- package/dist/build/public-dir-conflict.js +2 -1
- package/dist/build/report.d.ts +24 -20
- package/dist/build/report.js +10 -2
- package/dist/build/route-classification-injector.d.ts +2 -3
- package/dist/build/route-classification-manifest.d.ts +5 -6
- package/dist/build/run-prerender.d.ts +11 -9
- package/dist/build/run-prerender.js +26 -16
- package/dist/build/server-entry.d.ts +6 -0
- package/dist/build/server-entry.js +34 -0
- package/dist/build/server-manifest.d.ts +8 -3
- package/dist/build/server-manifest.js +14 -2
- package/dist/build/ssr-manifest.d.ts +5 -6
- package/dist/build/standalone.d.ts +2 -3
- package/dist/build/standalone.js +2 -2
- package/dist/build/static-export.d.ts +6 -7
- package/dist/cache/cache-adapters-virtual.d.ts +60 -20
- package/dist/cache/cache-adapters-virtual.js +50 -7
- package/dist/check.d.ts +11 -10
- package/dist/check.js +467 -176
- package/dist/cli-args.d.ts +7 -16
- package/dist/cli-args.js +2 -45
- package/dist/cli-dev-config.d.ts +10 -7
- package/dist/cli-dev-config.js +160 -3
- package/dist/cli.js +124 -442
- package/dist/client/app-nav-failure-handler.d.ts +6 -7
- package/dist/client/browser-globals.d.ts +4 -0
- package/dist/client/browser-globals.js +5 -0
- package/dist/client/client-rewrite-matcher.d.ts +2 -3
- package/dist/client/client-rewrites.d.ts +4 -5
- package/dist/client/dev-error-overlay-store.d.ts +13 -14
- package/dist/client/dev-error-overlay.d.ts +15 -15
- package/dist/client/dev-error-overlay.js +8 -5
- package/dist/client/instrumentation-client-inject.d.ts +3 -4
- package/dist/client/instrumentation-client-state.d.ts +5 -6
- package/dist/client/instrumentation-client.d.ts +3 -4
- package/dist/client/navigation-runtime.d.ts +20 -17
- package/dist/client/navigation-runtime.js +4 -3
- package/dist/client/pages-router-link-navigation.d.ts +4 -5
- package/dist/client/react-instance.d.ts +2 -3
- package/dist/client/validate-module-path.d.ts +2 -3
- package/dist/client/vinext-next-data.d.ts +7 -10
- package/dist/client/window-next.d.ts +4 -5
- package/dist/config/config-matchers.d.ts +16 -16
- package/dist/config/config-matchers.js +2 -4
- package/dist/config/dotenv.d.ts +3 -4
- package/dist/config/dotenv.js +14 -2
- package/dist/config/next-config.d.ts +31 -27
- package/dist/config/next-config.js +163 -16
- package/dist/config/prerender.d.ts +20 -16
- package/dist/config/prerender.js +10 -4
- package/dist/config/request-context.d.ts +5 -6
- package/dist/config/server-external-packages.d.ts +14 -3
- package/dist/config/server-external-packages.js +37 -3
- package/dist/config/tsconfig-paths.d.ts +3 -4
- package/dist/deps/.pnpm/ignore@5.3.2/deps/ignore/index.js +189 -0
- package/dist/deps/.pnpm/ua-parser-js@1.0.35/deps/ua-parser-js/src/ua-parser.js +1057 -0
- package/dist/entries/app-browser-entry.d.ts +4 -5
- package/dist/entries/app-browser-entry.js +1 -3
- package/dist/entries/app-rsc-entry.d.ts +10 -3
- package/dist/entries/app-rsc-entry.js +503 -51
- package/dist/entries/app-rsc-manifest.d.ts +4 -3
- package/dist/entries/app-rsc-manifest.js +26 -8
- package/dist/entries/app-ssr-entry.d.ts +2 -3
- package/dist/entries/app-ssr-entry.js +8 -1
- package/dist/entries/pages-client-entry.d.ts +3 -3
- package/dist/entries/pages-client-entry.js +17 -2
- package/dist/entries/pages-server-entry.d.ts +13 -3
- package/dist/entries/pages-server-entry.js +234 -33
- package/dist/entries/runtime-entry-module.d.ts +4 -5
- package/dist/image/image-adapters-virtual.d.ts +4 -5
- package/dist/index.d.ts +10 -11
- package/dist/index.js +848 -255
- package/dist/init-cloudflare.d.ts +26 -17
- package/dist/init-cloudflare.js +711 -103
- package/dist/init-platform.d.ts +26 -22
- package/dist/init-platform.js +85 -29
- package/dist/init.d.ts +19 -13
- package/dist/init.js +126 -42
- package/dist/plugins/action-owner-manifest.d.ts +3 -4
- package/dist/plugins/action-owner-manifest.js +10 -3
- package/dist/plugins/ast-scope.d.ts +10 -11
- package/dist/plugins/ast-scope.js +10 -22
- package/dist/plugins/ast-utils.d.ts +16 -29
- package/dist/plugins/ast-utils.js +27 -71
- package/dist/plugins/async-hooks-stub.d.ts +2 -3
- package/dist/plugins/client-reference-dedup.d.ts +4 -5
- package/dist/plugins/commonjs-syntax.d.ts +16 -0
- package/dist/plugins/commonjs-syntax.js +22 -0
- package/dist/plugins/css-data-url.d.ts +2 -3
- package/dist/plugins/css-module-imports.d.ts +3 -4
- package/dist/plugins/css-module-imports.js +1 -1
- package/dist/plugins/dynamic-preload-metadata.d.ts +3 -4
- package/dist/plugins/dynamic-preload-metadata.js +55 -154
- package/dist/plugins/environment.d.ts +2 -3
- package/dist/plugins/extensionless-dynamic-import.d.ts +2 -3
- package/dist/plugins/extensionless-dynamic-import.js +6 -10
- package/dist/plugins/fonts.d.ts +10 -11
- package/dist/plugins/fonts.js +4 -3
- package/dist/plugins/ignore-dynamic-requests.d.ts +14 -4
- package/dist/plugins/ignore-dynamic-requests.js +113 -91
- package/dist/plugins/import-meta-url.d.ts +6 -7
- package/dist/plugins/import-meta-url.js +36 -48
- package/dist/plugins/instrumentation-client.d.ts +3 -3
- package/dist/plugins/instrumentation-client.js +46 -10
- package/dist/plugins/middleware-export-validation.d.ts +3 -4
- package/dist/plugins/middleware-export-validation.js +3 -3
- package/dist/plugins/middleware-server-only.d.ts +2 -3
- package/dist/plugins/og-asset-ownership.d.ts +5 -4
- package/dist/plugins/og-asset-ownership.js +24 -13
- package/dist/plugins/og-assets.d.ts +22 -5
- package/dist/plugins/og-assets.js +82 -21
- package/dist/plugins/og-harfbuzz.d.ts +24 -0
- package/dist/plugins/og-harfbuzz.js +271 -0
- package/dist/plugins/optimize-imports.d.ts +7 -7
- package/dist/plugins/optimize-imports.js +34 -45
- package/dist/plugins/pages-node-externals.d.ts +2 -3
- package/dist/plugins/pages-node-externals.js +6 -11
- package/dist/plugins/postcss.d.ts +8 -4
- package/dist/plugins/postcss.js +1 -1
- package/dist/plugins/remove-console.d.ts +2 -3
- package/dist/plugins/remove-console.js +0 -1
- package/dist/plugins/require-condition-resolution.d.ts +3 -4
- package/dist/plugins/require-condition-resolution.js +17 -18
- package/dist/plugins/require-context.d.ts +3 -3
- package/dist/plugins/require-context.js +41 -22
- package/dist/plugins/rsc-client-reference-loaders.d.ts +2 -3
- package/dist/plugins/rsc-client-shim-excludes.d.ts +4 -5
- package/dist/plugins/rsc-client-shim-excludes.js +1 -0
- package/dist/plugins/rsc-reference-validation-normalizer.d.ts +2 -3
- package/dist/plugins/sass.d.ts +7 -8
- package/dist/plugins/sass.js +7 -4
- package/dist/plugins/scan-build-css.d.ts +12 -0
- package/dist/plugins/scan-build-css.js +39 -0
- package/dist/plugins/server-externals-manifest.d.ts +2 -3
- package/dist/plugins/strip-server-exports.d.ts +7 -6
- package/dist/plugins/strip-server-exports.js +4 -2
- package/dist/plugins/styled-jsx.d.ts +2 -3
- package/dist/plugins/styled-jsx.js +7 -7
- package/dist/plugins/transform-cache.d.ts +2 -3
- package/dist/plugins/transform-result.d.ts +21 -4
- package/dist/plugins/transform-result.js +23 -2
- package/dist/plugins/transitive-externals.d.ts +2 -3
- package/dist/plugins/typeof-window.d.ts +16 -7
- package/dist/plugins/typeof-window.js +62 -39
- package/dist/plugins/use-cache-callable.d.ts +2 -5
- package/dist/plugins/use-cache-callable.js +43 -22
- package/dist/plugins/wasm-module-import.d.ts +2 -3
- package/dist/plugins/worker-image-imports.d.ts +2 -3
- package/dist/plugins/worker-image-imports.js +6 -8
- package/dist/routing/app-route-graph.d.ts +18 -19
- package/dist/routing/app-route-graph.js +5 -6
- package/dist/routing/app-route-ids.d.ts +3 -0
- package/dist/routing/app-route-ids.js +6 -0
- package/dist/routing/app-router.d.ts +19 -6
- package/dist/routing/app-router.js +24 -2
- package/dist/routing/file-matcher.d.ts +9 -10
- package/dist/routing/pages-router.d.ts +6 -6
- package/dist/routing/pages-router.js +1 -1
- package/dist/routing/route-matching.d.ts +4 -5
- package/dist/routing/route-matching.js +4 -2
- package/dist/routing/route-pattern.d.ts +13 -14
- package/dist/routing/route-trie.d.ts +5 -6
- package/dist/routing/route-validation.d.ts +3 -4
- package/dist/routing/route-validation.js +12 -11
- package/dist/routing/utils.d.ts +13 -14
- package/dist/server/accept-encoding.d.ts +9 -10
- package/dist/server/api-handler.d.ts +2 -3
- package/dist/server/api-handler.js +9 -6
- package/dist/server/app-action-forwarding.d.ts +3 -4
- package/dist/server/app-action-forwarding.js +1 -1
- package/dist/server/app-action-request.d.ts +2 -3
- package/dist/server/app-bfcache-id.d.ts +4 -4
- package/dist/server/app-bfcache-id.js +7 -1
- package/dist/server/app-bfcache-identity.d.ts +8 -9
- package/dist/server/app-bfcache-identity.js +1 -2
- package/dist/server/app-browser-action-result.d.ts +15 -16
- package/dist/server/app-browser-client-reuse-manifest.d.ts +2 -3
- package/dist/server/app-browser-entry.js +91 -36
- package/dist/server/app-browser-error.d.ts +5 -6
- package/dist/server/app-browser-error.js +9 -3
- package/dist/server/app-browser-history-controller.d.ts +4 -5
- package/dist/server/app-browser-hydration.d.ts +16 -6
- package/dist/server/app-browser-hydration.js +15 -2
- package/dist/server/app-browser-interception-context.d.ts +3 -4
- package/dist/server/app-browser-mpa-navigation.d.ts +4 -5
- package/dist/server/app-browser-navigation-abort.d.ts +3 -4
- package/dist/server/app-browser-navigation-controller.d.ts +8 -8
- package/dist/server/app-browser-navigation-controller.js +9 -5
- package/dist/server/app-browser-navigation-response.d.ts +2 -3
- package/dist/server/app-browser-popstate.d.ts +4 -5
- package/dist/server/app-browser-prefetch-response.d.ts +5 -6
- package/dist/server/app-browser-rsc-redirect.d.ts +4 -5
- package/dist/server/app-browser-server-action-client.d.ts +7 -6
- package/dist/server/app-browser-server-action-client.js +9 -5
- package/dist/server/app-browser-server-action-navigation.d.ts +2 -3
- package/dist/server/app-browser-state.d.ts +17 -17
- package/dist/server/app-browser-state.js +7 -3
- package/dist/server/app-browser-stream.d.ts +5 -6
- package/dist/server/app-browser-stream.js +8 -6
- package/dist/server/app-browser-supplemental-refresh.d.ts +11 -12
- package/dist/server/app-browser-visible-commit.d.ts +6 -7
- package/dist/server/app-client-reference-preloader.d.ts +2 -3
- package/dist/server/app-elements-wire-key.d.ts +25 -0
- package/dist/server/app-elements-wire-key.js +69 -0
- package/dist/server/app-elements-wire.d.ts +34 -53
- package/dist/server/app-elements-wire.js +4 -75
- package/dist/server/app-elements.d.ts +5 -5
- package/dist/server/app-elements.js +1 -1
- package/dist/server/app-fallback-renderer.d.ts +4 -4
- package/dist/server/app-fallback-renderer.js +6 -6
- package/dist/server/app-fetch-tracing.d.ts +15 -0
- package/dist/server/app-fetch-tracing.js +38 -0
- package/dist/server/app-history-state.d.ts +25 -27
- package/dist/server/app-history-state.js +21 -16
- package/dist/server/app-hook-warning-suppression.d.ts +2 -3
- package/dist/server/app-hydration-cache-publication.d.ts +3 -4
- package/dist/server/app-inline-css-client.d.ts +3 -4
- package/dist/server/app-interception-context-header.d.ts +2 -3
- package/dist/server/app-layout-param-observation.d.ts +7 -8
- package/dist/server/app-metadata-tracing.d.ts +12 -0
- package/dist/server/app-metadata-tracing.js +17 -0
- package/dist/server/app-middleware.d.ts +7 -7
- package/dist/server/app-middleware.js +2 -3
- package/dist/server/app-mounted-slots-header.d.ts +2 -3
- package/dist/server/app-mounted-slots-header.js +2 -2
- package/dist/server/app-optimistic-routing.d.ts +10 -11
- package/dist/server/app-optimistic-routing.js +3 -2
- package/dist/server/app-page-boundary-render.d.ts +6 -6
- package/dist/server/app-page-boundary-render.js +10 -4
- package/dist/server/app-page-boundary.d.ts +9 -10
- package/dist/server/app-page-boundary.js +1 -1
- package/dist/server/app-page-cache-finalizer.d.ts +18 -9
- package/dist/server/app-page-cache-finalizer.js +51 -16
- package/dist/server/app-page-cache-render.d.ts +8 -5
- package/dist/server/app-page-cache-render.js +22 -4
- package/dist/server/app-page-cache.d.ts +28 -9
- package/dist/server/app-page-cache.js +95 -24
- package/dist/server/app-page-dispatch.d.ts +34 -12
- package/dist/server/app-page-dispatch.js +181 -64
- package/dist/server/app-page-element-builder.d.ts +13 -11
- package/dist/server/app-page-element-builder.js +104 -61
- package/dist/server/app-page-execution.d.ts +14 -14
- package/dist/server/app-page-execution.js +11 -7
- package/dist/server/app-page-head.d.ts +19 -16
- package/dist/server/app-page-head.js +25 -25
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +6 -5
- package/dist/server/app-page-http-access-fallback-metadata.js +9 -2
- package/dist/server/app-page-method.d.ts +5 -11
- package/dist/server/app-page-method.js +2 -9
- package/dist/server/app-page-params.d.ts +5 -6
- package/dist/server/app-page-ppr-runtime.d.ts +2 -2
- package/dist/server/app-page-probe.d.ts +5 -6
- package/dist/server/app-page-probe.js +5 -4
- package/dist/server/app-page-render-identity.d.ts +4 -5
- package/dist/server/app-page-render-observation.d.ts +8 -9
- package/dist/server/app-page-render-observation.js +1 -1
- package/dist/server/app-page-render.d.ts +41 -6
- package/dist/server/app-page-render.js +171 -24
- package/dist/server/app-page-request.d.ts +10 -9
- package/dist/server/app-page-request.js +16 -12
- package/dist/server/app-page-response.d.ts +20 -9
- package/dist/server/app-page-response.js +30 -12
- package/dist/server/app-page-route-wiring.d.ts +15 -15
- package/dist/server/app-page-route-wiring.js +31 -24
- package/dist/server/app-page-search-params-observation.d.ts +26 -5
- package/dist/server/app-page-search-params-observation.js +43 -7
- package/dist/server/app-page-segment-plan.d.ts +2 -3
- package/dist/server/app-page-segment-state.d.ts +11 -12
- package/dist/server/app-page-stream.d.ts +27 -11
- package/dist/server/app-page-stream.js +34 -6
- package/dist/server/app-page-tracing.d.ts +33 -0
- package/dist/server/app-page-tracing.js +50 -0
- package/dist/server/app-pages-bridge.d.ts +6 -6
- package/dist/server/app-pages-bridge.js +18 -4
- package/dist/server/app-post-middleware-context.d.ts +2 -3
- package/dist/server/app-ppr-fallback-shell-render.d.ts +3 -4
- package/dist/server/app-ppr-fallback-shell-render.js +3 -2
- package/dist/server/app-ppr-fallback-shell.d.ts +6 -7
- package/dist/server/app-prerender-endpoints.d.ts +5 -5
- package/dist/server/app-prerender-endpoints.js +3 -1
- package/dist/server/app-prerender-static-params.d.ts +15 -7
- package/dist/server/app-prerender-static-params.js +24 -9
- package/dist/server/app-render-abort-error.d.ts +3 -0
- package/dist/server/app-render-abort-error.js +8 -0
- package/dist/server/app-render-dependency.d.ts +14 -13
- package/dist/server/app-render-dependency.js +5 -1
- package/dist/server/app-request-context.d.ts +3 -4
- package/dist/server/app-request-stage-context.d.ts +5 -0
- package/dist/server/app-request-stage-context.js +11 -0
- package/dist/server/app-request-stage-dispatch.d.ts +25 -0
- package/dist/server/app-request-stage-dispatch.js +54 -0
- package/dist/server/app-request-stage-independent-entry.d.ts +8 -0
- package/dist/server/app-request-stage-independent-entry.js +112 -0
- package/dist/server/app-response-header-provenance.d.ts +13 -7
- package/dist/server/app-response-header-provenance.js +34 -1
- package/dist/server/app-response-stage-entry.d.ts +9 -0
- package/dist/server/app-response-stage-entry.js +87 -0
- package/dist/server/app-route-handler-cache.d.ts +4 -4
- package/dist/server/app-route-handler-cache.js +51 -35
- package/dist/server/app-route-handler-dispatch.d.ts +3 -3
- package/dist/server/app-route-handler-dispatch.js +77 -56
- package/dist/server/app-route-handler-execution.d.ts +26 -14
- package/dist/server/app-route-handler-execution.js +94 -28
- package/dist/server/app-route-handler-middleware-context.d.ts +8 -0
- package/dist/server/app-route-handler-middleware-context.js +15 -0
- package/dist/server/app-route-handler-policy.d.ts +11 -11
- package/dist/server/app-route-handler-policy.js +2 -2
- package/dist/server/app-route-handler-response.d.ts +9 -10
- package/dist/server/app-route-handler-response.js +14 -3
- package/dist/server/app-route-handler-runtime.d.ts +9 -10
- package/dist/server/app-route-handler-runtime.js +20 -16
- package/dist/server/app-route-module-loader.d.ts +6 -7
- package/dist/server/app-route-request-built-ins.d.ts +3 -4
- package/dist/server/app-route-tree-prefetch.d.ts +6 -7
- package/dist/server/app-route-tree-prefetch.js +2 -1
- package/dist/server/app-router-entry.d.ts +4 -1
- package/dist/server/app-router-entry.js +33 -17
- package/dist/server/app-rsc-cache-busting.d.ts +34 -27
- package/dist/server/app-rsc-cache-busting.js +14 -2
- package/dist/server/app-rsc-combined-handler.d.ts +9 -0
- package/dist/server/app-rsc-combined-handler.js +11 -0
- package/dist/server/app-rsc-embedded-chunks.d.ts +6 -7
- package/dist/server/app-rsc-error-handler.d.ts +12 -6
- package/dist/server/app-rsc-error-handler.js +15 -6
- package/dist/server/app-rsc-errors.d.ts +11 -9
- package/dist/server/app-rsc-errors.js +14 -16
- package/dist/server/app-rsc-handler.d.ts +32 -6
- package/dist/server/app-rsc-handler.js +425 -64
- package/dist/server/app-rsc-redirect-flight.d.ts +4 -5
- package/dist/server/app-rsc-render-mode.d.ts +8 -9
- package/dist/server/app-rsc-request-normalization.d.ts +3 -3
- package/dist/server/app-rsc-request-normalization.js +5 -3
- package/dist/server/app-rsc-response-finalizer.d.ts +8 -5
- package/dist/server/app-rsc-response-finalizer.js +10 -7
- package/dist/server/app-rsc-response-stage.d.ts +6 -0
- package/dist/server/app-rsc-response-stage.js +251 -0
- package/dist/server/app-rsc-route-matching.d.ts +3 -4
- package/dist/server/app-rsc-route-matching.js +3 -2
- package/dist/server/app-rsc-state-fingerprint.d.ts +3 -4
- package/dist/server/app-rsc-vary.d.ts +16 -0
- package/dist/server/app-rsc-vary.js +31 -0
- package/dist/server/app-segment-config.d.ts +119 -7
- package/dist/server/app-segment-config.js +242 -2
- package/dist/server/app-server-action-execution.d.ts +18 -13
- package/dist/server/app-server-action-execution.js +86 -33
- package/dist/server/app-ssr-entry.d.ts +14 -4
- package/dist/server/app-ssr-entry.js +62 -15
- package/dist/server/app-ssr-error-meta.d.ts +3 -4
- package/dist/server/app-ssr-error-meta.js +2 -1
- package/dist/server/app-ssr-router-instance.d.ts +2 -3
- package/dist/server/app-ssr-search-params-gate.d.ts +20 -0
- package/dist/server/app-ssr-search-params-gate.js +54 -0
- package/dist/server/app-ssr-stream.d.ts +13 -9
- package/dist/server/app-ssr-stream.js +34 -8
- package/dist/server/app-static-generation.d.ts +4 -5
- package/dist/server/app-visited-response-cache.d.ts +11 -12
- package/dist/server/app-visited-response-cache.js +2 -2
- package/dist/server/app-worker-stages.d.ts +112 -0
- package/dist/server/app-worker-stages.js +105 -0
- package/dist/server/artifact-compatibility.d.ts +11 -12
- package/dist/server/before-interactive-head.d.ts +2 -3
- package/dist/server/bfcache-identity.d.ts +7 -8
- package/dist/server/cache-control.d.ts +35 -13
- package/dist/server/cache-control.js +64 -6
- package/dist/server/cache-headers.d.ts +3 -4
- package/dist/server/cache-proof.d.ts +75 -70
- package/dist/server/cache-proof.js +9 -1
- package/dist/server/cacheability-limits.d.ts +4 -5
- package/dist/server/cacheability-limits.js +2 -2
- package/dist/server/cacheability-manifest.d.ts +42 -16
- package/dist/server/cacheability-manifest.js +60 -10
- package/dist/server/cacheability-request.d.ts +37 -8
- package/dist/server/cacheability-request.js +192 -90
- package/dist/server/client-reuse-manifest.d.ts +17 -18
- package/dist/server/client-reuse-manifest.js +2 -2
- package/dist/server/client-trace-metadata.d.ts +9 -6
- package/dist/server/client-trace-metadata.js +27 -15
- package/dist/server/cloudflare-workers-tracing.d.ts +1 -0
- package/dist/server/cloudflare-workers-tracing.js +8 -0
- package/dist/server/config-headers.d.ts +19 -5
- package/dist/server/config-headers.js +25 -11
- package/dist/server/cookie-utils.d.ts +2 -3
- package/dist/server/csp.d.ts +5 -6
- package/dist/server/default-global-error-module.d.ts +2 -3
- package/dist/server/default-global-not-found-module.d.ts +2 -3
- package/dist/server/default-not-found-module.d.ts +2 -3
- package/dist/server/defer-until-stream-consumed.d.ts +2 -3
- package/dist/server/defer-until-stream-consumed.js +2 -1
- package/dist/server/dev-initial-server-error.d.ts +3 -4
- package/dist/server/dev-initial-server-error.js +2 -1
- package/dist/server/dev-lockfile.d.ts +7 -8
- package/dist/server/dev-lockfile.js +4 -1
- package/dist/server/dev-module-runner.d.ts +2 -3
- package/dist/server/dev-origin-check.d.ts +5 -6
- package/dist/server/dev-route-files.d.ts +2 -3
- package/dist/server/dev-server.d.ts +4 -5
- package/dist/server/dev-server.js +141 -64
- package/dist/server/dev-stack-sourcemap.d.ts +7 -7
- package/dist/server/dev-stack-sourcemap.js +1 -1
- package/dist/server/document-initial-head.d.ts +3 -4
- package/dist/server/edge-api-runtime.d.ts +4 -5
- package/dist/server/fetch-handler.d.ts +3 -2
- package/dist/server/fetch-handler.js +3 -18
- package/dist/server/file-based-metadata.d.ts +2 -3
- package/dist/server/framework-tracer.d.ts +46 -0
- package/dist/server/framework-tracer.js +125 -0
- package/dist/server/fully-buffered-response.d.ts +11 -0
- package/dist/server/fully-buffered-response.js +19 -0
- package/dist/server/headers.d.ts +56 -61
- package/dist/server/headers.js +22 -31
- package/dist/server/html.d.ts +6 -27
- package/dist/server/html.js +16 -1
- package/dist/server/http-conditional.d.ts +5 -6
- package/dist/server/http-date.d.ts +2 -3
- package/dist/server/http-error-responses.d.ts +9 -10
- package/dist/server/http-error-responses.js +1 -0
- package/dist/server/http-range.d.ts +4 -5
- package/dist/server/hybrid-route-priority.d.ts +4 -5
- package/dist/server/image-optimization.d.ts +20 -21
- package/dist/server/implicit-tags.d.ts +3 -4
- package/dist/server/instrumentation-runtime.d.ts +17 -21
- package/dist/server/instrumentation-runtime.js +26 -8
- package/dist/server/instrumentation.d.ts +26 -30
- package/dist/server/instrumentation.js +18 -23
- package/dist/server/isr-cache.d.ts +30 -27
- package/dist/server/isr-cache.js +23 -70
- package/dist/server/isr-decision.d.ts +4 -4
- package/dist/server/metadata-route-build-data.d.ts +4 -5
- package/dist/server/metadata-route-response.d.ts +7 -7
- package/dist/server/metadata-route-response.js +158 -35
- package/dist/server/metadata-routes.d.ts +18 -19
- package/dist/server/middleware-matcher-pattern.d.ts +6 -7
- package/dist/server/middleware-matcher.d.ts +6 -7
- package/dist/server/middleware-path-to-regexp.d.ts +6 -7
- package/dist/server/middleware-path-to-regexp.js +11 -9
- package/dist/server/middleware-response-headers.d.ts +3 -4
- package/dist/server/middleware-runtime.d.ts +7 -8
- package/dist/server/middleware-runtime.js +36 -7
- package/dist/server/middleware.d.ts +5 -5
- package/dist/server/multi-stage.d.ts +141 -0
- package/dist/server/multi-stage.js +8 -0
- package/dist/server/navigation-planner.d.ts +26 -26
- package/dist/server/navigation-trace.d.ts +11 -12
- package/dist/server/next-error-digest.d.ts +4 -5
- package/dist/server/normalize-path.d.ts +5 -6
- package/dist/server/open-redirect.d.ts +2 -3
- package/dist/server/opentelemetry-api.d.ts +59 -0
- package/dist/server/opentelemetry-api.js +53 -0
- package/dist/server/opentelemetry-tracing.d.ts +5 -0
- package/dist/server/opentelemetry-tracing.js +83 -0
- package/dist/server/operation-token.d.ts +11 -12
- package/dist/server/otel-tracer-extension.d.ts +7 -9
- package/dist/server/otel-tracer-extension.js +37 -36
- package/dist/server/pages-api-route.d.ts +5 -4
- package/dist/server/pages-api-route.js +28 -9
- package/dist/server/pages-asset-tags.d.ts +7 -6
- package/dist/server/pages-asset-tags.js +104 -18
- package/dist/server/pages-body-parser-config.d.ts +4 -5
- package/dist/server/pages-body-parser-config.js +4 -4
- package/dist/server/pages-client-assets.d.ts +13 -5
- package/dist/server/pages-data-route.d.ts +11 -12
- package/dist/server/pages-data-route.js +1 -1
- package/dist/server/pages-default-404.d.ts +3 -4
- package/dist/server/pages-dev-hydration.d.ts +9 -4
- package/dist/server/pages-dev-hydration.js +19 -7
- package/dist/server/pages-dev-module-url.d.ts +3 -4
- package/dist/server/pages-dev-stylesheets.d.ts +5 -6
- package/dist/server/pages-document-asset-props.d.ts +6 -7
- package/dist/server/pages-document-initial-props.d.ts +5 -5
- package/dist/server/pages-document-initial-props.js +4 -2
- package/dist/server/pages-execution-tracing.d.ts +40 -0
- package/dist/server/pages-execution-tracing.js +80 -0
- package/dist/server/pages-get-initial-props.d.ts +9 -10
- package/dist/server/pages-i18n.d.ts +8 -8
- package/dist/server/pages-media-type.d.ts +4 -5
- package/dist/server/pages-node-compat.d.ts +11 -10
- package/dist/server/pages-node-compat.js +12 -4
- package/dist/server/pages-page-data.d.ts +23 -19
- package/dist/server/pages-page-data.js +82 -75
- package/dist/server/pages-page-handler.d.ts +7 -6
- package/dist/server/pages-page-handler.js +103 -47
- package/dist/server/pages-page-method.d.ts +2 -3
- package/dist/server/pages-page-response.d.ts +14 -10
- package/dist/server/pages-page-response.js +52 -32
- package/dist/server/pages-preview.d.ts +10 -11
- package/dist/server/pages-readiness.d.ts +2 -3
- package/dist/server/pages-request-pipeline.d.ts +15 -12
- package/dist/server/pages-request-pipeline.js +80 -35
- package/dist/server/pages-request-stage-entry.d.ts +23 -0
- package/dist/server/pages-request-stage-entry.js +316 -0
- package/dist/server/pages-response-stage-entry.d.ts +11 -0
- package/dist/server/pages-response-stage-entry.js +106 -0
- package/dist/server/pages-response-stage.d.ts +31 -0
- package/dist/server/pages-response-stage.js +49 -0
- package/dist/server/pages-revalidate.d.ts +3 -4
- package/dist/server/pages-revalidate.js +9 -4
- package/dist/server/pages-route-data-kind.d.ts +18 -0
- package/dist/server/pages-route-data-kind.js +11 -0
- package/dist/server/pages-router-entry.d.ts +1 -25
- package/dist/server/pages-router-entry.js +35 -148
- package/dist/server/pages-serializable-props.d.ts +3 -4
- package/dist/server/pregenerated-concrete-paths.d.ts +9 -7
- package/dist/server/pregenerated-concrete-paths.js +12 -6
- package/dist/server/prerender-cache-life-header.d.ts +3 -4
- package/dist/server/prerender-manifest.d.ts +17 -11
- package/dist/server/prerender-manifest.js +7 -4
- package/dist/server/prerender-route-params.d.ts +16 -9
- package/dist/server/prerender-route-params.js +18 -3
- package/dist/server/prerender-work-unit-setup.d.ts +2 -3
- package/dist/server/prerender-work-unit-setup.js +5 -5
- package/dist/server/prod-server.d.ts +12 -9
- package/dist/server/prod-server.js +127 -44
- package/dist/server/proxy-trust.d.ts +5 -6
- package/dist/server/request-log.d.ts +3 -4
- package/dist/server/request-pipeline.d.ts +16 -16
- package/dist/server/request-pipeline.js +7 -2
- package/dist/server/request-stage.d.ts +5 -0
- package/dist/server/request-stage.js +7 -0
- package/dist/server/request-tracing.d.ts +22 -0
- package/dist/server/request-tracing.js +180 -0
- package/dist/server/response-stage-cacheability.d.ts +37 -0
- package/dist/server/response-stage-cacheability.js +55 -0
- package/dist/server/response-stage-policy.d.ts +23 -0
- package/dist/server/response-stage-policy.js +89 -0
- package/dist/server/response-stage.d.ts +5 -0
- package/dist/server/response-stage.js +7 -0
- package/dist/server/response-start-tracing.d.ts +14 -0
- package/dist/server/response-start-tracing.js +80 -0
- package/dist/server/revalidation-host.d.ts +2 -3
- package/dist/server/revalidation-host.js +1 -1
- package/dist/server/revalidation-request.d.ts +8 -0
- package/dist/server/revalidation-request.js +37 -0
- package/dist/server/rsc-completion-metadata.d.ts +6 -7
- package/dist/server/rsc-stream-hints.d.ts +18 -7
- package/dist/server/rsc-stream-hints.js +70 -35
- package/dist/server/seed-cache.d.ts +2 -3
- package/dist/server/seed-cache.js +8 -7
- package/dist/server/server-action-not-found.d.ts +5 -6
- package/dist/server/server-globals.d.ts +2 -3
- package/dist/server/skip-cache-proof.d.ts +4 -4
- package/dist/server/socket-error-backstop.d.ts +5 -6
- package/dist/server/socket-error-backstop.js +1 -1
- package/dist/server/static-file-cache.d.ts +5 -6
- package/dist/server/static-file-cache.js +9 -7
- package/dist/server/static-file-signal.d.ts +9 -6
- package/dist/server/static-file-signal.js +51 -2
- package/dist/server/static-layout-client-reuse-proof.d.ts +4 -5
- package/dist/server/streaming-metadata.d.ts +2 -3
- package/dist/server/tracer.d.ts +5 -0
- package/dist/server/tracer.js +13 -0
- package/dist/server/worker-prerender-discovery.d.ts +5 -6
- package/dist/server/worker-revalidation-context.d.ts +4 -4
- package/dist/server/worker-revalidation-context.js +6 -5
- package/dist/server/worker-stages.d.ts +43 -0
- package/dist/server/worker-stages.js +25 -0
- package/dist/server/worker-utils.d.ts +5 -6
- package/dist/server/worker-utils.js +2 -1
- package/dist/server/workers-tracing.d.ts +34 -0
- package/dist/server/workers-tracing.js +67 -0
- package/dist/shims/amp.d.ts +3 -4
- package/dist/shims/app-router-scroll-state.d.ts +9 -10
- package/dist/shims/app-router-scroll.d.ts +4 -5
- package/dist/shims/app-router-scroll.js +2 -1
- package/dist/shims/app.d.ts +5 -6
- package/dist/shims/before-interactive-context.d.ts +5 -6
- package/dist/shims/cache-callable-runtime.d.ts +44 -4
- package/dist/shims/cache-callable-runtime.js +168 -8
- package/dist/shims/cache-for-request.d.ts +2 -3
- package/dist/shims/cache-handler.d.ts +33 -20
- package/dist/shims/cache-handler.js +61 -2
- package/dist/shims/cache-request-state.d.ts +26 -38
- package/dist/shims/cache-request-state.js +2 -13
- package/dist/shims/cache-runtime.d.ts +23 -21
- package/dist/shims/cache-runtime.js +110 -28
- package/dist/shims/cache.d.ts +17 -16
- package/dist/shims/cache.js +19 -15
- package/dist/shims/cacheability-classification.d.ts +50 -29
- package/dist/shims/cacheability-classification.js +29 -14
- package/dist/shims/cdn-cache-state.d.ts +13 -0
- package/dist/shims/cdn-cache-state.js +23 -0
- package/dist/shims/cdn-cache.d.ts +59 -21
- package/dist/shims/cdn-cache.js +31 -47
- package/dist/shims/client-hook-error.d.ts +3 -4
- package/dist/shims/client-locale.d.ts +2 -3
- package/dist/shims/client-page-root.d.ts +24 -0
- package/dist/shims/client-page-root.js +121 -0
- package/dist/shims/compat-router.d.ts +2 -3
- package/dist/shims/config.d.ts +3 -4
- package/dist/shims/constants.d.ts +73 -74
- package/dist/shims/constants.js +1 -1
- package/dist/shims/default-not-found.d.ts +2 -3
- package/dist/shims/document.d.ts +9 -9
- package/dist/shims/dynamic-preload-chunks.d.ts +2 -3
- package/dist/shims/dynamic-preload-chunks.js +17 -13
- package/dist/shims/dynamic.d.ts +3 -3
- package/dist/shims/error-boundary-navigation.d.ts +3 -4
- package/dist/shims/error-boundary.d.ts +17 -18
- package/dist/shims/error-boundary.js +17 -11
- package/dist/shims/error.d.ts +5 -19
- package/dist/shims/error.js +17 -10
- package/dist/shims/error.react-server.d.ts +4 -7
- package/dist/shims/error.react-server.js +4 -1
- package/dist/shims/fetch-cache.d.ts +22 -22
- package/dist/shims/fetch-cache.js +46 -20
- package/dist/shims/font-google-base.d.ts +9 -9
- package/dist/shims/font-google-base.js +2 -1
- package/dist/shims/font-local.d.ts +3 -3
- package/dist/shims/font-local.js +1 -1
- package/dist/shims/font-utils.d.ts +14 -15
- package/dist/shims/form.d.ts +2 -2
- package/dist/shims/form.js +10 -7
- package/dist/shims/hash-scroll.d.ts +5 -6
- package/dist/shims/head-state.d.ts +4 -5
- package/dist/shims/head.d.ts +16 -16
- package/dist/shims/head.js +5 -4
- package/dist/shims/headers.d.ts +44 -73
- package/dist/shims/headers.js +87 -144
- package/dist/shims/i18n-context.d.ts +5 -6
- package/dist/shims/i18n-state.d.ts +4 -5
- package/dist/shims/image-config.d.ts +5 -6
- package/dist/shims/image-config.js +2 -0
- package/dist/shims/image.d.ts +5 -5
- package/dist/shims/image.js +12 -8
- package/dist/shims/internal/als-registry.d.ts +4 -5
- package/dist/shims/internal/api-utils.d.ts +3 -4
- package/dist/shims/internal/app-page-props-cache-key.d.ts +32 -4
- package/dist/shims/internal/app-page-props-cache-key.js +53 -1
- package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +5 -6
- package/dist/shims/internal/app-prefetch-rsc-request.d.ts +5 -17
- package/dist/shims/internal/app-prefetch-rsc-request.js +5 -14
- package/dist/shims/internal/app-route-detection.d.ts +2 -2
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +5 -8
- package/dist/shims/internal/app-route-prefetch-policy.js +0 -1
- package/dist/shims/internal/app-router-context.d.ts +9 -10
- package/dist/shims/internal/cache-context-accessor.d.ts +16 -0
- package/dist/shims/internal/cache-context-accessor.js +15 -0
- package/dist/shims/internal/cookie-serialize.d.ts +4 -5
- package/dist/shims/internal/format-url-object.d.ts +7 -0
- package/dist/shims/internal/format-url-object.js +53 -0
- package/dist/shims/internal/headers-state.d.ts +74 -0
- package/dist/shims/internal/headers-state.js +157 -0
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +6 -7
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +3 -3
- package/dist/shims/internal/hybrid-client-route-owner.js +3 -2
- package/dist/shims/internal/interpolate-as.d.ts +5 -6
- package/dist/shims/internal/interpolate-as.js +4 -2
- package/dist/shims/internal/link-status-registry.d.ts +5 -6
- package/dist/shims/internal/make-hanging-promise.d.ts +3 -4
- package/dist/shims/internal/navigation-untracked.d.ts +2 -3
- package/dist/shims/internal/normalize-router-href.d.ts +15 -0
- package/dist/shims/internal/normalize-router-href.js +41 -0
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +8 -9
- package/dist/shims/internal/pages-data-target.d.ts +8 -6
- package/dist/shims/internal/pages-data-target.js +32 -36
- package/dist/shims/internal/pages-data-url.d.ts +4 -5
- package/dist/shims/internal/pages-data-url.js +2 -1
- package/dist/shims/internal/pages-router-accessor.d.ts +3 -4
- package/dist/shims/internal/pages-router-components.d.ts +3 -4
- package/dist/shims/internal/route-pattern-for-warning.d.ts +5 -6
- package/dist/shims/internal/route-pattern-for-warning.js +3 -3
- package/dist/shims/internal/router-context.d.ts +2 -3
- package/dist/shims/internal/thenable-well-known-properties.d.ts +10 -0
- package/dist/shims/internal/thenable-well-known-properties.js +33 -0
- package/dist/shims/internal/utils.d.ts +7 -8
- package/dist/shims/internal/work-unit-async-storage.d.ts +10 -11
- package/dist/shims/layout-segment-context.d.ts +3 -4
- package/dist/shims/link-prefetch.d.ts +9 -10
- package/dist/shims/link.d.ts +4 -4
- package/dist/shims/link.js +56 -116
- package/dist/shims/metadata.d.ts +15 -16
- package/dist/shims/metadata.js +40 -36
- package/dist/shims/navigation-context-accessors.d.ts +9 -0
- package/dist/shims/navigation-context-accessors.js +19 -0
- package/dist/shims/navigation-context-state.d.ts +27 -18
- package/dist/shims/navigation-errors.d.ts +18 -19
- package/dist/shims/navigation-state.d.ts +6 -7
- package/dist/shims/navigation.d.ts +80 -68
- package/dist/shims/navigation.js +26 -18
- package/dist/shims/navigation.react-server.d.ts +9 -9
- package/dist/shims/offline.d.ts +2 -3
- package/dist/shims/og.d.ts +2 -2
- package/dist/shims/pages-router-runtime.d.ts +4 -5
- package/dist/shims/ppr-fallback-shell.d.ts +13 -14
- package/dist/shims/readonly-url-search-params.d.ts +2 -3
- package/dist/shims/request-context.d.ts +5 -6
- package/dist/shims/request-state-types.d.ts +2 -1
- package/dist/shims/root-params.d.ts +14 -15
- package/dist/shims/root-params.js +1 -1
- package/dist/shims/router-state.d.ts +5 -6
- package/dist/shims/router-state.js +1 -1
- package/dist/shims/router.d.ts +22 -21
- package/dist/shims/router.js +339 -164
- package/dist/shims/script-nonce-context.d.ts +8 -6
- package/dist/shims/script-nonce-context.js +15 -6
- package/dist/shims/script.d.ts +4 -4
- package/dist/shims/script.js +9 -7
- package/dist/shims/search-params-gate.d.ts +35 -0
- package/dist/shims/search-params-gate.js +32 -0
- package/dist/shims/server.d.ts +19 -51
- package/dist/shims/server.js +66 -30
- package/dist/shims/slot.d.ts +33 -15
- package/dist/shims/slot.js +41 -9
- package/dist/shims/streamed-icons.d.ts +3 -4
- package/dist/shims/thenable-params.d.ts +5 -7
- package/dist/shims/thenable-params.js +3 -24
- package/dist/shims/unified-request-context.d.ts +35 -32
- package/dist/shims/unified-request-context.js +34 -24
- package/dist/shims/unrecognized-action-error.d.ts +3 -4
- package/dist/shims/url-safety.d.ts +5 -6
- package/dist/shims/url-utils.d.ts +12 -13
- package/dist/shims/use-merged-ref.d.ts +2 -3
- package/dist/shims/user-agent.d.ts +31 -0
- package/dist/shims/user-agent.js +16 -0
- package/dist/shims/web-vitals.d.ts +2 -2
- package/dist/typegen.d.ts +3 -4
- package/dist/utils/asset-prefix.d.ts +7 -8
- package/dist/utils/base-path.d.ts +5 -6
- package/dist/utils/built-asset-url.d.ts +2 -3
- package/dist/utils/built-asset-url.js +1 -1
- package/dist/utils/cache-control-metadata.d.ts +4 -5
- package/dist/utils/client-build-manifest.d.ts +6 -7
- package/dist/utils/client-build-manifest.js +2 -1
- package/dist/utils/client-entry-manifest.d.ts +6 -7
- package/dist/utils/client-runtime-metadata.d.ts +8 -3
- package/dist/utils/client-runtime-metadata.js +18 -1
- package/dist/utils/commonjs-loader.d.ts +4 -5
- package/dist/utils/compare.d.ts +2 -3
- package/dist/utils/deployment-id.d.ts +6 -7
- package/dist/utils/dev-error-recovery-event.d.ts +2 -3
- package/dist/utils/dev-stack-sourcemap-endpoint.d.ts +2 -3
- package/dist/utils/domain-locale.d.ts +7 -8
- package/dist/utils/encode-cache-tag.d.ts +4 -4
- package/dist/utils/encode-cache-tag.js +11 -1
- package/dist/utils/error-cause.d.ts +2 -3
- package/dist/utils/external-url.d.ts +2 -3
- package/dist/utils/has-trailing-comma.d.ts +3 -4
- package/dist/utils/hash.d.ts +3 -4
- package/dist/utils/html-limited-bots.d.ts +3 -4
- package/dist/utils/lazy-chunks.d.ts +8 -9
- package/dist/utils/lazy-chunks.js +4 -4
- package/dist/utils/manifest-paths.d.ts +5 -6
- package/dist/utils/mdx-scan.d.ts +11 -4
- package/dist/utils/mdx-scan.js +27 -1
- package/dist/utils/middleware-request-headers.d.ts +7 -6
- package/dist/utils/middleware-request-headers.js +6 -1
- package/dist/utils/navigation-signal.d.ts +3 -3
- package/dist/utils/navigation-signal.js +16 -1
- package/dist/utils/number.d.ts +2 -3
- package/dist/utils/package-name.d.ts +3 -4
- package/dist/utils/parse-cookie.d.ts +4 -5
- package/dist/utils/path.d.ts +8 -9
- package/dist/utils/plugin-options.d.ts +2 -3
- package/dist/utils/precompressed-variant.d.ts +3 -4
- package/dist/utils/prerender-output-paths.d.ts +4 -5
- package/dist/utils/project.d.ts +19 -30
- package/dist/utils/project.js +20 -29
- package/dist/utils/promise.d.ts +2 -3
- package/dist/utils/protocol-headers.d.ts +14 -15
- package/dist/utils/public-file-path.d.ts +2 -3
- package/dist/utils/public-routes.d.ts +2 -3
- package/dist/utils/query.d.ts +14 -9
- package/dist/utils/query.js +22 -1
- package/dist/utils/react-compiler-support.d.ts +6 -7
- package/dist/utils/react-version.d.ts +4 -3
- package/dist/utils/react-version.js +19 -1
- package/dist/utils/record.d.ts +2 -3
- package/dist/utils/redirect-digest.d.ts +3 -4
- package/dist/utils/regex-safety.d.ts +4 -5
- package/dist/utils/regex.d.ts +2 -3
- package/dist/utils/safe-json-file.d.ts +2 -3
- package/dist/utils/sorted-array.d.ts +2 -3
- package/dist/utils/text-stream.d.ts +3 -4
- package/dist/utils/vinext-root.d.ts +2 -3
- package/dist/utils/virtual-module.d.ts +3 -4
- package/dist/utils/vite-cli-invocation.d.ts +21 -0
- package/dist/utils/vite-cli-invocation.js +151 -0
- package/dist/utils/vite-version.d.ts +5 -6
- package/next-package.json +4 -0
- package/package.json +51 -6
- package/dist/server/metadata-route-cache-policy.d.ts +0 -6
- package/dist/server/metadata-route-cache-policy.js +0 -6
package/dist/index.js
CHANGED
|
@@ -1,34 +1,46 @@
|
|
|
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 { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
|
|
4
3
|
import { buildViteResolveExtensions, createValidFileMatcher, findFileWithExts, normalizeViteResolveExtensions } from "./routing/file-matcher.js";
|
|
4
|
+
import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
|
|
5
|
+
import { claimViteCliBuildInvocation, getViteCliInvocation, isViteCliConfigFile } from "./utils/vite-cli-invocation.js";
|
|
6
|
+
import { VINEXT_DEV_CLI_LIFECYCLE, applyDevServerDefaults, claimViteCliDevInvocation, createDevServerLifecyclePlugin, reserveViteCliDevInvocation } from "./cli-dev-config.js";
|
|
7
|
+
import { isUnknownRecord } from "./utils/record.js";
|
|
8
|
+
import { getReactUpgradeDeps } from "./utils/react-version.js";
|
|
9
|
+
import { loadDotenv } from "./config/dotenv.js";
|
|
10
|
+
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
|
|
11
|
+
import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
|
|
12
|
+
import { encodeMiddlewareRequestHeaders } from "./utils/middleware-request-headers.js";
|
|
13
|
+
import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
|
|
14
|
+
import { omitUnusedBuildSourcemap } from "./plugins/transform-result.js";
|
|
15
|
+
import { assetPrefixPathname, isNextStaticPath, resolveAssetsDir } from "./utils/asset-prefix.js";
|
|
16
|
+
import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
|
|
17
|
+
import { VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
|
|
18
|
+
import { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
|
|
5
19
|
import { hasBasePath, stripBasePath } from "./utils/base-path.js";
|
|
20
|
+
import { appRouteGraph, appRouter, invalidateAppRouteCache, matchAppRoute } from "./routing/app-router.js";
|
|
21
|
+
import { generateRouteTypes } from "./typegen.js";
|
|
6
22
|
import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./routing/pages-router.js";
|
|
7
|
-
import {
|
|
23
|
+
import { resolveRuntimeEntryModule } from "./entries/runtime-entry-module.js";
|
|
8
24
|
import { INTERNAL_HEADERS, NEXTJS_DEPLOYMENT_ID_HEADER, VINEXT_INTERNAL_HEADERS, VINEXT_TIMING_HEADER } from "./server/headers.js";
|
|
9
|
-
import { encodeMiddlewareRequestHeaders } from "./utils/middleware-request-headers.js";
|
|
10
25
|
import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
|
|
11
|
-
import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
|
|
12
26
|
import { validateMiddlewareMatcherPatterns } from "./server/middleware-matcher-pattern.js";
|
|
13
|
-
import { methodNotAllowedResponse } from "./server/http-error-responses.js";
|
|
27
|
+
import { methodNotAllowedResponse, notFoundStaticAssetResponse } from "./server/http-error-responses.js";
|
|
14
28
|
import { isOpenRedirectShaped } from "./server/open-redirect.js";
|
|
15
29
|
import { canonicalizeRequestUrlPathname, filterInternalHeaders, normalizeTrailingSlash } from "./server/request-pipeline.js";
|
|
16
30
|
import { resolvePagesI18nRequest, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
|
|
31
|
+
import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
|
|
17
32
|
import { findMiddlewareFile, isProxyFile, runMiddleware } from "./server/middleware.js";
|
|
18
33
|
import { extractMiddlewareMatcherConfig, extractMiddlewareMatcherConfigValue, hasExportedName } from "./build/report.js";
|
|
19
|
-
import { generateServerEntry } from "./entries/pages-server-entry.js";
|
|
20
|
-
import { generateClientEntry } from "./entries/pages-client-entry.js";
|
|
21
|
-
import { appRouteGraph, appRouter, invalidateAppRouteCache, matchAppRoute } from "./routing/app-router.js";
|
|
22
|
-
import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
|
|
23
|
-
import { isUnknownRecord } from "./utils/record.js";
|
|
34
|
+
import { generatePagesRequestEntry, generatePagesResponseEntry, generateServerEntry } from "./entries/pages-server-entry.js";
|
|
35
|
+
import { compileClientMiddlewareMatchers, generateClientEntry } from "./entries/pages-client-entry.js";
|
|
24
36
|
import { logRequest, now } from "./server/request-log.js";
|
|
25
37
|
import { encodeUrlParserIgnoredCharacters, isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname, shouldAddTrailingSlashToPagesDataPath, urlParserCreatesPagesDataPath } from "./server/pages-data-route.js";
|
|
26
|
-
import { resolveAssetsDir } from "./utils/asset-prefix.js";
|
|
27
38
|
import { getPagesPreviewModeId } from "./server/pages-preview.js";
|
|
28
39
|
import { createSSRHandler } from "./server/dev-server.js";
|
|
29
40
|
import { handleApiRoute } from "./server/api-handler.js";
|
|
30
41
|
import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath, resolveDevImageRedirect } from "./server/image-optimization.js";
|
|
31
|
-
import { CACHEABILITY_MANIFEST_MODULE } from "./server/cacheability-manifest.js";
|
|
42
|
+
import { CACHEABILITY_MANIFEST_MODULE, CACHEABILITY_REQUEST_PROJECTION_MODULE } from "./server/cacheability-manifest.js";
|
|
43
|
+
import { PREGENERATED_CONCRETE_PATHS_MODULE } from "./server/pregenerated-concrete-paths.js";
|
|
32
44
|
import { installSocketErrorBackstop } from "./server/socket-error-backstop.js";
|
|
33
45
|
import { isPathInside, isPathInsideOrEqual, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
|
|
34
46
|
import { invalidateMetadataFileCache, scanMetadataFiles } from "./server/metadata-routes.js";
|
|
@@ -36,24 +48,25 @@ import { shouldInvalidateAppRouteFile } from "./server/dev-route-files.js";
|
|
|
36
48
|
import { createDirectRunner } from "./server/dev-module-runner.js";
|
|
37
49
|
import { validateDevRequest } from "./server/dev-origin-check.js";
|
|
38
50
|
import { createActionOwnerManifestPlugin } from "./plugins/action-owner-manifest.js";
|
|
39
|
-
import { generateRscEntry } from "./entries/app-rsc-entry.js";
|
|
51
|
+
import { generateAppRequestRscEntry, generateAppResponseRscEntry, generateRscEntry } from "./entries/app-rsc-entry.js";
|
|
40
52
|
import { generateSsrEntry } from "./entries/app-ssr-entry.js";
|
|
41
|
-
import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VIRTUAL_CACHE_ADAPTERS, generateCacheAdaptersModule,
|
|
53
|
+
import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VIRTUAL_CACHE_ADAPTERS, VIRTUAL_CDN_CACHE_ADAPTER, generateCacheAdaptersModule, generateCdnCacheAdapterModule } from "./cache/cache-adapters-virtual.js";
|
|
42
54
|
import { VIRTUAL_IMAGE_ADAPTERS, generateImageAdaptersModule } from "./image/image-adapters-virtual.js";
|
|
43
55
|
import { generateBrowserEntry, toLinkPrefetchRoutes } from "./entries/app-browser-entry.js";
|
|
44
56
|
import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
|
|
45
57
|
import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
|
|
46
|
-
import {
|
|
47
|
-
import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
|
|
48
|
-
import { VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
|
|
49
|
-
import { loadDotenv } from "./config/dotenv.js";
|
|
50
|
-
import { mergeServerExternalPackages } from "./config/server-external-packages.js";
|
|
58
|
+
import { findOpenTelemetryPackages, mergeServerExternalPackages } from "./config/server-external-packages.js";
|
|
51
59
|
import { precompressAssets } from "./build/precompress.js";
|
|
60
|
+
import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY, normalizeVinextPrerenderConfig } from "./config/prerender.js";
|
|
61
|
+
import { PAGES_CLIENT_ASSETS_MODULE, buildPagesClientAssetsModule, writePagesClientAssetsModuleIfMissing } from "./build/pages-client-assets-module.js";
|
|
62
|
+
import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
|
|
63
|
+
import { VINEXT_BUILD_LIFECYCLE_CONFIG, createBuildLifecyclePlugins } from "./build/lifecycle.js";
|
|
52
64
|
import { ensureAssetsIgnore } from "./build/assets-ignore.js";
|
|
53
65
|
import { emitNextClientRuntimeManifests } from "./build/next-client-runtime-manifests.js";
|
|
54
66
|
import { collectInlineCssManifest, injectInlineCssManifestGlobal } from "./build/inline-css.js";
|
|
55
67
|
import { readTrustedRevalidationHostname } from "./server/revalidation-host.js";
|
|
56
68
|
import { installDevStackSourcemapMiddleware } from "./server/dev-stack-sourcemap.js";
|
|
69
|
+
import { traceFrameworkRequest } from "./server/request-tracing.js";
|
|
57
70
|
import { runPagesRequest } from "./server/pages-request-pipeline.js";
|
|
58
71
|
import { pagesRouteHasPriorityOverAppRoute, validateHybridRouteConflicts } from "./server/hybrid-route-priority.js";
|
|
59
72
|
import { hasReactCompilerPlugin, isReactCompilerPlugin, isReactCompilerRequested, reactCompilerUnsupportedMessage } from "./utils/react-compiler-support.js";
|
|
@@ -66,7 +79,8 @@ import { dataUrlCssPlugin } from "./plugins/css-data-url.js";
|
|
|
66
79
|
import { createCssModuleImportCompatibilityPlugin } from "./plugins/css-module-imports.js";
|
|
67
80
|
import { createRscClientReferenceLoadersPlugin } from "./plugins/rsc-client-reference-loaders.js";
|
|
68
81
|
import { createRscReferenceValidationNormalizerPlugin } from "./plugins/rsc-reference-validation-normalizer.js";
|
|
69
|
-
import {
|
|
82
|
+
import { createScanBuildCssPlugin } from "./plugins/scan-build-css.js";
|
|
83
|
+
import { createInstrumentationClientTransformPlugin, createInstrumentationServerTransformPlugin } from "./plugins/instrumentation-client.js";
|
|
70
84
|
import { createStyledJsxPlugin } from "./plugins/styled-jsx.js";
|
|
71
85
|
import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
|
|
72
86
|
import { createMiddlewareServerOnlyPlugin } from "./plugins/middleware-server-only.js";
|
|
@@ -76,46 +90,45 @@ import { validateMiddlewareModuleExports } from "./plugins/middleware-export-val
|
|
|
76
90
|
import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
|
|
77
91
|
import { augmentSsrManifestFromBundle, relativeWithinRoot, tryRealpathSync } from "./build/ssr-manifest.js";
|
|
78
92
|
import { createDynamicPreloadMetadataPlugin } from "./plugins/dynamic-preload-metadata.js";
|
|
93
|
+
import { createTransformCache } from "./plugins/transform-cache.js";
|
|
94
|
+
import { createOgHarfbuzzPlugin } from "./plugins/og-harfbuzz.js";
|
|
79
95
|
import { createOgAssetsPlugin, createOgInlineFetchAssetsPlugin } from "./plugins/og-assets.js";
|
|
80
96
|
import { createUseCacheCallablePlugin } from "./plugins/use-cache-callable.js";
|
|
81
|
-
import { generateRouteTypes } from "./typegen.js";
|
|
82
97
|
import { SSR_EXTERNAL_REACT_ENTRIES, VINEXT_OPTIMIZE_DEPS_EXCLUDE, mergeOptimizeDepsExclude } from "./plugins/rsc-client-shim-excludes.js";
|
|
83
98
|
import { createServerExternalsManifestPlugin } from "./plugins/server-externals-manifest.js";
|
|
84
99
|
import { createTransitiveExternalsPlugin } from "./plugins/transitive-externals.js";
|
|
85
100
|
import public_shim_map_default from "./shims/public-shim-map.json.js";
|
|
86
101
|
import { VINEXT_CLIENT_ENTRY_MANIFEST } from "./utils/client-entry-manifest.js";
|
|
87
102
|
import { computeClientRuntimeMetadata } from "./utils/client-runtime-metadata.js";
|
|
88
|
-
import {
|
|
89
|
-
import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
|
|
103
|
+
import { readPrerenderSecret, readServerRuntimeOutputDirs } from "./build/server-manifest.js";
|
|
90
104
|
import { createModuleDependencyCache } from "./build/module-dependency-cache.js";
|
|
91
|
-
import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
|
|
92
105
|
import { markCssUrlAssetReferences, restoreDedupedCssAssetReferences } from "./build/css-url-assets.js";
|
|
93
106
|
import { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter, createSassTsconfigPathImporters } from "./plugins/sass.js";
|
|
94
|
-
import { createClientAssetFileNames, createClientCodeSplittingConfig, createClientFileNameConfig, createClientManualChunks, createRscFrameworkChunkOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfig, withBuildBundlerOptions } from "./build/client-build-config.js";
|
|
95
|
-
import { hasExportAllCandidate, stripServerExports, validatePageExports } from "./plugins/strip-server-exports.js";
|
|
107
|
+
import { createClientAssetFileNames, createClientCodeSplittingConfig, createClientFileNameConfig, createClientManualChunks, createMultiStageChunkFileNames, createMultiStageCodeSplittingConfig, createRscFrameworkChunkOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfig, withBuildBundlerOptions } from "./build/client-build-config.js";
|
|
108
|
+
import { EXPORT_ALL_CANDIDATE_FILTER, hasExportAllCandidate, stripServerExports, validatePageExports } from "./plugins/strip-server-exports.js";
|
|
96
109
|
import { removeConsoleCalls } from "./plugins/remove-console.js";
|
|
97
110
|
import { createImportMetaUrlPlugin } from "./plugins/import-meta-url.js";
|
|
98
111
|
import { createWorkerImageImportsPlugin } from "./plugins/worker-image-imports.js";
|
|
99
112
|
import { createRequireContextPlugin } from "./plugins/require-context.js";
|
|
113
|
+
import { COMMONJS_SYNTAX_CODE_FILTER } from "./plugins/commonjs-syntax.js";
|
|
100
114
|
import { createRequireConditionResolutionPlugin, isConditionalRequireScriptModuleId } from "./plugins/require-condition-resolution.js";
|
|
101
|
-
import { createTransformCache } from "./plugins/transform-cache.js";
|
|
102
115
|
import { createExtensionlessDynamicImportPlugin } from "./plugins/extensionless-dynamic-import.js";
|
|
103
116
|
import { createWasmModuleImportPlugin } from "./plugins/wasm-module-import.js";
|
|
104
|
-
import { consumerEnvironmentConditionFilter, getTypeofWindowReplacement, replaceConsumerEnvironmentConditions } from "./plugins/typeof-window.js";
|
|
117
|
+
import { consumerEnvironmentConditionFilter, getTypeofWindowReplacement, mayFoldChangeScannedImports, replaceConsumerEnvironmentConditions } from "./plugins/typeof-window.js";
|
|
105
118
|
import { hasMdxFiles } from "./utils/mdx-scan.js";
|
|
106
119
|
import { publicFilePathVariants } from "./utils/public-file-path.js";
|
|
107
120
|
import { scanPublicFileRoutes } from "./utils/public-routes.js";
|
|
108
121
|
import { createIgnoreDynamicRequestsPlugin } from "./plugins/ignore-dynamic-requests.js";
|
|
109
122
|
import { assertSupportedViteVersion, getDepOptimizeNodeEnvOptions, serializeViteDefine } from "./utils/vite-version.js";
|
|
110
|
-
import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY, normalizeVinextPrerenderConfig } from "./config/prerender.js";
|
|
111
123
|
import { staticExportApp, staticExportPages } from "./build/static-export.js";
|
|
112
124
|
import { createRequire } from "node:module";
|
|
113
125
|
import fs from "node:fs";
|
|
114
|
-
import { createIdResolver, createLogger, parseAst, transformWithOxc } from "vite";
|
|
115
126
|
import { pathToFileURL } from "node:url";
|
|
127
|
+
import { createIdResolver, createLogger, isRunnableDevEnvironment, parseAst, transformWithOxc } from "vite";
|
|
128
|
+
import { execFileSync } from "node:child_process";
|
|
116
129
|
import { createHash, randomBytes } from "node:crypto";
|
|
117
|
-
import commonjs from "vite-plugin-commonjs";
|
|
118
130
|
import MagicString from "magic-string";
|
|
131
|
+
import commonjs from "vite-plugin-commonjs";
|
|
119
132
|
//#region src/index.ts
|
|
120
133
|
const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_EXCLUDE = Object.freeze(["vinext/server/fetch-handler", "vinext/server/pages-router-entry"]);
|
|
121
134
|
const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
@@ -123,12 +136,42 @@ const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
|
123
136
|
"react-dom",
|
|
124
137
|
"react-dom/server.edge",
|
|
125
138
|
"react/jsx-runtime",
|
|
126
|
-
"react/jsx-dev-runtime"
|
|
127
|
-
|
|
139
|
+
"react/jsx-dev-runtime"
|
|
140
|
+
]);
|
|
141
|
+
const APP_CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
142
|
+
"use-sync-external-store/shim",
|
|
143
|
+
"use-sync-external-store/shim/index.js",
|
|
144
|
+
"use-sync-external-store/shim/with-selector",
|
|
145
|
+
"use-sync-external-store/shim/with-selector.js",
|
|
146
|
+
"use-sync-external-store/with-selector",
|
|
147
|
+
"use-sync-external-store/with-selector.js"
|
|
128
148
|
]);
|
|
129
|
-
const OPTIONAL_OPTIMIZE_DEPS_WARNING_RE = /Failed to resolve dependency: .*use-sync-external-store\/with-selector.*present in .* 'optimizeDeps\.include'/;
|
|
130
|
-
const VINEXT_FILTERED_OPTIMIZE_DEPS_WARN = Symbol.for("vinext.filteredOptimizeDepsWarn");
|
|
131
149
|
const ANSI_ESCAPE_RE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
|
|
150
|
+
const RSC_ENVIRONMENTS = /* @__PURE__ */ new Set([
|
|
151
|
+
"rsc",
|
|
152
|
+
"ssr",
|
|
153
|
+
"client"
|
|
154
|
+
]);
|
|
155
|
+
const VINEXT_GENERATED_DIR_RE = /(?:^|[/\\])\.vinext(?:[/\\]|$)/;
|
|
156
|
+
function scopeRscPlugin(plugin) {
|
|
157
|
+
const applyToEnvironment = plugin.applyToEnvironment;
|
|
158
|
+
return {
|
|
159
|
+
...plugin,
|
|
160
|
+
applyToEnvironment(environment) {
|
|
161
|
+
if (!RSC_ENVIRONMENTS.has(environment.name)) return false;
|
|
162
|
+
return applyToEnvironment?.(environment) ?? true;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const earlyViteCliInvocation = getViteCliInvocation();
|
|
167
|
+
const viteCliBuildConfigNodeEnv = earlyViteCliInvocation?.command === "build" && process.env.NODE_ENV === "test" ? "test" : void 0;
|
|
168
|
+
if (earlyViteCliInvocation) {
|
|
169
|
+
if (!process.env.NODE_ENV) Reflect.set(process.env, "NODE_ENV", earlyViteCliInvocation.command === "build" ? viteCliBuildConfigNodeEnv ?? "production" : earlyViteCliInvocation.mode === "test" ? "test" : "development");
|
|
170
|
+
loadDotenv({
|
|
171
|
+
root: earlyViteCliInvocation.root,
|
|
172
|
+
mode: earlyViteCliInvocation.mode
|
|
173
|
+
});
|
|
174
|
+
}
|
|
132
175
|
installSocketErrorBackstop();
|
|
133
176
|
function hasServerOnlyMarkerImport(code) {
|
|
134
177
|
if (!code.includes("server-only")) return false;
|
|
@@ -183,6 +226,7 @@ function resolveShimModulePath(shimsDir, moduleName) {
|
|
|
183
226
|
}
|
|
184
227
|
return path.join(shimsDir, `${moduleName}.js`);
|
|
185
228
|
}
|
|
229
|
+
const PATCHED_SERVER_PACKAGES = ["@vercel/og"];
|
|
186
230
|
function isVercelOgImport(id) {
|
|
187
231
|
return id === "@vercel/og" || id === "@vercel/og.js";
|
|
188
232
|
}
|
|
@@ -312,7 +356,7 @@ function createDevPagesModuleDependencyReader(root, resolve) {
|
|
|
312
356
|
if (typeof specifier !== "string") continue;
|
|
313
357
|
const resolved = await resolve(specifier, cleanModulePath, { skipSelf: true });
|
|
314
358
|
if (!resolved?.id) continue;
|
|
315
|
-
if (isStylesheetSpecifier(specifier)) {
|
|
359
|
+
if (isStylesheetSpecifier(specifier) || isStylesheetSpecifier(resolved.id)) {
|
|
316
360
|
const asset = resolvedStylesheetToDevManifestAsset(root, resolved.id);
|
|
317
361
|
if (asset) dependencies.push({
|
|
318
362
|
type: "stylesheet",
|
|
@@ -509,15 +553,24 @@ function mergeStringArrayValues(value, additions) {
|
|
|
509
553
|
function stripAnsi(value) {
|
|
510
554
|
return value.replace(ANSI_ESCAPE_RE, "");
|
|
511
555
|
}
|
|
512
|
-
function
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
556
|
+
function createOptionalOptimizeDepsLogger(logger, warnings) {
|
|
557
|
+
if (warnings.size === 0) return logger;
|
|
558
|
+
return {
|
|
559
|
+
get hasWarned() {
|
|
560
|
+
return logger.hasWarned;
|
|
561
|
+
},
|
|
562
|
+
set hasWarned(value) {
|
|
563
|
+
logger.hasWarned = value;
|
|
564
|
+
},
|
|
565
|
+
info: logger.info.bind(logger),
|
|
566
|
+
warn(msg, options) {
|
|
567
|
+
if (!warnings.has(stripAnsi(msg))) logger.warn(msg, options);
|
|
568
|
+
},
|
|
569
|
+
warnOnce: logger.warnOnce.bind(logger),
|
|
570
|
+
error: logger.error.bind(logger),
|
|
571
|
+
clearScreen: logger.clearScreen.bind(logger),
|
|
572
|
+
hasErrorLogged: logger.hasErrorLogged.bind(logger)
|
|
519
573
|
};
|
|
520
|
-
marker[VINEXT_FILTERED_OPTIMIZE_DEPS_WARN] = true;
|
|
521
574
|
}
|
|
522
575
|
const _tsconfigAliasCache = /* @__PURE__ */ new Map();
|
|
523
576
|
/**
|
|
@@ -597,8 +650,8 @@ const tsconfigAliasCustomResolver = async function(updatedId, importer, options)
|
|
|
597
650
|
* stylesheet-scoping resolver to entries that came from tsconfig `paths`.
|
|
598
651
|
* Array order preserves the map's first-match ordering.
|
|
599
652
|
*/
|
|
600
|
-
function buildResolveAliasEntries(aliasMap, tsconfigPathAliases) {
|
|
601
|
-
return Object.entries(aliasMap).map(([find, replacement]) => tsconfigPathAliases
|
|
653
|
+
function buildResolveAliasEntries(aliasMap, tsconfigPathAliases, explicitAliases) {
|
|
654
|
+
return Object.entries(aliasMap).map(([find, replacement]) => Object.hasOwn(tsconfigPathAliases, find) && !Object.hasOwn(explicitAliases, find) ? {
|
|
602
655
|
find,
|
|
603
656
|
replacement,
|
|
604
657
|
customResolver: tsconfigAliasCustomResolver
|
|
@@ -621,26 +674,49 @@ function suppressAliasCustomResolverDeprecationWarning(logger) {
|
|
|
621
674
|
return logger;
|
|
622
675
|
}
|
|
623
676
|
const VIRTUAL_WORKER_ENTRY = "virtual:vinext-worker-entry";
|
|
624
|
-
const RESOLVED_WORKER_ENTRY = "\
|
|
677
|
+
const RESOLVED_WORKER_ENTRY = "\0" + VIRTUAL_WORKER_ENTRY;
|
|
678
|
+
const VIRTUAL_REQUEST_STAGE = "virtual:vinext-request-stage";
|
|
679
|
+
const RESOLVED_REQUEST_STAGE = "\0" + VIRTUAL_REQUEST_STAGE;
|
|
680
|
+
const VIRTUAL_RESPONSE_STAGE = "virtual:vinext-response-stage";
|
|
681
|
+
const RESOLVED_RESPONSE_STAGE = "\0" + VIRTUAL_RESPONSE_STAGE;
|
|
625
682
|
const VIRTUAL_SERVER_ENTRY = "virtual:vinext-server-entry";
|
|
626
|
-
const RESOLVED_SERVER_ENTRY = "\
|
|
683
|
+
const RESOLVED_SERVER_ENTRY = "\0" + VIRTUAL_SERVER_ENTRY;
|
|
684
|
+
const VIRTUAL_PAGES_REQUEST_ENTRY = "virtual:vinext-pages-request-entry";
|
|
685
|
+
const RESOLVED_PAGES_REQUEST_ENTRY = "\0" + VIRTUAL_PAGES_REQUEST_ENTRY;
|
|
686
|
+
const VIRTUAL_PAGES_RESPONSE_ENTRY = "virtual:vinext-pages-response-entry";
|
|
687
|
+
const RESOLVED_PAGES_RESPONSE_ENTRY = "\0" + VIRTUAL_PAGES_RESPONSE_ENTRY;
|
|
627
688
|
const VIRTUAL_CLIENT_ENTRY = "virtual:vinext-client-entry";
|
|
628
|
-
const RESOLVED_CLIENT_ENTRY = "\
|
|
689
|
+
const RESOLVED_CLIENT_ENTRY = "\0" + VIRTUAL_CLIENT_ENTRY;
|
|
629
690
|
const VIRTUAL_PAGES_CLIENT_ASSETS = "virtual:vinext-pages-client-assets";
|
|
630
|
-
const RESOLVED_PAGES_CLIENT_ASSETS = "\
|
|
691
|
+
const RESOLVED_PAGES_CLIENT_ASSETS = "\0" + VIRTUAL_PAGES_CLIENT_ASSETS;
|
|
631
692
|
const VIRTUAL_RSC_ENTRY = "virtual:vinext-rsc-entry";
|
|
632
|
-
const RESOLVED_RSC_ENTRY = "\
|
|
693
|
+
const RESOLVED_RSC_ENTRY = "\0" + VIRTUAL_RSC_ENTRY;
|
|
633
694
|
const VIRTUAL_CACHEABILITY_MANIFEST = "virtual:vinext-cacheability-manifest";
|
|
634
|
-
const RESOLVED_CACHEABILITY_MANIFEST = "\
|
|
695
|
+
const RESOLVED_CACHEABILITY_MANIFEST = "\0" + VIRTUAL_CACHEABILITY_MANIFEST;
|
|
696
|
+
const VIRTUAL_CACHEABILITY_REQUEST_PROJECTION = "virtual:vinext-cacheability-request-projection";
|
|
697
|
+
const RESOLVED_CACHEABILITY_REQUEST_PROJECTION = "\0" + VIRTUAL_CACHEABILITY_REQUEST_PROJECTION;
|
|
698
|
+
const VIRTUAL_PREGENERATED_CONCRETE_PATHS = "virtual:vinext-pregenerated-concrete-paths";
|
|
699
|
+
const RESOLVED_PREGENERATED_CONCRETE_PATHS = "\0" + VIRTUAL_PREGENERATED_CONCRETE_PATHS;
|
|
700
|
+
const VIRTUAL_APP_REQUEST_ENTRY = "virtual:vinext-app-request-entry";
|
|
701
|
+
const RESOLVED_APP_REQUEST_ENTRY = "\0" + VIRTUAL_APP_REQUEST_ENTRY;
|
|
702
|
+
const VIRTUAL_APP_RESPONSE_ENTRY = "virtual:vinext-app-response-entry";
|
|
703
|
+
const RESOLVED_APP_RESPONSE_ENTRY = "\0" + VIRTUAL_APP_RESPONSE_ENTRY;
|
|
635
704
|
const VIRTUAL_APP_SSR_ENTRY = "virtual:vinext-app-ssr-entry";
|
|
636
|
-
const RESOLVED_APP_SSR_ENTRY = "\
|
|
705
|
+
const RESOLVED_APP_SSR_ENTRY = "\0" + VIRTUAL_APP_SSR_ENTRY;
|
|
637
706
|
const VIRTUAL_APP_BROWSER_ENTRY = "virtual:vinext-app-browser-entry";
|
|
638
|
-
const RESOLVED_APP_BROWSER_ENTRY = "\
|
|
707
|
+
const RESOLVED_APP_BROWSER_ENTRY = "\0" + VIRTUAL_APP_BROWSER_ENTRY;
|
|
639
708
|
const VIRTUAL_APP_CAPABILITIES = "virtual:vinext-app-capabilities";
|
|
640
|
-
const RESOLVED_APP_CAPABILITIES = "\
|
|
709
|
+
const RESOLVED_APP_CAPABILITIES = "\0" + VIRTUAL_APP_CAPABILITIES;
|
|
641
710
|
const RESOLVED_ROOT_PARAMS = "\0virtual:vinext-root-params";
|
|
711
|
+
const APP_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("app-request-stage-independent-entry");
|
|
712
|
+
const APP_RESPONSE_STAGE_ENTRY = resolveRuntimeEntryModule("app-response-stage-entry");
|
|
713
|
+
const PAGES_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("pages-request-stage-entry");
|
|
714
|
+
const PAGES_RESPONSE_STAGE_ENTRY = resolveRuntimeEntryModule("pages-response-stage-entry");
|
|
715
|
+
const WORKER_ROUTER_ENTRIES = /* @__PURE__ */ new Set([resolveRuntimeEntryModule("app-router-entry"), resolveRuntimeEntryModule("pages-router-entry")]);
|
|
642
716
|
/** Virtual module that registers config-driven cache adapters (see VinextOptions.cache). */
|
|
643
717
|
const RESOLVED_CACHE_ADAPTERS = "\0" + VIRTUAL_CACHE_ADAPTERS;
|
|
718
|
+
/** CDN-only registrar kept out of the data-cache response graph. */
|
|
719
|
+
const RESOLVED_CDN_CACHE_ADAPTER = "\0" + VIRTUAL_CDN_CACHE_ADAPTER;
|
|
644
720
|
/** Virtual module that registers the config-driven image optimizer (see VinextOptions.images). */
|
|
645
721
|
const RESOLVED_IMAGE_ADAPTERS = "\0" + VIRTUAL_IMAGE_ADAPTERS;
|
|
646
722
|
/** Virtual module for composed instrumentation-client bootstrap. */
|
|
@@ -671,9 +747,10 @@ const _shimsDir = path.resolve(__dirname, "shims") + "/";
|
|
|
671
747
|
const _serverDir = path.resolve(__dirname, "server");
|
|
672
748
|
const _fontGoogleShimPath = resolveShimModulePath(_shimsDir, "font-google");
|
|
673
749
|
const _appBrowserServerActionClientPath = resolveShimModulePath(_serverDir, "app-browser-server-action-client");
|
|
750
|
+
const _appRscCombinedHandlerPath = resolveShimModulePath(_serverDir, "app-rsc-combined-handler");
|
|
674
751
|
const _appRscHandlerPath = resolveShimModulePath(_serverDir, "app-rsc-handler");
|
|
675
752
|
const _pagesClientAssetsPath = resolveShimModulePath(_serverDir, "pages-client-assets");
|
|
676
|
-
const _canExternalizeAppRscHandler = _appRscHandlerPath.endsWith(".js");
|
|
753
|
+
const _canExternalizeAppRscHandler = _appRscHandlerPath.endsWith(".js") && _appRscCombinedHandlerPath.endsWith(".js");
|
|
677
754
|
function isValidExportIdentifier(name) {
|
|
678
755
|
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
679
756
|
}
|
|
@@ -745,8 +822,10 @@ for (const [specifier, definition] of Object.entries(_publicNextShimMap)) {
|
|
|
745
822
|
_reactServerShims.set(`${specifier}.js`, definition.shim);
|
|
746
823
|
}
|
|
747
824
|
_reactServerShims.set("next/dist/client/components/navigation", "navigation");
|
|
748
|
-
const
|
|
749
|
-
const
|
|
825
|
+
const clientManualChunks = createClientManualChunks(_shimsDir);
|
|
826
|
+
const clientCodeSplittingConfig = createClientCodeSplittingConfig(clientManualChunks);
|
|
827
|
+
const appClientManualChunks = createClientManualChunks(_shimsDir, true);
|
|
828
|
+
const appClientCodeSplittingConfig = createClientCodeSplittingConfig(appClientManualChunks);
|
|
750
829
|
function getClientOutputConfig(assetsDir, preserveAppRouteBoundaries = false) {
|
|
751
830
|
const codeSplitting = preserveAppRouteBoundaries ? appClientCodeSplittingConfig : clientCodeSplittingConfig;
|
|
752
831
|
return {
|
|
@@ -771,7 +850,9 @@ function createServerEnvironmentFileNameResolver(config, outputRoot) {
|
|
|
771
850
|
};
|
|
772
851
|
}
|
|
773
852
|
function vinext(options = {}) {
|
|
853
|
+
const internalOptions = options;
|
|
774
854
|
const { supportsNativeTypeofWindowFolding: useNativeTypeofWindowFolding } = assertSupportedViteVersion();
|
|
855
|
+
const reservedDevCliInvocation = reserveViteCliDevInvocation();
|
|
775
856
|
const prerenderConfig = normalizeVinextPrerenderConfig(options.prerender);
|
|
776
857
|
const cacheAdapterBuildOutputs = [options.cache?.data?.output, options.cache?.cdn?.output].filter((output) => output !== void 0);
|
|
777
858
|
let root;
|
|
@@ -781,20 +862,33 @@ function vinext(options = {}) {
|
|
|
781
862
|
let hasAppDir = false;
|
|
782
863
|
let hasPagesDir = false;
|
|
783
864
|
let nextConfig;
|
|
865
|
+
let nitroBuildDir;
|
|
784
866
|
let fileMatcher;
|
|
785
867
|
let middlewarePath = null;
|
|
868
|
+
let canonicalMiddlewarePath = null;
|
|
786
869
|
let instrumentationPath = null;
|
|
787
870
|
let instrumentationClientPath = null;
|
|
788
871
|
let clientInjectModule = null;
|
|
789
872
|
let globalNotFoundCssIsolationPath = null;
|
|
790
873
|
let clientAssetsInlineLimit = 0;
|
|
791
874
|
let hasCloudflarePlugin = false;
|
|
875
|
+
let matchedMultiStageOutput;
|
|
876
|
+
let selectedMultiStageOutput;
|
|
877
|
+
const isMultiStageServerEnvironment = (environment) => isServerEnvironment(environment) && (!hasAppDir || environment.name === "rsc");
|
|
792
878
|
let warnedInlineNextConfigOverride = false;
|
|
793
879
|
let hasNitroPlugin = false;
|
|
880
|
+
let nitroHostRuntime = "node";
|
|
794
881
|
let resolvedServerExternalPackages = [];
|
|
882
|
+
let registerNodeOpenTelemetryLoader = false;
|
|
795
883
|
let pagesTsconfigAliases = {};
|
|
796
884
|
let pagesBundledPackages = /* @__PURE__ */ new Set();
|
|
797
885
|
let isServeCommand = false;
|
|
886
|
+
let buildEmptyOutDir;
|
|
887
|
+
let buildLifecycleEnabled = false;
|
|
888
|
+
let hasPlainPagesBuildEnvironments = false;
|
|
889
|
+
let originalPlainPagesEnvironments;
|
|
890
|
+
let buildLifecycleInvocation;
|
|
891
|
+
let reactUpgradeChecked = false;
|
|
798
892
|
let pagesOptimizeEntries = [];
|
|
799
893
|
const importMetaUrlCapability = createImportMetaUrlPlugin({
|
|
800
894
|
getRoot: () => root,
|
|
@@ -804,7 +898,8 @@ function vinext(options = {}) {
|
|
|
804
898
|
}
|
|
805
899
|
});
|
|
806
900
|
const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
|
|
807
|
-
|
|
901
|
+
const resolvePagesClientAssetsOutputDir = (environmentName, outputDir) => !selectedMultiStageOutput && !hasAppDir && !hasCloudflarePlugin && environmentName === "ssr" ? path.dirname(outputDir) : outputDir;
|
|
902
|
+
let pagesClientAssetsModule = internalOptions.__pagesClientAssetsModule ?? null;
|
|
808
903
|
let devPublicFileRoutes = null;
|
|
809
904
|
let publicDirConflictOptions = null;
|
|
810
905
|
let copyPublicDirIntoStaticExportBasePath = false;
|
|
@@ -812,12 +907,14 @@ function vinext(options = {}) {
|
|
|
812
907
|
let rscCompatibilityId;
|
|
813
908
|
let draftModeSecret = getPagesPreviewModeId();
|
|
814
909
|
const prerenderSecret = process.env.__VINEXT_SHARED_PRERENDER_SECRET ?? randomBytes(32).toString("hex");
|
|
910
|
+
let revalidateSecret = process.env.__VINEXT_SHARED_REVALIDATE_SECRET;
|
|
815
911
|
let previewBuildCredentials;
|
|
816
912
|
const sassComposesLoader = createSassAwareFileSystemLoader();
|
|
817
|
-
|
|
913
|
+
const rscClassificationManifests = /* @__PURE__ */ new Map();
|
|
818
914
|
let rscActionOwnerRoutes = null;
|
|
819
915
|
let rscActionOwnerSharedRoots = [];
|
|
820
916
|
const serverEntryKindsByEnvironment = /* @__PURE__ */ new Map();
|
|
917
|
+
const serverRuntimeOutputDirs = /* @__PURE__ */ new Set();
|
|
821
918
|
function recordServerEntryLoad(environmentName, id) {
|
|
822
919
|
if (!environmentName) return;
|
|
823
920
|
let entries = serverEntryKindsByEnvironment.get(environmentName);
|
|
@@ -854,7 +951,17 @@ function vinext(options = {}) {
|
|
|
854
951
|
*/
|
|
855
952
|
async function generateServerEntry$1(configuredPublicDir) {
|
|
856
953
|
const publicFiles = isServeCommand && devPublicFileRoutes ? [...devPublicFileRoutes].sort() : scanPublicFileRoutes(root, configuredPublicDir === "" ? false : configuredPublicDir);
|
|
857
|
-
return generateServerEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, publicFiles,
|
|
954
|
+
return generateServerEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, publicFiles, {
|
|
955
|
+
nodeOpenTelemetryLoader: registerNodeOpenTelemetryLoader,
|
|
956
|
+
prerenderSecret
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
async function generatePagesRequestEntry$1(configuredPublicDir) {
|
|
960
|
+
const publicFiles = isServeCommand && devPublicFileRoutes ? [...devPublicFileRoutes].sort() : scanPublicFileRoutes(root, configuredPublicDir === "" ? false : configuredPublicDir);
|
|
961
|
+
return generatePagesRequestEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, publicFiles, prerenderSecret);
|
|
962
|
+
}
|
|
963
|
+
function generatePagesResponseEntry$1() {
|
|
964
|
+
return generatePagesResponseEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, prerenderSecret);
|
|
858
965
|
}
|
|
859
966
|
/**
|
|
860
967
|
* Generate the virtual client hydration entry module.
|
|
@@ -881,7 +988,8 @@ function vinext(options = {}) {
|
|
|
881
988
|
});
|
|
882
989
|
}
|
|
883
990
|
const autoRsc = options.rsc !== false;
|
|
884
|
-
const
|
|
991
|
+
const earlyRoot = earlyViteCliInvocation?.root ?? process.cwd();
|
|
992
|
+
const earlyBaseDir = path.resolve(earlyRoot, options.appDir ?? ".");
|
|
885
993
|
const earlyAppDirExists = !options.disableAppRouter && (fs.existsSync(path.join(earlyBaseDir, "app")) || fs.existsSync(path.join(earlyBaseDir, "src", "app")));
|
|
886
994
|
let resolvedReactPath = null;
|
|
887
995
|
let resolvedRscPath = null;
|
|
@@ -903,14 +1011,12 @@ function vinext(options = {}) {
|
|
|
903
1011
|
} });
|
|
904
1012
|
const useCachePlugin = await createUseCacheCallablePlugin({
|
|
905
1013
|
projectRoot: earlyBaseDir,
|
|
906
|
-
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href
|
|
907
|
-
getAppDir: () => appDir,
|
|
908
|
-
matchesPageExtension: (fileName) => fileMatcher.extensionRegex.test(fileName)
|
|
1014
|
+
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href
|
|
909
1015
|
});
|
|
910
1016
|
const useServerIndex = plugins.findIndex((plugin) => plugin.name === "rsc:use-server");
|
|
911
1017
|
if (useServerIndex === -1) throw new Error("vinext: Failed to locate @vitejs/plugin-rsc use-server plugin.");
|
|
912
1018
|
plugins.splice(useServerIndex, 0, useCachePlugin);
|
|
913
|
-
return plugins;
|
|
1019
|
+
return plugins.map(scopeRscPlugin);
|
|
914
1020
|
}).catch((cause) => {
|
|
915
1021
|
throw new Error("vinext: Failed to load @vitejs/plugin-rsc.", { cause });
|
|
916
1022
|
});
|
|
@@ -919,8 +1025,6 @@ function vinext(options = {}) {
|
|
|
919
1025
|
manualUseCachePluginPromise = createUseCacheCallablePlugin({
|
|
920
1026
|
projectRoot: earlyBaseDir,
|
|
921
1027
|
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href,
|
|
922
|
-
getAppDir: () => appDir,
|
|
923
|
-
matchesPageExtension: (fileName) => fileMatcher.extensionRegex.test(fileName),
|
|
924
1028
|
allowMissingRsc: true
|
|
925
1029
|
});
|
|
926
1030
|
}
|
|
@@ -987,9 +1091,10 @@ function vinext(options = {}) {
|
|
|
987
1091
|
}
|
|
988
1092
|
const delegate = mdxFactory(mdxOpts);
|
|
989
1093
|
mdxDelegate = delegate;
|
|
990
|
-
if (reason === "detected")
|
|
991
|
-
|
|
992
|
-
|
|
1094
|
+
if (reason === "detected") {
|
|
1095
|
+
if (nextConfig.mdx) console.log("[vinext] Auto-injected @mdx-js/rollup with remark/rehype plugins from next.config");
|
|
1096
|
+
else console.log("[vinext] Auto-injected @mdx-js/rollup for MDX support");
|
|
1097
|
+
} else console.log("[vinext] Auto-injected @mdx-js/rollup for on-demand MDX support");
|
|
993
1098
|
return delegate;
|
|
994
1099
|
} catch {
|
|
995
1100
|
if (reason === "detected" && !warnedMissingMdxPlugin) {
|
|
@@ -1029,30 +1134,97 @@ function vinext(options = {}) {
|
|
|
1029
1134
|
}
|
|
1030
1135
|
};
|
|
1031
1136
|
const cachedConsumerConditionTransform = createTransformCache();
|
|
1137
|
+
const cachedJsxInJsTransform = createTransformCache();
|
|
1032
1138
|
let transformProjectLocalCommonJs = false;
|
|
1033
1139
|
let transformBundledCommonJsDependencies = false;
|
|
1034
1140
|
const commonJsPlugin = commonjs({ filter(id) {
|
|
1141
|
+
if (isPathInside(__dirname, toSlash(stripViteModuleQuery(id)))) return false;
|
|
1035
1142
|
return commonjsTransformFilter(id, transformProjectLocalCommonJs, transformBundledCommonJsDependencies, importMetaUrlCapability.isBundledCommonJsDependencyId);
|
|
1036
1143
|
} });
|
|
1037
1144
|
const commonJsTransform = commonJsPlugin.transform;
|
|
1038
|
-
if (typeof commonJsTransform === "function")
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1145
|
+
if (typeof commonJsTransform === "function") {
|
|
1146
|
+
const environmentAwareCommonJsTransform = function(code, id, ...args) {
|
|
1147
|
+
const normalizedId = toSlash(stripViteModuleQuery(id));
|
|
1148
|
+
const nitroServicePath = this.environment.name === "nitro" && nitroBuildDir && normalizedId.endsWith("/entry.js") ? path.relative(path.join(canonicalize(nitroBuildDir), "vite/services"), normalizedId) : "";
|
|
1149
|
+
if (/^[^/]+\/entry\.js$/.test(nitroServicePath)) return null;
|
|
1150
|
+
if (isPathInside(__dirname, toSlash(stripViteModuleQuery(id)))) return null;
|
|
1151
|
+
if (this.environment.mode === "dev" && this.environment.depsOptimizer?.isOptimizedDepFile(id)) return null;
|
|
1152
|
+
const isDev = this.environment.mode === "dev";
|
|
1153
|
+
const isServer = this.environment.config.consumer === "server";
|
|
1154
|
+
const bundledDependency = isDev && isServer && (code.includes("__filename") || code.includes("__dirname")) && importMetaUrlCapability.isBundledCommonJsDependencyId(id);
|
|
1155
|
+
const projectLocal = !bundledDependency && !id.includes("/node_modules/") && !id.includes("\\node_modules\\");
|
|
1156
|
+
const userCondition = commonjsTransformFilter(id, projectLocal && isDev, bundledDependency, importMetaUrlCapability.isBundledCommonJsDependencyId);
|
|
1157
|
+
if (userCondition === false) return null;
|
|
1158
|
+
if (userCondition !== true && id.includes("node_modules")) return null;
|
|
1159
|
+
const previousProjectLocal = transformProjectLocalCommonJs;
|
|
1160
|
+
const previous = transformBundledCommonJsDependencies;
|
|
1161
|
+
transformProjectLocalCommonJs = projectLocal && isDev;
|
|
1162
|
+
transformBundledCommonJsDependencies = bundledDependency;
|
|
1163
|
+
try {
|
|
1164
|
+
return commonJsTransform.call(this, code, id, ...args);
|
|
1165
|
+
} finally {
|
|
1166
|
+
transformProjectLocalCommonJs = previousProjectLocal;
|
|
1167
|
+
transformBundledCommonJsDependencies = previous;
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
1170
|
+
commonJsPlugin.transform = {
|
|
1171
|
+
filter: { code: { include: COMMONJS_SYNTAX_CODE_FILTER } },
|
|
1172
|
+
handler: environmentAwareCommonJsTransform
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
const buildLifecyclePlugins = createBuildLifecyclePlugins({
|
|
1176
|
+
isEnabled: (builder) => buildLifecycleEnabled && builder.config.build.write !== false && !builder.config.build.lib && (buildLifecycleInvocation !== void 0 || !builder.config.build.watch && !builder.config.build.ssr && getBuildBundlerOptions(builder.config.build)?.input === void 0),
|
|
1177
|
+
onComplete: () => buildLifecycleInvocation?.onComplete?.(),
|
|
1178
|
+
shouldDeferPostBuild: () => buildLifecycleInvocation !== void 0,
|
|
1179
|
+
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),
|
|
1180
|
+
onPrepare: () => {
|
|
1181
|
+
if (!hasAppDir || reactUpgradeChecked) return;
|
|
1182
|
+
reactUpgradeChecked = true;
|
|
1183
|
+
const reactUpgrade = getReactUpgradeDeps(root);
|
|
1184
|
+
if (reactUpgrade.length === 0) return;
|
|
1185
|
+
const [packageManager, ...packageManagerArgs] = detectPackageManager(root).replace(/ -D$/, "").split(" ");
|
|
1186
|
+
console.log(" Upgrading React for RSC compatibility...");
|
|
1187
|
+
execFileSync(packageManager, [...packageManagerArgs, ...reactUpgrade], {
|
|
1188
|
+
cwd: root,
|
|
1189
|
+
stdio: "inherit",
|
|
1190
|
+
shell: process.platform === "win32"
|
|
1191
|
+
});
|
|
1192
|
+
},
|
|
1193
|
+
shouldBuildPlainPages: () => !hasAppDir && !hasCloudflarePlugin && !hasNitroPlugin,
|
|
1194
|
+
createContext: () => ({
|
|
1195
|
+
cacheConfig: options.cache ?? null,
|
|
1196
|
+
configNodeEnv: viteCliBuildConfigNodeEnv,
|
|
1197
|
+
createPagesOnlyPlugins: (pagesClientAssetsModule) => vinext({
|
|
1198
|
+
...options,
|
|
1199
|
+
disableAppRouter: true,
|
|
1200
|
+
precompress: false,
|
|
1201
|
+
prerender: void 0,
|
|
1202
|
+
__skipBuildLifecycle: true,
|
|
1203
|
+
__pagesClientAssetsModule: pagesClientAssetsModule
|
|
1204
|
+
}),
|
|
1205
|
+
emptyOutDir: buildEmptyOutDir,
|
|
1206
|
+
hasAppDir,
|
|
1207
|
+
hasPagesDir,
|
|
1208
|
+
nextConfig,
|
|
1209
|
+
prerenderConfig,
|
|
1210
|
+
prerenderConcurrency: prerenderConfig?.concurrency,
|
|
1211
|
+
prerenderSecret,
|
|
1212
|
+
previewBuildCredentials,
|
|
1213
|
+
revalidateSecret,
|
|
1214
|
+
root,
|
|
1215
|
+
routeRootConfig: {
|
|
1216
|
+
appDir: options.appDir,
|
|
1217
|
+
disableAppRouter: options.disableAppRouter,
|
|
1218
|
+
rscOutDir: options.rscOutDir,
|
|
1219
|
+
ssrOutDir: options.ssrOutDir
|
|
1220
|
+
},
|
|
1221
|
+
rscBuildIdentity,
|
|
1222
|
+
rscCompatibilityId,
|
|
1223
|
+
skipHybridPagesBundle: hasCloudflarePlugin
|
|
1224
|
+
})
|
|
1225
|
+
});
|
|
1055
1226
|
const plugins = [
|
|
1227
|
+
buildLifecyclePlugins[0],
|
|
1056
1228
|
createStyledJsxPlugin(earlyBaseDir),
|
|
1057
1229
|
mdxProxyPlugin,
|
|
1058
1230
|
reactPluginPromise,
|
|
@@ -1087,15 +1259,17 @@ function vinext(options = {}) {
|
|
|
1087
1259
|
if (!code.includes("use client") && !code.includes("use server")) return;
|
|
1088
1260
|
if (!hasReactDirective(code)) return;
|
|
1089
1261
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1262
|
+
return cachedJsxInJsTransform(id, code, void 0, async () => {
|
|
1263
|
+
const result = await transformWithOxc(code, id, {
|
|
1264
|
+
lang: "jsx",
|
|
1265
|
+
jsx: { runtime: "automatic" },
|
|
1266
|
+
sourcemap: true
|
|
1267
|
+
});
|
|
1268
|
+
return {
|
|
1269
|
+
code: result.code,
|
|
1270
|
+
map: result.map
|
|
1271
|
+
};
|
|
1094
1272
|
});
|
|
1095
|
-
return {
|
|
1096
|
-
code: result.code,
|
|
1097
|
-
map: result.map
|
|
1098
|
-
};
|
|
1099
1273
|
}
|
|
1100
1274
|
}
|
|
1101
1275
|
},
|
|
@@ -1119,6 +1293,7 @@ function vinext(options = {}) {
|
|
|
1119
1293
|
}),
|
|
1120
1294
|
dataUrlCssPlugin(),
|
|
1121
1295
|
createCssModuleImportCompatibilityPlugin(),
|
|
1296
|
+
createDevServerLifecyclePlugin({}, (config) => config[VINEXT_DEV_CLI_LIFECYCLE] === true),
|
|
1122
1297
|
{
|
|
1123
1298
|
name: "vinext:config",
|
|
1124
1299
|
enforce: "pre",
|
|
@@ -1126,33 +1301,48 @@ function vinext(options = {}) {
|
|
|
1126
1301
|
[VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY]: options.nextConfig ?? null,
|
|
1127
1302
|
[VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY]: {
|
|
1128
1303
|
appDir: options.appDir,
|
|
1304
|
+
clientOutDir: options.clientOutDir,
|
|
1129
1305
|
disableAppRouter: options.disableAppRouter,
|
|
1130
1306
|
rscOutDir: options.rscOutDir,
|
|
1131
1307
|
ssrOutDir: options.ssrOutDir
|
|
1132
1308
|
},
|
|
1133
1309
|
[VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY]: options.cache ?? null,
|
|
1134
1310
|
async config(config, env) {
|
|
1311
|
+
hasPlainPagesBuildEnvironments = false;
|
|
1312
|
+
originalPlainPagesEnvironments = void 0;
|
|
1313
|
+
buildEmptyOutDir = typeof config.build?.emptyOutDir === "boolean" ? config.build.emptyOutDir : void 0;
|
|
1135
1314
|
isServeCommand = env.command === "serve";
|
|
1136
|
-
root = toSlash(config.root ??
|
|
1315
|
+
root = path.resolve(toSlash(process.cwd()), config.root ?? ".");
|
|
1316
|
+
const devCliLifecycleEnabled = env.command === "serve" && env.isPreview !== true && claimViteCliDevInvocation(root, config["__vinextDevRestart"] === true, reservedDevCliInvocation && config.configFile === false);
|
|
1317
|
+
buildLifecycleInvocation = config[VINEXT_BUILD_LIFECYCLE_CONFIG];
|
|
1318
|
+
buildLifecycleEnabled = env.command === "build" && !internalOptions.__skipBuildLifecycle && (buildLifecycleInvocation !== void 0 || claimViteCliBuildInvocation());
|
|
1137
1319
|
const userResolve = config.resolve;
|
|
1138
1320
|
let tsconfigPathAliases = {};
|
|
1139
1321
|
let sassTsconfigPathAliases = [];
|
|
1140
1322
|
const swcHelpersAlias = resolveSwcHelpersAlias(root);
|
|
1141
1323
|
const mode = env?.mode ?? "development";
|
|
1142
|
-
if (config.envDir !== false)
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1324
|
+
if (config.envDir !== false) {
|
|
1325
|
+
const envDir = config.envDir ?? root;
|
|
1326
|
+
loadDotenv({
|
|
1327
|
+
root: envDir,
|
|
1328
|
+
mode
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1146
1331
|
let resolvedNodeEnv;
|
|
1147
1332
|
if (env?.command === "build" || env?.isPreview === true) resolvedNodeEnv = "production";
|
|
1148
1333
|
else if (mode === "test") resolvedNodeEnv = "test";
|
|
1149
1334
|
else resolvedNodeEnv = "development";
|
|
1150
|
-
if (process.env.NODE_ENV !== resolvedNodeEnv) Reflect.set(process.env, "NODE_ENV", resolvedNodeEnv);
|
|
1151
|
-
if (env?.command === "build")
|
|
1335
|
+
if (!(process.env.NODE_ENV === "test" && viteCliBuildConfigNodeEnv === "test") && process.env.NODE_ENV !== resolvedNodeEnv) Reflect.set(process.env, "NODE_ENV", resolvedNodeEnv);
|
|
1336
|
+
if (env?.command === "build") {
|
|
1337
|
+
previewBuildCredentials = getPreviewBuildCredentials() ?? createPreviewBuildCredentials();
|
|
1338
|
+
if (buildLifecycleEnabled) revalidateSecret ??= randomBytes(32).toString("hex");
|
|
1339
|
+
}
|
|
1152
1340
|
draftModeSecret = previewBuildCredentials?.id ?? getPagesPreviewModeId();
|
|
1153
1341
|
let baseDir;
|
|
1154
|
-
if (options.appDir)
|
|
1155
|
-
|
|
1342
|
+
if (options.appDir) {
|
|
1343
|
+
const dir = path.isAbsolute(options.appDir) ? options.appDir : path.resolve(root, options.appDir);
|
|
1344
|
+
baseDir = toSlash(dir);
|
|
1345
|
+
} else {
|
|
1156
1346
|
const hasRootApp = fs.existsSync(path.join(root, "app"));
|
|
1157
1347
|
const hasRootPages = fs.existsSync(path.join(root, "pages"));
|
|
1158
1348
|
const hasSrcApp = fs.existsSync(path.join(root, "src", "app"));
|
|
@@ -1186,6 +1376,7 @@ function vinext(options = {}) {
|
|
|
1186
1376
|
buildId: sharedBuildId
|
|
1187
1377
|
};
|
|
1188
1378
|
}
|
|
1379
|
+
if (env?.command === "build" && earlyViteCliInvocation?.command === "build") Reflect.set(process.env, "NODE_ENV", "production");
|
|
1189
1380
|
const configuredTsconfigPath = isUnknownRecord(nextConfig.typescript) ? typeof nextConfig.typescript.tsconfigPath === "string" ? nextConfig.typescript.tsconfigPath : void 0 : void 0;
|
|
1190
1381
|
const resolvedTsconfigAliases = resolveTsconfigAliases(root, configuredTsconfigPath);
|
|
1191
1382
|
tsconfigPathAliases = resolvedTsconfigAliases.vite;
|
|
@@ -1207,6 +1398,8 @@ function vinext(options = {}) {
|
|
|
1207
1398
|
instrumentationClientPath = findInstrumentationClientFile(root, fileMatcher);
|
|
1208
1399
|
const middlewareConventionDir = canonicalize(baseDir) === canonicalize(path.join(root, "src")) ? path.join(root, "src") : root;
|
|
1209
1400
|
middlewarePath = findMiddlewareFile(root, fileMatcher, middlewareConventionDir);
|
|
1401
|
+
pageTransformCanonicalPaths.clear();
|
|
1402
|
+
canonicalMiddlewarePath = middlewarePath ? canonicalize(middlewarePath) : null;
|
|
1210
1403
|
if (middlewarePath) {
|
|
1211
1404
|
const staticMatcher = extractMiddlewareMatcherConfigValue(middlewarePath);
|
|
1212
1405
|
if (staticMatcher !== void 0) validateMiddlewareMatcherPatterns(staticMatcher);
|
|
@@ -1260,7 +1453,6 @@ function vinext(options = {}) {
|
|
|
1260
1453
|
defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_LOCAL_IP"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowLocalIP ?? false));
|
|
1261
1454
|
defines["process.env.__VINEXT_IMAGE_UNOPTIMIZED"] = JSON.stringify(String(nextConfig.images?.unoptimized === true));
|
|
1262
1455
|
defines["process.env.__VINEXT_BUILD_ID"] = JSON.stringify(nextConfig.buildId);
|
|
1263
|
-
defines["process.env.__VINEXT_CANONICAL_RSC_REQUESTS"] = JSON.stringify(env?.command === "build" && hasVerbatimResponseVary(options.cache) ? "1" : "");
|
|
1264
1456
|
defines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify(rscCompatibilityId);
|
|
1265
1457
|
defines["process.env.__VINEXT_RSC_BUILD_IDENTITY"] = JSON.stringify(rscBuildIdentity ?? "");
|
|
1266
1458
|
defines["process.env.__VINEXT_DEPLOYMENT_ID"] = JSON.stringify(nextConfig.deploymentId ?? "");
|
|
@@ -1318,6 +1510,9 @@ function vinext(options = {}) {
|
|
|
1318
1510
|
}
|
|
1319
1511
|
flattenPlugins(config.plugins ?? []);
|
|
1320
1512
|
hasCloudflarePlugin = pluginsFlat.some((p) => p && typeof p === "object" && "name" in p && typeof p.name === "string" && (p.name === "vite-plugin-cloudflare" || p.name.startsWith("vite-plugin-cloudflare:")));
|
|
1513
|
+
const configuredMultiStageOutput = options.cache?.cdn?.output;
|
|
1514
|
+
matchedMultiStageOutput = configuredMultiStageOutput?.type === "multi-stage" && (configuredMultiStageOutput.matchesBuild?.({ plugins: pluginsFlat }) ?? true) ? configuredMultiStageOutput : void 0;
|
|
1515
|
+
selectedMultiStageOutput = isServeCommand ? void 0 : matchedMultiStageOutput;
|
|
1321
1516
|
hasNitroPlugin = pluginsFlat.some((p) => p && typeof p === "object" && "name" in p && typeof p.name === "string" && (p.name === "nitro" || p.name.startsWith("nitro:")));
|
|
1322
1517
|
let postcssOverride;
|
|
1323
1518
|
if (!config.css?.postcss || typeof config.css.postcss === "string") postcssOverride = await resolvePostcssStringPlugins(root);
|
|
@@ -1327,11 +1522,20 @@ function vinext(options = {}) {
|
|
|
1327
1522
|
const isSSR = !!config.build?.ssr;
|
|
1328
1523
|
const serverTranspilePackages = [...nextConfig?.turbopackTranspilePackages ?? [], ...nextConfig?.optimizePackageImports ?? []];
|
|
1329
1524
|
pagesBundledPackages = new Set(serverTranspilePackages);
|
|
1330
|
-
const
|
|
1525
|
+
const openTelemetryPackages = findOpenTelemetryPackages(root);
|
|
1526
|
+
registerNodeOpenTelemetryLoader = env.command === "build" && !hasCloudflarePlugin && !hasNitroPlugin && instrumentationPath !== null && openTelemetryPackages.includes("@opentelemetry/instrumentation") && !serverTranspilePackages.includes("@opentelemetry/instrumentation") && (() => {
|
|
1527
|
+
try {
|
|
1528
|
+
createRequire(path.join(root, "package.json")).resolve("@opentelemetry/instrumentation/hook.mjs");
|
|
1529
|
+
return true;
|
|
1530
|
+
} catch {
|
|
1531
|
+
return false;
|
|
1532
|
+
}
|
|
1533
|
+
})();
|
|
1534
|
+
const nextServerExternal = mergeServerExternalPackages(nextConfig?.serverExternalPackages, serverTranspilePackages, openTelemetryPackages);
|
|
1331
1535
|
resolvedServerExternalPackages = nextServerExternal;
|
|
1332
1536
|
const isMultiEnv = hasAppDir || hasCloudflarePlugin || hasNitroPlugin;
|
|
1333
1537
|
const hasBuildInput = getBuildBundlerOptions(config.build)?.input !== void 0;
|
|
1334
|
-
const shouldInjectPlainPagesEnvironments = !hasAppDir && !hasCloudflarePlugin && !isSSR && !hasBuildInput;
|
|
1538
|
+
const shouldInjectPlainPagesEnvironments = !hasAppDir && !hasCloudflarePlugin && !isSSR && !hasBuildInput && !config.build?.lib;
|
|
1335
1539
|
const hasClientBuildEnvironment = hasAppDir || hasCloudflarePlugin || hasNitroPlugin || shouldInjectPlainPagesEnvironments;
|
|
1336
1540
|
const clientAssetsDir = resolveAssetsDir(nextConfig.assetPrefix ?? "");
|
|
1337
1541
|
clientAssetsInlineLimit = config.build?.assetsInlineLimit ?? 0;
|
|
@@ -1340,8 +1544,23 @@ function vinext(options = {}) {
|
|
|
1340
1544
|
overlay: false
|
|
1341
1545
|
};
|
|
1342
1546
|
const cssModulesOverride = config.css?.modules === false || typeof config.css?.modules === "object" && "Loader" in config.css.modules ? {} : { modules: { Loader: sassComposesLoader.Loader } };
|
|
1547
|
+
const explicitViteAliases = config.resolve?.alias;
|
|
1548
|
+
const userAliasEntries = Array.isArray(explicitViteAliases) ? explicitViteAliases : Object.entries(explicitViteAliases ?? {}).map(([find, replacement]) => ({
|
|
1549
|
+
find,
|
|
1550
|
+
replacement
|
|
1551
|
+
}));
|
|
1552
|
+
if (config.resolve) {
|
|
1553
|
+
config.resolve = { ...config.resolve };
|
|
1554
|
+
delete config.resolve.alias;
|
|
1555
|
+
}
|
|
1343
1556
|
const viteConfig = {
|
|
1344
1557
|
appType: "custom",
|
|
1558
|
+
...devCliLifecycleEnabled ? { [VINEXT_DEV_CLI_LIFECYCLE]: true } : {},
|
|
1559
|
+
...hasAppDir && hasNitroPlugin ? { rsc: { serverHandler: false } } : {},
|
|
1560
|
+
...!hasAppDir && hasCloudflarePlugin ? { builder: {
|
|
1561
|
+
...config.builder,
|
|
1562
|
+
sharedConfigBuild: true
|
|
1563
|
+
} } : {},
|
|
1345
1564
|
build: {
|
|
1346
1565
|
ssrEmitAssets: true,
|
|
1347
1566
|
cssTarget: [
|
|
@@ -1369,13 +1588,20 @@ function vinext(options = {}) {
|
|
|
1369
1588
|
},
|
|
1370
1589
|
worker: { plugins: () => [createWorkerImageImportsPlugin({ deploymentId: nextConfig.deploymentId })] },
|
|
1371
1590
|
server: {
|
|
1591
|
+
watch: config.server?.watch === null ? null : {
|
|
1592
|
+
ignored: [VINEXT_GENERATED_DIR_RE],
|
|
1593
|
+
exclude: [VINEXT_GENERATED_DIR_RE]
|
|
1594
|
+
},
|
|
1372
1595
|
cors: {
|
|
1373
1596
|
preflightContinue: true,
|
|
1374
1597
|
origin: /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/
|
|
1375
1598
|
},
|
|
1376
1599
|
hmr: devHmrConfig
|
|
1377
1600
|
},
|
|
1378
|
-
...hasCloudflarePlugin || hasNitroPlugin ? {} : config.ssr?.external === true ? { ssr: {
|
|
1601
|
+
...hasCloudflarePlugin || hasNitroPlugin ? {} : config.ssr?.external === true ? { ssr: {
|
|
1602
|
+
external: true,
|
|
1603
|
+
noExternal: [...PATCHED_SERVER_PACKAGES]
|
|
1604
|
+
} } : { ssr: {
|
|
1379
1605
|
external: [
|
|
1380
1606
|
"react",
|
|
1381
1607
|
"react-dom",
|
|
@@ -1387,13 +1613,16 @@ function vinext(options = {}) {
|
|
|
1387
1613
|
noExternal: true
|
|
1388
1614
|
} },
|
|
1389
1615
|
resolve: {
|
|
1390
|
-
alias: buildResolveAliasEntries({
|
|
1616
|
+
alias: [...userAliasEntries, ...buildResolveAliasEntries({
|
|
1391
1617
|
...swcHelpersAlias ? { "@swc/helpers/_": swcHelpersAlias } : {},
|
|
1392
1618
|
...tsconfigPathAliases,
|
|
1393
1619
|
...nextConfig.aliases,
|
|
1394
1620
|
...nextShimMap,
|
|
1395
1621
|
"vinext/server/pages-client-assets": _pagesClientAssetsPath
|
|
1396
|
-
}, tsconfigPathAliases
|
|
1622
|
+
}, tsconfigPathAliases, {
|
|
1623
|
+
...nextConfig.aliases,
|
|
1624
|
+
...nextShimMap
|
|
1625
|
+
})],
|
|
1397
1626
|
dedupe: [
|
|
1398
1627
|
"react",
|
|
1399
1628
|
"react-dom",
|
|
@@ -1468,28 +1697,84 @@ function vinext(options = {}) {
|
|
|
1468
1697
|
}
|
|
1469
1698
|
};
|
|
1470
1699
|
pagesOptimizeEntries = !hasAppDir ? [...hasPagesDir ? [toRelativeFileEntry(root, pagesDir) + "/**/*.{tsx,ts,jsx,js}"] : [], ...[instrumentationPath, instrumentationClientPath].flatMap((entry) => entry ? [toRelativeFileEntry(root, entry)] : [])] : [];
|
|
1700
|
+
if (env.command === "serve" && !hasAppDir && !hasCloudflarePlugin && !shouldInjectPlainPagesEnvironments) viteConfig.optimizeDeps.include = [.../* @__PURE__ */ new Set([...incomingInclude, "react-dom/client"])];
|
|
1471
1701
|
if (hasAppDir) {
|
|
1472
1702
|
const appEntries = [`${path.relative(root, appDir)}/**/*.{tsx,ts,jsx,js}`];
|
|
1473
1703
|
const explicitInstrumentationEntries = [instrumentationPath, instrumentationClientPath].flatMap((entry) => entry ? [toRelativeFileEntry(root, entry)] : []);
|
|
1474
1704
|
const optimizeEntries = [.../* @__PURE__ */ new Set([...appEntries, ...explicitInstrumentationEntries])];
|
|
1705
|
+
const additionalRscOptimizeIncludes = [];
|
|
1706
|
+
if (env.command === "serve" && hasCloudflarePlugin && nextConfig?.aliases["next-intl/config"] && !(config.environments?.rsc?.optimizeDeps?.noDiscovery ?? config.optimizeDeps?.noDiscovery)) {
|
|
1707
|
+
const projectRequire = createRequire(path.join(root, "package.json"));
|
|
1708
|
+
const excluded = [...incomingExclude, ...config.environments?.rsc?.optimizeDeps?.exclude ?? []];
|
|
1709
|
+
for (const id of [
|
|
1710
|
+
"@formatjs/intl-localematcher",
|
|
1711
|
+
"negotiator",
|
|
1712
|
+
"@formatjs/fast-memoize",
|
|
1713
|
+
"intl-messageformat"
|
|
1714
|
+
]) {
|
|
1715
|
+
if (excluded.includes(id)) continue;
|
|
1716
|
+
try {
|
|
1717
|
+
projectRequire.resolve(id);
|
|
1718
|
+
additionalRscOptimizeIncludes.push(id);
|
|
1719
|
+
} catch {}
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
const additionalClientOptimizeIncludes = [];
|
|
1723
|
+
let hasNextIntl = Boolean(nextConfig?.aliases["next-intl/config"]);
|
|
1724
|
+
if (env.command === "serve" && !hasNextIntl) try {
|
|
1725
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
1726
|
+
hasNextIntl = [
|
|
1727
|
+
"dependencies",
|
|
1728
|
+
"devDependencies",
|
|
1729
|
+
"optionalDependencies",
|
|
1730
|
+
"peerDependencies"
|
|
1731
|
+
].some((field) => Object.hasOwn(pkg[field] ?? {}, "next-intl"));
|
|
1732
|
+
} catch {}
|
|
1733
|
+
if (env.command === "serve" && hasNextIntl && !(config.environments?.client?.optimizeDeps?.noDiscovery ?? config.optimizeDeps?.noDiscovery)) {
|
|
1734
|
+
const excluded = [...incomingExclude, ...config.environments?.client?.optimizeDeps?.exclude ?? []];
|
|
1735
|
+
try {
|
|
1736
|
+
const projectRequire = createRequire(path.join(root, "package.json"));
|
|
1737
|
+
const packageRequire = createRequire(projectRequire.resolve("next-intl"));
|
|
1738
|
+
for (const id of [
|
|
1739
|
+
"use-intl",
|
|
1740
|
+
"use-intl/react",
|
|
1741
|
+
"use-intl/_IntlProvider",
|
|
1742
|
+
"use-intl/_useLocale"
|
|
1743
|
+
]) {
|
|
1744
|
+
const include = `next-intl > ${id}`;
|
|
1745
|
+
if (excluded.includes("use-intl") || excluded.includes(id) || excluded.includes(include)) continue;
|
|
1746
|
+
try {
|
|
1747
|
+
packageRequire.resolve(id);
|
|
1748
|
+
additionalClientOptimizeIncludes.push(include);
|
|
1749
|
+
} catch {}
|
|
1750
|
+
}
|
|
1751
|
+
if (!excluded.includes("next") && !excluded.includes("next/link")) additionalClientOptimizeIncludes.push("next/link");
|
|
1752
|
+
} catch {}
|
|
1753
|
+
}
|
|
1475
1754
|
const appClientInput = { index: VIRTUAL_APP_BROWSER_ENTRY };
|
|
1476
1755
|
if (hasPagesDir) appClientInput["vinext-client-entry"] = VIRTUAL_CLIENT_ENTRY;
|
|
1756
|
+
const nitroDevEnvironmentResolve = hasNitroPlugin && env?.command === "serve" ? { resolve: { noExternal: ["next"] } } : {};
|
|
1477
1757
|
viteConfig.environments = {
|
|
1478
1758
|
rsc: {
|
|
1759
|
+
...nitroDevEnvironmentResolve,
|
|
1479
1760
|
...hasCloudflarePlugin || hasNitroPlugin ? {} : { resolve: {
|
|
1480
1761
|
external: userSsrExternal === true ? true : [
|
|
1481
1762
|
"satori",
|
|
1482
1763
|
"@resvg/resvg-js",
|
|
1483
1764
|
"yoga-wasm-web",
|
|
1484
|
-
...env?.command === "serve" && _canExternalizeAppRscHandler ? ["vinext/server/app-rsc-handler"] : [],
|
|
1765
|
+
...env?.command === "serve" && _canExternalizeAppRscHandler ? ["vinext/server/app-rsc-combined-handler", "vinext/server/app-rsc-handler"] : [],
|
|
1485
1766
|
...userSsrExternal
|
|
1486
1767
|
],
|
|
1487
|
-
|
|
1768
|
+
noExternal: userSsrExternal === true ? [...PATCHED_SERVER_PACKAGES] : true
|
|
1488
1769
|
} },
|
|
1489
1770
|
optimizeDeps: {
|
|
1490
1771
|
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE),
|
|
1491
1772
|
entries: optimizeEntries,
|
|
1492
|
-
include: [.../* @__PURE__ */ new Set([
|
|
1773
|
+
include: [.../* @__PURE__ */ new Set([
|
|
1774
|
+
...incomingInclude,
|
|
1775
|
+
...additionalRscOptimizeIncludes,
|
|
1776
|
+
"react-server-dom-webpack/static.edge"
|
|
1777
|
+
])],
|
|
1493
1778
|
...depOptimizeNodeEnvOptions
|
|
1494
1779
|
},
|
|
1495
1780
|
build: {
|
|
@@ -1501,13 +1786,14 @@ function vinext(options = {}) {
|
|
|
1501
1786
|
}
|
|
1502
1787
|
},
|
|
1503
1788
|
ssr: {
|
|
1789
|
+
...nitroDevEnvironmentResolve,
|
|
1504
1790
|
...hasCloudflarePlugin || hasNitroPlugin ? {} : { resolve: {
|
|
1505
1791
|
external: userSsrExternal === true ? true : [
|
|
1506
1792
|
...userSsrExternal,
|
|
1507
1793
|
"ipaddr.js",
|
|
1508
1794
|
...externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []
|
|
1509
1795
|
],
|
|
1510
|
-
|
|
1796
|
+
noExternal: userSsrExternal === true ? [...PATCHED_SERVER_PACKAGES] : true
|
|
1511
1797
|
} },
|
|
1512
1798
|
optimizeDeps: {
|
|
1513
1799
|
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], userSsrExternal === true || externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []),
|
|
@@ -1526,6 +1812,7 @@ function vinext(options = {}) {
|
|
|
1526
1812
|
entries: optimizeEntries,
|
|
1527
1813
|
include: [.../* @__PURE__ */ new Set([
|
|
1528
1814
|
...incomingInclude,
|
|
1815
|
+
...additionalClientOptimizeIncludes,
|
|
1529
1816
|
"react",
|
|
1530
1817
|
"react-dom",
|
|
1531
1818
|
"react-dom/client",
|
|
@@ -1549,6 +1836,7 @@ function vinext(options = {}) {
|
|
|
1549
1836
|
} else if (hasCloudflarePlugin) viteConfig.environments = { client: {
|
|
1550
1837
|
consumer: "client",
|
|
1551
1838
|
optimizeDeps: {
|
|
1839
|
+
include: ["react-dom/client"],
|
|
1552
1840
|
...pagesOptimizeEntries.length > 0 ? { entries: pagesOptimizeEntries } : {},
|
|
1553
1841
|
...depOptimizeNodeEnvOptions
|
|
1554
1842
|
},
|
|
@@ -1563,49 +1851,55 @@ function vinext(options = {}) {
|
|
|
1563
1851
|
})
|
|
1564
1852
|
}
|
|
1565
1853
|
} };
|
|
1566
|
-
else if (shouldInjectPlainPagesEnvironments)
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
resolve: {
|
|
1587
|
-
external: [
|
|
1588
|
-
"react",
|
|
1589
|
-
"react-dom",
|
|
1590
|
-
"react-dom/server",
|
|
1591
|
-
"ipaddr.js",
|
|
1592
|
-
...nextServerExternal
|
|
1593
|
-
],
|
|
1594
|
-
noExternal: true
|
|
1595
|
-
},
|
|
1596
|
-
optimizeDeps: {
|
|
1597
|
-
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], Object.keys(nextShimMap)),
|
|
1598
|
-
...depOptimizeNodeEnvOptions
|
|
1854
|
+
else if (shouldInjectPlainPagesEnvironments) {
|
|
1855
|
+
const plainPagesEnvironments = {
|
|
1856
|
+
client: {
|
|
1857
|
+
consumer: "client",
|
|
1858
|
+
optimizeDeps: {
|
|
1859
|
+
include: ["react-dom/client"],
|
|
1860
|
+
...pagesOptimizeEntries.length > 0 ? { entries: pagesOptimizeEntries } : {},
|
|
1861
|
+
...depOptimizeNodeEnvOptions
|
|
1862
|
+
},
|
|
1863
|
+
build: {
|
|
1864
|
+
outDir: "dist/client",
|
|
1865
|
+
manifest: true,
|
|
1866
|
+
ssrManifest: true,
|
|
1867
|
+
assetsInlineLimit: clientAssetsInlineLimit,
|
|
1868
|
+
...withBuildBundlerOptions({
|
|
1869
|
+
input: { index: VIRTUAL_CLIENT_ENTRY },
|
|
1870
|
+
output: getClientOutputConfig(clientAssetsDir),
|
|
1871
|
+
treeshake: getClientTreeshakeConfig()
|
|
1872
|
+
})
|
|
1873
|
+
}
|
|
1599
1874
|
},
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1875
|
+
ssr: {
|
|
1876
|
+
resolve: {
|
|
1877
|
+
external: [
|
|
1878
|
+
"react",
|
|
1879
|
+
"react-dom",
|
|
1880
|
+
"react-dom/server",
|
|
1881
|
+
"ipaddr.js",
|
|
1882
|
+
...nextServerExternal
|
|
1883
|
+
],
|
|
1884
|
+
noExternal: true
|
|
1885
|
+
},
|
|
1886
|
+
optimizeDeps: {
|
|
1887
|
+
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], Object.keys(nextShimMap)),
|
|
1888
|
+
...depOptimizeNodeEnvOptions
|
|
1889
|
+
},
|
|
1890
|
+
build: {
|
|
1891
|
+
outDir: "dist/server",
|
|
1892
|
+
...withBuildBundlerOptions({
|
|
1893
|
+
input: { index: hasNitroPlugin ? VIRTUAL_WORKER_ENTRY : VIRTUAL_SERVER_ENTRY },
|
|
1894
|
+
output: { entryFileNames: "entry.js" }
|
|
1895
|
+
})
|
|
1896
|
+
}
|
|
1606
1897
|
}
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1898
|
+
};
|
|
1899
|
+
originalPlainPagesEnvironments = config.environments;
|
|
1900
|
+
viteConfig.environments = plainPagesEnvironments;
|
|
1901
|
+
hasPlainPagesBuildEnvironments = env.command === "build";
|
|
1902
|
+
}
|
|
1609
1903
|
if (pagesOptimizeEntries.length > 0 && !hasCloudflarePlugin) viteConfig.optimizeDeps = {
|
|
1610
1904
|
...viteConfig.optimizeDeps,
|
|
1611
1905
|
entries: pagesOptimizeEntries
|
|
@@ -1637,7 +1931,25 @@ function vinext(options = {}) {
|
|
|
1637
1931
|
return null;
|
|
1638
1932
|
},
|
|
1639
1933
|
async configResolved(config) {
|
|
1640
|
-
if (isServeCommand &&
|
|
1934
|
+
if (isServeCommand && !config["__vinextDevCliLifecycle"] && config.configFile && isViteCliConfigFile(config.configFile, config.inlineConfig)) {
|
|
1935
|
+
if (claimViteCliDevInvocation(config.root, false, true)) {
|
|
1936
|
+
config[VINEXT_DEV_CLI_LIFECYCLE] = true;
|
|
1937
|
+
if (!config.server.middlewareMode) applyDevServerDefaults(config.server, {});
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
if (isServeCommand && (hasAppDir || hasCloudflarePlugin && hasPagesDir)) {
|
|
1941
|
+
const optionalWarnings = /* @__PURE__ */ new Set();
|
|
1942
|
+
for (const [name, environment] of Object.entries(config.environments)) {
|
|
1943
|
+
const optimizer = environment.optimizeDeps;
|
|
1944
|
+
const optionalIncludes = hasAppDir ? name === "client" && !optimizer.noDiscovery ? APP_CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE : [] : name !== "client" ? ["use-sync-external-store/with-selector"] : [];
|
|
1945
|
+
for (const id of optionalIncludes) {
|
|
1946
|
+
if (optimizer.include?.includes(id) || optimizer.exclude?.some((excluded) => id === excluded || id.startsWith(`${excluded}/`))) continue;
|
|
1947
|
+
(optimizer.include ??= []).push(id);
|
|
1948
|
+
optionalWarnings.add(`Failed to resolve dependency: ${id}, present in ${name} 'optimizeDeps.include'`);
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
Object.assign(config, { logger: createOptionalOptimizeDepsLogger(config.logger, optionalWarnings) });
|
|
1952
|
+
}
|
|
1641
1953
|
if (config.worker?.rolldownOptions) {
|
|
1642
1954
|
const workerFileNames = `${resolveAssetsDir(nextConfig.assetPrefix ?? "")}/workers/[name]-[hash].js`;
|
|
1643
1955
|
const workerOutputs = config.worker.rolldownOptions.output;
|
|
@@ -1722,9 +2034,16 @@ function vinext(options = {}) {
|
|
|
1722
2034
|
}
|
|
1723
2035
|
},
|
|
1724
2036
|
resolveId: {
|
|
1725
|
-
filter: { id: /(?:next\/|vinext\/(?:shims\/|server\/app-rsc-handler)|virtual:vinext-|@vercel\/og(?:\.js)?$)/ },
|
|
2037
|
+
filter: { id: /(?:next\/|vinext\/(?:shims\/|server\/(?:app-rsc-(?:combined-)?handler|app-router-entry|pages-router-entry))|virtual:vinext-|@vercel\/og(?:\.js)?$)/ },
|
|
1726
2038
|
handler(id, importer) {
|
|
1727
2039
|
const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
|
|
2040
|
+
if (cleanId === "vinext/server/app-rsc-combined-handler") {
|
|
2041
|
+
if (_canExternalizeAppRscHandler && this.environment?.name === "rsc" && this.environment.config?.command === "serve") return {
|
|
2042
|
+
id: _appRscCombinedHandlerPath,
|
|
2043
|
+
external: true
|
|
2044
|
+
};
|
|
2045
|
+
return _appRscCombinedHandlerPath;
|
|
2046
|
+
}
|
|
1728
2047
|
if (cleanId === "vinext/server/app-rsc-handler") {
|
|
1729
2048
|
if (_canExternalizeAppRscHandler && this.environment?.name === "rsc" && this.environment.config?.command === "serve") return {
|
|
1730
2049
|
id: _appRscHandlerPath,
|
|
@@ -1735,11 +2054,20 @@ function vinext(options = {}) {
|
|
|
1735
2054
|
if (isVercelOgImport(cleanId) && !isVinextOgShimImporter(importer)) return resolveShimModulePath(_shimsDir, "og");
|
|
1736
2055
|
if (cleanId.startsWith("vinext/shims/")) return resolveShimModulePath(_shimsDir, stripJsExtension(stripViteModuleQuery(cleanId.slice(13))));
|
|
1737
2056
|
if (cleanId === VIRTUAL_WORKER_ENTRY) return RESOLVED_WORKER_ENTRY;
|
|
1738
|
-
if (cleanId
|
|
2057
|
+
if (selectedMultiStageOutput && (cleanId === "vinext/server/app-router-entry" || cleanId === "vinext/server/pages-router-entry")) return RESOLVED_WORKER_ENTRY;
|
|
2058
|
+
if (cleanId.endsWith("/" + VIRTUAL_WORKER_ENTRY)) return RESOLVED_WORKER_ENTRY;
|
|
2059
|
+
if (cleanId === VIRTUAL_REQUEST_STAGE) return RESOLVED_REQUEST_STAGE;
|
|
2060
|
+
if (cleanId.endsWith("/" + VIRTUAL_REQUEST_STAGE)) return RESOLVED_REQUEST_STAGE;
|
|
2061
|
+
if (cleanId === VIRTUAL_RESPONSE_STAGE) return RESOLVED_RESPONSE_STAGE;
|
|
2062
|
+
if (cleanId.endsWith("/" + VIRTUAL_RESPONSE_STAGE)) return RESOLVED_RESPONSE_STAGE;
|
|
1739
2063
|
if (cleanId === VIRTUAL_SERVER_ENTRY) return RESOLVED_SERVER_ENTRY;
|
|
2064
|
+
if (cleanId === VIRTUAL_PAGES_REQUEST_ENTRY) return RESOLVED_PAGES_REQUEST_ENTRY;
|
|
2065
|
+
if (cleanId === VIRTUAL_PAGES_RESPONSE_ENTRY) return RESOLVED_PAGES_RESPONSE_ENTRY;
|
|
1740
2066
|
if (cleanId === VIRTUAL_CLIENT_ENTRY) return RESOLVED_CLIENT_ENTRY;
|
|
1741
|
-
if (cleanId.endsWith("/
|
|
1742
|
-
if (cleanId.endsWith("/
|
|
2067
|
+
if (cleanId.endsWith("/" + VIRTUAL_SERVER_ENTRY)) return RESOLVED_SERVER_ENTRY;
|
|
2068
|
+
if (cleanId.endsWith("/" + VIRTUAL_PAGES_REQUEST_ENTRY)) return RESOLVED_PAGES_REQUEST_ENTRY;
|
|
2069
|
+
if (cleanId.endsWith("/" + VIRTUAL_PAGES_RESPONSE_ENTRY)) return RESOLVED_PAGES_RESPONSE_ENTRY;
|
|
2070
|
+
if (cleanId.endsWith("/" + VIRTUAL_CLIENT_ENTRY)) return RESOLVED_CLIENT_ENTRY;
|
|
1743
2071
|
if (cleanId === VIRTUAL_RSC_ENTRY) return RESOLVED_RSC_ENTRY;
|
|
1744
2072
|
if (cleanId === VIRTUAL_CACHEABILITY_MANIFEST) {
|
|
1745
2073
|
if ((hasAppDir ? this.environment?.name === "rsc" : this.environment !== void 0 && isServerEnvironment(this.environment)) && this.environment.config?.command === "build") return {
|
|
@@ -1748,16 +2076,35 @@ function vinext(options = {}) {
|
|
|
1748
2076
|
};
|
|
1749
2077
|
return RESOLVED_CACHEABILITY_MANIFEST;
|
|
1750
2078
|
}
|
|
2079
|
+
if (cleanId === VIRTUAL_CACHEABILITY_REQUEST_PROJECTION) {
|
|
2080
|
+
if (hasAppDir && this.environment?.name === "rsc" && this.environment.config?.command === "build") return {
|
|
2081
|
+
id: `./${CACHEABILITY_REQUEST_PROJECTION_MODULE}`,
|
|
2082
|
+
external: true
|
|
2083
|
+
};
|
|
2084
|
+
return RESOLVED_CACHEABILITY_REQUEST_PROJECTION;
|
|
2085
|
+
}
|
|
2086
|
+
if (cleanId === VIRTUAL_PREGENERATED_CONCRETE_PATHS) {
|
|
2087
|
+
if ((hasAppDir ? this.environment?.name === "rsc" : this.environment !== void 0 && isServerEnvironment(this.environment)) && this.environment.config?.command === "build") return {
|
|
2088
|
+
id: `./${PREGENERATED_CONCRETE_PATHS_MODULE}`,
|
|
2089
|
+
external: true
|
|
2090
|
+
};
|
|
2091
|
+
return RESOLVED_PREGENERATED_CONCRETE_PATHS;
|
|
2092
|
+
}
|
|
2093
|
+
if (cleanId === VIRTUAL_APP_REQUEST_ENTRY) return RESOLVED_APP_REQUEST_ENTRY;
|
|
2094
|
+
if (cleanId === VIRTUAL_APP_RESPONSE_ENTRY) return RESOLVED_APP_RESPONSE_ENTRY;
|
|
1751
2095
|
if (cleanId === VIRTUAL_APP_SSR_ENTRY) return RESOLVED_APP_SSR_ENTRY;
|
|
1752
2096
|
if (cleanId === VIRTUAL_APP_BROWSER_ENTRY) return RESOLVED_APP_BROWSER_ENTRY;
|
|
1753
2097
|
if (cleanId === VIRTUAL_APP_CAPABILITIES) return RESOLVED_APP_CAPABILITIES;
|
|
1754
2098
|
if (cleanId === "next/root-params" || cleanId === "next/root-params.js") return RESOLVED_ROOT_PARAMS;
|
|
1755
2099
|
if (cleanId === "virtual:vinext-cache-adapters" || cleanId.endsWith("/virtual:vinext-cache-adapters")) return RESOLVED_CACHE_ADAPTERS;
|
|
2100
|
+
if (cleanId === "virtual:vinext-cdn-cache-adapter" || cleanId.endsWith("/virtual:vinext-cdn-cache-adapter")) return RESOLVED_CDN_CACHE_ADAPTER;
|
|
1756
2101
|
if (cleanId === "virtual:vinext-image-adapters" || cleanId.endsWith("/virtual:vinext-image-adapters")) return RESOLVED_IMAGE_ADAPTERS;
|
|
1757
2102
|
if (cleanId.startsWith("virtual:vinext-google-fonts?")) return RESOLVED_VIRTUAL_GOOGLE_FONTS + cleanId.slice(VIRTUAL_GOOGLE_FONTS.length);
|
|
1758
|
-
if (cleanId.endsWith("/
|
|
1759
|
-
if (cleanId.endsWith("/
|
|
1760
|
-
if (cleanId.endsWith("/
|
|
2103
|
+
if (cleanId.endsWith("/" + VIRTUAL_RSC_ENTRY)) return RESOLVED_RSC_ENTRY;
|
|
2104
|
+
if (cleanId.endsWith("/" + VIRTUAL_APP_REQUEST_ENTRY)) return RESOLVED_APP_REQUEST_ENTRY;
|
|
2105
|
+
if (cleanId.endsWith("/" + VIRTUAL_APP_RESPONSE_ENTRY)) return RESOLVED_APP_RESPONSE_ENTRY;
|
|
2106
|
+
if (cleanId.endsWith("/" + VIRTUAL_APP_SSR_ENTRY)) return RESOLVED_APP_SSR_ENTRY;
|
|
2107
|
+
if (cleanId.endsWith("/" + VIRTUAL_APP_BROWSER_ENTRY)) return RESOLVED_APP_BROWSER_ENTRY;
|
|
1761
2108
|
if (cleanId.includes("/virtual:vinext-google-fonts?")) {
|
|
1762
2109
|
const queryIndex = cleanId.indexOf(VIRTUAL_GOOGLE_FONTS + "?");
|
|
1763
2110
|
return RESOLVED_VIRTUAL_GOOGLE_FONTS + cleanId.slice(queryIndex + VIRTUAL_GOOGLE_FONTS.length);
|
|
@@ -1772,14 +2119,41 @@ function vinext(options = {}) {
|
|
|
1772
2119
|
load: {
|
|
1773
2120
|
filter: { id: /virtual:vinext-/ },
|
|
1774
2121
|
async handler(id) {
|
|
1775
|
-
if (id === RESOLVED_WORKER_ENTRY)
|
|
2122
|
+
if (id === RESOLVED_WORKER_ENTRY) {
|
|
2123
|
+
if (selectedMultiStageOutput?.type === "multi-stage") return [
|
|
2124
|
+
`export { default } from ${JSON.stringify(selectedMultiStageOutput.entry)};`,
|
|
2125
|
+
`export * from ${JSON.stringify(selectedMultiStageOutput.entry)};`,
|
|
2126
|
+
""
|
|
2127
|
+
].join("\n");
|
|
2128
|
+
const entry = hasAppDir ? "vinext/server/app-router-entry" : "vinext/server/pages-router-entry";
|
|
2129
|
+
if (!hasAppDir && hasNitroPlugin) return [
|
|
2130
|
+
`import worker from ${JSON.stringify(entry)};`,
|
|
2131
|
+
"export default { fetch(request, env, ctx) {",
|
|
2132
|
+
` return worker.fetch(request, env, { ...ctx, hostRuntime: ${JSON.stringify(nitroHostRuntime)} });`,
|
|
2133
|
+
"} };"
|
|
2134
|
+
].join("\n");
|
|
2135
|
+
return `export { default } from ${JSON.stringify(entry)};`;
|
|
2136
|
+
}
|
|
2137
|
+
if (id === RESOLVED_REQUEST_STAGE) return `export { handleRequestStage } from ${JSON.stringify(hasAppDir ? APP_REQUEST_STAGE_ENTRY : PAGES_REQUEST_STAGE_ENTRY)};\n`;
|
|
2138
|
+
if (id === RESOLVED_RESPONSE_STAGE) return `export * from ${JSON.stringify(hasAppDir ? APP_RESPONSE_STAGE_ENTRY : PAGES_RESPONSE_STAGE_ENTRY)};\n`;
|
|
1776
2139
|
if (id === RESOLVED_SERVER_ENTRY) {
|
|
1777
2140
|
recordServerEntryLoad(this.environment?.name, id);
|
|
1778
2141
|
return await generateServerEntry$1(this.environment.config.publicDir === "" ? false : this.environment.config.publicDir);
|
|
1779
2142
|
}
|
|
2143
|
+
if (id === RESOLVED_PAGES_REQUEST_ENTRY) {
|
|
2144
|
+
recordServerEntryLoad(this.environment?.name, id);
|
|
2145
|
+
return await generatePagesRequestEntry$1(this.environment.config.publicDir === "" ? false : this.environment.config.publicDir);
|
|
2146
|
+
}
|
|
2147
|
+
if (id === RESOLVED_PAGES_RESPONSE_ENTRY) {
|
|
2148
|
+
recordServerEntryLoad(this.environment?.name, id);
|
|
2149
|
+
return await generatePagesResponseEntry$1();
|
|
2150
|
+
}
|
|
1780
2151
|
if (id === RESOLVED_CLIENT_ENTRY) return await generateClientEntry$1();
|
|
1781
2152
|
if (id === RESOLVED_PAGES_CLIENT_ASSETS) {
|
|
1782
|
-
const metadata = {
|
|
2153
|
+
const metadata = {
|
|
2154
|
+
clientEntry: DEV_PAGES_CLIENT_ENTRY,
|
|
2155
|
+
crossOrigin: nextConfig?.crossOrigin ?? ""
|
|
2156
|
+
};
|
|
1783
2157
|
const ssrManifest = {};
|
|
1784
2158
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
1785
2159
|
const pagesRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
@@ -1792,18 +2166,21 @@ function vinext(options = {}) {
|
|
|
1792
2166
|
if (Object.keys(ssrManifest).length > 0) metadata.ssrManifest = ssrManifest;
|
|
1793
2167
|
return `export default ${JSON.stringify(metadata)};`;
|
|
1794
2168
|
}
|
|
1795
|
-
if (id === RESOLVED_CACHEABILITY_MANIFEST) return "export default null;";
|
|
1796
|
-
if (id ===
|
|
2169
|
+
if (id === RESOLVED_CACHEABILITY_MANIFEST || id === RESOLVED_CACHEABILITY_REQUEST_PROJECTION) return "export default null;";
|
|
2170
|
+
if (id === RESOLVED_PREGENERATED_CONCRETE_PATHS) return "export {};";
|
|
2171
|
+
if ((id === RESOLVED_RSC_ENTRY || id === RESOLVED_APP_REQUEST_ENTRY || id === RESOLVED_APP_RESPONSE_ENTRY) && hasAppDir) {
|
|
1797
2172
|
recordServerEntryLoad(this.environment?.name, id);
|
|
1798
2173
|
const routes = await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher);
|
|
1799
2174
|
const metaRoutes = scanMetadataFiles(appDir);
|
|
1800
2175
|
const hasServerActions = await resolveHasServerActions(this.environment.config);
|
|
1801
2176
|
const globalErrorPath = findFileWithExts(appDir, "global-error", fileMatcher);
|
|
1802
2177
|
const globalNotFoundPath = nextConfig?.globalNotFound ? findFileWithExts(appDir, "global-not-found", fileMatcher) : null;
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
2178
|
+
if (id !== RESOLVED_APP_REQUEST_ENTRY) {
|
|
2179
|
+
rscClassificationManifests.set(id, collectRouteClassificationManifest(routes));
|
|
2180
|
+
rscActionOwnerRoutes = this.environment.config.command === "build" && hasServerActions ? routes : null;
|
|
2181
|
+
rscActionOwnerSharedRoots = [globalErrorPath, globalNotFoundPath].filter((path) => path !== null);
|
|
2182
|
+
}
|
|
2183
|
+
return (id === RESOLVED_APP_REQUEST_ENTRY ? generateAppRequestRscEntry : id === RESOLVED_APP_RESPONSE_ENTRY ? generateAppResponseRscEntry : generateRscEntry)(appDir, routes, middlewarePath, metaRoutes, globalErrorPath, nextConfig?.basePath, nextConfig?.trailingSlash, {
|
|
1807
2184
|
redirects: nextConfig?.redirects,
|
|
1808
2185
|
rewrites: nextConfig?.rewrites,
|
|
1809
2186
|
headers: nextConfig?.headers,
|
|
@@ -1813,7 +2190,9 @@ function vinext(options = {}) {
|
|
|
1813
2190
|
bodySizeLimitLabel: nextConfig?.serverActionsBodySizeLimitLabel,
|
|
1814
2191
|
htmlLimitedBots: nextConfig?.htmlLimitedBots,
|
|
1815
2192
|
clientTraceMetadata: nextConfig?.clientTraceMetadata,
|
|
2193
|
+
nodeOpenTelemetryLoader: registerNodeOpenTelemetryLoader,
|
|
1816
2194
|
assetPrefix: nextConfig?.assetPrefix,
|
|
2195
|
+
crossOrigin: nextConfig?.crossOrigin,
|
|
1817
2196
|
expireTime: nextConfig?.expireTime,
|
|
1818
2197
|
reactMaxHeadersLength: nextConfig?.reactMaxHeadersLength,
|
|
1819
2198
|
cacheMaxMemorySize: nextConfig?.cacheMaxMemorySize,
|
|
@@ -1842,6 +2221,7 @@ function vinext(options = {}) {
|
|
|
1842
2221
|
}
|
|
1843
2222
|
if (id === RESOLVED_ROOT_PARAMS) return generateRootParamsModule((hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : []).flatMap((route) => route.rootParamNames ?? []));
|
|
1844
2223
|
if (id === RESOLVED_CACHE_ADAPTERS) return generateCacheAdaptersModule(options.cache);
|
|
2224
|
+
if (id === RESOLVED_CDN_CACHE_ADAPTER) return generateCdnCacheAdapterModule(options.cache);
|
|
1845
2225
|
if (id === RESOLVED_IMAGE_ADAPTERS) return generateImageAdaptersModule(options.images);
|
|
1846
2226
|
if (id === RESOLVED_APP_SSR_ENTRY && hasAppDir) {
|
|
1847
2227
|
recordServerEntryLoad(this.environment?.name, id);
|
|
@@ -1876,9 +2256,12 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1876
2256
|
order: "pre",
|
|
1877
2257
|
handler(code, chunk) {
|
|
1878
2258
|
if (this.environment?.name !== "rsc") return null;
|
|
1879
|
-
if (!rscClassificationManifest) return null;
|
|
1880
2259
|
const hasClassificationStub = code.includes("__VINEXT_CLASS");
|
|
1881
2260
|
if (!hasClassificationStub) return null;
|
|
2261
|
+
const rscEntryId = [RESOLVED_RSC_ENTRY, RESOLVED_APP_RESPONSE_ENTRY].find((id) => chunk.moduleIds.includes(id));
|
|
2262
|
+
if (!rscEntryId) return null;
|
|
2263
|
+
const rscClassificationManifest = rscClassificationManifests.get(rscEntryId);
|
|
2264
|
+
if (!rscClassificationManifest) return null;
|
|
1882
2265
|
const enableClassificationDebug = Boolean(process.env.VINEXT_DEBUG_CLASSIFICATION);
|
|
1883
2266
|
const patchPlan = hasClassificationStub && rscClassificationManifest ? planRouteClassificationInjection({
|
|
1884
2267
|
canonicalizeLayoutPath: canonicalize,
|
|
@@ -1900,7 +2283,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1900
2283
|
}) : { kind: "skip" };
|
|
1901
2284
|
const nextCode = patchPlan.kind === "skip" ? code : patchPlan.code;
|
|
1902
2285
|
if (patchPlan.kind === "skip") return null;
|
|
1903
|
-
|
|
2286
|
+
rscClassificationManifests.delete(rscEntryId);
|
|
1904
2287
|
return {
|
|
1905
2288
|
code: nextCode,
|
|
1906
2289
|
map: null
|
|
@@ -1908,6 +2291,21 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1908
2291
|
}
|
|
1909
2292
|
}
|
|
1910
2293
|
},
|
|
2294
|
+
{
|
|
2295
|
+
name: "vinext:cloudflare-framework-tracing",
|
|
2296
|
+
transform: {
|
|
2297
|
+
filter: { id: /(?:app|pages)-router-entry\.[cm]?[jt]s(?:\?|$)/ },
|
|
2298
|
+
handler(code, id) {
|
|
2299
|
+
if (!hasCloudflarePlugin) return null;
|
|
2300
|
+
const cleanId = toSlash(stripViteModuleQuery(id));
|
|
2301
|
+
if (!WORKER_ROUTER_ENTRIES.has(cleanId)) return null;
|
|
2302
|
+
return {
|
|
2303
|
+
code: `import "vinext/internal/server/cloudflare-workers-tracing";\n${code}`,
|
|
2304
|
+
map: null
|
|
2305
|
+
};
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
},
|
|
1911
2309
|
{
|
|
1912
2310
|
name: "vinext:pages-client-assets-resolver",
|
|
1913
2311
|
sharedDuringBuild: true,
|
|
@@ -1915,11 +2313,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1915
2313
|
filter: { id: /virtual:vinext-pages-client-assets$/ },
|
|
1916
2314
|
handler(id) {
|
|
1917
2315
|
const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
|
|
1918
|
-
if (cleanId !== VIRTUAL_PAGES_CLIENT_ASSETS && !cleanId.endsWith("/
|
|
2316
|
+
if (cleanId !== VIRTUAL_PAGES_CLIENT_ASSETS && !cleanId.endsWith("/" + VIRTUAL_PAGES_CLIENT_ASSETS)) return;
|
|
1919
2317
|
if (this.environment?.config.command !== "build") return RESOLVED_PAGES_CLIENT_ASSETS;
|
|
1920
2318
|
const buildRoot = this.environment.config.root ?? process.cwd();
|
|
1921
2319
|
const environmentOutDir = path.resolve(buildRoot, this.environment.config.build.outDir);
|
|
1922
|
-
const sidecarDir =
|
|
2320
|
+
const sidecarDir = resolvePagesClientAssetsOutputDir(this.environment.name, environmentOutDir);
|
|
1923
2321
|
let externalId = path.relative(environmentOutDir, path.join(sidecarDir, PAGES_CLIENT_ASSETS_MODULE));
|
|
1924
2322
|
if (!externalId.startsWith(".")) externalId = `./${externalId}`;
|
|
1925
2323
|
pagesClientAssetsOutputDirs.add(sidecarDir);
|
|
@@ -1928,6 +2326,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1928
2326
|
external: true
|
|
1929
2327
|
};
|
|
1930
2328
|
}
|
|
2329
|
+
},
|
|
2330
|
+
outputOptions(output) {
|
|
2331
|
+
const environment = this.environment;
|
|
2332
|
+
if (!selectedMultiStageOutput || !environment || !isMultiStageServerEnvironment(environment)) return;
|
|
2333
|
+
const buildRoot = environment.config.root ?? process.cwd();
|
|
2334
|
+
const outputDir = path.resolve(buildRoot, output.dir ?? environment.config.build.outDir);
|
|
2335
|
+
pagesClientAssetsOutputDirs.add(resolvePagesClientAssetsOutputDir(environment.name, outputDir));
|
|
1931
2336
|
}
|
|
1932
2337
|
},
|
|
1933
2338
|
{
|
|
@@ -1949,6 +2354,49 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1949
2354
|
}
|
|
1950
2355
|
}
|
|
1951
2356
|
},
|
|
2357
|
+
{
|
|
2358
|
+
name: "vinext:multi-stage-host-entry",
|
|
2359
|
+
transform: {
|
|
2360
|
+
filter: { id: /virtual:|\.[cm]?[jt]sx?(?:\?|$)/ },
|
|
2361
|
+
handler(code, id) {
|
|
2362
|
+
const environment = this.environment;
|
|
2363
|
+
if (!isServeCommand && (!environment || !isMultiStageServerEnvironment(environment))) return null;
|
|
2364
|
+
const transformed = matchedMultiStageOutput?.transformHostEntry?.({
|
|
2365
|
+
code,
|
|
2366
|
+
id
|
|
2367
|
+
});
|
|
2368
|
+
return transformed == null ? null : {
|
|
2369
|
+
code: transformed,
|
|
2370
|
+
map: null
|
|
2371
|
+
};
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
},
|
|
2375
|
+
{
|
|
2376
|
+
name: "vinext:multi-stage-server-output",
|
|
2377
|
+
apply: "build",
|
|
2378
|
+
buildStart() {
|
|
2379
|
+
const entries = selectedMultiStageOutput?.entries;
|
|
2380
|
+
const environment = this.environment;
|
|
2381
|
+
if (!entries || !environment || !isMultiStageServerEnvironment(environment)) return;
|
|
2382
|
+
for (const [name, id] of [["vinext-request-stage", entries.request], ["vinext-response-stage", entries.response]]) this.emitFile({
|
|
2383
|
+
id,
|
|
2384
|
+
name,
|
|
2385
|
+
preserveSignature: "strict",
|
|
2386
|
+
type: "chunk"
|
|
2387
|
+
});
|
|
2388
|
+
},
|
|
2389
|
+
outputOptions(output) {
|
|
2390
|
+
const environment = this.environment;
|
|
2391
|
+
if (!selectedMultiStageOutput || !environment || !isMultiStageServerEnvironment(environment)) return;
|
|
2392
|
+
if (output.format !== void 0 && output.format !== "es" && output.format !== "esm" && output.format !== "module") throw new Error(`[vinext] Multi-stage output requires an ES module format; ${JSON.stringify(output.format)} cannot represent independently deployable request and response entries.`);
|
|
2393
|
+
return {
|
|
2394
|
+
...output,
|
|
2395
|
+
chunkFileNames: createMultiStageChunkFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? ""), output.chunkFileNames),
|
|
2396
|
+
codeSplitting: createMultiStageCodeSplittingConfig(output.codeSplitting)
|
|
2397
|
+
};
|
|
2398
|
+
}
|
|
2399
|
+
},
|
|
1952
2400
|
{
|
|
1953
2401
|
name: "vinext:css-url-assets-defaults",
|
|
1954
2402
|
apply: "build",
|
|
@@ -1957,7 +2405,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1957
2405
|
if (!hasAppDir || name !== "rsc" && name !== "ssr") return null;
|
|
1958
2406
|
const output = getBuildBundlerOptions(config.build)?.output;
|
|
1959
2407
|
if (Array.isArray(output) || output?.assetFileNames !== void 0) return null;
|
|
1960
|
-
|
|
2408
|
+
const assetFileNames = createClientAssetFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? ""));
|
|
2409
|
+
return { build: { ...withBuildBundlerOptions({ output: { assetFileNames } }) } };
|
|
1961
2410
|
}
|
|
1962
2411
|
},
|
|
1963
2412
|
{
|
|
@@ -1990,6 +2439,18 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1990
2439
|
fileName: CACHEABILITY_MANIFEST_MODULE,
|
|
1991
2440
|
source: "export default null;\n"
|
|
1992
2441
|
});
|
|
2442
|
+
if (hasAppDir) {
|
|
2443
|
+
this.emitFile({
|
|
2444
|
+
type: "asset",
|
|
2445
|
+
fileName: CACHEABILITY_REQUEST_PROJECTION_MODULE,
|
|
2446
|
+
source: "export default null;\n"
|
|
2447
|
+
});
|
|
2448
|
+
this.emitFile({
|
|
2449
|
+
type: "asset",
|
|
2450
|
+
fileName: PREGENERATED_CONCRETE_PATHS_MODULE,
|
|
2451
|
+
source: "delete globalThis.__VINEXT_PREGENERATED_CONCRETE_PATHS;\n"
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
1993
2454
|
}
|
|
1994
2455
|
},
|
|
1995
2456
|
{
|
|
@@ -2026,7 +2487,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2026
2487
|
}
|
|
2027
2488
|
},
|
|
2028
2489
|
asyncHooksStubPlugin,
|
|
2029
|
-
createInstrumentationClientTransformPlugin(() => instrumentationClientPath),
|
|
2490
|
+
createInstrumentationClientTransformPlugin(() => instrumentationClientPath, () => nextConfig.instrumentationClientRouteManifest),
|
|
2491
|
+
createInstrumentationServerTransformPlugin(() => instrumentationPath, () => nextConfig.instrumentationServerValueInjections),
|
|
2030
2492
|
{
|
|
2031
2493
|
name: "vinext:instrumentation-client-inject",
|
|
2032
2494
|
enforce: "pre",
|
|
@@ -2122,6 +2584,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2122
2584
|
const devBuildId = nextConfig?.buildId ?? process.env.__VINEXT_BUILD_ID ?? "development";
|
|
2123
2585
|
server.middlewares.use((req, _res, next) => {
|
|
2124
2586
|
req.__vinextOriginalEncodedUrl ??= req.url;
|
|
2587
|
+
delete req.headers[VINEXT_MW_CTX_HEADER];
|
|
2125
2588
|
next();
|
|
2126
2589
|
});
|
|
2127
2590
|
server.middlewares.use((req, _res, next) => {
|
|
@@ -2148,8 +2611,23 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2148
2611
|
return `http://localhost:${typeof address === "object" && address ? address.port : server.config.server.port ?? 3e3}`;
|
|
2149
2612
|
};
|
|
2150
2613
|
let cachedSSRHandler = null;
|
|
2614
|
+
const devPageRouteDataKinds = /* @__PURE__ */ new Map();
|
|
2615
|
+
function classifyDevPageFile(filePath) {
|
|
2616
|
+
const cached = devPageRouteDataKinds.get(filePath);
|
|
2617
|
+
if (cached) return cached;
|
|
2618
|
+
let dataKind = "none";
|
|
2619
|
+
try {
|
|
2620
|
+
const source = fs.readFileSync(filePath, "utf8");
|
|
2621
|
+
dataKind = hasExportedName(source, "getStaticProps") ? "static" : hasExportedName(source, "getServerSideProps") ? "server" : "none";
|
|
2622
|
+
} catch {}
|
|
2623
|
+
devPageRouteDataKinds.set(filePath, dataKind);
|
|
2624
|
+
return dataKind;
|
|
2625
|
+
}
|
|
2151
2626
|
function getPagesRunner() {
|
|
2152
|
-
if (!pagesRunner)
|
|
2627
|
+
if (!pagesRunner) {
|
|
2628
|
+
const env = server.environments["ssr"] ?? Object.values(server.environments).find((e) => e !== server.environments["rsc"]) ?? Object.values(server.environments)[0];
|
|
2629
|
+
pagesRunner = createDirectRunner(env);
|
|
2630
|
+
}
|
|
2153
2631
|
return pagesRunner;
|
|
2154
2632
|
}
|
|
2155
2633
|
/**
|
|
@@ -2198,6 +2676,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2198
2676
|
}
|
|
2199
2677
|
pagesRunner?.clearCache();
|
|
2200
2678
|
}
|
|
2679
|
+
function invalidatePagesHydrationProxies() {
|
|
2680
|
+
const graph = server.environments.client?.moduleGraph;
|
|
2681
|
+
if (!graph) return;
|
|
2682
|
+
for (const mod of graph.idToModuleMap.values()) if (mod.id?.includes("?html-proxy&index=")) graph.invalidateModule(mod);
|
|
2683
|
+
}
|
|
2201
2684
|
function invalidateAppRoutingModules() {
|
|
2202
2685
|
invalidateAppRouteCache();
|
|
2203
2686
|
invalidateMetadataFileCache();
|
|
@@ -2309,13 +2792,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2309
2792
|
if (hasAppDir) invalidateRscEntryModule();
|
|
2310
2793
|
if (hasCloudflarePlugin && hasPagesDir && !hasAppDir) invalidatePagesServerEntry();
|
|
2311
2794
|
};
|
|
2795
|
+
function invalidatePagesMiddlewareMatcher(filePath) {
|
|
2796
|
+
if (!hasPagesDir || !middlewarePath || toSlash(filePath) !== middlewarePath) return;
|
|
2797
|
+
cachedSSRHandler = null;
|
|
2798
|
+
server.ws.send({ type: "full-reload" });
|
|
2799
|
+
}
|
|
2312
2800
|
server.watcher.on("add", (filePath) => {
|
|
2801
|
+
invalidatePagesMiddlewareMatcher(filePath);
|
|
2313
2802
|
updatePublicFileRoute(filePath, true);
|
|
2314
2803
|
let routeChanged = false;
|
|
2315
2804
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
2316
2805
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
2317
2806
|
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2318
2807
|
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2808
|
+
devPageRouteDataKinds.delete(toSlash(filePath));
|
|
2319
2809
|
invalidateRouteCache(pagesDir);
|
|
2320
2810
|
routeChanged = true;
|
|
2321
2811
|
}
|
|
@@ -2326,23 +2816,37 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2326
2816
|
}
|
|
2327
2817
|
if (routeChanged) {
|
|
2328
2818
|
invalidatePagesServerEntry();
|
|
2819
|
+
if (hasPagesDir) invalidatePagesHydrationProxies();
|
|
2329
2820
|
if (!hasAppDir) server.ws.send({ type: "full-reload" });
|
|
2330
2821
|
invalidateHybridClientEntries();
|
|
2331
2822
|
revalidateHybridRoutes();
|
|
2332
2823
|
}
|
|
2333
2824
|
});
|
|
2334
2825
|
server.watcher.on("change", (filePath) => {
|
|
2826
|
+
invalidatePagesMiddlewareMatcher(filePath);
|
|
2827
|
+
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2828
|
+
const pageFile = toSlash(filePath);
|
|
2829
|
+
const previousKind = devPageRouteDataKinds.get(pageFile);
|
|
2830
|
+
devPageRouteDataKinds.delete(pageFile);
|
|
2831
|
+
if (previousKind !== void 0 && previousKind !== classifyDevPageFile(pageFile)) {
|
|
2832
|
+
cachedSSRHandler = null;
|
|
2833
|
+
invalidatePagesHydrationProxies();
|
|
2834
|
+
server.ws.send({ type: "full-reload" });
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2335
2837
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
2336
2838
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
2337
2839
|
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2338
2840
|
});
|
|
2339
2841
|
server.watcher.on("unlink", (filePath) => {
|
|
2842
|
+
invalidatePagesMiddlewareMatcher(filePath);
|
|
2340
2843
|
updatePublicFileRoute(filePath, false);
|
|
2341
2844
|
let routeChanged = false;
|
|
2342
2845
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
2343
2846
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
2344
2847
|
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2345
2848
|
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2849
|
+
devPageRouteDataKinds.delete(toSlash(filePath));
|
|
2346
2850
|
invalidateRouteCache(pagesDir);
|
|
2347
2851
|
routeChanged = true;
|
|
2348
2852
|
}
|
|
@@ -2353,6 +2857,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2353
2857
|
}
|
|
2354
2858
|
if (routeChanged) {
|
|
2355
2859
|
invalidatePagesServerEntry();
|
|
2860
|
+
if (hasPagesDir) invalidatePagesHydrationProxies();
|
|
2356
2861
|
if (!hasAppDir) server.ws.send({ type: "full-reload" });
|
|
2357
2862
|
invalidateHybridClientEntries();
|
|
2358
2863
|
revalidateHybridRoutes();
|
|
@@ -2393,7 +2898,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2393
2898
|
});
|
|
2394
2899
|
server.middlewares.use((req, res, next) => {
|
|
2395
2900
|
if (!hasPagesDir || !handlePagesMiddleware || !isUnsupportedDevPublicRequest(req)) return next();
|
|
2396
|
-
handlePagesMiddleware(req, res, next);
|
|
2901
|
+
handlePagesMiddleware(req, res, next).catch(next);
|
|
2397
2902
|
});
|
|
2398
2903
|
installDevStackSourcemapMiddleware(server);
|
|
2399
2904
|
return () => {
|
|
@@ -2453,9 +2958,15 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2453
2958
|
restore();
|
|
2454
2959
|
return false;
|
|
2455
2960
|
};
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2961
|
+
const pagesInstrumentationReady = (async () => {
|
|
2962
|
+
if (!instrumentationPath || hasAppDir && hasCloudflarePlugin) return;
|
|
2963
|
+
if (hasAppDir) {
|
|
2964
|
+
const environment = server.environments["rsc"];
|
|
2965
|
+
if (!isRunnableDevEnvironment(environment)) return;
|
|
2966
|
+
return runInstrumentation(environment.runner, instrumentationPath);
|
|
2967
|
+
} else return runInstrumentation(getPagesRunner(), instrumentationPath);
|
|
2968
|
+
})();
|
|
2969
|
+
pagesInstrumentationReady.catch(() => {});
|
|
2459
2970
|
if (hasAppDir) server.middlewares.use((req, res, next) => {
|
|
2460
2971
|
const url = req.url ?? "/";
|
|
2461
2972
|
const [pathname] = url.split("?");
|
|
@@ -2506,13 +3017,10 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2506
3017
|
});
|
|
2507
3018
|
next();
|
|
2508
3019
|
});
|
|
2509
|
-
|
|
3020
|
+
const handlePagesRequest = async (req, res, next) => {
|
|
2510
3021
|
try {
|
|
2511
3022
|
let url = req.url ?? "/";
|
|
2512
3023
|
const originalRequestUrl = url;
|
|
2513
|
-
if (!hasPagesDir) return next();
|
|
2514
|
-
if (url.startsWith("/@") || url.startsWith("/__vite") || url.startsWith("/node_modules")) return next();
|
|
2515
|
-
if (url.split("?")[0].endsWith(".rsc")) return next();
|
|
2516
3024
|
const blockReason = validateDevRequest({
|
|
2517
3025
|
origin: req.headers.origin,
|
|
2518
3026
|
host: req.headers.host,
|
|
@@ -2663,7 +3171,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2663
3171
|
const apiRouteUrl = stripI18nLocaleForApiRoute(pathname, nextConfig?.i18n ?? null);
|
|
2664
3172
|
filePathMatchesPagesRoute = matchRoute(pageRouteUrl, pageRoutes) !== null || matchRoute(apiRouteUrl, apiRoutes) !== null;
|
|
2665
3173
|
}
|
|
2666
|
-
if (isFilePathRequest && !isDataReq && !filePathMatchesRewrite && !filePathMatchesPagesRoute && !isExistingPublicMutation) return next();
|
|
3174
|
+
if (isFilePathRequest && !isDataReq && !filePathMatchesRewrite && !filePathMatchesPagesRoute && !isNextStaticPath(pathname, "", assetPrefixPathname(nextConfig?.assetPrefix ?? "")) && !isExistingPublicMutation) return next();
|
|
2667
3175
|
const rawHeaders = new Headers(Object.fromEntries(Object.entries(req.headers).filter(([k, v]) => v !== void 0 && !k.startsWith(":")).map(([k, v]) => [k, Array.isArray(v) ? v.join(", ") : String(v)])));
|
|
2668
3176
|
const isDataRequest = isDataReq;
|
|
2669
3177
|
const nodeRequestHeaders = filterInternalHeaders(rawHeaders);
|
|
@@ -2706,19 +3214,9 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2706
3214
|
const getDevApiRoutes = () => devApiRoutesPromise ??= apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
2707
3215
|
let devAppRoutesPromise = null;
|
|
2708
3216
|
const getDevAppRoutes = () => devAppRoutesPromise ??= hasAppDir && appDir ? appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : Promise.resolve([]);
|
|
2709
|
-
const
|
|
2710
|
-
const
|
|
2711
|
-
|
|
2712
|
-
if (cached) return cached;
|
|
2713
|
-
let dataKind = "none";
|
|
2714
|
-
try {
|
|
2715
|
-
const source = fs.readFileSync(route.filePath, "utf8");
|
|
2716
|
-
dataKind = hasExportedName(source, "getStaticProps") ? "static" : hasExportedName(source, "getServerSideProps") ? "server" : "none";
|
|
2717
|
-
} catch {}
|
|
2718
|
-
devPageRouteDataKinds.set(route.filePath, dataKind);
|
|
2719
|
-
return dataKind;
|
|
2720
|
-
};
|
|
2721
|
-
const pipelineResult = await runPagesRequest(webRequest, {
|
|
3217
|
+
const classifyDevPageRoute = (route) => classifyDevPageFile(route.filePath);
|
|
3218
|
+
const pipelineDeps = {
|
|
3219
|
+
assetPrefix: nextConfig?.assetPrefix,
|
|
2722
3220
|
basePath: bp,
|
|
2723
3221
|
trailingSlash: nextConfig?.trailingSlash ?? false,
|
|
2724
3222
|
i18nConfig: nextConfig?.i18n ?? null,
|
|
@@ -2738,12 +3236,15 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2738
3236
|
configMatchPathname,
|
|
2739
3237
|
runMiddleware: devRunMiddlewareAdapter,
|
|
2740
3238
|
matchApiRoute: async (apiUrl) => {
|
|
2741
|
-
const
|
|
3239
|
+
const devApiRoutes = await getDevApiRoutes();
|
|
3240
|
+
const pagesMatch = matchRoute(apiUrl, devApiRoutes);
|
|
2742
3241
|
if (pagesMatch) return pagesMatch;
|
|
2743
|
-
|
|
3242
|
+
const devAppRoutes = await getDevAppRoutes();
|
|
3243
|
+
return matchAppRoute(apiUrl, devAppRoutes);
|
|
2744
3244
|
},
|
|
2745
3245
|
matchPageRoute: (resolvedPathname, request) => {
|
|
2746
|
-
const
|
|
3246
|
+
const routeUrl = nextConfig?.i18n ? resolvePagesI18nRequest(resolvedPathname, nextConfig.i18n, request.headers, getUrlHostname(request.url), bp, nextConfig.trailingSlash ?? false).url : resolvedPathname;
|
|
3247
|
+
const m = matchRoute(routeUrl, devPageRoutes);
|
|
2747
3248
|
return m ? { route: {
|
|
2748
3249
|
dataKind: classifyDevPageRoute(m.route),
|
|
2749
3250
|
isDynamic: m.route.isDynamic,
|
|
@@ -2762,11 +3263,14 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2762
3263
|
externalInit.body = Readable.toWeb(req);
|
|
2763
3264
|
externalInit.duplex = "half";
|
|
2764
3265
|
}
|
|
2765
|
-
|
|
3266
|
+
const reqWithBody = new Request(new URL(url, requestOrigin), externalInit);
|
|
3267
|
+
return proxyExternalRequest(reqWithBody, externalUrl);
|
|
2766
3268
|
},
|
|
2767
3269
|
serveFilesystemRoute: async (requestPathname, stagedHeaders, phase, resolvedUrl) => {
|
|
2768
3270
|
if (isImageOptimizationPath(requestPathname)) {
|
|
2769
|
-
const
|
|
3271
|
+
const imageRequestUrl = new URL(resolvedUrl, requestOrigin);
|
|
3272
|
+
const allowedWidths = [...nextConfig.images?.deviceSizes ?? DEFAULT_DEVICE_SIZES, ...nextConfig.images?.imageSizes ?? DEFAULT_IMAGE_SIZES];
|
|
3273
|
+
const encodedLocation = resolveDevImageRedirect(imageRequestUrl, allowedWidths, nextConfig.images?.qualities);
|
|
2770
3274
|
return encodedLocation ? new Response(null, {
|
|
2771
3275
|
status: 302,
|
|
2772
3276
|
headers: { Location: encodedLocation }
|
|
@@ -2777,7 +3281,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2777
3281
|
if (!isRetrievalMethod) return isExistingDevPublicFile(requestPathname) ? methodNotAllowedResponse("GET, HEAD") : false;
|
|
2778
3282
|
return serveRewrittenViteFilesystemRoute(req, res, requestPathname, stagedHeaders);
|
|
2779
3283
|
}
|
|
2780
|
-
}
|
|
3284
|
+
};
|
|
3285
|
+
const pipelineResult = await runPagesRequest(webRequest, pipelineDeps);
|
|
2781
3286
|
if (pipelineResult.type === "response") {
|
|
2782
3287
|
await writeWebResponseToNodeRes(res, pipelineResult.response);
|
|
2783
3288
|
return;
|
|
@@ -2841,12 +3346,19 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2841
3346
|
const renderMatch = matchRoute(resolvedPathname, routes);
|
|
2842
3347
|
if (hasAppDir && appDir) {
|
|
2843
3348
|
if (!renderMatch) return next();
|
|
2844
|
-
const
|
|
3349
|
+
const appRoutes = await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher);
|
|
3350
|
+
const appMatch = matchAppRoute(resolvedPathname, appRoutes);
|
|
2845
3351
|
if (appMatch && !pagesRouteHasPriorityOverAppRoute(renderMatch.route, appMatch.route)) return next();
|
|
2846
3352
|
}
|
|
3353
|
+
if (!renderMatch && isNextStaticPath(resolvedPathname, "", assetPrefixPathname(nextConfig?.assetPrefix ?? ""))) {
|
|
3354
|
+
const headers = new Headers();
|
|
3355
|
+
forEachStagedHeader((key, value) => headers.append(key, value));
|
|
3356
|
+
await writeWebResponseToNodeRes(res, notFoundStaticAssetResponse(headers));
|
|
3357
|
+
return;
|
|
3358
|
+
}
|
|
2847
3359
|
if (!cachedSSRHandler || cachedSSRHandler.routes !== routes) cachedSSRHandler = {
|
|
2848
3360
|
routes,
|
|
2849
|
-
handler: createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false, middlewarePath !== null, (nextConfig?.rewrites.beforeFiles.length ?? 0) > 0 || (nextConfig?.rewrites.afterFiles.length ?? 0) > 0 || (nextConfig?.rewrites.fallback.length ?? 0) > 0, nextConfig?.clientTraceMetadata, nextConfig?.htmlLimitedBots, nextConfig?.reactStrictMode === true, nextConfig?.expireTime, nextConfig?.crossOrigin, devBuildId)
|
|
3361
|
+
handler: createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false, middlewarePath !== null, (nextConfig?.rewrites.beforeFiles.length ?? 0) > 0 || (nextConfig?.rewrites.afterFiles.length ?? 0) > 0 || (nextConfig?.rewrites.fallback.length ?? 0) > 0, nextConfig?.clientTraceMetadata, nextConfig?.htmlLimitedBots, nextConfig?.reactStrictMode === true, nextConfig?.expireTime, nextConfig?.crossOrigin, devBuildId, middlewarePath ? compileClientMiddlewareMatchers(extractMiddlewareMatcherConfig(middlewarePath)) : void 0, classifyDevPageRoute)
|
|
2850
3362
|
};
|
|
2851
3363
|
flushStagedHeaders();
|
|
2852
3364
|
flushRequestHeaders();
|
|
@@ -2855,11 +3367,54 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2855
3367
|
await cachedSSRHandler.handler(req, res, pipelineResult.resolvedUrl, req.__vinextMiddlewareStatus, pipelineResult.isDataReq, originalRequestUrl);
|
|
2856
3368
|
}
|
|
2857
3369
|
} catch (e) {
|
|
2858
|
-
next(e);
|
|
3370
|
+
return next(e);
|
|
2859
3371
|
}
|
|
2860
3372
|
};
|
|
3373
|
+
handlePagesMiddleware = async (req, res, next) => {
|
|
3374
|
+
const url = req.url ?? "/";
|
|
3375
|
+
if (!hasPagesDir) return next();
|
|
3376
|
+
if (url.startsWith("/@") || url.startsWith("/__vite") || url.startsWith("/node_modules")) return next();
|
|
3377
|
+
if (url.split("?")[0].endsWith(".rsc")) return next();
|
|
3378
|
+
if (hasCloudflarePlugin) return next();
|
|
3379
|
+
await pagesInstrumentationReady;
|
|
3380
|
+
const traceHeaders = new Headers();
|
|
3381
|
+
for (const [name, value] of Object.entries(req.headers)) {
|
|
3382
|
+
if (value === void 0 || name.startsWith(":")) continue;
|
|
3383
|
+
traceHeaders.set(name, Array.isArray(value) ? value.join(", ") : value);
|
|
3384
|
+
}
|
|
3385
|
+
const continueRequest = (error) => new Promise((resolve, reject) => {
|
|
3386
|
+
const finish = () => {
|
|
3387
|
+
res.off("finish", finish);
|
|
3388
|
+
res.off("close", finish);
|
|
3389
|
+
res.off("error", fail);
|
|
3390
|
+
resolve();
|
|
3391
|
+
};
|
|
3392
|
+
const fail = (responseError) => {
|
|
3393
|
+
res.off("finish", finish);
|
|
3394
|
+
res.off("close", finish);
|
|
3395
|
+
res.off("error", fail);
|
|
3396
|
+
reject(responseError);
|
|
3397
|
+
};
|
|
3398
|
+
res.once("finish", finish);
|
|
3399
|
+
res.once("close", finish);
|
|
3400
|
+
res.once("error", fail);
|
|
3401
|
+
try {
|
|
3402
|
+
next(error);
|
|
3403
|
+
if (res.writableFinished || res.destroyed) finish();
|
|
3404
|
+
} catch (nextError) {
|
|
3405
|
+
fail(nextError);
|
|
3406
|
+
}
|
|
3407
|
+
});
|
|
3408
|
+
return traceFrameworkRequest({
|
|
3409
|
+
callback: () => handlePagesRequest(req, res, continueRequest),
|
|
3410
|
+
getStatus: () => res.statusCode,
|
|
3411
|
+
headers: traceHeaders,
|
|
3412
|
+
method: req.method ?? "GET",
|
|
3413
|
+
target: url
|
|
3414
|
+
});
|
|
3415
|
+
};
|
|
2861
3416
|
server.middlewares.use((req, res, next) => {
|
|
2862
|
-
handlePagesMiddleware(req, res, next);
|
|
3417
|
+
handlePagesMiddleware(req, res, next).catch(next);
|
|
2863
3418
|
});
|
|
2864
3419
|
};
|
|
2865
3420
|
}
|
|
@@ -2867,12 +3422,15 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2867
3422
|
{
|
|
2868
3423
|
name: "vinext:validate-middleware-exports",
|
|
2869
3424
|
enforce: "pre",
|
|
2870
|
-
transform
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
3425
|
+
transform: {
|
|
3426
|
+
filter: { id: { exclude: VIRTUAL_MODULE_ID_RE } },
|
|
3427
|
+
handler(code, id) {
|
|
3428
|
+
if (!middlewarePath) return null;
|
|
3429
|
+
const modulePath = stripViteModuleQuery(id);
|
|
3430
|
+
if (canonicalizePageTransformPath(modulePath) !== canonicalMiddlewarePath) return null;
|
|
3431
|
+
validateMiddlewareModuleExports(code, modulePath, middlewarePath, isProxyFile(middlewarePath));
|
|
3432
|
+
return null;
|
|
3433
|
+
}
|
|
2876
3434
|
}
|
|
2877
3435
|
},
|
|
2878
3436
|
{
|
|
@@ -2880,7 +3438,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2880
3438
|
transform: {
|
|
2881
3439
|
filter: {
|
|
2882
3440
|
id: { exclude: VIRTUAL_MODULE_ID_RE },
|
|
2883
|
-
code:
|
|
3441
|
+
code: EXPORT_ALL_CANDIDATE_FILTER
|
|
2884
3442
|
},
|
|
2885
3443
|
handler(code, id) {
|
|
2886
3444
|
if (this.environment?.name !== "client") return null;
|
|
@@ -2977,6 +3535,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2977
3535
|
filter: { code: consumerEnvironmentConditionFilter },
|
|
2978
3536
|
handler(code, id) {
|
|
2979
3537
|
const scansImports = this.environment.config.build.write === false;
|
|
3538
|
+
const skipsUnobservableFold = scansImports && useNativeTypeofWindowFolding && this.environment.config.isBundled;
|
|
3539
|
+
if (skipsUnobservableFold && !mayFoldChangeScannedImports(code)) return null;
|
|
2980
3540
|
const replaceTypeofWindow = !useNativeTypeofWindowFolding || scansImports;
|
|
2981
3541
|
const replaceProcessBrowser = scansImports;
|
|
2982
3542
|
if (!replaceTypeofWindow && !replaceProcessBrowser) return null;
|
|
@@ -2984,12 +3544,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2984
3544
|
if (toSlash(id).startsWith(cacheDir)) return null;
|
|
2985
3545
|
const typeofWindow = getTypeofWindowReplacement(this.environment);
|
|
2986
3546
|
const processBrowser = this.environment.config.consumer === "client";
|
|
2987
|
-
const variant = `${replaceTypeofWindow ? typeofWindow : "-"}:${replaceProcessBrowser ? processBrowser : "-"}`;
|
|
2988
|
-
return cachedConsumerConditionTransform(id, code, variant, () => replaceConsumerEnvironmentConditions(code, {
|
|
3547
|
+
const variant = `${replaceTypeofWindow ? typeofWindow : "-"}:${replaceProcessBrowser ? processBrowser : "-"}:${skipsUnobservableFold ? "gated" : "full"}`;
|
|
3548
|
+
return omitUnusedBuildSourcemap(this.environment, cachedConsumerConditionTransform(id, code, variant, () => replaceConsumerEnvironmentConditions(code, {
|
|
2989
3549
|
...replaceTypeofWindow ? { typeofWindow } : {},
|
|
2990
3550
|
...replaceProcessBrowser ? { processBrowser } : {},
|
|
2991
|
-
pruneUnreachableImports: scansImports
|
|
2992
|
-
|
|
3551
|
+
pruneUnreachableImports: scansImports,
|
|
3552
|
+
onlyIfScannedImportsChange: skipsUnobservableFold
|
|
3553
|
+
}, id)));
|
|
2993
3554
|
}
|
|
2994
3555
|
}
|
|
2995
3556
|
},
|
|
@@ -3000,8 +3561,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3000
3561
|
const serverDefines = { ...nextConfig.compilerDefineServer };
|
|
3001
3562
|
serverDefines["process.env.NEXT_RUNTIME"] = JSON.stringify("nodejs");
|
|
3002
3563
|
serverDefines["process.env.NEXT_PHASE"] = "globalThis.__VINEXT_NEXT_PHASE";
|
|
3003
|
-
|
|
3004
|
-
if (sharedRevalidateSecret) serverDefines["process.env.__VINEXT_REVALIDATE_SECRET"] = JSON.stringify(sharedRevalidateSecret);
|
|
3564
|
+
if (revalidateSecret) serverDefines["process.env.__VINEXT_REVALIDATE_SECRET"] = JSON.stringify(revalidateSecret);
|
|
3005
3565
|
if (previewBuildCredentials) {
|
|
3006
3566
|
serverDefines["process.env.__VINEXT_PREVIEW_MODE_ID"] = JSON.stringify(previewBuildCredentials.id);
|
|
3007
3567
|
serverDefines["process.env.__VINEXT_PREVIEW_MODE_SIGNING_KEY"] = JSON.stringify(previewBuildCredentials.signingKey);
|
|
@@ -3176,7 +3736,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3176
3736
|
sequential: true,
|
|
3177
3737
|
order: "post",
|
|
3178
3738
|
handler() {
|
|
3179
|
-
if (buildIdWritten) return;
|
|
3739
|
+
if (buildIdWritten || !isServerEnvironment(this.environment)) return;
|
|
3180
3740
|
buildIdWritten = true;
|
|
3181
3741
|
const outDir = path.join(root, "dist", "server");
|
|
3182
3742
|
fs.mkdirSync(outDir, { recursive: true });
|
|
@@ -3207,14 +3767,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3207
3767
|
if (!environment || (hasAppDir ? environment.name !== "rsc" : !isServerEnvironment(environment))) return;
|
|
3208
3768
|
const outDir = options.dir;
|
|
3209
3769
|
if (!outDir) return;
|
|
3210
|
-
const
|
|
3770
|
+
const canonicalServerDir = path.join(root, "dist", "server");
|
|
3771
|
+
if (selectedMultiStageOutput) {
|
|
3772
|
+
if (readPrerenderSecret(canonicalServerDir) === prerenderSecret) for (const runtimeOutputDir of readServerRuntimeOutputDirs(canonicalServerDir, root)) serverRuntimeOutputDirs.add(runtimeOutputDir);
|
|
3773
|
+
serverRuntimeOutputDirs.add(path.resolve(outDir));
|
|
3774
|
+
}
|
|
3775
|
+
const manifest = {
|
|
3776
|
+
prerenderSecret,
|
|
3777
|
+
...serverRuntimeOutputDirs.size === 0 ? {} : { runtimeOutputDirs: [...serverRuntimeOutputDirs].map((runtimeOutputDir) => path.relative(root, runtimeOutputDir) || ".").sort() }
|
|
3778
|
+
};
|
|
3779
|
+
const source = JSON.stringify(manifest);
|
|
3211
3780
|
fs.writeFileSync(path.join(outDir, "vinext-server.json"), source);
|
|
3212
|
-
if (
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
fs.mkdirSync(canonicalServerDir, { recursive: true });
|
|
3216
|
-
fs.writeFileSync(path.join(canonicalServerDir, "vinext-server.json"), source);
|
|
3217
|
-
}
|
|
3781
|
+
if (path.resolve(outDir) !== canonicalServerDir) {
|
|
3782
|
+
fs.mkdirSync(canonicalServerDir, { recursive: true });
|
|
3783
|
+
fs.writeFileSync(path.join(canonicalServerDir, "vinext-server.json"), source);
|
|
3218
3784
|
}
|
|
3219
3785
|
}
|
|
3220
3786
|
}
|
|
@@ -3222,6 +3788,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3222
3788
|
{
|
|
3223
3789
|
name: "vinext:nitro-route-rules",
|
|
3224
3790
|
nitro: { setup: async (nitro) => {
|
|
3791
|
+
nitroBuildDir = nitro.options.buildDir ? path.resolve(root, nitro.options.buildDir) : void 0;
|
|
3792
|
+
nitroHostRuntime = nitro.options.exportConditions?.includes("workerd") ? "worker" : "node";
|
|
3225
3793
|
if (!nextConfig) return;
|
|
3226
3794
|
if (!hasAppDir && !hasPagesDir) return;
|
|
3227
3795
|
if (resolvedServerExternalPackages.length > 0) nitro.options.traceDeps = [.../* @__PURE__ */ new Set([...nitro.options.traceDeps ?? [], ...resolvedServerExternalPackages])];
|
|
@@ -3252,7 +3820,10 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3252
3820
|
const ssrManifestPath = path.join(viteDir, "ssr-manifest.json");
|
|
3253
3821
|
if (!fs.existsSync(ssrManifestPath)) return;
|
|
3254
3822
|
try {
|
|
3255
|
-
const
|
|
3823
|
+
const ssrManifest = JSON.parse(fs.readFileSync(ssrManifestPath, "utf-8"));
|
|
3824
|
+
const buildRoot = this.environment?.config.root ?? process.cwd();
|
|
3825
|
+
const buildBase = this.environment?.config.base ?? "/";
|
|
3826
|
+
const augmentedManifest = augmentSsrManifestFromBundle(ssrManifest, bundle, buildRoot, buildBase);
|
|
3256
3827
|
fs.writeFileSync(ssrManifestPath, JSON.stringify(augmentedManifest, null, 2));
|
|
3257
3828
|
} catch (err) {
|
|
3258
3829
|
console.warn("[vinext] Failed to augment SSR manifest:", err);
|
|
@@ -3372,17 +3943,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3372
3943
|
clientEntry: runtimeMetadata.clientEntryFile ?? void 0,
|
|
3373
3944
|
appBootstrapPreinitModules: runtimeMetadata.appBootstrapPreinitModules,
|
|
3374
3945
|
ssrManifest,
|
|
3946
|
+
cssGraph: runtimeMetadata.cssGraph,
|
|
3375
3947
|
lazyChunks: runtimeMetadata.lazyChunks ?? void 0,
|
|
3376
|
-
dynamicPreloads: runtimeMetadata.dynamicPreloads ?? void 0
|
|
3948
|
+
dynamicPreloads: runtimeMetadata.dynamicPreloads ?? void 0,
|
|
3949
|
+
crossOrigin: nextConfig.crossOrigin ?? ""
|
|
3377
3950
|
});
|
|
3378
|
-
const buildSession = process.env.__VINEXT_PAGES_CLIENT_ASSETS_BUILD_SESSION;
|
|
3379
|
-
if (hasAppDir && hasPagesDir && buildSession) setPagesClientAssetsBuildMetadata(buildSession, pagesClientAssetsModule);
|
|
3380
|
-
}
|
|
3381
|
-
if (pagesClientAssetsModule === null) {
|
|
3382
|
-
if (pagesClientAssetsOutputDirs.size === 0) return;
|
|
3383
|
-
const buildSession = process.env.__VINEXT_PAGES_CLIENT_ASSETS_BUILD_SESSION;
|
|
3384
|
-
if (buildSession) pagesClientAssetsModule = takePagesClientAssetsBuildMetadata(buildSession);
|
|
3385
3951
|
}
|
|
3952
|
+
if (pagesClientAssetsModule === null && pagesClientAssetsOutputDirs.size === 0) return;
|
|
3386
3953
|
if (pagesClientAssetsModule === null) {
|
|
3387
3954
|
const emptyModule = buildPagesClientAssetsModule({});
|
|
3388
3955
|
for (const outputDir of pagesClientAssetsOutputDirs) writePagesClientAssetsModuleIfMissing(outputDir, emptyModule);
|
|
@@ -3416,7 +3983,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3416
3983
|
const envConfig = this.environment?.config;
|
|
3417
3984
|
if (!envConfig) return;
|
|
3418
3985
|
const buildRoot = envConfig.root ?? process.cwd();
|
|
3419
|
-
const
|
|
3986
|
+
const clientDir = path.resolve(buildRoot, "dist", "client");
|
|
3987
|
+
const manifest = collectInlineCssManifest(clientDir, nextConfig.assetPrefix);
|
|
3420
3988
|
const rscOutDir = path.resolve(buildRoot, options.rscOutDir ?? path.join("dist", "server"));
|
|
3421
3989
|
for (const entryFile of ["index.js", "index.mjs"]) if (injectInlineCssManifestGlobal(path.join(rscOutDir, entryFile), manifest)) break;
|
|
3422
3990
|
}
|
|
@@ -3453,6 +4021,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3453
4021
|
}
|
|
3454
4022
|
},
|
|
3455
4023
|
createWasmModuleImportPlugin(),
|
|
4024
|
+
createOgHarfbuzzPlugin(),
|
|
3456
4025
|
{
|
|
3457
4026
|
name: "vinext:og-font-patch",
|
|
3458
4027
|
enforce: "pre",
|
|
@@ -3524,7 +4093,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3524
4093
|
const buildRoot = config.root ?? process.cwd();
|
|
3525
4094
|
const outDir = path.resolve(buildRoot, outputOptions.dir);
|
|
3526
4095
|
const loadedEntries = serverEntryKindsByEnvironment.get(this.environment?.name ?? "");
|
|
3527
|
-
const isPrimaryServerOutput = Boolean(loadedEntries?.has(RESOLVED_RSC_ENTRY) || loadedEntries?.has(RESOLVED_SERVER_ENTRY) && !loadedEntries.has(RESOLVED_APP_SSR_ENTRY));
|
|
4096
|
+
const isPrimaryServerOutput = Boolean(loadedEntries?.has(RESOLVED_RSC_ENTRY) || loadedEntries?.has(RESOLVED_APP_REQUEST_ENTRY) || loadedEntries?.has(RESOLVED_APP_RESPONSE_ENTRY) || loadedEntries?.has(RESOLVED_PAGES_REQUEST_ENTRY) || loadedEntries?.has(RESOLVED_PAGES_RESPONSE_ENTRY) || loadedEntries?.has(RESOLVED_SERVER_ENTRY) && !loadedEntries.has(RESOLVED_APP_SSR_ENTRY));
|
|
3528
4097
|
for (const output of cacheAdapterBuildOutputs) {
|
|
3529
4098
|
if (output.matchesBuild && !output.matchesBuild(build)) continue;
|
|
3530
4099
|
await output.finalizeBuildOutput?.({
|
|
@@ -3537,22 +4106,46 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3537
4106
|
}
|
|
3538
4107
|
});
|
|
3539
4108
|
if (rscPluginPromise) plugins.push(rscPluginPromise);
|
|
3540
|
-
if (earlyAppDirExists)
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
4109
|
+
if (earlyAppDirExists) {
|
|
4110
|
+
plugins.push(createActionOwnerManifestPlugin({
|
|
4111
|
+
canonicalizeModuleId: canonicalize,
|
|
4112
|
+
async getManager(config) {
|
|
4113
|
+
return (await rscPluginModulePromise)?.getPluginApi(config)?.manager;
|
|
4114
|
+
},
|
|
4115
|
+
getRoutes: () => rscActionOwnerRoutes ?? [],
|
|
4116
|
+
getSharedRoots: () => rscActionOwnerSharedRoots,
|
|
4117
|
+
onComplete() {
|
|
4118
|
+
rscActionOwnerRoutes = null;
|
|
4119
|
+
rscActionOwnerSharedRoots = [];
|
|
4120
|
+
}
|
|
4121
|
+
}));
|
|
4122
|
+
plugins.push(createScanBuildCssPlugin());
|
|
4123
|
+
}
|
|
3552
4124
|
if (rscPluginPromise) {
|
|
3553
4125
|
plugins.push(createRscReferenceValidationNormalizerPlugin());
|
|
3554
4126
|
plugins.push(createRscClientReferenceLoadersPlugin());
|
|
3555
4127
|
} else if (manualUseCachePluginPromise) plugins.push(manualUseCachePluginPromise);
|
|
4128
|
+
plugins.push({
|
|
4129
|
+
name: "vinext:plain-pages-build-config",
|
|
4130
|
+
apply: "build",
|
|
4131
|
+
enforce: "post",
|
|
4132
|
+
config: {
|
|
4133
|
+
order: "post",
|
|
4134
|
+
handler(config) {
|
|
4135
|
+
if (!hasPlainPagesBuildEnvironments) return;
|
|
4136
|
+
if (config.build?.watch || config.build?.ssr || config.build?.lib || getBuildBundlerOptions(config.build)?.input !== void 0) {
|
|
4137
|
+
for (const name of ["client", "ssr"]) if (originalPlainPagesEnvironments?.[name]) config.environments[name] = originalPlainPagesEnvironments[name];
|
|
4138
|
+
else delete config.environments?.[name];
|
|
4139
|
+
return;
|
|
4140
|
+
}
|
|
4141
|
+
return { builder: {
|
|
4142
|
+
...config.builder,
|
|
4143
|
+
sharedConfigBuild: true
|
|
4144
|
+
} };
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4147
|
+
});
|
|
4148
|
+
plugins.push(buildLifecyclePlugins[1]);
|
|
3556
4149
|
return plugins;
|
|
3557
4150
|
}
|
|
3558
4151
|
/**
|