vinext 1.0.0-beta.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -92
- package/THIRD_PARTY_LICENSES.md +25 -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 +1 -13
- package/dist/build/precompress.d.ts +2 -3
- 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 +273 -97
- 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 +65 -15
- package/dist/build/prerender.js +139 -43
- 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 +25 -16
- package/dist/build/server-entry.d.ts +4 -0
- package/dist/build/server-entry.js +28 -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/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 +21 -17
- package/dist/client/navigation-runtime.js +2 -1
- 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 +2 -1
- 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 +502 -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 +711 -189
- package/dist/init-cloudflare.d.ts +26 -17
- package/dist/init-cloudflare.js +710 -102
- 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 +123 -41
- 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/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 +3 -4
- package/dist/plugins/ignore-dynamic-requests.js +60 -89
- package/dist/plugins/import-meta-url.d.ts +6 -7
- package/dist/plugins/import-meta-url.js +31 -43
- 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 +3 -4
- package/dist/plugins/og-assets.d.ts +4 -5
- package/dist/plugins/og-assets.js +32 -13
- package/dist/plugins/og-harfbuzz.d.ts +24 -0
- package/dist/plugins/og-harfbuzz.js +260 -0
- package/dist/plugins/optimize-imports.d.ts +7 -7
- package/dist/plugins/optimize-imports.js +32 -44
- 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 +2 -3
- package/dist/plugins/require-context.js +13 -21
- 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/server-externals-manifest.d.ts +2 -3
- package/dist/plugins/strip-server-exports.d.ts +5 -6
- package/dist/plugins/strip-server-exports.js +1 -1
- 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 +3 -4
- package/dist/plugins/transitive-externals.d.ts +2 -3
- package/dist/plugins/typeof-window.d.ts +6 -7
- package/dist/plugins/typeof-window.js +30 -31
- 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 +19 -19
- package/dist/routing/app-route-graph.js +3 -2
- 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 +3 -4
- package/dist/server/app-bfcache-identity.d.ts +8 -9
- 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 +87 -34
- 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 +14 -1
- 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 +8 -4
- 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 +6 -2
- package/dist/server/app-browser-stream.d.ts +4 -5
- 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 +26 -27
- package/dist/server/app-history-state.js +19 -11
- 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 -5
- 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 -25
- 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 +42 -6
- 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 +49 -0
- package/dist/server/app-pages-bridge.d.ts +6 -6
- package/dist/server/app-pages-bridge.js +17 -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-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 +115 -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 +2 -3
- package/dist/server/app-route-handler-cache.js +46 -34
- package/dist/server/app-route-handler-dispatch.d.ts +3 -3
- package/dist/server/app-route-handler-dispatch.js +68 -54
- package/dist/server/app-route-handler-execution.d.ts +17 -13
- package/dist/server/app-route-handler-execution.js +69 -18
- 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-response.d.ts +9 -10
- package/dist/server/app-route-handler-response.js +2 -0
- 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 +2 -0
- package/dist/server/app-router-entry.js +28 -8
- 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 +12 -9
- package/dist/server/app-rsc-errors.js +15 -13
- package/dist/server/app-rsc-handler.d.ts +31 -6
- package/dist/server/app-rsc-handler.js +411 -61
- 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 +2 -1
- package/dist/server/app-rsc-response-finalizer.d.ts +8 -5
- package/dist/server/app-rsc-response-finalizer.js +6 -6
- 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 +16 -12
- 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 +61 -14
- 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 +33 -7
- 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 +71 -5
- 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 +159 -57
- 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 +130 -61
- 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 +54 -61
- package/dist/server/headers.js +18 -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-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 +28 -27
- package/dist/server/isr-cache.js +18 -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-cache-policy.d.ts +2 -3
- package/dist/server/metadata-route-response.d.ts +7 -7
- package/dist/server/metadata-route-response.js +68 -2
- 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 +20 -7
- package/dist/server/pages-asset-tags.d.ts +6 -6
- package/dist/server/pages-asset-tags.js +37 -2
- 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 +11 -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 +18 -19
- package/dist/server/pages-page-data.js +11 -10
- package/dist/server/pages-page-handler.d.ts +7 -6
- package/dist/server/pages-page-handler.js +77 -39
- 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 +49 -31
- 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 +14 -12
- package/dist/server/pages-request-pipeline.js +60 -30
- package/dist/server/pages-request-stage-entry.d.ts +23 -0
- package/dist/server/pages-request-stage-entry.js +314 -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 +11 -11
- package/dist/server/prerender-manifest.js +6 -3
- 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 +124 -31
- 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 +2 -3
- package/dist/server/worker-revalidation-context.js +5 -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 +17 -0
- package/dist/server/workers-tracing.js +27 -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 +28 -29
- package/dist/shims/cache-runtime.d.ts +23 -21
- package/dist/shims/cache-runtime.js +107 -27
- package/dist/shims/cache.d.ts +15 -15
- package/dist/shims/cache.js +15 -13
- package/dist/shims/cacheability-classification.d.ts +49 -28
- package/dist/shims/cacheability-classification.js +27 -12
- 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 +50 -21
- package/dist/shims/cdn-cache.js +15 -38
- 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 +4 -4
- package/dist/shims/error.react-server.d.ts +3 -4
- package/dist/shims/fetch-cache.d.ts +22 -22
- package/dist/shims/fetch-cache.js +42 -17
- 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 +67 -33
- package/dist/shims/headers.js +93 -6
- 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/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/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 +24 -16
- 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/root-params.d.ts +14 -15
- 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 +14 -28
- 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 +34 -31
- 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 +3 -4
- 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 +144 -0
- package/dist/utils/vite-version.d.ts +5 -6
- package/next-package.json +4 -0
- package/package.json +47 -6
package/dist/index.js
CHANGED
|
@@ -1,34 +1,45 @@
|
|
|
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 { resolveAssetsDir } from "./utils/asset-prefix.js";
|
|
15
|
+
import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
|
|
16
|
+
import { VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
|
|
17
|
+
import { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
|
|
5
18
|
import { hasBasePath, stripBasePath } from "./utils/base-path.js";
|
|
19
|
+
import { appRouteGraph, appRouter, invalidateAppRouteCache, matchAppRoute } from "./routing/app-router.js";
|
|
20
|
+
import { generateRouteTypes } from "./typegen.js";
|
|
6
21
|
import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./routing/pages-router.js";
|
|
7
|
-
import {
|
|
22
|
+
import { resolveRuntimeEntryModule } from "./entries/runtime-entry-module.js";
|
|
8
23
|
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
24
|
import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
|
|
11
|
-
import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
|
|
12
25
|
import { validateMiddlewareMatcherPatterns } from "./server/middleware-matcher-pattern.js";
|
|
13
26
|
import { methodNotAllowedResponse } from "./server/http-error-responses.js";
|
|
14
27
|
import { isOpenRedirectShaped } from "./server/open-redirect.js";
|
|
15
28
|
import { canonicalizeRequestUrlPathname, filterInternalHeaders, normalizeTrailingSlash } from "./server/request-pipeline.js";
|
|
16
29
|
import { resolvePagesI18nRequest, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
|
|
30
|
+
import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
|
|
17
31
|
import { findMiddlewareFile, isProxyFile, runMiddleware } from "./server/middleware.js";
|
|
18
32
|
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";
|
|
33
|
+
import { generatePagesRequestEntry, generatePagesResponseEntry, generateServerEntry } from "./entries/pages-server-entry.js";
|
|
34
|
+
import { compileClientMiddlewareMatchers, generateClientEntry } from "./entries/pages-client-entry.js";
|
|
24
35
|
import { logRequest, now } from "./server/request-log.js";
|
|
25
36
|
import { encodeUrlParserIgnoredCharacters, isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname, shouldAddTrailingSlashToPagesDataPath, urlParserCreatesPagesDataPath } from "./server/pages-data-route.js";
|
|
26
|
-
import { resolveAssetsDir } from "./utils/asset-prefix.js";
|
|
27
37
|
import { getPagesPreviewModeId } from "./server/pages-preview.js";
|
|
28
38
|
import { createSSRHandler } from "./server/dev-server.js";
|
|
29
39
|
import { handleApiRoute } from "./server/api-handler.js";
|
|
30
40
|
import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath, resolveDevImageRedirect } from "./server/image-optimization.js";
|
|
31
|
-
import { CACHEABILITY_MANIFEST_MODULE } from "./server/cacheability-manifest.js";
|
|
41
|
+
import { CACHEABILITY_MANIFEST_MODULE, CACHEABILITY_REQUEST_PROJECTION_MODULE } from "./server/cacheability-manifest.js";
|
|
42
|
+
import { PREGENERATED_CONCRETE_PATHS_MODULE } from "./server/pregenerated-concrete-paths.js";
|
|
32
43
|
import { installSocketErrorBackstop } from "./server/socket-error-backstop.js";
|
|
33
44
|
import { isPathInside, isPathInsideOrEqual, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
|
|
34
45
|
import { invalidateMetadataFileCache, scanMetadataFiles } from "./server/metadata-routes.js";
|
|
@@ -36,24 +47,25 @@ import { shouldInvalidateAppRouteFile } from "./server/dev-route-files.js";
|
|
|
36
47
|
import { createDirectRunner } from "./server/dev-module-runner.js";
|
|
37
48
|
import { validateDevRequest } from "./server/dev-origin-check.js";
|
|
38
49
|
import { createActionOwnerManifestPlugin } from "./plugins/action-owner-manifest.js";
|
|
39
|
-
import { generateRscEntry } from "./entries/app-rsc-entry.js";
|
|
50
|
+
import { generateAppRequestRscEntry, generateAppResponseRscEntry, generateRscEntry } from "./entries/app-rsc-entry.js";
|
|
40
51
|
import { generateSsrEntry } from "./entries/app-ssr-entry.js";
|
|
41
|
-
import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VIRTUAL_CACHE_ADAPTERS, generateCacheAdaptersModule,
|
|
52
|
+
import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, VIRTUAL_CACHE_ADAPTERS, VIRTUAL_CDN_CACHE_ADAPTER, generateCacheAdaptersModule, generateCdnCacheAdapterModule } from "./cache/cache-adapters-virtual.js";
|
|
42
53
|
import { VIRTUAL_IMAGE_ADAPTERS, generateImageAdaptersModule } from "./image/image-adapters-virtual.js";
|
|
43
54
|
import { generateBrowserEntry, toLinkPrefetchRoutes } from "./entries/app-browser-entry.js";
|
|
44
55
|
import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
|
|
45
56
|
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";
|
|
57
|
+
import { findOpenTelemetryPackages, mergeServerExternalPackages } from "./config/server-external-packages.js";
|
|
51
58
|
import { precompressAssets } from "./build/precompress.js";
|
|
59
|
+
import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY, normalizeVinextPrerenderConfig } from "./config/prerender.js";
|
|
60
|
+
import { PAGES_CLIENT_ASSETS_MODULE, buildPagesClientAssetsModule, writePagesClientAssetsModuleIfMissing } from "./build/pages-client-assets-module.js";
|
|
61
|
+
import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
|
|
62
|
+
import { VINEXT_BUILD_LIFECYCLE_CONFIG, createBuildLifecyclePlugins } from "./build/lifecycle.js";
|
|
52
63
|
import { ensureAssetsIgnore } from "./build/assets-ignore.js";
|
|
53
64
|
import { emitNextClientRuntimeManifests } from "./build/next-client-runtime-manifests.js";
|
|
54
65
|
import { collectInlineCssManifest, injectInlineCssManifestGlobal } from "./build/inline-css.js";
|
|
55
66
|
import { readTrustedRevalidationHostname } from "./server/revalidation-host.js";
|
|
56
67
|
import { installDevStackSourcemapMiddleware } from "./server/dev-stack-sourcemap.js";
|
|
68
|
+
import { traceFrameworkRequest } from "./server/request-tracing.js";
|
|
57
69
|
import { runPagesRequest } from "./server/pages-request-pipeline.js";
|
|
58
70
|
import { pagesRouteHasPriorityOverAppRoute, validateHybridRouteConflicts } from "./server/hybrid-route-priority.js";
|
|
59
71
|
import { hasReactCompilerPlugin, isReactCompilerPlugin, isReactCompilerRequested, reactCompilerUnsupportedMessage } from "./utils/react-compiler-support.js";
|
|
@@ -66,7 +78,7 @@ import { dataUrlCssPlugin } from "./plugins/css-data-url.js";
|
|
|
66
78
|
import { createCssModuleImportCompatibilityPlugin } from "./plugins/css-module-imports.js";
|
|
67
79
|
import { createRscClientReferenceLoadersPlugin } from "./plugins/rsc-client-reference-loaders.js";
|
|
68
80
|
import { createRscReferenceValidationNormalizerPlugin } from "./plugins/rsc-reference-validation-normalizer.js";
|
|
69
|
-
import { createInstrumentationClientTransformPlugin } from "./plugins/instrumentation-client.js";
|
|
81
|
+
import { createInstrumentationClientTransformPlugin, createInstrumentationServerTransformPlugin } from "./plugins/instrumentation-client.js";
|
|
70
82
|
import { createStyledJsxPlugin } from "./plugins/styled-jsx.js";
|
|
71
83
|
import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
|
|
72
84
|
import { createMiddlewareServerOnlyPlugin } from "./plugins/middleware-server-only.js";
|
|
@@ -76,22 +88,20 @@ import { validateMiddlewareModuleExports } from "./plugins/middleware-export-val
|
|
|
76
88
|
import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
|
|
77
89
|
import { augmentSsrManifestFromBundle, relativeWithinRoot, tryRealpathSync } from "./build/ssr-manifest.js";
|
|
78
90
|
import { createDynamicPreloadMetadataPlugin } from "./plugins/dynamic-preload-metadata.js";
|
|
91
|
+
import { createOgHarfbuzzPlugin } from "./plugins/og-harfbuzz.js";
|
|
79
92
|
import { createOgAssetsPlugin, createOgInlineFetchAssetsPlugin } from "./plugins/og-assets.js";
|
|
80
93
|
import { createUseCacheCallablePlugin } from "./plugins/use-cache-callable.js";
|
|
81
|
-
import { generateRouteTypes } from "./typegen.js";
|
|
82
94
|
import { SSR_EXTERNAL_REACT_ENTRIES, VINEXT_OPTIMIZE_DEPS_EXCLUDE, mergeOptimizeDepsExclude } from "./plugins/rsc-client-shim-excludes.js";
|
|
83
95
|
import { createServerExternalsManifestPlugin } from "./plugins/server-externals-manifest.js";
|
|
84
96
|
import { createTransitiveExternalsPlugin } from "./plugins/transitive-externals.js";
|
|
85
97
|
import public_shim_map_default from "./shims/public-shim-map.json.js";
|
|
86
98
|
import { VINEXT_CLIENT_ENTRY_MANIFEST } from "./utils/client-entry-manifest.js";
|
|
87
99
|
import { computeClientRuntimeMetadata } from "./utils/client-runtime-metadata.js";
|
|
88
|
-
import {
|
|
89
|
-
import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
|
|
100
|
+
import { readPrerenderSecret, readServerRuntimeOutputDirs } from "./build/server-manifest.js";
|
|
90
101
|
import { createModuleDependencyCache } from "./build/module-dependency-cache.js";
|
|
91
|
-
import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
|
|
92
102
|
import { markCssUrlAssetReferences, restoreDedupedCssAssetReferences } from "./build/css-url-assets.js";
|
|
93
103
|
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";
|
|
104
|
+
import { createClientAssetFileNames, createClientCodeSplittingConfig, createClientFileNameConfig, createClientManualChunks, createMultiStageChunkFileNames, createMultiStageCodeSplittingConfig, createRscFrameworkChunkOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfig, withBuildBundlerOptions } from "./build/client-build-config.js";
|
|
95
105
|
import { hasExportAllCandidate, stripServerExports, validatePageExports } from "./plugins/strip-server-exports.js";
|
|
96
106
|
import { removeConsoleCalls } from "./plugins/remove-console.js";
|
|
97
107
|
import { createImportMetaUrlPlugin } from "./plugins/import-meta-url.js";
|
|
@@ -107,15 +117,15 @@ import { publicFilePathVariants } from "./utils/public-file-path.js";
|
|
|
107
117
|
import { scanPublicFileRoutes } from "./utils/public-routes.js";
|
|
108
118
|
import { createIgnoreDynamicRequestsPlugin } from "./plugins/ignore-dynamic-requests.js";
|
|
109
119
|
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
120
|
import { staticExportApp, staticExportPages } from "./build/static-export.js";
|
|
112
121
|
import { createRequire } from "node:module";
|
|
113
122
|
import fs from "node:fs";
|
|
114
|
-
import { createIdResolver, createLogger, parseAst, transformWithOxc } from "vite";
|
|
115
123
|
import { pathToFileURL } from "node:url";
|
|
124
|
+
import { createIdResolver, createLogger, isRunnableDevEnvironment, parseAst, transformWithOxc } from "vite";
|
|
125
|
+
import { execFileSync } from "node:child_process";
|
|
116
126
|
import { createHash, randomBytes } from "node:crypto";
|
|
117
|
-
import commonjs from "vite-plugin-commonjs";
|
|
118
127
|
import MagicString from "magic-string";
|
|
128
|
+
import commonjs from "vite-plugin-commonjs";
|
|
119
129
|
//#region src/index.ts
|
|
120
130
|
const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_EXCLUDE = Object.freeze(["vinext/server/fetch-handler", "vinext/server/pages-router-entry"]);
|
|
121
131
|
const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
@@ -129,6 +139,30 @@ const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
|
|
|
129
139
|
const OPTIONAL_OPTIMIZE_DEPS_WARNING_RE = /Failed to resolve dependency: .*use-sync-external-store\/with-selector.*present in .* 'optimizeDeps\.include'/;
|
|
130
140
|
const VINEXT_FILTERED_OPTIMIZE_DEPS_WARN = Symbol.for("vinext.filteredOptimizeDepsWarn");
|
|
131
141
|
const ANSI_ESCAPE_RE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
|
|
142
|
+
const RSC_ENVIRONMENTS = /* @__PURE__ */ new Set([
|
|
143
|
+
"rsc",
|
|
144
|
+
"ssr",
|
|
145
|
+
"client"
|
|
146
|
+
]);
|
|
147
|
+
function scopeRscPlugin(plugin) {
|
|
148
|
+
const applyToEnvironment = plugin.applyToEnvironment;
|
|
149
|
+
return {
|
|
150
|
+
...plugin,
|
|
151
|
+
applyToEnvironment(environment) {
|
|
152
|
+
if (!RSC_ENVIRONMENTS.has(environment.name)) return false;
|
|
153
|
+
return applyToEnvironment?.(environment) ?? true;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const earlyViteCliInvocation = getViteCliInvocation();
|
|
158
|
+
const viteCliBuildConfigNodeEnv = earlyViteCliInvocation?.command === "build" && process.env.NODE_ENV === "test" ? "test" : void 0;
|
|
159
|
+
if (earlyViteCliInvocation) {
|
|
160
|
+
if (!process.env.NODE_ENV) Reflect.set(process.env, "NODE_ENV", earlyViteCliInvocation.command === "build" ? viteCliBuildConfigNodeEnv ?? "production" : earlyViteCliInvocation.mode === "test" ? "test" : "development");
|
|
161
|
+
loadDotenv({
|
|
162
|
+
root: earlyViteCliInvocation.root,
|
|
163
|
+
mode: earlyViteCliInvocation.mode
|
|
164
|
+
});
|
|
165
|
+
}
|
|
132
166
|
installSocketErrorBackstop();
|
|
133
167
|
function hasServerOnlyMarkerImport(code) {
|
|
134
168
|
if (!code.includes("server-only")) return false;
|
|
@@ -183,6 +217,7 @@ function resolveShimModulePath(shimsDir, moduleName) {
|
|
|
183
217
|
}
|
|
184
218
|
return path.join(shimsDir, `${moduleName}.js`);
|
|
185
219
|
}
|
|
220
|
+
const PATCHED_SERVER_PACKAGES = ["@vercel/og"];
|
|
186
221
|
function isVercelOgImport(id) {
|
|
187
222
|
return id === "@vercel/og" || id === "@vercel/og.js";
|
|
188
223
|
}
|
|
@@ -312,7 +347,7 @@ function createDevPagesModuleDependencyReader(root, resolve) {
|
|
|
312
347
|
if (typeof specifier !== "string") continue;
|
|
313
348
|
const resolved = await resolve(specifier, cleanModulePath, { skipSelf: true });
|
|
314
349
|
if (!resolved?.id) continue;
|
|
315
|
-
if (isStylesheetSpecifier(specifier)) {
|
|
350
|
+
if (isStylesheetSpecifier(specifier) || isStylesheetSpecifier(resolved.id)) {
|
|
316
351
|
const asset = resolvedStylesheetToDevManifestAsset(root, resolved.id);
|
|
317
352
|
if (asset) dependencies.push({
|
|
318
353
|
type: "stylesheet",
|
|
@@ -597,8 +632,8 @@ const tsconfigAliasCustomResolver = async function(updatedId, importer, options)
|
|
|
597
632
|
* stylesheet-scoping resolver to entries that came from tsconfig `paths`.
|
|
598
633
|
* Array order preserves the map's first-match ordering.
|
|
599
634
|
*/
|
|
600
|
-
function buildResolveAliasEntries(aliasMap, tsconfigPathAliases) {
|
|
601
|
-
return Object.entries(aliasMap).map(([find, replacement]) => tsconfigPathAliases
|
|
635
|
+
function buildResolveAliasEntries(aliasMap, tsconfigPathAliases, explicitAliases) {
|
|
636
|
+
return Object.entries(aliasMap).map(([find, replacement]) => Object.hasOwn(tsconfigPathAliases, find) && !Object.hasOwn(explicitAliases, find) ? {
|
|
602
637
|
find,
|
|
603
638
|
replacement,
|
|
604
639
|
customResolver: tsconfigAliasCustomResolver
|
|
@@ -621,26 +656,49 @@ function suppressAliasCustomResolverDeprecationWarning(logger) {
|
|
|
621
656
|
return logger;
|
|
622
657
|
}
|
|
623
658
|
const VIRTUAL_WORKER_ENTRY = "virtual:vinext-worker-entry";
|
|
624
|
-
const RESOLVED_WORKER_ENTRY = "\
|
|
659
|
+
const RESOLVED_WORKER_ENTRY = "\0" + VIRTUAL_WORKER_ENTRY;
|
|
660
|
+
const VIRTUAL_REQUEST_STAGE = "virtual:vinext-request-stage";
|
|
661
|
+
const RESOLVED_REQUEST_STAGE = "\0" + VIRTUAL_REQUEST_STAGE;
|
|
662
|
+
const VIRTUAL_RESPONSE_STAGE = "virtual:vinext-response-stage";
|
|
663
|
+
const RESOLVED_RESPONSE_STAGE = "\0" + VIRTUAL_RESPONSE_STAGE;
|
|
625
664
|
const VIRTUAL_SERVER_ENTRY = "virtual:vinext-server-entry";
|
|
626
|
-
const RESOLVED_SERVER_ENTRY = "\
|
|
665
|
+
const RESOLVED_SERVER_ENTRY = "\0" + VIRTUAL_SERVER_ENTRY;
|
|
666
|
+
const VIRTUAL_PAGES_REQUEST_ENTRY = "virtual:vinext-pages-request-entry";
|
|
667
|
+
const RESOLVED_PAGES_REQUEST_ENTRY = "\0" + VIRTUAL_PAGES_REQUEST_ENTRY;
|
|
668
|
+
const VIRTUAL_PAGES_RESPONSE_ENTRY = "virtual:vinext-pages-response-entry";
|
|
669
|
+
const RESOLVED_PAGES_RESPONSE_ENTRY = "\0" + VIRTUAL_PAGES_RESPONSE_ENTRY;
|
|
627
670
|
const VIRTUAL_CLIENT_ENTRY = "virtual:vinext-client-entry";
|
|
628
|
-
const RESOLVED_CLIENT_ENTRY = "\
|
|
671
|
+
const RESOLVED_CLIENT_ENTRY = "\0" + VIRTUAL_CLIENT_ENTRY;
|
|
629
672
|
const VIRTUAL_PAGES_CLIENT_ASSETS = "virtual:vinext-pages-client-assets";
|
|
630
|
-
const RESOLVED_PAGES_CLIENT_ASSETS = "\
|
|
673
|
+
const RESOLVED_PAGES_CLIENT_ASSETS = "\0" + VIRTUAL_PAGES_CLIENT_ASSETS;
|
|
631
674
|
const VIRTUAL_RSC_ENTRY = "virtual:vinext-rsc-entry";
|
|
632
|
-
const RESOLVED_RSC_ENTRY = "\
|
|
675
|
+
const RESOLVED_RSC_ENTRY = "\0" + VIRTUAL_RSC_ENTRY;
|
|
633
676
|
const VIRTUAL_CACHEABILITY_MANIFEST = "virtual:vinext-cacheability-manifest";
|
|
634
|
-
const RESOLVED_CACHEABILITY_MANIFEST = "\
|
|
677
|
+
const RESOLVED_CACHEABILITY_MANIFEST = "\0" + VIRTUAL_CACHEABILITY_MANIFEST;
|
|
678
|
+
const VIRTUAL_CACHEABILITY_REQUEST_PROJECTION = "virtual:vinext-cacheability-request-projection";
|
|
679
|
+
const RESOLVED_CACHEABILITY_REQUEST_PROJECTION = "\0" + VIRTUAL_CACHEABILITY_REQUEST_PROJECTION;
|
|
680
|
+
const VIRTUAL_PREGENERATED_CONCRETE_PATHS = "virtual:vinext-pregenerated-concrete-paths";
|
|
681
|
+
const RESOLVED_PREGENERATED_CONCRETE_PATHS = "\0" + VIRTUAL_PREGENERATED_CONCRETE_PATHS;
|
|
682
|
+
const VIRTUAL_APP_REQUEST_ENTRY = "virtual:vinext-app-request-entry";
|
|
683
|
+
const RESOLVED_APP_REQUEST_ENTRY = "\0" + VIRTUAL_APP_REQUEST_ENTRY;
|
|
684
|
+
const VIRTUAL_APP_RESPONSE_ENTRY = "virtual:vinext-app-response-entry";
|
|
685
|
+
const RESOLVED_APP_RESPONSE_ENTRY = "\0" + VIRTUAL_APP_RESPONSE_ENTRY;
|
|
635
686
|
const VIRTUAL_APP_SSR_ENTRY = "virtual:vinext-app-ssr-entry";
|
|
636
|
-
const RESOLVED_APP_SSR_ENTRY = "\
|
|
687
|
+
const RESOLVED_APP_SSR_ENTRY = "\0" + VIRTUAL_APP_SSR_ENTRY;
|
|
637
688
|
const VIRTUAL_APP_BROWSER_ENTRY = "virtual:vinext-app-browser-entry";
|
|
638
|
-
const RESOLVED_APP_BROWSER_ENTRY = "\
|
|
689
|
+
const RESOLVED_APP_BROWSER_ENTRY = "\0" + VIRTUAL_APP_BROWSER_ENTRY;
|
|
639
690
|
const VIRTUAL_APP_CAPABILITIES = "virtual:vinext-app-capabilities";
|
|
640
|
-
const RESOLVED_APP_CAPABILITIES = "\
|
|
691
|
+
const RESOLVED_APP_CAPABILITIES = "\0" + VIRTUAL_APP_CAPABILITIES;
|
|
641
692
|
const RESOLVED_ROOT_PARAMS = "\0virtual:vinext-root-params";
|
|
693
|
+
const APP_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("app-request-stage-independent-entry");
|
|
694
|
+
const APP_RESPONSE_STAGE_ENTRY = resolveRuntimeEntryModule("app-response-stage-entry");
|
|
695
|
+
const PAGES_REQUEST_STAGE_ENTRY = resolveRuntimeEntryModule("pages-request-stage-entry");
|
|
696
|
+
const PAGES_RESPONSE_STAGE_ENTRY = resolveRuntimeEntryModule("pages-response-stage-entry");
|
|
697
|
+
const WORKER_ROUTER_ENTRIES = /* @__PURE__ */ new Set([resolveRuntimeEntryModule("app-router-entry"), resolveRuntimeEntryModule("pages-router-entry")]);
|
|
642
698
|
/** Virtual module that registers config-driven cache adapters (see VinextOptions.cache). */
|
|
643
699
|
const RESOLVED_CACHE_ADAPTERS = "\0" + VIRTUAL_CACHE_ADAPTERS;
|
|
700
|
+
/** CDN-only registrar kept out of the data-cache response graph. */
|
|
701
|
+
const RESOLVED_CDN_CACHE_ADAPTER = "\0" + VIRTUAL_CDN_CACHE_ADAPTER;
|
|
644
702
|
/** Virtual module that registers the config-driven image optimizer (see VinextOptions.images). */
|
|
645
703
|
const RESOLVED_IMAGE_ADAPTERS = "\0" + VIRTUAL_IMAGE_ADAPTERS;
|
|
646
704
|
/** Virtual module for composed instrumentation-client bootstrap. */
|
|
@@ -671,9 +729,10 @@ const _shimsDir = path.resolve(__dirname, "shims") + "/";
|
|
|
671
729
|
const _serverDir = path.resolve(__dirname, "server");
|
|
672
730
|
const _fontGoogleShimPath = resolveShimModulePath(_shimsDir, "font-google");
|
|
673
731
|
const _appBrowserServerActionClientPath = resolveShimModulePath(_serverDir, "app-browser-server-action-client");
|
|
732
|
+
const _appRscCombinedHandlerPath = resolveShimModulePath(_serverDir, "app-rsc-combined-handler");
|
|
674
733
|
const _appRscHandlerPath = resolveShimModulePath(_serverDir, "app-rsc-handler");
|
|
675
734
|
const _pagesClientAssetsPath = resolveShimModulePath(_serverDir, "pages-client-assets");
|
|
676
|
-
const _canExternalizeAppRscHandler = _appRscHandlerPath.endsWith(".js");
|
|
735
|
+
const _canExternalizeAppRscHandler = _appRscHandlerPath.endsWith(".js") && _appRscCombinedHandlerPath.endsWith(".js");
|
|
677
736
|
function isValidExportIdentifier(name) {
|
|
678
737
|
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
679
738
|
}
|
|
@@ -745,8 +804,10 @@ for (const [specifier, definition] of Object.entries(_publicNextShimMap)) {
|
|
|
745
804
|
_reactServerShims.set(`${specifier}.js`, definition.shim);
|
|
746
805
|
}
|
|
747
806
|
_reactServerShims.set("next/dist/client/components/navigation", "navigation");
|
|
748
|
-
const
|
|
749
|
-
const
|
|
807
|
+
const clientManualChunks = createClientManualChunks(_shimsDir);
|
|
808
|
+
const clientCodeSplittingConfig = createClientCodeSplittingConfig(clientManualChunks);
|
|
809
|
+
const appClientManualChunks = createClientManualChunks(_shimsDir, true);
|
|
810
|
+
const appClientCodeSplittingConfig = createClientCodeSplittingConfig(appClientManualChunks);
|
|
750
811
|
function getClientOutputConfig(assetsDir, preserveAppRouteBoundaries = false) {
|
|
751
812
|
const codeSplitting = preserveAppRouteBoundaries ? appClientCodeSplittingConfig : clientCodeSplittingConfig;
|
|
752
813
|
return {
|
|
@@ -771,7 +832,9 @@ function createServerEnvironmentFileNameResolver(config, outputRoot) {
|
|
|
771
832
|
};
|
|
772
833
|
}
|
|
773
834
|
function vinext(options = {}) {
|
|
835
|
+
const internalOptions = options;
|
|
774
836
|
const { supportsNativeTypeofWindowFolding: useNativeTypeofWindowFolding } = assertSupportedViteVersion();
|
|
837
|
+
const reservedDevCliInvocation = reserveViteCliDevInvocation();
|
|
775
838
|
const prerenderConfig = normalizeVinextPrerenderConfig(options.prerender);
|
|
776
839
|
const cacheAdapterBuildOutputs = [options.cache?.data?.output, options.cache?.cdn?.output].filter((output) => output !== void 0);
|
|
777
840
|
let root;
|
|
@@ -781,6 +844,7 @@ function vinext(options = {}) {
|
|
|
781
844
|
let hasAppDir = false;
|
|
782
845
|
let hasPagesDir = false;
|
|
783
846
|
let nextConfig;
|
|
847
|
+
let nitroBuildDir;
|
|
784
848
|
let fileMatcher;
|
|
785
849
|
let middlewarePath = null;
|
|
786
850
|
let instrumentationPath = null;
|
|
@@ -789,12 +853,23 @@ function vinext(options = {}) {
|
|
|
789
853
|
let globalNotFoundCssIsolationPath = null;
|
|
790
854
|
let clientAssetsInlineLimit = 0;
|
|
791
855
|
let hasCloudflarePlugin = false;
|
|
856
|
+
let matchedMultiStageOutput;
|
|
857
|
+
let selectedMultiStageOutput;
|
|
858
|
+
const isMultiStageServerEnvironment = (environment) => isServerEnvironment(environment) && (!hasAppDir || environment.name === "rsc");
|
|
792
859
|
let warnedInlineNextConfigOverride = false;
|
|
793
860
|
let hasNitroPlugin = false;
|
|
861
|
+
let nitroHostRuntime = "node";
|
|
794
862
|
let resolvedServerExternalPackages = [];
|
|
863
|
+
let registerNodeOpenTelemetryLoader = false;
|
|
795
864
|
let pagesTsconfigAliases = {};
|
|
796
865
|
let pagesBundledPackages = /* @__PURE__ */ new Set();
|
|
797
866
|
let isServeCommand = false;
|
|
867
|
+
let buildEmptyOutDir;
|
|
868
|
+
let buildLifecycleEnabled = false;
|
|
869
|
+
let hasPlainPagesBuildEnvironments = false;
|
|
870
|
+
let originalPlainPagesEnvironments;
|
|
871
|
+
let buildLifecycleInvocation;
|
|
872
|
+
let reactUpgradeChecked = false;
|
|
798
873
|
let pagesOptimizeEntries = [];
|
|
799
874
|
const importMetaUrlCapability = createImportMetaUrlPlugin({
|
|
800
875
|
getRoot: () => root,
|
|
@@ -804,7 +879,8 @@ function vinext(options = {}) {
|
|
|
804
879
|
}
|
|
805
880
|
});
|
|
806
881
|
const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
|
|
807
|
-
|
|
882
|
+
const resolvePagesClientAssetsOutputDir = (environmentName, outputDir) => !selectedMultiStageOutput && !hasAppDir && !hasCloudflarePlugin && environmentName === "ssr" ? path.dirname(outputDir) : outputDir;
|
|
883
|
+
let pagesClientAssetsModule = internalOptions.__pagesClientAssetsModule ?? null;
|
|
808
884
|
let devPublicFileRoutes = null;
|
|
809
885
|
let publicDirConflictOptions = null;
|
|
810
886
|
let copyPublicDirIntoStaticExportBasePath = false;
|
|
@@ -812,12 +888,14 @@ function vinext(options = {}) {
|
|
|
812
888
|
let rscCompatibilityId;
|
|
813
889
|
let draftModeSecret = getPagesPreviewModeId();
|
|
814
890
|
const prerenderSecret = process.env.__VINEXT_SHARED_PRERENDER_SECRET ?? randomBytes(32).toString("hex");
|
|
891
|
+
let revalidateSecret = process.env.__VINEXT_SHARED_REVALIDATE_SECRET;
|
|
815
892
|
let previewBuildCredentials;
|
|
816
893
|
const sassComposesLoader = createSassAwareFileSystemLoader();
|
|
817
|
-
|
|
894
|
+
const rscClassificationManifests = /* @__PURE__ */ new Map();
|
|
818
895
|
let rscActionOwnerRoutes = null;
|
|
819
896
|
let rscActionOwnerSharedRoots = [];
|
|
820
897
|
const serverEntryKindsByEnvironment = /* @__PURE__ */ new Map();
|
|
898
|
+
const serverRuntimeOutputDirs = /* @__PURE__ */ new Set();
|
|
821
899
|
function recordServerEntryLoad(environmentName, id) {
|
|
822
900
|
if (!environmentName) return;
|
|
823
901
|
let entries = serverEntryKindsByEnvironment.get(environmentName);
|
|
@@ -854,7 +932,17 @@ function vinext(options = {}) {
|
|
|
854
932
|
*/
|
|
855
933
|
async function generateServerEntry$1(configuredPublicDir) {
|
|
856
934
|
const publicFiles = isServeCommand && devPublicFileRoutes ? [...devPublicFileRoutes].sort() : scanPublicFileRoutes(root, configuredPublicDir === "" ? false : configuredPublicDir);
|
|
857
|
-
return generateServerEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, publicFiles,
|
|
935
|
+
return generateServerEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, publicFiles, {
|
|
936
|
+
nodeOpenTelemetryLoader: registerNodeOpenTelemetryLoader,
|
|
937
|
+
prerenderSecret
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
async function generatePagesRequestEntry$1(configuredPublicDir) {
|
|
941
|
+
const publicFiles = isServeCommand && devPublicFileRoutes ? [...devPublicFileRoutes].sort() : scanPublicFileRoutes(root, configuredPublicDir === "" ? false : configuredPublicDir);
|
|
942
|
+
return generatePagesRequestEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, publicFiles, prerenderSecret);
|
|
943
|
+
}
|
|
944
|
+
function generatePagesResponseEntry$1() {
|
|
945
|
+
return generatePagesResponseEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, prerenderSecret);
|
|
858
946
|
}
|
|
859
947
|
/**
|
|
860
948
|
* Generate the virtual client hydration entry module.
|
|
@@ -881,7 +969,8 @@ function vinext(options = {}) {
|
|
|
881
969
|
});
|
|
882
970
|
}
|
|
883
971
|
const autoRsc = options.rsc !== false;
|
|
884
|
-
const
|
|
972
|
+
const earlyRoot = earlyViteCliInvocation?.root ?? process.cwd();
|
|
973
|
+
const earlyBaseDir = path.resolve(earlyRoot, options.appDir ?? ".");
|
|
885
974
|
const earlyAppDirExists = !options.disableAppRouter && (fs.existsSync(path.join(earlyBaseDir, "app")) || fs.existsSync(path.join(earlyBaseDir, "src", "app")));
|
|
886
975
|
let resolvedReactPath = null;
|
|
887
976
|
let resolvedRscPath = null;
|
|
@@ -903,14 +992,12 @@ function vinext(options = {}) {
|
|
|
903
992
|
} });
|
|
904
993
|
const useCachePlugin = await createUseCacheCallablePlugin({
|
|
905
994
|
projectRoot: earlyBaseDir,
|
|
906
|
-
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href
|
|
907
|
-
getAppDir: () => appDir,
|
|
908
|
-
matchesPageExtension: (fileName) => fileMatcher.extensionRegex.test(fileName)
|
|
995
|
+
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href
|
|
909
996
|
});
|
|
910
997
|
const useServerIndex = plugins.findIndex((plugin) => plugin.name === "rsc:use-server");
|
|
911
998
|
if (useServerIndex === -1) throw new Error("vinext: Failed to locate @vitejs/plugin-rsc use-server plugin.");
|
|
912
999
|
plugins.splice(useServerIndex, 0, useCachePlugin);
|
|
913
|
-
return plugins;
|
|
1000
|
+
return plugins.map(scopeRscPlugin);
|
|
914
1001
|
}).catch((cause) => {
|
|
915
1002
|
throw new Error("vinext: Failed to load @vitejs/plugin-rsc.", { cause });
|
|
916
1003
|
});
|
|
@@ -919,8 +1006,6 @@ function vinext(options = {}) {
|
|
|
919
1006
|
manualUseCachePluginPromise = createUseCacheCallablePlugin({
|
|
920
1007
|
projectRoot: earlyBaseDir,
|
|
921
1008
|
cacheRuntime: pathToFileURL(resolveShimModulePath(shimsDir, "cache-callable-runtime")).href,
|
|
922
|
-
getAppDir: () => appDir,
|
|
923
|
-
matchesPageExtension: (fileName) => fileMatcher.extensionRegex.test(fileName),
|
|
924
1009
|
allowMissingRsc: true
|
|
925
1010
|
});
|
|
926
1011
|
}
|
|
@@ -987,9 +1072,10 @@ function vinext(options = {}) {
|
|
|
987
1072
|
}
|
|
988
1073
|
const delegate = mdxFactory(mdxOpts);
|
|
989
1074
|
mdxDelegate = delegate;
|
|
990
|
-
if (reason === "detected")
|
|
991
|
-
|
|
992
|
-
|
|
1075
|
+
if (reason === "detected") {
|
|
1076
|
+
if (nextConfig.mdx) console.log("[vinext] Auto-injected @mdx-js/rollup with remark/rehype plugins from next.config");
|
|
1077
|
+
else console.log("[vinext] Auto-injected @mdx-js/rollup for MDX support");
|
|
1078
|
+
} else console.log("[vinext] Auto-injected @mdx-js/rollup for on-demand MDX support");
|
|
993
1079
|
return delegate;
|
|
994
1080
|
} catch {
|
|
995
1081
|
if (reason === "detected" && !warnedMissingMdxPlugin) {
|
|
@@ -1036,6 +1122,10 @@ function vinext(options = {}) {
|
|
|
1036
1122
|
} });
|
|
1037
1123
|
const commonJsTransform = commonJsPlugin.transform;
|
|
1038
1124
|
if (typeof commonJsTransform === "function") commonJsPlugin.transform = function environmentAwareCommonJsTransform(code, id, ...args) {
|
|
1125
|
+
const normalizedId = toSlash(stripViteModuleQuery(id));
|
|
1126
|
+
const nitroServicePath = this.environment.name === "nitro" && nitroBuildDir && normalizedId.endsWith("/entry.js") ? path.relative(path.join(canonicalize(nitroBuildDir), "vite/services"), normalizedId) : "";
|
|
1127
|
+
if (/^[^/]+\/entry\.js$/.test(nitroServicePath)) return null;
|
|
1128
|
+
if (isPathInside(__dirname, toSlash(stripViteModuleQuery(id)))) return null;
|
|
1039
1129
|
if (this.environment.mode === "dev" && this.environment.depsOptimizer?.isOptimizedDepFile(id)) return null;
|
|
1040
1130
|
const isDev = this.environment.mode === "dev";
|
|
1041
1131
|
const isServer = this.environment.config.consumer === "server";
|
|
@@ -1052,7 +1142,59 @@ function vinext(options = {}) {
|
|
|
1052
1142
|
transformBundledCommonJsDependencies = previous;
|
|
1053
1143
|
}
|
|
1054
1144
|
};
|
|
1145
|
+
const buildLifecyclePlugins = createBuildLifecyclePlugins({
|
|
1146
|
+
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),
|
|
1147
|
+
onComplete: () => buildLifecycleInvocation?.onComplete?.(),
|
|
1148
|
+
shouldDeferPostBuild: () => buildLifecycleInvocation !== void 0,
|
|
1149
|
+
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),
|
|
1150
|
+
onPrepare: () => {
|
|
1151
|
+
if (!hasAppDir || reactUpgradeChecked) return;
|
|
1152
|
+
reactUpgradeChecked = true;
|
|
1153
|
+
const reactUpgrade = getReactUpgradeDeps(root);
|
|
1154
|
+
if (reactUpgrade.length === 0) return;
|
|
1155
|
+
const [packageManager, ...packageManagerArgs] = detectPackageManager(root).replace(/ -D$/, "").split(" ");
|
|
1156
|
+
console.log(" Upgrading React for RSC compatibility...");
|
|
1157
|
+
execFileSync(packageManager, [...packageManagerArgs, ...reactUpgrade], {
|
|
1158
|
+
cwd: root,
|
|
1159
|
+
stdio: "inherit",
|
|
1160
|
+
shell: process.platform === "win32"
|
|
1161
|
+
});
|
|
1162
|
+
},
|
|
1163
|
+
shouldBuildPlainPages: () => !hasAppDir && !hasCloudflarePlugin && !hasNitroPlugin,
|
|
1164
|
+
createContext: () => ({
|
|
1165
|
+
cacheConfig: options.cache ?? null,
|
|
1166
|
+
configNodeEnv: viteCliBuildConfigNodeEnv,
|
|
1167
|
+
createPagesOnlyPlugins: (pagesClientAssetsModule) => vinext({
|
|
1168
|
+
...options,
|
|
1169
|
+
disableAppRouter: true,
|
|
1170
|
+
precompress: false,
|
|
1171
|
+
prerender: void 0,
|
|
1172
|
+
__skipBuildLifecycle: true,
|
|
1173
|
+
__pagesClientAssetsModule: pagesClientAssetsModule
|
|
1174
|
+
}),
|
|
1175
|
+
emptyOutDir: buildEmptyOutDir,
|
|
1176
|
+
hasAppDir,
|
|
1177
|
+
hasPagesDir,
|
|
1178
|
+
nextConfig,
|
|
1179
|
+
prerenderConfig,
|
|
1180
|
+
prerenderConcurrency: prerenderConfig?.concurrency,
|
|
1181
|
+
prerenderSecret,
|
|
1182
|
+
previewBuildCredentials,
|
|
1183
|
+
revalidateSecret,
|
|
1184
|
+
root,
|
|
1185
|
+
routeRootConfig: {
|
|
1186
|
+
appDir: options.appDir,
|
|
1187
|
+
disableAppRouter: options.disableAppRouter,
|
|
1188
|
+
rscOutDir: options.rscOutDir,
|
|
1189
|
+
ssrOutDir: options.ssrOutDir
|
|
1190
|
+
},
|
|
1191
|
+
rscBuildIdentity,
|
|
1192
|
+
rscCompatibilityId,
|
|
1193
|
+
skipHybridPagesBundle: hasCloudflarePlugin
|
|
1194
|
+
})
|
|
1195
|
+
});
|
|
1055
1196
|
const plugins = [
|
|
1197
|
+
buildLifecyclePlugins[0],
|
|
1056
1198
|
createStyledJsxPlugin(earlyBaseDir),
|
|
1057
1199
|
mdxProxyPlugin,
|
|
1058
1200
|
reactPluginPromise,
|
|
@@ -1119,6 +1261,7 @@ function vinext(options = {}) {
|
|
|
1119
1261
|
}),
|
|
1120
1262
|
dataUrlCssPlugin(),
|
|
1121
1263
|
createCssModuleImportCompatibilityPlugin(),
|
|
1264
|
+
createDevServerLifecyclePlugin({}, (config) => config[VINEXT_DEV_CLI_LIFECYCLE] === true),
|
|
1122
1265
|
{
|
|
1123
1266
|
name: "vinext:config",
|
|
1124
1267
|
enforce: "pre",
|
|
@@ -1126,33 +1269,48 @@ function vinext(options = {}) {
|
|
|
1126
1269
|
[VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY]: options.nextConfig ?? null,
|
|
1127
1270
|
[VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY]: {
|
|
1128
1271
|
appDir: options.appDir,
|
|
1272
|
+
clientOutDir: options.clientOutDir,
|
|
1129
1273
|
disableAppRouter: options.disableAppRouter,
|
|
1130
1274
|
rscOutDir: options.rscOutDir,
|
|
1131
1275
|
ssrOutDir: options.ssrOutDir
|
|
1132
1276
|
},
|
|
1133
1277
|
[VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY]: options.cache ?? null,
|
|
1134
1278
|
async config(config, env) {
|
|
1279
|
+
hasPlainPagesBuildEnvironments = false;
|
|
1280
|
+
originalPlainPagesEnvironments = void 0;
|
|
1281
|
+
buildEmptyOutDir = typeof config.build?.emptyOutDir === "boolean" ? config.build.emptyOutDir : void 0;
|
|
1135
1282
|
isServeCommand = env.command === "serve";
|
|
1136
|
-
root = toSlash(config.root ??
|
|
1283
|
+
root = path.resolve(toSlash(process.cwd()), config.root ?? ".");
|
|
1284
|
+
const devCliLifecycleEnabled = env.command === "serve" && env.isPreview !== true && claimViteCliDevInvocation(root, config["__vinextDevRestart"] === true, reservedDevCliInvocation && config.configFile === false);
|
|
1285
|
+
buildLifecycleInvocation = config[VINEXT_BUILD_LIFECYCLE_CONFIG];
|
|
1286
|
+
buildLifecycleEnabled = env.command === "build" && !internalOptions.__skipBuildLifecycle && (buildLifecycleInvocation !== void 0 || claimViteCliBuildInvocation());
|
|
1137
1287
|
const userResolve = config.resolve;
|
|
1138
1288
|
let tsconfigPathAliases = {};
|
|
1139
1289
|
let sassTsconfigPathAliases = [];
|
|
1140
1290
|
const swcHelpersAlias = resolveSwcHelpersAlias(root);
|
|
1141
1291
|
const mode = env?.mode ?? "development";
|
|
1142
|
-
if (config.envDir !== false)
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1292
|
+
if (config.envDir !== false) {
|
|
1293
|
+
const envDir = config.envDir ?? root;
|
|
1294
|
+
loadDotenv({
|
|
1295
|
+
root: envDir,
|
|
1296
|
+
mode
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1146
1299
|
let resolvedNodeEnv;
|
|
1147
1300
|
if (env?.command === "build" || env?.isPreview === true) resolvedNodeEnv = "production";
|
|
1148
1301
|
else if (mode === "test") resolvedNodeEnv = "test";
|
|
1149
1302
|
else resolvedNodeEnv = "development";
|
|
1150
|
-
if (process.env.NODE_ENV !== resolvedNodeEnv) Reflect.set(process.env, "NODE_ENV", resolvedNodeEnv);
|
|
1151
|
-
if (env?.command === "build")
|
|
1303
|
+
if (!(process.env.NODE_ENV === "test" && viteCliBuildConfigNodeEnv === "test") && process.env.NODE_ENV !== resolvedNodeEnv) Reflect.set(process.env, "NODE_ENV", resolvedNodeEnv);
|
|
1304
|
+
if (env?.command === "build") {
|
|
1305
|
+
previewBuildCredentials = getPreviewBuildCredentials() ?? createPreviewBuildCredentials();
|
|
1306
|
+
if (buildLifecycleEnabled) revalidateSecret ??= randomBytes(32).toString("hex");
|
|
1307
|
+
}
|
|
1152
1308
|
draftModeSecret = previewBuildCredentials?.id ?? getPagesPreviewModeId();
|
|
1153
1309
|
let baseDir;
|
|
1154
|
-
if (options.appDir)
|
|
1155
|
-
|
|
1310
|
+
if (options.appDir) {
|
|
1311
|
+
const dir = path.isAbsolute(options.appDir) ? options.appDir : path.resolve(root, options.appDir);
|
|
1312
|
+
baseDir = toSlash(dir);
|
|
1313
|
+
} else {
|
|
1156
1314
|
const hasRootApp = fs.existsSync(path.join(root, "app"));
|
|
1157
1315
|
const hasRootPages = fs.existsSync(path.join(root, "pages"));
|
|
1158
1316
|
const hasSrcApp = fs.existsSync(path.join(root, "src", "app"));
|
|
@@ -1186,6 +1344,7 @@ function vinext(options = {}) {
|
|
|
1186
1344
|
buildId: sharedBuildId
|
|
1187
1345
|
};
|
|
1188
1346
|
}
|
|
1347
|
+
if (env?.command === "build" && earlyViteCliInvocation?.command === "build") Reflect.set(process.env, "NODE_ENV", "production");
|
|
1189
1348
|
const configuredTsconfigPath = isUnknownRecord(nextConfig.typescript) ? typeof nextConfig.typescript.tsconfigPath === "string" ? nextConfig.typescript.tsconfigPath : void 0 : void 0;
|
|
1190
1349
|
const resolvedTsconfigAliases = resolveTsconfigAliases(root, configuredTsconfigPath);
|
|
1191
1350
|
tsconfigPathAliases = resolvedTsconfigAliases.vite;
|
|
@@ -1260,7 +1419,6 @@ function vinext(options = {}) {
|
|
|
1260
1419
|
defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_LOCAL_IP"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowLocalIP ?? false));
|
|
1261
1420
|
defines["process.env.__VINEXT_IMAGE_UNOPTIMIZED"] = JSON.stringify(String(nextConfig.images?.unoptimized === true));
|
|
1262
1421
|
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
1422
|
defines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify(rscCompatibilityId);
|
|
1265
1423
|
defines["process.env.__VINEXT_RSC_BUILD_IDENTITY"] = JSON.stringify(rscBuildIdentity ?? "");
|
|
1266
1424
|
defines["process.env.__VINEXT_DEPLOYMENT_ID"] = JSON.stringify(nextConfig.deploymentId ?? "");
|
|
@@ -1318,6 +1476,9 @@ function vinext(options = {}) {
|
|
|
1318
1476
|
}
|
|
1319
1477
|
flattenPlugins(config.plugins ?? []);
|
|
1320
1478
|
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:")));
|
|
1479
|
+
const configuredMultiStageOutput = options.cache?.cdn?.output;
|
|
1480
|
+
matchedMultiStageOutput = configuredMultiStageOutput?.type === "multi-stage" && (configuredMultiStageOutput.matchesBuild?.({ plugins: pluginsFlat }) ?? true) ? configuredMultiStageOutput : void 0;
|
|
1481
|
+
selectedMultiStageOutput = isServeCommand ? void 0 : matchedMultiStageOutput;
|
|
1321
1482
|
hasNitroPlugin = pluginsFlat.some((p) => p && typeof p === "object" && "name" in p && typeof p.name === "string" && (p.name === "nitro" || p.name.startsWith("nitro:")));
|
|
1322
1483
|
let postcssOverride;
|
|
1323
1484
|
if (!config.css?.postcss || typeof config.css.postcss === "string") postcssOverride = await resolvePostcssStringPlugins(root);
|
|
@@ -1327,11 +1488,20 @@ function vinext(options = {}) {
|
|
|
1327
1488
|
const isSSR = !!config.build?.ssr;
|
|
1328
1489
|
const serverTranspilePackages = [...nextConfig?.turbopackTranspilePackages ?? [], ...nextConfig?.optimizePackageImports ?? []];
|
|
1329
1490
|
pagesBundledPackages = new Set(serverTranspilePackages);
|
|
1330
|
-
const
|
|
1491
|
+
const openTelemetryPackages = findOpenTelemetryPackages(root);
|
|
1492
|
+
registerNodeOpenTelemetryLoader = env.command === "build" && !hasCloudflarePlugin && !hasNitroPlugin && instrumentationPath !== null && openTelemetryPackages.includes("@opentelemetry/instrumentation") && !serverTranspilePackages.includes("@opentelemetry/instrumentation") && (() => {
|
|
1493
|
+
try {
|
|
1494
|
+
createRequire(path.join(root, "package.json")).resolve("@opentelemetry/instrumentation/hook.mjs");
|
|
1495
|
+
return true;
|
|
1496
|
+
} catch {
|
|
1497
|
+
return false;
|
|
1498
|
+
}
|
|
1499
|
+
})();
|
|
1500
|
+
const nextServerExternal = mergeServerExternalPackages(nextConfig?.serverExternalPackages, serverTranspilePackages, openTelemetryPackages);
|
|
1331
1501
|
resolvedServerExternalPackages = nextServerExternal;
|
|
1332
1502
|
const isMultiEnv = hasAppDir || hasCloudflarePlugin || hasNitroPlugin;
|
|
1333
1503
|
const hasBuildInput = getBuildBundlerOptions(config.build)?.input !== void 0;
|
|
1334
|
-
const shouldInjectPlainPagesEnvironments = !hasAppDir && !hasCloudflarePlugin && !isSSR && !hasBuildInput;
|
|
1504
|
+
const shouldInjectPlainPagesEnvironments = !hasAppDir && !hasCloudflarePlugin && !isSSR && !hasBuildInput && !config.build?.lib;
|
|
1335
1505
|
const hasClientBuildEnvironment = hasAppDir || hasCloudflarePlugin || hasNitroPlugin || shouldInjectPlainPagesEnvironments;
|
|
1336
1506
|
const clientAssetsDir = resolveAssetsDir(nextConfig.assetPrefix ?? "");
|
|
1337
1507
|
clientAssetsInlineLimit = config.build?.assetsInlineLimit ?? 0;
|
|
@@ -1340,8 +1510,22 @@ function vinext(options = {}) {
|
|
|
1340
1510
|
overlay: false
|
|
1341
1511
|
};
|
|
1342
1512
|
const cssModulesOverride = config.css?.modules === false || typeof config.css?.modules === "object" && "Loader" in config.css.modules ? {} : { modules: { Loader: sassComposesLoader.Loader } };
|
|
1513
|
+
const explicitViteAliases = config.resolve?.alias;
|
|
1514
|
+
const userAliasEntries = Array.isArray(explicitViteAliases) ? explicitViteAliases : Object.entries(explicitViteAliases ?? {}).map(([find, replacement]) => ({
|
|
1515
|
+
find,
|
|
1516
|
+
replacement
|
|
1517
|
+
}));
|
|
1518
|
+
if (config.resolve) {
|
|
1519
|
+
config.resolve = { ...config.resolve };
|
|
1520
|
+
delete config.resolve.alias;
|
|
1521
|
+
}
|
|
1343
1522
|
const viteConfig = {
|
|
1344
1523
|
appType: "custom",
|
|
1524
|
+
...devCliLifecycleEnabled ? { [VINEXT_DEV_CLI_LIFECYCLE]: true } : {},
|
|
1525
|
+
...!hasAppDir && hasCloudflarePlugin ? { builder: {
|
|
1526
|
+
...config.builder,
|
|
1527
|
+
sharedConfigBuild: true
|
|
1528
|
+
} } : {},
|
|
1345
1529
|
build: {
|
|
1346
1530
|
ssrEmitAssets: true,
|
|
1347
1531
|
cssTarget: [
|
|
@@ -1375,7 +1559,10 @@ function vinext(options = {}) {
|
|
|
1375
1559
|
},
|
|
1376
1560
|
hmr: devHmrConfig
|
|
1377
1561
|
},
|
|
1378
|
-
...hasCloudflarePlugin || hasNitroPlugin ? {} : config.ssr?.external === true ? { ssr: {
|
|
1562
|
+
...hasCloudflarePlugin || hasNitroPlugin ? {} : config.ssr?.external === true ? { ssr: {
|
|
1563
|
+
external: true,
|
|
1564
|
+
noExternal: [...PATCHED_SERVER_PACKAGES]
|
|
1565
|
+
} } : { ssr: {
|
|
1379
1566
|
external: [
|
|
1380
1567
|
"react",
|
|
1381
1568
|
"react-dom",
|
|
@@ -1387,13 +1574,16 @@ function vinext(options = {}) {
|
|
|
1387
1574
|
noExternal: true
|
|
1388
1575
|
} },
|
|
1389
1576
|
resolve: {
|
|
1390
|
-
alias: buildResolveAliasEntries({
|
|
1577
|
+
alias: [...userAliasEntries, ...buildResolveAliasEntries({
|
|
1391
1578
|
...swcHelpersAlias ? { "@swc/helpers/_": swcHelpersAlias } : {},
|
|
1392
1579
|
...tsconfigPathAliases,
|
|
1393
1580
|
...nextConfig.aliases,
|
|
1394
1581
|
...nextShimMap,
|
|
1395
1582
|
"vinext/server/pages-client-assets": _pagesClientAssetsPath
|
|
1396
|
-
}, tsconfigPathAliases
|
|
1583
|
+
}, tsconfigPathAliases, {
|
|
1584
|
+
...nextConfig.aliases,
|
|
1585
|
+
...nextShimMap
|
|
1586
|
+
})],
|
|
1397
1587
|
dedupe: [
|
|
1398
1588
|
"react",
|
|
1399
1589
|
"react-dom",
|
|
@@ -1468,10 +1658,60 @@ function vinext(options = {}) {
|
|
|
1468
1658
|
}
|
|
1469
1659
|
};
|
|
1470
1660
|
pagesOptimizeEntries = !hasAppDir ? [...hasPagesDir ? [toRelativeFileEntry(root, pagesDir) + "/**/*.{tsx,ts,jsx,js}"] : [], ...[instrumentationPath, instrumentationClientPath].flatMap((entry) => entry ? [toRelativeFileEntry(root, entry)] : [])] : [];
|
|
1661
|
+
if (env.command === "serve" && !hasAppDir && !hasCloudflarePlugin && !shouldInjectPlainPagesEnvironments) viteConfig.optimizeDeps.include = [.../* @__PURE__ */ new Set([...incomingInclude, "react-dom/client"])];
|
|
1471
1662
|
if (hasAppDir) {
|
|
1472
1663
|
const appEntries = [`${path.relative(root, appDir)}/**/*.{tsx,ts,jsx,js}`];
|
|
1473
1664
|
const explicitInstrumentationEntries = [instrumentationPath, instrumentationClientPath].flatMap((entry) => entry ? [toRelativeFileEntry(root, entry)] : []);
|
|
1474
1665
|
const optimizeEntries = [.../* @__PURE__ */ new Set([...appEntries, ...explicitInstrumentationEntries])];
|
|
1666
|
+
const additionalRscOptimizeIncludes = [];
|
|
1667
|
+
if (env.command === "serve" && hasCloudflarePlugin && nextConfig?.aliases["next-intl/config"] && !(config.environments?.rsc?.optimizeDeps?.noDiscovery ?? config.optimizeDeps?.noDiscovery)) {
|
|
1668
|
+
const projectRequire = createRequire(path.join(root, "package.json"));
|
|
1669
|
+
const excluded = [...incomingExclude, ...config.environments?.rsc?.optimizeDeps?.exclude ?? []];
|
|
1670
|
+
for (const id of [
|
|
1671
|
+
"@formatjs/intl-localematcher",
|
|
1672
|
+
"negotiator",
|
|
1673
|
+
"@formatjs/fast-memoize",
|
|
1674
|
+
"intl-messageformat"
|
|
1675
|
+
]) {
|
|
1676
|
+
if (excluded.includes(id)) continue;
|
|
1677
|
+
try {
|
|
1678
|
+
projectRequire.resolve(id);
|
|
1679
|
+
additionalRscOptimizeIncludes.push(id);
|
|
1680
|
+
} catch {}
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
const additionalClientOptimizeIncludes = [];
|
|
1684
|
+
let hasNextIntl = Boolean(nextConfig?.aliases["next-intl/config"]);
|
|
1685
|
+
if (env.command === "serve" && !hasNextIntl) try {
|
|
1686
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
1687
|
+
hasNextIntl = [
|
|
1688
|
+
"dependencies",
|
|
1689
|
+
"devDependencies",
|
|
1690
|
+
"optionalDependencies",
|
|
1691
|
+
"peerDependencies"
|
|
1692
|
+
].some((field) => Object.hasOwn(pkg[field] ?? {}, "next-intl"));
|
|
1693
|
+
} catch {}
|
|
1694
|
+
if (env.command === "serve" && hasNextIntl && !(config.environments?.client?.optimizeDeps?.noDiscovery ?? config.optimizeDeps?.noDiscovery)) {
|
|
1695
|
+
const excluded = [...incomingExclude, ...config.environments?.client?.optimizeDeps?.exclude ?? []];
|
|
1696
|
+
try {
|
|
1697
|
+
const projectRequire = createRequire(path.join(root, "package.json"));
|
|
1698
|
+
const packageRequire = createRequire(projectRequire.resolve("next-intl"));
|
|
1699
|
+
for (const id of [
|
|
1700
|
+
"use-intl",
|
|
1701
|
+
"use-intl/react",
|
|
1702
|
+
"use-intl/_IntlProvider",
|
|
1703
|
+
"use-intl/_useLocale"
|
|
1704
|
+
]) {
|
|
1705
|
+
const include = `next-intl > ${id}`;
|
|
1706
|
+
if (excluded.includes("use-intl") || excluded.includes(id) || excluded.includes(include)) continue;
|
|
1707
|
+
try {
|
|
1708
|
+
packageRequire.resolve(id);
|
|
1709
|
+
additionalClientOptimizeIncludes.push(include);
|
|
1710
|
+
} catch {}
|
|
1711
|
+
}
|
|
1712
|
+
if (!excluded.includes("next") && !excluded.includes("next/link")) additionalClientOptimizeIncludes.push("next/link");
|
|
1713
|
+
} catch {}
|
|
1714
|
+
}
|
|
1475
1715
|
const appClientInput = { index: VIRTUAL_APP_BROWSER_ENTRY };
|
|
1476
1716
|
if (hasPagesDir) appClientInput["vinext-client-entry"] = VIRTUAL_CLIENT_ENTRY;
|
|
1477
1717
|
viteConfig.environments = {
|
|
@@ -1481,15 +1721,19 @@ function vinext(options = {}) {
|
|
|
1481
1721
|
"satori",
|
|
1482
1722
|
"@resvg/resvg-js",
|
|
1483
1723
|
"yoga-wasm-web",
|
|
1484
|
-
...env?.command === "serve" && _canExternalizeAppRscHandler ? ["vinext/server/app-rsc-handler"] : [],
|
|
1724
|
+
...env?.command === "serve" && _canExternalizeAppRscHandler ? ["vinext/server/app-rsc-combined-handler", "vinext/server/app-rsc-handler"] : [],
|
|
1485
1725
|
...userSsrExternal
|
|
1486
1726
|
],
|
|
1487
|
-
|
|
1727
|
+
noExternal: userSsrExternal === true ? [...PATCHED_SERVER_PACKAGES] : true
|
|
1488
1728
|
} },
|
|
1489
1729
|
optimizeDeps: {
|
|
1490
1730
|
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE),
|
|
1491
1731
|
entries: optimizeEntries,
|
|
1492
|
-
include: [.../* @__PURE__ */ new Set([
|
|
1732
|
+
include: [.../* @__PURE__ */ new Set([
|
|
1733
|
+
...incomingInclude,
|
|
1734
|
+
...additionalRscOptimizeIncludes,
|
|
1735
|
+
"react-server-dom-webpack/static.edge"
|
|
1736
|
+
])],
|
|
1493
1737
|
...depOptimizeNodeEnvOptions
|
|
1494
1738
|
},
|
|
1495
1739
|
build: {
|
|
@@ -1507,7 +1751,7 @@ function vinext(options = {}) {
|
|
|
1507
1751
|
"ipaddr.js",
|
|
1508
1752
|
...externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []
|
|
1509
1753
|
],
|
|
1510
|
-
|
|
1754
|
+
noExternal: userSsrExternal === true ? [...PATCHED_SERVER_PACKAGES] : true
|
|
1511
1755
|
} },
|
|
1512
1756
|
optimizeDeps: {
|
|
1513
1757
|
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], userSsrExternal === true || externalizeSsrReactInDev ? SSR_EXTERNAL_REACT_ENTRIES : []),
|
|
@@ -1526,6 +1770,7 @@ function vinext(options = {}) {
|
|
|
1526
1770
|
entries: optimizeEntries,
|
|
1527
1771
|
include: [.../* @__PURE__ */ new Set([
|
|
1528
1772
|
...incomingInclude,
|
|
1773
|
+
...additionalClientOptimizeIncludes,
|
|
1529
1774
|
"react",
|
|
1530
1775
|
"react-dom",
|
|
1531
1776
|
"react-dom/client",
|
|
@@ -1549,6 +1794,7 @@ function vinext(options = {}) {
|
|
|
1549
1794
|
} else if (hasCloudflarePlugin) viteConfig.environments = { client: {
|
|
1550
1795
|
consumer: "client",
|
|
1551
1796
|
optimizeDeps: {
|
|
1797
|
+
include: ["react-dom/client"],
|
|
1552
1798
|
...pagesOptimizeEntries.length > 0 ? { entries: pagesOptimizeEntries } : {},
|
|
1553
1799
|
...depOptimizeNodeEnvOptions
|
|
1554
1800
|
},
|
|
@@ -1563,49 +1809,55 @@ function vinext(options = {}) {
|
|
|
1563
1809
|
})
|
|
1564
1810
|
}
|
|
1565
1811
|
} };
|
|
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
|
|
1812
|
+
else if (shouldInjectPlainPagesEnvironments) {
|
|
1813
|
+
const plainPagesEnvironments = {
|
|
1814
|
+
client: {
|
|
1815
|
+
consumer: "client",
|
|
1816
|
+
optimizeDeps: {
|
|
1817
|
+
include: ["react-dom/client"],
|
|
1818
|
+
...pagesOptimizeEntries.length > 0 ? { entries: pagesOptimizeEntries } : {},
|
|
1819
|
+
...depOptimizeNodeEnvOptions
|
|
1820
|
+
},
|
|
1821
|
+
build: {
|
|
1822
|
+
outDir: "dist/client",
|
|
1823
|
+
manifest: true,
|
|
1824
|
+
ssrManifest: true,
|
|
1825
|
+
assetsInlineLimit: clientAssetsInlineLimit,
|
|
1826
|
+
...withBuildBundlerOptions({
|
|
1827
|
+
input: { index: VIRTUAL_CLIENT_ENTRY },
|
|
1828
|
+
output: getClientOutputConfig(clientAssetsDir),
|
|
1829
|
+
treeshake: getClientTreeshakeConfig()
|
|
1830
|
+
})
|
|
1831
|
+
}
|
|
1599
1832
|
},
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1833
|
+
ssr: {
|
|
1834
|
+
resolve: {
|
|
1835
|
+
external: [
|
|
1836
|
+
"react",
|
|
1837
|
+
"react-dom",
|
|
1838
|
+
"react-dom/server",
|
|
1839
|
+
"ipaddr.js",
|
|
1840
|
+
...nextServerExternal
|
|
1841
|
+
],
|
|
1842
|
+
noExternal: true
|
|
1843
|
+
},
|
|
1844
|
+
optimizeDeps: {
|
|
1845
|
+
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], Object.keys(nextShimMap)),
|
|
1846
|
+
...depOptimizeNodeEnvOptions
|
|
1847
|
+
},
|
|
1848
|
+
build: {
|
|
1849
|
+
outDir: "dist/server",
|
|
1850
|
+
...withBuildBundlerOptions({
|
|
1851
|
+
input: { index: hasNitroPlugin ? VIRTUAL_WORKER_ENTRY : VIRTUAL_SERVER_ENTRY },
|
|
1852
|
+
output: { entryFileNames: "entry.js" }
|
|
1853
|
+
})
|
|
1854
|
+
}
|
|
1606
1855
|
}
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1856
|
+
};
|
|
1857
|
+
originalPlainPagesEnvironments = config.environments;
|
|
1858
|
+
viteConfig.environments = plainPagesEnvironments;
|
|
1859
|
+
hasPlainPagesBuildEnvironments = env.command === "build";
|
|
1860
|
+
}
|
|
1609
1861
|
if (pagesOptimizeEntries.length > 0 && !hasCloudflarePlugin) viteConfig.optimizeDeps = {
|
|
1610
1862
|
...viteConfig.optimizeDeps,
|
|
1611
1863
|
entries: pagesOptimizeEntries
|
|
@@ -1637,6 +1889,12 @@ function vinext(options = {}) {
|
|
|
1637
1889
|
return null;
|
|
1638
1890
|
},
|
|
1639
1891
|
async configResolved(config) {
|
|
1892
|
+
if (isServeCommand && !config["__vinextDevCliLifecycle"] && config.configFile && isViteCliConfigFile(config.configFile, config.inlineConfig)) {
|
|
1893
|
+
if (claimViteCliDevInvocation(config.root, false, true)) {
|
|
1894
|
+
config[VINEXT_DEV_CLI_LIFECYCLE] = true;
|
|
1895
|
+
if (!config.server.middlewareMode) applyDevServerDefaults(config.server, {});
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1640
1898
|
if (isServeCommand && hasCloudflarePlugin && hasPagesDir && !hasAppDir) suppressOptionalOptimizeDepsWarnings(config.logger);
|
|
1641
1899
|
if (config.worker?.rolldownOptions) {
|
|
1642
1900
|
const workerFileNames = `${resolveAssetsDir(nextConfig.assetPrefix ?? "")}/workers/[name]-[hash].js`;
|
|
@@ -1722,9 +1980,16 @@ function vinext(options = {}) {
|
|
|
1722
1980
|
}
|
|
1723
1981
|
},
|
|
1724
1982
|
resolveId: {
|
|
1725
|
-
filter: { id: /(?:next\/|vinext\/(?:shims\/|server\/app-rsc-handler)|virtual:vinext-|@vercel\/og(?:\.js)?$)/ },
|
|
1983
|
+
filter: { id: /(?:next\/|vinext\/(?:shims\/|server\/(?:app-rsc-(?:combined-)?handler|app-router-entry|pages-router-entry))|virtual:vinext-|@vercel\/og(?:\.js)?$)/ },
|
|
1726
1984
|
handler(id, importer) {
|
|
1727
1985
|
const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
|
|
1986
|
+
if (cleanId === "vinext/server/app-rsc-combined-handler") {
|
|
1987
|
+
if (_canExternalizeAppRscHandler && this.environment?.name === "rsc" && this.environment.config?.command === "serve") return {
|
|
1988
|
+
id: _appRscCombinedHandlerPath,
|
|
1989
|
+
external: true
|
|
1990
|
+
};
|
|
1991
|
+
return _appRscCombinedHandlerPath;
|
|
1992
|
+
}
|
|
1728
1993
|
if (cleanId === "vinext/server/app-rsc-handler") {
|
|
1729
1994
|
if (_canExternalizeAppRscHandler && this.environment?.name === "rsc" && this.environment.config?.command === "serve") return {
|
|
1730
1995
|
id: _appRscHandlerPath,
|
|
@@ -1735,11 +2000,20 @@ function vinext(options = {}) {
|
|
|
1735
2000
|
if (isVercelOgImport(cleanId) && !isVinextOgShimImporter(importer)) return resolveShimModulePath(_shimsDir, "og");
|
|
1736
2001
|
if (cleanId.startsWith("vinext/shims/")) return resolveShimModulePath(_shimsDir, stripJsExtension(stripViteModuleQuery(cleanId.slice(13))));
|
|
1737
2002
|
if (cleanId === VIRTUAL_WORKER_ENTRY) return RESOLVED_WORKER_ENTRY;
|
|
1738
|
-
if (cleanId
|
|
2003
|
+
if (selectedMultiStageOutput && (cleanId === "vinext/server/app-router-entry" || cleanId === "vinext/server/pages-router-entry")) return RESOLVED_WORKER_ENTRY;
|
|
2004
|
+
if (cleanId.endsWith("/" + VIRTUAL_WORKER_ENTRY)) return RESOLVED_WORKER_ENTRY;
|
|
2005
|
+
if (cleanId === VIRTUAL_REQUEST_STAGE) return RESOLVED_REQUEST_STAGE;
|
|
2006
|
+
if (cleanId.endsWith("/" + VIRTUAL_REQUEST_STAGE)) return RESOLVED_REQUEST_STAGE;
|
|
2007
|
+
if (cleanId === VIRTUAL_RESPONSE_STAGE) return RESOLVED_RESPONSE_STAGE;
|
|
2008
|
+
if (cleanId.endsWith("/" + VIRTUAL_RESPONSE_STAGE)) return RESOLVED_RESPONSE_STAGE;
|
|
1739
2009
|
if (cleanId === VIRTUAL_SERVER_ENTRY) return RESOLVED_SERVER_ENTRY;
|
|
2010
|
+
if (cleanId === VIRTUAL_PAGES_REQUEST_ENTRY) return RESOLVED_PAGES_REQUEST_ENTRY;
|
|
2011
|
+
if (cleanId === VIRTUAL_PAGES_RESPONSE_ENTRY) return RESOLVED_PAGES_RESPONSE_ENTRY;
|
|
1740
2012
|
if (cleanId === VIRTUAL_CLIENT_ENTRY) return RESOLVED_CLIENT_ENTRY;
|
|
1741
|
-
if (cleanId.endsWith("/
|
|
1742
|
-
if (cleanId.endsWith("/
|
|
2013
|
+
if (cleanId.endsWith("/" + VIRTUAL_SERVER_ENTRY)) return RESOLVED_SERVER_ENTRY;
|
|
2014
|
+
if (cleanId.endsWith("/" + VIRTUAL_PAGES_REQUEST_ENTRY)) return RESOLVED_PAGES_REQUEST_ENTRY;
|
|
2015
|
+
if (cleanId.endsWith("/" + VIRTUAL_PAGES_RESPONSE_ENTRY)) return RESOLVED_PAGES_RESPONSE_ENTRY;
|
|
2016
|
+
if (cleanId.endsWith("/" + VIRTUAL_CLIENT_ENTRY)) return RESOLVED_CLIENT_ENTRY;
|
|
1743
2017
|
if (cleanId === VIRTUAL_RSC_ENTRY) return RESOLVED_RSC_ENTRY;
|
|
1744
2018
|
if (cleanId === VIRTUAL_CACHEABILITY_MANIFEST) {
|
|
1745
2019
|
if ((hasAppDir ? this.environment?.name === "rsc" : this.environment !== void 0 && isServerEnvironment(this.environment)) && this.environment.config?.command === "build") return {
|
|
@@ -1748,16 +2022,35 @@ function vinext(options = {}) {
|
|
|
1748
2022
|
};
|
|
1749
2023
|
return RESOLVED_CACHEABILITY_MANIFEST;
|
|
1750
2024
|
}
|
|
2025
|
+
if (cleanId === VIRTUAL_CACHEABILITY_REQUEST_PROJECTION) {
|
|
2026
|
+
if (hasAppDir && this.environment?.name === "rsc" && this.environment.config?.command === "build") return {
|
|
2027
|
+
id: `./${CACHEABILITY_REQUEST_PROJECTION_MODULE}`,
|
|
2028
|
+
external: true
|
|
2029
|
+
};
|
|
2030
|
+
return RESOLVED_CACHEABILITY_REQUEST_PROJECTION;
|
|
2031
|
+
}
|
|
2032
|
+
if (cleanId === VIRTUAL_PREGENERATED_CONCRETE_PATHS) {
|
|
2033
|
+
if ((hasAppDir ? this.environment?.name === "rsc" : this.environment !== void 0 && isServerEnvironment(this.environment)) && this.environment.config?.command === "build") return {
|
|
2034
|
+
id: `./${PREGENERATED_CONCRETE_PATHS_MODULE}`,
|
|
2035
|
+
external: true
|
|
2036
|
+
};
|
|
2037
|
+
return RESOLVED_PREGENERATED_CONCRETE_PATHS;
|
|
2038
|
+
}
|
|
2039
|
+
if (cleanId === VIRTUAL_APP_REQUEST_ENTRY) return RESOLVED_APP_REQUEST_ENTRY;
|
|
2040
|
+
if (cleanId === VIRTUAL_APP_RESPONSE_ENTRY) return RESOLVED_APP_RESPONSE_ENTRY;
|
|
1751
2041
|
if (cleanId === VIRTUAL_APP_SSR_ENTRY) return RESOLVED_APP_SSR_ENTRY;
|
|
1752
2042
|
if (cleanId === VIRTUAL_APP_BROWSER_ENTRY) return RESOLVED_APP_BROWSER_ENTRY;
|
|
1753
2043
|
if (cleanId === VIRTUAL_APP_CAPABILITIES) return RESOLVED_APP_CAPABILITIES;
|
|
1754
2044
|
if (cleanId === "next/root-params" || cleanId === "next/root-params.js") return RESOLVED_ROOT_PARAMS;
|
|
1755
2045
|
if (cleanId === "virtual:vinext-cache-adapters" || cleanId.endsWith("/virtual:vinext-cache-adapters")) return RESOLVED_CACHE_ADAPTERS;
|
|
2046
|
+
if (cleanId === "virtual:vinext-cdn-cache-adapter" || cleanId.endsWith("/virtual:vinext-cdn-cache-adapter")) return RESOLVED_CDN_CACHE_ADAPTER;
|
|
1756
2047
|
if (cleanId === "virtual:vinext-image-adapters" || cleanId.endsWith("/virtual:vinext-image-adapters")) return RESOLVED_IMAGE_ADAPTERS;
|
|
1757
2048
|
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("/
|
|
2049
|
+
if (cleanId.endsWith("/" + VIRTUAL_RSC_ENTRY)) return RESOLVED_RSC_ENTRY;
|
|
2050
|
+
if (cleanId.endsWith("/" + VIRTUAL_APP_REQUEST_ENTRY)) return RESOLVED_APP_REQUEST_ENTRY;
|
|
2051
|
+
if (cleanId.endsWith("/" + VIRTUAL_APP_RESPONSE_ENTRY)) return RESOLVED_APP_RESPONSE_ENTRY;
|
|
2052
|
+
if (cleanId.endsWith("/" + VIRTUAL_APP_SSR_ENTRY)) return RESOLVED_APP_SSR_ENTRY;
|
|
2053
|
+
if (cleanId.endsWith("/" + VIRTUAL_APP_BROWSER_ENTRY)) return RESOLVED_APP_BROWSER_ENTRY;
|
|
1761
2054
|
if (cleanId.includes("/virtual:vinext-google-fonts?")) {
|
|
1762
2055
|
const queryIndex = cleanId.indexOf(VIRTUAL_GOOGLE_FONTS + "?");
|
|
1763
2056
|
return RESOLVED_VIRTUAL_GOOGLE_FONTS + cleanId.slice(queryIndex + VIRTUAL_GOOGLE_FONTS.length);
|
|
@@ -1772,14 +2065,41 @@ function vinext(options = {}) {
|
|
|
1772
2065
|
load: {
|
|
1773
2066
|
filter: { id: /virtual:vinext-/ },
|
|
1774
2067
|
async handler(id) {
|
|
1775
|
-
if (id === RESOLVED_WORKER_ENTRY)
|
|
2068
|
+
if (id === RESOLVED_WORKER_ENTRY) {
|
|
2069
|
+
if (selectedMultiStageOutput?.type === "multi-stage") return [
|
|
2070
|
+
`export { default } from ${JSON.stringify(selectedMultiStageOutput.entry)};`,
|
|
2071
|
+
`export * from ${JSON.stringify(selectedMultiStageOutput.entry)};`,
|
|
2072
|
+
""
|
|
2073
|
+
].join("\n");
|
|
2074
|
+
const entry = hasAppDir ? "vinext/server/app-router-entry" : "vinext/server/pages-router-entry";
|
|
2075
|
+
if (!hasAppDir && hasNitroPlugin) return [
|
|
2076
|
+
`import worker from ${JSON.stringify(entry)};`,
|
|
2077
|
+
"export default { fetch(request, env, ctx) {",
|
|
2078
|
+
` return worker.fetch(request, env, { ...ctx, hostRuntime: ${JSON.stringify(nitroHostRuntime)} });`,
|
|
2079
|
+
"} };"
|
|
2080
|
+
].join("\n");
|
|
2081
|
+
return `export { default } from ${JSON.stringify(entry)};`;
|
|
2082
|
+
}
|
|
2083
|
+
if (id === RESOLVED_REQUEST_STAGE) return `export { handleRequestStage } from ${JSON.stringify(hasAppDir ? APP_REQUEST_STAGE_ENTRY : PAGES_REQUEST_STAGE_ENTRY)};\n`;
|
|
2084
|
+
if (id === RESOLVED_RESPONSE_STAGE) return `export * from ${JSON.stringify(hasAppDir ? APP_RESPONSE_STAGE_ENTRY : PAGES_RESPONSE_STAGE_ENTRY)};\n`;
|
|
1776
2085
|
if (id === RESOLVED_SERVER_ENTRY) {
|
|
1777
2086
|
recordServerEntryLoad(this.environment?.name, id);
|
|
1778
2087
|
return await generateServerEntry$1(this.environment.config.publicDir === "" ? false : this.environment.config.publicDir);
|
|
1779
2088
|
}
|
|
2089
|
+
if (id === RESOLVED_PAGES_REQUEST_ENTRY) {
|
|
2090
|
+
recordServerEntryLoad(this.environment?.name, id);
|
|
2091
|
+
return await generatePagesRequestEntry$1(this.environment.config.publicDir === "" ? false : this.environment.config.publicDir);
|
|
2092
|
+
}
|
|
2093
|
+
if (id === RESOLVED_PAGES_RESPONSE_ENTRY) {
|
|
2094
|
+
recordServerEntryLoad(this.environment?.name, id);
|
|
2095
|
+
return await generatePagesResponseEntry$1();
|
|
2096
|
+
}
|
|
1780
2097
|
if (id === RESOLVED_CLIENT_ENTRY) return await generateClientEntry$1();
|
|
1781
2098
|
if (id === RESOLVED_PAGES_CLIENT_ASSETS) {
|
|
1782
|
-
const metadata = {
|
|
2099
|
+
const metadata = {
|
|
2100
|
+
clientEntry: DEV_PAGES_CLIENT_ENTRY,
|
|
2101
|
+
crossOrigin: nextConfig?.crossOrigin ?? ""
|
|
2102
|
+
};
|
|
1783
2103
|
const ssrManifest = {};
|
|
1784
2104
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
1785
2105
|
const pagesRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
@@ -1792,18 +2112,21 @@ function vinext(options = {}) {
|
|
|
1792
2112
|
if (Object.keys(ssrManifest).length > 0) metadata.ssrManifest = ssrManifest;
|
|
1793
2113
|
return `export default ${JSON.stringify(metadata)};`;
|
|
1794
2114
|
}
|
|
1795
|
-
if (id === RESOLVED_CACHEABILITY_MANIFEST) return "export default null;";
|
|
1796
|
-
if (id ===
|
|
2115
|
+
if (id === RESOLVED_CACHEABILITY_MANIFEST || id === RESOLVED_CACHEABILITY_REQUEST_PROJECTION) return "export default null;";
|
|
2116
|
+
if (id === RESOLVED_PREGENERATED_CONCRETE_PATHS) return "export {};";
|
|
2117
|
+
if ((id === RESOLVED_RSC_ENTRY || id === RESOLVED_APP_REQUEST_ENTRY || id === RESOLVED_APP_RESPONSE_ENTRY) && hasAppDir) {
|
|
1797
2118
|
recordServerEntryLoad(this.environment?.name, id);
|
|
1798
2119
|
const routes = await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher);
|
|
1799
2120
|
const metaRoutes = scanMetadataFiles(appDir);
|
|
1800
2121
|
const hasServerActions = await resolveHasServerActions(this.environment.config);
|
|
1801
2122
|
const globalErrorPath = findFileWithExts(appDir, "global-error", fileMatcher);
|
|
1802
2123
|
const globalNotFoundPath = nextConfig?.globalNotFound ? findFileWithExts(appDir, "global-not-found", fileMatcher) : null;
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
2124
|
+
if (id !== RESOLVED_APP_REQUEST_ENTRY) {
|
|
2125
|
+
rscClassificationManifests.set(id, collectRouteClassificationManifest(routes));
|
|
2126
|
+
rscActionOwnerRoutes = this.environment.config.command === "build" && hasServerActions ? routes : null;
|
|
2127
|
+
rscActionOwnerSharedRoots = [globalErrorPath, globalNotFoundPath].filter((path) => path !== null);
|
|
2128
|
+
}
|
|
2129
|
+
return (id === RESOLVED_APP_REQUEST_ENTRY ? generateAppRequestRscEntry : id === RESOLVED_APP_RESPONSE_ENTRY ? generateAppResponseRscEntry : generateRscEntry)(appDir, routes, middlewarePath, metaRoutes, globalErrorPath, nextConfig?.basePath, nextConfig?.trailingSlash, {
|
|
1807
2130
|
redirects: nextConfig?.redirects,
|
|
1808
2131
|
rewrites: nextConfig?.rewrites,
|
|
1809
2132
|
headers: nextConfig?.headers,
|
|
@@ -1813,7 +2136,9 @@ function vinext(options = {}) {
|
|
|
1813
2136
|
bodySizeLimitLabel: nextConfig?.serverActionsBodySizeLimitLabel,
|
|
1814
2137
|
htmlLimitedBots: nextConfig?.htmlLimitedBots,
|
|
1815
2138
|
clientTraceMetadata: nextConfig?.clientTraceMetadata,
|
|
2139
|
+
nodeOpenTelemetryLoader: registerNodeOpenTelemetryLoader,
|
|
1816
2140
|
assetPrefix: nextConfig?.assetPrefix,
|
|
2141
|
+
crossOrigin: nextConfig?.crossOrigin,
|
|
1817
2142
|
expireTime: nextConfig?.expireTime,
|
|
1818
2143
|
reactMaxHeadersLength: nextConfig?.reactMaxHeadersLength,
|
|
1819
2144
|
cacheMaxMemorySize: nextConfig?.cacheMaxMemorySize,
|
|
@@ -1842,6 +2167,7 @@ function vinext(options = {}) {
|
|
|
1842
2167
|
}
|
|
1843
2168
|
if (id === RESOLVED_ROOT_PARAMS) return generateRootParamsModule((hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : []).flatMap((route) => route.rootParamNames ?? []));
|
|
1844
2169
|
if (id === RESOLVED_CACHE_ADAPTERS) return generateCacheAdaptersModule(options.cache);
|
|
2170
|
+
if (id === RESOLVED_CDN_CACHE_ADAPTER) return generateCdnCacheAdapterModule(options.cache);
|
|
1845
2171
|
if (id === RESOLVED_IMAGE_ADAPTERS) return generateImageAdaptersModule(options.images);
|
|
1846
2172
|
if (id === RESOLVED_APP_SSR_ENTRY && hasAppDir) {
|
|
1847
2173
|
recordServerEntryLoad(this.environment?.name, id);
|
|
@@ -1876,9 +2202,12 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1876
2202
|
order: "pre",
|
|
1877
2203
|
handler(code, chunk) {
|
|
1878
2204
|
if (this.environment?.name !== "rsc") return null;
|
|
1879
|
-
if (!rscClassificationManifest) return null;
|
|
1880
2205
|
const hasClassificationStub = code.includes("__VINEXT_CLASS");
|
|
1881
2206
|
if (!hasClassificationStub) return null;
|
|
2207
|
+
const rscEntryId = [RESOLVED_RSC_ENTRY, RESOLVED_APP_RESPONSE_ENTRY].find((id) => chunk.moduleIds.includes(id));
|
|
2208
|
+
if (!rscEntryId) return null;
|
|
2209
|
+
const rscClassificationManifest = rscClassificationManifests.get(rscEntryId);
|
|
2210
|
+
if (!rscClassificationManifest) return null;
|
|
1882
2211
|
const enableClassificationDebug = Boolean(process.env.VINEXT_DEBUG_CLASSIFICATION);
|
|
1883
2212
|
const patchPlan = hasClassificationStub && rscClassificationManifest ? planRouteClassificationInjection({
|
|
1884
2213
|
canonicalizeLayoutPath: canonicalize,
|
|
@@ -1900,7 +2229,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1900
2229
|
}) : { kind: "skip" };
|
|
1901
2230
|
const nextCode = patchPlan.kind === "skip" ? code : patchPlan.code;
|
|
1902
2231
|
if (patchPlan.kind === "skip") return null;
|
|
1903
|
-
|
|
2232
|
+
rscClassificationManifests.delete(rscEntryId);
|
|
1904
2233
|
return {
|
|
1905
2234
|
code: nextCode,
|
|
1906
2235
|
map: null
|
|
@@ -1908,6 +2237,21 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1908
2237
|
}
|
|
1909
2238
|
}
|
|
1910
2239
|
},
|
|
2240
|
+
{
|
|
2241
|
+
name: "vinext:cloudflare-framework-tracing",
|
|
2242
|
+
transform: {
|
|
2243
|
+
filter: { id: /(?:app|pages)-router-entry\.[cm]?[jt]s(?:\?|$)/ },
|
|
2244
|
+
handler(code, id) {
|
|
2245
|
+
if (!hasCloudflarePlugin) return null;
|
|
2246
|
+
const cleanId = toSlash(stripViteModuleQuery(id));
|
|
2247
|
+
if (!WORKER_ROUTER_ENTRIES.has(cleanId)) return null;
|
|
2248
|
+
return {
|
|
2249
|
+
code: `import "vinext/internal/server/cloudflare-workers-tracing";\n${code}`,
|
|
2250
|
+
map: null
|
|
2251
|
+
};
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
},
|
|
1911
2255
|
{
|
|
1912
2256
|
name: "vinext:pages-client-assets-resolver",
|
|
1913
2257
|
sharedDuringBuild: true,
|
|
@@ -1915,11 +2259,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1915
2259
|
filter: { id: /virtual:vinext-pages-client-assets$/ },
|
|
1916
2260
|
handler(id) {
|
|
1917
2261
|
const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
|
|
1918
|
-
if (cleanId !== VIRTUAL_PAGES_CLIENT_ASSETS && !cleanId.endsWith("/
|
|
2262
|
+
if (cleanId !== VIRTUAL_PAGES_CLIENT_ASSETS && !cleanId.endsWith("/" + VIRTUAL_PAGES_CLIENT_ASSETS)) return;
|
|
1919
2263
|
if (this.environment?.config.command !== "build") return RESOLVED_PAGES_CLIENT_ASSETS;
|
|
1920
2264
|
const buildRoot = this.environment.config.root ?? process.cwd();
|
|
1921
2265
|
const environmentOutDir = path.resolve(buildRoot, this.environment.config.build.outDir);
|
|
1922
|
-
const sidecarDir =
|
|
2266
|
+
const sidecarDir = resolvePagesClientAssetsOutputDir(this.environment.name, environmentOutDir);
|
|
1923
2267
|
let externalId = path.relative(environmentOutDir, path.join(sidecarDir, PAGES_CLIENT_ASSETS_MODULE));
|
|
1924
2268
|
if (!externalId.startsWith(".")) externalId = `./${externalId}`;
|
|
1925
2269
|
pagesClientAssetsOutputDirs.add(sidecarDir);
|
|
@@ -1928,6 +2272,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1928
2272
|
external: true
|
|
1929
2273
|
};
|
|
1930
2274
|
}
|
|
2275
|
+
},
|
|
2276
|
+
outputOptions(output) {
|
|
2277
|
+
const environment = this.environment;
|
|
2278
|
+
if (!selectedMultiStageOutput || !environment || !isMultiStageServerEnvironment(environment)) return;
|
|
2279
|
+
const buildRoot = environment.config.root ?? process.cwd();
|
|
2280
|
+
const outputDir = path.resolve(buildRoot, output.dir ?? environment.config.build.outDir);
|
|
2281
|
+
pagesClientAssetsOutputDirs.add(resolvePagesClientAssetsOutputDir(environment.name, outputDir));
|
|
1931
2282
|
}
|
|
1932
2283
|
},
|
|
1933
2284
|
{
|
|
@@ -1949,6 +2300,49 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1949
2300
|
}
|
|
1950
2301
|
}
|
|
1951
2302
|
},
|
|
2303
|
+
{
|
|
2304
|
+
name: "vinext:multi-stage-host-entry",
|
|
2305
|
+
transform: {
|
|
2306
|
+
filter: { id: /virtual:|\.[cm]?[jt]sx?(?:\?|$)/ },
|
|
2307
|
+
handler(code, id) {
|
|
2308
|
+
const environment = this.environment;
|
|
2309
|
+
if (!isServeCommand && (!environment || !isMultiStageServerEnvironment(environment))) return null;
|
|
2310
|
+
const transformed = matchedMultiStageOutput?.transformHostEntry?.({
|
|
2311
|
+
code,
|
|
2312
|
+
id
|
|
2313
|
+
});
|
|
2314
|
+
return transformed == null ? null : {
|
|
2315
|
+
code: transformed,
|
|
2316
|
+
map: null
|
|
2317
|
+
};
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
},
|
|
2321
|
+
{
|
|
2322
|
+
name: "vinext:multi-stage-server-output",
|
|
2323
|
+
apply: "build",
|
|
2324
|
+
buildStart() {
|
|
2325
|
+
const entries = selectedMultiStageOutput?.entries;
|
|
2326
|
+
const environment = this.environment;
|
|
2327
|
+
if (!entries || !environment || !isMultiStageServerEnvironment(environment)) return;
|
|
2328
|
+
for (const [name, id] of [["vinext-request-stage", entries.request], ["vinext-response-stage", entries.response]]) this.emitFile({
|
|
2329
|
+
id,
|
|
2330
|
+
name,
|
|
2331
|
+
preserveSignature: "strict",
|
|
2332
|
+
type: "chunk"
|
|
2333
|
+
});
|
|
2334
|
+
},
|
|
2335
|
+
outputOptions(output) {
|
|
2336
|
+
const environment = this.environment;
|
|
2337
|
+
if (!selectedMultiStageOutput || !environment || !isMultiStageServerEnvironment(environment)) return;
|
|
2338
|
+
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.`);
|
|
2339
|
+
return {
|
|
2340
|
+
...output,
|
|
2341
|
+
chunkFileNames: createMultiStageChunkFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? ""), output.chunkFileNames),
|
|
2342
|
+
codeSplitting: createMultiStageCodeSplittingConfig(output.codeSplitting)
|
|
2343
|
+
};
|
|
2344
|
+
}
|
|
2345
|
+
},
|
|
1952
2346
|
{
|
|
1953
2347
|
name: "vinext:css-url-assets-defaults",
|
|
1954
2348
|
apply: "build",
|
|
@@ -1957,7 +2351,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1957
2351
|
if (!hasAppDir || name !== "rsc" && name !== "ssr") return null;
|
|
1958
2352
|
const output = getBuildBundlerOptions(config.build)?.output;
|
|
1959
2353
|
if (Array.isArray(output) || output?.assetFileNames !== void 0) return null;
|
|
1960
|
-
|
|
2354
|
+
const assetFileNames = createClientAssetFileNames(resolveAssetsDir(nextConfig.assetPrefix ?? ""));
|
|
2355
|
+
return { build: { ...withBuildBundlerOptions({ output: { assetFileNames } }) } };
|
|
1961
2356
|
}
|
|
1962
2357
|
},
|
|
1963
2358
|
{
|
|
@@ -1990,6 +2385,18 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1990
2385
|
fileName: CACHEABILITY_MANIFEST_MODULE,
|
|
1991
2386
|
source: "export default null;\n"
|
|
1992
2387
|
});
|
|
2388
|
+
if (hasAppDir) {
|
|
2389
|
+
this.emitFile({
|
|
2390
|
+
type: "asset",
|
|
2391
|
+
fileName: CACHEABILITY_REQUEST_PROJECTION_MODULE,
|
|
2392
|
+
source: "export default null;\n"
|
|
2393
|
+
});
|
|
2394
|
+
this.emitFile({
|
|
2395
|
+
type: "asset",
|
|
2396
|
+
fileName: PREGENERATED_CONCRETE_PATHS_MODULE,
|
|
2397
|
+
source: "delete globalThis.__VINEXT_PREGENERATED_CONCRETE_PATHS;\n"
|
|
2398
|
+
});
|
|
2399
|
+
}
|
|
1993
2400
|
}
|
|
1994
2401
|
},
|
|
1995
2402
|
{
|
|
@@ -2026,7 +2433,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2026
2433
|
}
|
|
2027
2434
|
},
|
|
2028
2435
|
asyncHooksStubPlugin,
|
|
2029
|
-
createInstrumentationClientTransformPlugin(() => instrumentationClientPath),
|
|
2436
|
+
createInstrumentationClientTransformPlugin(() => instrumentationClientPath, () => nextConfig.instrumentationClientRouteManifest),
|
|
2437
|
+
createInstrumentationServerTransformPlugin(() => instrumentationPath, () => nextConfig.instrumentationServerValueInjections),
|
|
2030
2438
|
{
|
|
2031
2439
|
name: "vinext:instrumentation-client-inject",
|
|
2032
2440
|
enforce: "pre",
|
|
@@ -2148,8 +2556,23 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2148
2556
|
return `http://localhost:${typeof address === "object" && address ? address.port : server.config.server.port ?? 3e3}`;
|
|
2149
2557
|
};
|
|
2150
2558
|
let cachedSSRHandler = null;
|
|
2559
|
+
const devPageRouteDataKinds = /* @__PURE__ */ new Map();
|
|
2560
|
+
function classifyDevPageFile(filePath) {
|
|
2561
|
+
const cached = devPageRouteDataKinds.get(filePath);
|
|
2562
|
+
if (cached) return cached;
|
|
2563
|
+
let dataKind = "none";
|
|
2564
|
+
try {
|
|
2565
|
+
const source = fs.readFileSync(filePath, "utf8");
|
|
2566
|
+
dataKind = hasExportedName(source, "getStaticProps") ? "static" : hasExportedName(source, "getServerSideProps") ? "server" : "none";
|
|
2567
|
+
} catch {}
|
|
2568
|
+
devPageRouteDataKinds.set(filePath, dataKind);
|
|
2569
|
+
return dataKind;
|
|
2570
|
+
}
|
|
2151
2571
|
function getPagesRunner() {
|
|
2152
|
-
if (!pagesRunner)
|
|
2572
|
+
if (!pagesRunner) {
|
|
2573
|
+
const env = server.environments["ssr"] ?? Object.values(server.environments).find((e) => e !== server.environments["rsc"]) ?? Object.values(server.environments)[0];
|
|
2574
|
+
pagesRunner = createDirectRunner(env);
|
|
2575
|
+
}
|
|
2153
2576
|
return pagesRunner;
|
|
2154
2577
|
}
|
|
2155
2578
|
/**
|
|
@@ -2198,6 +2621,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2198
2621
|
}
|
|
2199
2622
|
pagesRunner?.clearCache();
|
|
2200
2623
|
}
|
|
2624
|
+
function invalidatePagesHydrationProxies() {
|
|
2625
|
+
const graph = server.environments.client?.moduleGraph;
|
|
2626
|
+
if (!graph) return;
|
|
2627
|
+
for (const mod of graph.idToModuleMap.values()) if (mod.id?.includes("?html-proxy&index=")) graph.invalidateModule(mod);
|
|
2628
|
+
}
|
|
2201
2629
|
function invalidateAppRoutingModules() {
|
|
2202
2630
|
invalidateAppRouteCache();
|
|
2203
2631
|
invalidateMetadataFileCache();
|
|
@@ -2309,13 +2737,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2309
2737
|
if (hasAppDir) invalidateRscEntryModule();
|
|
2310
2738
|
if (hasCloudflarePlugin && hasPagesDir && !hasAppDir) invalidatePagesServerEntry();
|
|
2311
2739
|
};
|
|
2740
|
+
function invalidatePagesMiddlewareMatcher(filePath) {
|
|
2741
|
+
if (!hasPagesDir || !middlewarePath || toSlash(filePath) !== middlewarePath) return;
|
|
2742
|
+
cachedSSRHandler = null;
|
|
2743
|
+
server.ws.send({ type: "full-reload" });
|
|
2744
|
+
}
|
|
2312
2745
|
server.watcher.on("add", (filePath) => {
|
|
2746
|
+
invalidatePagesMiddlewareMatcher(filePath);
|
|
2313
2747
|
updatePublicFileRoute(filePath, true);
|
|
2314
2748
|
let routeChanged = false;
|
|
2315
2749
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
2316
2750
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
2317
2751
|
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2318
2752
|
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2753
|
+
devPageRouteDataKinds.delete(toSlash(filePath));
|
|
2319
2754
|
invalidateRouteCache(pagesDir);
|
|
2320
2755
|
routeChanged = true;
|
|
2321
2756
|
}
|
|
@@ -2326,23 +2761,37 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2326
2761
|
}
|
|
2327
2762
|
if (routeChanged) {
|
|
2328
2763
|
invalidatePagesServerEntry();
|
|
2764
|
+
if (hasPagesDir) invalidatePagesHydrationProxies();
|
|
2329
2765
|
if (!hasAppDir) server.ws.send({ type: "full-reload" });
|
|
2330
2766
|
invalidateHybridClientEntries();
|
|
2331
2767
|
revalidateHybridRoutes();
|
|
2332
2768
|
}
|
|
2333
2769
|
});
|
|
2334
2770
|
server.watcher.on("change", (filePath) => {
|
|
2771
|
+
invalidatePagesMiddlewareMatcher(filePath);
|
|
2772
|
+
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2773
|
+
const pageFile = toSlash(filePath);
|
|
2774
|
+
const previousKind = devPageRouteDataKinds.get(pageFile);
|
|
2775
|
+
devPageRouteDataKinds.delete(pageFile);
|
|
2776
|
+
if (previousKind !== void 0 && previousKind !== classifyDevPageFile(pageFile)) {
|
|
2777
|
+
cachedSSRHandler = null;
|
|
2778
|
+
invalidatePagesHydrationProxies();
|
|
2779
|
+
server.ws.send({ type: "full-reload" });
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2335
2782
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
2336
2783
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
2337
2784
|
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2338
2785
|
});
|
|
2339
2786
|
server.watcher.on("unlink", (filePath) => {
|
|
2787
|
+
invalidatePagesMiddlewareMatcher(filePath);
|
|
2340
2788
|
updatePublicFileRoute(filePath, false);
|
|
2341
2789
|
let routeChanged = false;
|
|
2342
2790
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
2343
2791
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
2344
2792
|
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2345
2793
|
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2794
|
+
devPageRouteDataKinds.delete(toSlash(filePath));
|
|
2346
2795
|
invalidateRouteCache(pagesDir);
|
|
2347
2796
|
routeChanged = true;
|
|
2348
2797
|
}
|
|
@@ -2353,6 +2802,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2353
2802
|
}
|
|
2354
2803
|
if (routeChanged) {
|
|
2355
2804
|
invalidatePagesServerEntry();
|
|
2805
|
+
if (hasPagesDir) invalidatePagesHydrationProxies();
|
|
2356
2806
|
if (!hasAppDir) server.ws.send({ type: "full-reload" });
|
|
2357
2807
|
invalidateHybridClientEntries();
|
|
2358
2808
|
revalidateHybridRoutes();
|
|
@@ -2393,7 +2843,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2393
2843
|
});
|
|
2394
2844
|
server.middlewares.use((req, res, next) => {
|
|
2395
2845
|
if (!hasPagesDir || !handlePagesMiddleware || !isUnsupportedDevPublicRequest(req)) return next();
|
|
2396
|
-
handlePagesMiddleware(req, res, next);
|
|
2846
|
+
handlePagesMiddleware(req, res, next).catch(next);
|
|
2397
2847
|
});
|
|
2398
2848
|
installDevStackSourcemapMiddleware(server);
|
|
2399
2849
|
return () => {
|
|
@@ -2453,9 +2903,15 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2453
2903
|
restore();
|
|
2454
2904
|
return false;
|
|
2455
2905
|
};
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2906
|
+
const pagesInstrumentationReady = (async () => {
|
|
2907
|
+
if (!instrumentationPath || hasAppDir && hasCloudflarePlugin) return;
|
|
2908
|
+
if (hasAppDir) {
|
|
2909
|
+
const environment = server.environments["rsc"];
|
|
2910
|
+
if (!isRunnableDevEnvironment(environment)) return;
|
|
2911
|
+
return runInstrumentation(environment.runner, instrumentationPath);
|
|
2912
|
+
} else return runInstrumentation(getPagesRunner(), instrumentationPath);
|
|
2913
|
+
})();
|
|
2914
|
+
pagesInstrumentationReady.catch(() => {});
|
|
2459
2915
|
if (hasAppDir) server.middlewares.use((req, res, next) => {
|
|
2460
2916
|
const url = req.url ?? "/";
|
|
2461
2917
|
const [pathname] = url.split("?");
|
|
@@ -2506,13 +2962,10 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2506
2962
|
});
|
|
2507
2963
|
next();
|
|
2508
2964
|
});
|
|
2509
|
-
|
|
2965
|
+
const handlePagesRequest = async (req, res, next) => {
|
|
2510
2966
|
try {
|
|
2511
2967
|
let url = req.url ?? "/";
|
|
2512
2968
|
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
2969
|
const blockReason = validateDevRequest({
|
|
2517
2970
|
origin: req.headers.origin,
|
|
2518
2971
|
host: req.headers.host,
|
|
@@ -2706,19 +3159,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2706
3159
|
const getDevApiRoutes = () => devApiRoutesPromise ??= apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
2707
3160
|
let devAppRoutesPromise = null;
|
|
2708
3161
|
const getDevAppRoutes = () => devAppRoutesPromise ??= hasAppDir && appDir ? appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : Promise.resolve([]);
|
|
2709
|
-
const
|
|
2710
|
-
const
|
|
2711
|
-
const cached = devPageRouteDataKinds.get(route.filePath);
|
|
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, {
|
|
3162
|
+
const classifyDevPageRoute = (route) => classifyDevPageFile(route.filePath);
|
|
3163
|
+
const pipelineDeps = {
|
|
2722
3164
|
basePath: bp,
|
|
2723
3165
|
trailingSlash: nextConfig?.trailingSlash ?? false,
|
|
2724
3166
|
i18nConfig: nextConfig?.i18n ?? null,
|
|
@@ -2738,12 +3180,15 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2738
3180
|
configMatchPathname,
|
|
2739
3181
|
runMiddleware: devRunMiddlewareAdapter,
|
|
2740
3182
|
matchApiRoute: async (apiUrl) => {
|
|
2741
|
-
const
|
|
3183
|
+
const devApiRoutes = await getDevApiRoutes();
|
|
3184
|
+
const pagesMatch = matchRoute(apiUrl, devApiRoutes);
|
|
2742
3185
|
if (pagesMatch) return pagesMatch;
|
|
2743
|
-
|
|
3186
|
+
const devAppRoutes = await getDevAppRoutes();
|
|
3187
|
+
return matchAppRoute(apiUrl, devAppRoutes);
|
|
2744
3188
|
},
|
|
2745
3189
|
matchPageRoute: (resolvedPathname, request) => {
|
|
2746
|
-
const
|
|
3190
|
+
const routeUrl = nextConfig?.i18n ? resolvePagesI18nRequest(resolvedPathname, nextConfig.i18n, request.headers, getUrlHostname(request.url), bp, nextConfig.trailingSlash ?? false).url : resolvedPathname;
|
|
3191
|
+
const m = matchRoute(routeUrl, devPageRoutes);
|
|
2747
3192
|
return m ? { route: {
|
|
2748
3193
|
dataKind: classifyDevPageRoute(m.route),
|
|
2749
3194
|
isDynamic: m.route.isDynamic,
|
|
@@ -2762,11 +3207,14 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2762
3207
|
externalInit.body = Readable.toWeb(req);
|
|
2763
3208
|
externalInit.duplex = "half";
|
|
2764
3209
|
}
|
|
2765
|
-
|
|
3210
|
+
const reqWithBody = new Request(new URL(url, requestOrigin), externalInit);
|
|
3211
|
+
return proxyExternalRequest(reqWithBody, externalUrl);
|
|
2766
3212
|
},
|
|
2767
3213
|
serveFilesystemRoute: async (requestPathname, stagedHeaders, phase, resolvedUrl) => {
|
|
2768
3214
|
if (isImageOptimizationPath(requestPathname)) {
|
|
2769
|
-
const
|
|
3215
|
+
const imageRequestUrl = new URL(resolvedUrl, requestOrigin);
|
|
3216
|
+
const allowedWidths = [...nextConfig.images?.deviceSizes ?? DEFAULT_DEVICE_SIZES, ...nextConfig.images?.imageSizes ?? DEFAULT_IMAGE_SIZES];
|
|
3217
|
+
const encodedLocation = resolveDevImageRedirect(imageRequestUrl, allowedWidths, nextConfig.images?.qualities);
|
|
2770
3218
|
return encodedLocation ? new Response(null, {
|
|
2771
3219
|
status: 302,
|
|
2772
3220
|
headers: { Location: encodedLocation }
|
|
@@ -2777,7 +3225,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2777
3225
|
if (!isRetrievalMethod) return isExistingDevPublicFile(requestPathname) ? methodNotAllowedResponse("GET, HEAD") : false;
|
|
2778
3226
|
return serveRewrittenViteFilesystemRoute(req, res, requestPathname, stagedHeaders);
|
|
2779
3227
|
}
|
|
2780
|
-
}
|
|
3228
|
+
};
|
|
3229
|
+
const pipelineResult = await runPagesRequest(webRequest, pipelineDeps);
|
|
2781
3230
|
if (pipelineResult.type === "response") {
|
|
2782
3231
|
await writeWebResponseToNodeRes(res, pipelineResult.response);
|
|
2783
3232
|
return;
|
|
@@ -2841,12 +3290,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2841
3290
|
const renderMatch = matchRoute(resolvedPathname, routes);
|
|
2842
3291
|
if (hasAppDir && appDir) {
|
|
2843
3292
|
if (!renderMatch) return next();
|
|
2844
|
-
const
|
|
3293
|
+
const appRoutes = await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher);
|
|
3294
|
+
const appMatch = matchAppRoute(resolvedPathname, appRoutes);
|
|
2845
3295
|
if (appMatch && !pagesRouteHasPriorityOverAppRoute(renderMatch.route, appMatch.route)) return next();
|
|
2846
3296
|
}
|
|
2847
3297
|
if (!cachedSSRHandler || cachedSSRHandler.routes !== routes) cachedSSRHandler = {
|
|
2848
3298
|
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)
|
|
3299
|
+
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
3300
|
};
|
|
2851
3301
|
flushStagedHeaders();
|
|
2852
3302
|
flushRequestHeaders();
|
|
@@ -2855,11 +3305,54 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2855
3305
|
await cachedSSRHandler.handler(req, res, pipelineResult.resolvedUrl, req.__vinextMiddlewareStatus, pipelineResult.isDataReq, originalRequestUrl);
|
|
2856
3306
|
}
|
|
2857
3307
|
} catch (e) {
|
|
2858
|
-
next(e);
|
|
3308
|
+
return next(e);
|
|
3309
|
+
}
|
|
3310
|
+
};
|
|
3311
|
+
handlePagesMiddleware = async (req, res, next) => {
|
|
3312
|
+
const url = req.url ?? "/";
|
|
3313
|
+
if (!hasPagesDir) return next();
|
|
3314
|
+
if (url.startsWith("/@") || url.startsWith("/__vite") || url.startsWith("/node_modules")) return next();
|
|
3315
|
+
if (url.split("?")[0].endsWith(".rsc")) return next();
|
|
3316
|
+
if (hasCloudflarePlugin) return next();
|
|
3317
|
+
await pagesInstrumentationReady;
|
|
3318
|
+
const traceHeaders = new Headers();
|
|
3319
|
+
for (const [name, value] of Object.entries(req.headers)) {
|
|
3320
|
+
if (value === void 0 || name.startsWith(":")) continue;
|
|
3321
|
+
traceHeaders.set(name, Array.isArray(value) ? value.join(", ") : value);
|
|
2859
3322
|
}
|
|
3323
|
+
const continueRequest = (error) => new Promise((resolve, reject) => {
|
|
3324
|
+
const finish = () => {
|
|
3325
|
+
res.off("finish", finish);
|
|
3326
|
+
res.off("close", finish);
|
|
3327
|
+
res.off("error", fail);
|
|
3328
|
+
resolve();
|
|
3329
|
+
};
|
|
3330
|
+
const fail = (responseError) => {
|
|
3331
|
+
res.off("finish", finish);
|
|
3332
|
+
res.off("close", finish);
|
|
3333
|
+
res.off("error", fail);
|
|
3334
|
+
reject(responseError);
|
|
3335
|
+
};
|
|
3336
|
+
res.once("finish", finish);
|
|
3337
|
+
res.once("close", finish);
|
|
3338
|
+
res.once("error", fail);
|
|
3339
|
+
try {
|
|
3340
|
+
next(error);
|
|
3341
|
+
if (res.writableFinished || res.destroyed) finish();
|
|
3342
|
+
} catch (nextError) {
|
|
3343
|
+
fail(nextError);
|
|
3344
|
+
}
|
|
3345
|
+
});
|
|
3346
|
+
return traceFrameworkRequest({
|
|
3347
|
+
callback: () => handlePagesRequest(req, res, continueRequest),
|
|
3348
|
+
getStatus: () => res.statusCode,
|
|
3349
|
+
headers: traceHeaders,
|
|
3350
|
+
method: req.method ?? "GET",
|
|
3351
|
+
target: url
|
|
3352
|
+
});
|
|
2860
3353
|
};
|
|
2861
3354
|
server.middlewares.use((req, res, next) => {
|
|
2862
|
-
handlePagesMiddleware(req, res, next);
|
|
3355
|
+
handlePagesMiddleware(req, res, next).catch(next);
|
|
2863
3356
|
});
|
|
2864
3357
|
};
|
|
2865
3358
|
}
|
|
@@ -3000,8 +3493,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3000
3493
|
const serverDefines = { ...nextConfig.compilerDefineServer };
|
|
3001
3494
|
serverDefines["process.env.NEXT_RUNTIME"] = JSON.stringify("nodejs");
|
|
3002
3495
|
serverDefines["process.env.NEXT_PHASE"] = "globalThis.__VINEXT_NEXT_PHASE";
|
|
3003
|
-
|
|
3004
|
-
if (sharedRevalidateSecret) serverDefines["process.env.__VINEXT_REVALIDATE_SECRET"] = JSON.stringify(sharedRevalidateSecret);
|
|
3496
|
+
if (revalidateSecret) serverDefines["process.env.__VINEXT_REVALIDATE_SECRET"] = JSON.stringify(revalidateSecret);
|
|
3005
3497
|
if (previewBuildCredentials) {
|
|
3006
3498
|
serverDefines["process.env.__VINEXT_PREVIEW_MODE_ID"] = JSON.stringify(previewBuildCredentials.id);
|
|
3007
3499
|
serverDefines["process.env.__VINEXT_PREVIEW_MODE_SIGNING_KEY"] = JSON.stringify(previewBuildCredentials.signingKey);
|
|
@@ -3176,7 +3668,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3176
3668
|
sequential: true,
|
|
3177
3669
|
order: "post",
|
|
3178
3670
|
handler() {
|
|
3179
|
-
if (buildIdWritten) return;
|
|
3671
|
+
if (buildIdWritten || !isServerEnvironment(this.environment)) return;
|
|
3180
3672
|
buildIdWritten = true;
|
|
3181
3673
|
const outDir = path.join(root, "dist", "server");
|
|
3182
3674
|
fs.mkdirSync(outDir, { recursive: true });
|
|
@@ -3207,14 +3699,20 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3207
3699
|
if (!environment || (hasAppDir ? environment.name !== "rsc" : !isServerEnvironment(environment))) return;
|
|
3208
3700
|
const outDir = options.dir;
|
|
3209
3701
|
if (!outDir) return;
|
|
3210
|
-
const
|
|
3702
|
+
const canonicalServerDir = path.join(root, "dist", "server");
|
|
3703
|
+
if (selectedMultiStageOutput) {
|
|
3704
|
+
if (readPrerenderSecret(canonicalServerDir) === prerenderSecret) for (const runtimeOutputDir of readServerRuntimeOutputDirs(canonicalServerDir, root)) serverRuntimeOutputDirs.add(runtimeOutputDir);
|
|
3705
|
+
serverRuntimeOutputDirs.add(path.resolve(outDir));
|
|
3706
|
+
}
|
|
3707
|
+
const manifest = {
|
|
3708
|
+
prerenderSecret,
|
|
3709
|
+
...serverRuntimeOutputDirs.size === 0 ? {} : { runtimeOutputDirs: [...serverRuntimeOutputDirs].map((runtimeOutputDir) => path.relative(root, runtimeOutputDir) || ".").sort() }
|
|
3710
|
+
};
|
|
3711
|
+
const source = JSON.stringify(manifest);
|
|
3211
3712
|
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
|
-
}
|
|
3713
|
+
if (path.resolve(outDir) !== canonicalServerDir) {
|
|
3714
|
+
fs.mkdirSync(canonicalServerDir, { recursive: true });
|
|
3715
|
+
fs.writeFileSync(path.join(canonicalServerDir, "vinext-server.json"), source);
|
|
3218
3716
|
}
|
|
3219
3717
|
}
|
|
3220
3718
|
}
|
|
@@ -3222,6 +3720,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3222
3720
|
{
|
|
3223
3721
|
name: "vinext:nitro-route-rules",
|
|
3224
3722
|
nitro: { setup: async (nitro) => {
|
|
3723
|
+
nitroBuildDir = nitro.options.buildDir ? path.resolve(root, nitro.options.buildDir) : void 0;
|
|
3724
|
+
nitroHostRuntime = nitro.options.exportConditions?.includes("workerd") ? "worker" : "node";
|
|
3225
3725
|
if (!nextConfig) return;
|
|
3226
3726
|
if (!hasAppDir && !hasPagesDir) return;
|
|
3227
3727
|
if (resolvedServerExternalPackages.length > 0) nitro.options.traceDeps = [.../* @__PURE__ */ new Set([...nitro.options.traceDeps ?? [], ...resolvedServerExternalPackages])];
|
|
@@ -3252,7 +3752,10 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3252
3752
|
const ssrManifestPath = path.join(viteDir, "ssr-manifest.json");
|
|
3253
3753
|
if (!fs.existsSync(ssrManifestPath)) return;
|
|
3254
3754
|
try {
|
|
3255
|
-
const
|
|
3755
|
+
const ssrManifest = JSON.parse(fs.readFileSync(ssrManifestPath, "utf-8"));
|
|
3756
|
+
const buildRoot = this.environment?.config.root ?? process.cwd();
|
|
3757
|
+
const buildBase = this.environment?.config.base ?? "/";
|
|
3758
|
+
const augmentedManifest = augmentSsrManifestFromBundle(ssrManifest, bundle, buildRoot, buildBase);
|
|
3256
3759
|
fs.writeFileSync(ssrManifestPath, JSON.stringify(augmentedManifest, null, 2));
|
|
3257
3760
|
} catch (err) {
|
|
3258
3761
|
console.warn("[vinext] Failed to augment SSR manifest:", err);
|
|
@@ -3372,17 +3875,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3372
3875
|
clientEntry: runtimeMetadata.clientEntryFile ?? void 0,
|
|
3373
3876
|
appBootstrapPreinitModules: runtimeMetadata.appBootstrapPreinitModules,
|
|
3374
3877
|
ssrManifest,
|
|
3878
|
+
cssGraph: runtimeMetadata.cssGraph,
|
|
3375
3879
|
lazyChunks: runtimeMetadata.lazyChunks ?? void 0,
|
|
3376
|
-
dynamicPreloads: runtimeMetadata.dynamicPreloads ?? void 0
|
|
3880
|
+
dynamicPreloads: runtimeMetadata.dynamicPreloads ?? void 0,
|
|
3881
|
+
crossOrigin: nextConfig.crossOrigin ?? ""
|
|
3377
3882
|
});
|
|
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
3883
|
}
|
|
3884
|
+
if (pagesClientAssetsModule === null && pagesClientAssetsOutputDirs.size === 0) return;
|
|
3386
3885
|
if (pagesClientAssetsModule === null) {
|
|
3387
3886
|
const emptyModule = buildPagesClientAssetsModule({});
|
|
3388
3887
|
for (const outputDir of pagesClientAssetsOutputDirs) writePagesClientAssetsModuleIfMissing(outputDir, emptyModule);
|
|
@@ -3416,7 +3915,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3416
3915
|
const envConfig = this.environment?.config;
|
|
3417
3916
|
if (!envConfig) return;
|
|
3418
3917
|
const buildRoot = envConfig.root ?? process.cwd();
|
|
3419
|
-
const
|
|
3918
|
+
const clientDir = path.resolve(buildRoot, "dist", "client");
|
|
3919
|
+
const manifest = collectInlineCssManifest(clientDir, nextConfig.assetPrefix);
|
|
3420
3920
|
const rscOutDir = path.resolve(buildRoot, options.rscOutDir ?? path.join("dist", "server"));
|
|
3421
3921
|
for (const entryFile of ["index.js", "index.mjs"]) if (injectInlineCssManifestGlobal(path.join(rscOutDir, entryFile), manifest)) break;
|
|
3422
3922
|
}
|
|
@@ -3453,6 +3953,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3453
3953
|
}
|
|
3454
3954
|
},
|
|
3455
3955
|
createWasmModuleImportPlugin(),
|
|
3956
|
+
createOgHarfbuzzPlugin(),
|
|
3456
3957
|
{
|
|
3457
3958
|
name: "vinext:og-font-patch",
|
|
3458
3959
|
enforce: "pre",
|
|
@@ -3524,7 +4025,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3524
4025
|
const buildRoot = config.root ?? process.cwd();
|
|
3525
4026
|
const outDir = path.resolve(buildRoot, outputOptions.dir);
|
|
3526
4027
|
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));
|
|
4028
|
+
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
4029
|
for (const output of cacheAdapterBuildOutputs) {
|
|
3529
4030
|
if (output.matchesBuild && !output.matchesBuild(build)) continue;
|
|
3530
4031
|
await output.finalizeBuildOutput?.({
|
|
@@ -3553,6 +4054,27 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
3553
4054
|
plugins.push(createRscReferenceValidationNormalizerPlugin());
|
|
3554
4055
|
plugins.push(createRscClientReferenceLoadersPlugin());
|
|
3555
4056
|
} else if (manualUseCachePluginPromise) plugins.push(manualUseCachePluginPromise);
|
|
4057
|
+
plugins.push({
|
|
4058
|
+
name: "vinext:plain-pages-build-config",
|
|
4059
|
+
apply: "build",
|
|
4060
|
+
enforce: "post",
|
|
4061
|
+
config: {
|
|
4062
|
+
order: "post",
|
|
4063
|
+
handler(config) {
|
|
4064
|
+
if (!hasPlainPagesBuildEnvironments) return;
|
|
4065
|
+
if (config.build?.watch || config.build?.ssr || config.build?.lib || getBuildBundlerOptions(config.build)?.input !== void 0) {
|
|
4066
|
+
for (const name of ["client", "ssr"]) if (originalPlainPagesEnvironments?.[name]) config.environments[name] = originalPlainPagesEnvironments[name];
|
|
4067
|
+
else delete config.environments?.[name];
|
|
4068
|
+
return;
|
|
4069
|
+
}
|
|
4070
|
+
return { builder: {
|
|
4071
|
+
...config.builder,
|
|
4072
|
+
sharedConfigBuild: true
|
|
4073
|
+
} };
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
});
|
|
4077
|
+
plugins.push(buildLifecyclePlugins[1]);
|
|
3556
4078
|
return plugins;
|
|
3557
4079
|
}
|
|
3558
4080
|
/**
|