vinext 1.0.0-beta.4 → 1.0.0-beta.6
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 +44 -3
- package/dist/build/client-build-config.d.ts +0 -1
- package/dist/build/css-url-assets.d.ts +0 -1
- package/dist/build/google-fonts/build-url.d.ts +5 -2
- package/dist/build/google-fonts/font-metadata.d.ts +7 -3
- package/dist/build/google-fonts/get-axes.d.ts +0 -1
- package/dist/build/layout-classification.d.ts +7 -4
- package/dist/build/next-client-runtime-manifests.d.ts +0 -1
- package/dist/build/next-client-runtime-manifests.js +2 -19
- package/dist/build/nitro-route-rules.d.ts +0 -1
- package/dist/build/pages-client-assets-module.d.ts +0 -1
- package/dist/build/precompress.d.ts +7 -2
- package/dist/build/precompress.js +41 -7
- package/dist/build/prerender-paths.d.ts +2 -2
- package/dist/build/prerender-paths.js +3 -4
- package/dist/build/prerender-phase.d.ts +15 -0
- package/dist/build/prerender-phase.js +37 -0
- package/dist/build/prerender-server-entry.d.ts +1 -1
- package/dist/build/prerender-server-entry.js +3 -3
- package/dist/build/prerender-server-pool.d.ts +4 -2
- package/dist/build/prerender-server-pool.js +2 -0
- package/dist/build/prerender.d.ts +40 -33
- package/dist/build/prerender.js +99 -18
- package/dist/build/public-dir-conflict.d.ts +14 -0
- package/dist/build/public-dir-conflict.js +25 -0
- package/dist/build/report.d.ts +2 -2
- package/dist/build/route-classification-injector.d.ts +0 -1
- package/dist/build/route-classification-manifest.d.ts +5 -3
- package/dist/build/run-prerender.d.ts +3 -2
- package/dist/build/run-prerender.js +9 -6
- package/dist/build/static-export.d.ts +23 -12
- package/dist/cache/cache-adapters-virtual.d.ts +5 -2
- package/dist/check.js +4 -4
- package/dist/cli-dev-config.d.ts +0 -1
- package/dist/cli.d.ts +1 -1
- package/dist/client/client-rewrite-matcher.d.ts +12 -0
- package/dist/client/client-rewrite-matcher.js +20 -0
- package/dist/client/client-rewrites.d.ts +31 -0
- package/dist/client/client-rewrites.js +41 -0
- package/dist/client/dev-error-overlay.d.ts +0 -1
- package/dist/client/empty-module.d.ts +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +2 -0
- package/dist/client/instrumentation-client-state.d.ts +0 -1
- package/dist/client/navigation-runtime.d.ts +6 -1
- package/dist/client/navigation-runtime.js +5 -1
- package/dist/client/pages-router-link-navigation.d.ts +3 -21
- package/dist/client/react-instance-bootstrap.d.ts +1 -0
- package/dist/client/react-instance-bootstrap.js +7 -0
- package/dist/client/react-instance.d.ts +13 -0
- package/dist/client/react-instance.js +20 -0
- package/dist/client/vinext-next-data.d.ts +13 -6
- package/dist/client/window-next.d.ts +5 -2
- package/dist/config/config-matchers.d.ts +3 -5
- package/dist/config/config-matchers.js +7 -6
- package/dist/config/dotenv.d.ts +1 -5
- package/dist/config/next-config.d.ts +113 -54
- package/dist/config/next-config.js +27 -7
- package/dist/config/prerender.d.ts +0 -1
- package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +808 -0
- package/dist/entries/app-browser-entry.d.ts +0 -1
- package/dist/entries/app-browser-entry.js +8 -3
- package/dist/entries/app-rsc-entry.d.ts +30 -16
- package/dist/entries/app-rsc-entry.js +48 -10
- package/dist/entries/app-rsc-manifest.d.ts +0 -1
- package/dist/entries/app-rsc-manifest.js +1 -0
- package/dist/entries/pages-client-entry.d.ts +0 -1
- package/dist/entries/pages-client-entry.js +15 -5
- package/dist/entries/pages-server-entry.d.ts +1 -2
- package/dist/entries/pages-server-entry.js +21 -5
- package/dist/image/image-adapters-virtual.d.ts +4 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +328 -227
- package/dist/init-cloudflare.d.ts +0 -1
- package/dist/init-platform.d.ts +0 -1
- package/dist/init.d.ts +40 -20
- package/dist/plugins/ast-scope.d.ts +0 -1
- package/dist/plugins/async-hooks-stub.d.ts +0 -1
- package/dist/plugins/client-reference-dedup.d.ts +0 -1
- package/dist/plugins/css-data-url.d.ts +0 -1
- package/dist/plugins/css-module-imports.d.ts +0 -1
- package/dist/plugins/dynamic-preload-metadata.d.ts +0 -1
- package/dist/plugins/extensionless-dynamic-import.d.ts +0 -1
- package/dist/plugins/extensionless-dynamic-import.js +352 -13
- package/dist/plugins/fonts.d.ts +0 -1
- package/dist/plugins/ignore-dynamic-requests.d.ts +0 -1
- package/dist/plugins/ignore-dynamic-requests.js +28 -4
- package/dist/plugins/import-meta-url.d.ts +0 -1
- package/dist/plugins/instrumentation-client.d.ts +0 -1
- package/dist/plugins/middleware-server-only.d.ts +0 -1
- package/dist/plugins/og-asset-ownership.d.ts +0 -1
- package/dist/plugins/og-assets.d.ts +0 -1
- package/dist/plugins/optimize-imports.d.ts +0 -1
- package/dist/plugins/pages-node-externals.d.ts +23 -0
- package/dist/plugins/pages-node-externals.js +206 -0
- package/dist/plugins/remove-console.d.ts +0 -1
- package/dist/plugins/require-context.d.ts +0 -1
- package/dist/plugins/require-context.js +143 -26
- package/dist/plugins/rsc-client-reference-loaders.d.ts +0 -1
- package/dist/plugins/rsc-reference-validation-normalizer.d.ts +0 -1
- package/dist/plugins/sass.d.ts +30 -2
- package/dist/plugins/sass.js +64 -1
- package/dist/plugins/server-externals-manifest.d.ts +0 -1
- package/dist/plugins/strip-server-exports.d.ts +0 -1
- package/dist/plugins/styled-jsx.d.ts +0 -1
- package/dist/plugins/transitive-externals.d.ts +24 -0
- package/dist/plugins/transitive-externals.js +121 -0
- package/dist/plugins/typeof-window.d.ts +11 -1
- package/dist/plugins/typeof-window.js +141 -13
- package/dist/plugins/use-cache-callable.d.ts +12 -0
- package/dist/plugins/use-cache-callable.js +209 -0
- package/dist/plugins/wasm-module-import.d.ts +0 -1
- package/dist/routing/app-route-graph.d.ts +115 -56
- package/dist/routing/app-route-graph.js +2 -1
- package/dist/routing/app-router.d.ts +0 -1
- package/dist/routing/pages-router.d.ts +9 -5
- package/dist/routing/route-matching.d.ts +0 -1
- package/dist/routing/utils.d.ts +1 -23
- package/dist/routing/utils.js +1 -30
- package/dist/server/accept-encoding.d.ts +0 -1
- package/dist/server/api-handler.d.ts +0 -1
- package/dist/server/api-handler.js +1 -1
- package/dist/server/app-bfcache-identity.d.ts +9 -10
- package/dist/server/app-bfcache-identity.js +27 -128
- package/dist/server/app-browser-action-result.d.ts +0 -1
- package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -1
- package/dist/server/app-browser-entry.d.ts +1 -1
- package/dist/server/app-browser-entry.js +46 -30
- package/dist/server/app-browser-history-controller.d.ts +8 -5
- package/dist/server/app-browser-hydration.d.ts +0 -1
- package/dist/server/app-browser-interception-context.d.ts +0 -1
- package/dist/server/app-browser-mpa-navigation.d.ts +0 -1
- package/dist/server/app-browser-navigation-controller.d.ts +2 -5
- package/dist/server/app-browser-popstate.d.ts +0 -1
- package/dist/server/app-browser-prefetch-response.d.ts +17 -1
- package/dist/server/app-browser-prefetch-response.js +23 -1
- package/dist/server/app-browser-server-action-client.d.ts +1 -1
- package/dist/server/app-browser-server-action-client.js +3 -2
- package/dist/server/app-browser-server-action-navigation.d.ts +0 -1
- package/dist/server/app-browser-state.d.ts +4 -3
- package/dist/server/app-browser-state.js +2 -4
- package/dist/server/app-browser-stream.d.ts +0 -1
- package/dist/server/app-browser-visible-commit.d.ts +1 -1
- package/dist/server/app-browser-visible-commit.js +6 -2
- package/dist/server/app-elements-wire.d.ts +16 -13
- package/dist/server/app-elements-wire.js +37 -10
- package/dist/server/app-elements.d.ts +2 -3
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-fallback-renderer.d.ts +8 -4
- package/dist/server/app-fallback-renderer.js +2 -1
- package/dist/server/app-history-state.d.ts +2 -2
- package/dist/server/app-history-state.js +1 -1
- package/dist/server/app-hook-warning-suppression.d.ts +0 -1
- package/dist/server/app-layout-param-observation.d.ts +0 -1
- package/dist/server/app-layout-param-observation.js +1 -1
- package/dist/server/app-middleware.d.ts +5 -1
- package/dist/server/app-middleware.js +96 -31
- package/dist/server/app-optimistic-routing.d.ts +1 -0
- package/dist/server/app-page-boundary-render.d.ts +8 -4
- package/dist/server/app-page-boundary-render.js +4 -7
- package/dist/server/app-page-cache-finalizer.d.ts +3 -3
- package/dist/server/app-page-cache-finalizer.js +45 -19
- package/dist/server/app-page-cache-render.d.ts +3 -2
- package/dist/server/app-page-cache-render.js +5 -2
- package/dist/server/app-page-cache.d.ts +3 -4
- package/dist/server/app-page-cache.js +33 -15
- package/dist/server/app-page-dispatch.d.ts +11 -5
- package/dist/server/app-page-dispatch.js +11 -6
- package/dist/server/app-page-element-builder.d.ts +61 -19
- package/dist/server/app-page-element-builder.js +113 -43
- package/dist/server/app-page-execution.d.ts +12 -5
- package/dist/server/app-page-execution.js +20 -7
- package/dist/server/app-page-head.d.ts +2 -2
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +2 -2
- package/dist/server/app-page-params.d.ts +0 -1
- package/dist/server/app-page-ppr-runtime.d.ts +0 -1
- package/dist/server/app-page-probe.d.ts +4 -3
- package/dist/server/app-page-probe.js +1 -1
- package/dist/server/app-page-render-identity.d.ts +1 -0
- package/dist/server/app-page-render-observation.d.ts +0 -1
- package/dist/server/app-page-render.d.ts +6 -4
- package/dist/server/app-page-render.js +53 -25
- package/dist/server/app-page-request.d.ts +3 -1
- package/dist/server/app-page-request.js +3 -34
- package/dist/server/app-page-response.d.ts +13 -3
- package/dist/server/app-page-response.js +17 -11
- package/dist/server/app-page-route-wiring.d.ts +27 -5
- package/dist/server/app-page-route-wiring.js +110 -58
- package/dist/server/app-page-search-params-observation.d.ts +0 -1
- package/dist/server/app-page-segment-plan.d.ts +56 -0
- package/dist/server/app-page-segment-plan.js +177 -0
- package/dist/server/app-page-segment-state.d.ts +18 -2
- package/dist/server/app-page-segment-state.js +23 -4
- package/dist/server/app-page-stream.d.ts +31 -10
- package/dist/server/app-page-stream.js +10 -3
- package/dist/server/app-pages-bridge.d.ts +0 -1
- package/dist/server/app-pages-bridge.js +12 -1
- package/dist/server/app-post-middleware-context.d.ts +0 -1
- package/dist/server/app-ppr-fallback-shell-render.d.ts +0 -1
- package/dist/server/app-prerender-endpoints.d.ts +1 -1
- package/dist/server/app-prerender-endpoints.js +12 -0
- package/dist/server/app-prerender-static-params.d.ts +0 -1
- package/dist/server/app-render-dependency.d.ts +11 -4
- package/dist/server/app-render-dependency.js +59 -9
- package/dist/server/app-request-context.d.ts +1 -0
- package/dist/server/app-response-header-provenance.d.ts +13 -0
- package/dist/server/app-response-header-provenance.js +26 -0
- package/dist/server/app-route-handler-cache.d.ts +3 -2
- package/dist/server/app-route-handler-cache.js +7 -3
- package/dist/server/app-route-handler-dispatch.d.ts +0 -1
- package/dist/server/app-route-handler-dispatch.js +4 -2
- package/dist/server/app-route-handler-execution.d.ts +2 -2
- package/dist/server/app-route-handler-execution.js +15 -7
- package/dist/server/app-route-handler-policy.d.ts +1 -1
- package/dist/server/app-route-handler-response.d.ts +3 -2
- package/dist/server/app-route-handler-response.js +15 -5
- package/dist/server/app-route-handler-runtime.d.ts +1 -2
- package/dist/server/app-route-handler-runtime.js +218 -85
- package/dist/server/app-route-module-loader.d.ts +32 -6
- package/dist/server/app-route-module-loader.js +73 -3
- package/dist/server/app-route-request-built-ins.d.ts +16 -0
- package/dist/server/app-route-request-built-ins.js +41 -0
- package/dist/server/app-router-entry.d.ts +0 -1
- package/dist/server/app-router-entry.js +4 -4
- package/dist/server/app-rsc-cache-busting.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.js +24 -16
- package/dist/server/app-rsc-handler.d.ts +9 -2
- package/dist/server/app-rsc-handler.js +176 -47
- package/dist/server/app-rsc-redirect-flight.d.ts +0 -1
- package/dist/server/app-rsc-request-normalization.d.ts +19 -10
- package/dist/server/app-rsc-response-finalizer.d.ts +7 -2
- package/dist/server/app-rsc-response-finalizer.js +34 -18
- package/dist/server/app-rsc-route-matching.d.ts +6 -1
- package/dist/server/app-rsc-route-matching.js +47 -2
- package/dist/server/app-rsc-state-fingerprint.d.ts +14 -0
- package/dist/server/app-rsc-state-fingerprint.js +13 -0
- package/dist/server/app-segment-config.d.ts +0 -1
- package/dist/server/app-server-action-execution.d.ts +41 -8
- package/dist/server/app-server-action-execution.js +191 -113
- package/dist/server/app-ssr-entry.d.ts +11 -3
- package/dist/server/app-ssr-entry.js +19 -8
- package/dist/server/app-ssr-router-instance.d.ts +0 -1
- package/dist/server/app-ssr-stream.d.ts +13 -2
- package/dist/server/app-ssr-stream.js +30 -5
- package/dist/server/app-static-generation.d.ts +0 -1
- package/dist/server/app-visited-response-cache.d.ts +1 -1
- package/dist/server/before-interactive-head.d.ts +0 -1
- package/dist/server/before-interactive-head.js +2 -0
- package/dist/server/bfcache-identity.d.ts +45 -0
- package/dist/server/bfcache-identity.js +52 -0
- package/dist/server/cache-control.d.ts +11 -7
- package/dist/server/cache-control.js +23 -11
- package/dist/server/cache-proof.d.ts +0 -1
- package/dist/server/client-reuse-manifest.d.ts +0 -1
- package/dist/server/config-headers.d.ts +6 -2
- package/dist/server/config-headers.js +19 -3
- package/dist/server/csp.d.ts +0 -1
- package/dist/server/default-global-error-module.d.ts +0 -1
- package/dist/server/default-global-not-found-module.d.ts +0 -1
- package/dist/server/default-not-found-module.d.ts +0 -1
- package/dist/server/dev-lockfile.d.ts +21 -9
- package/dist/server/dev-module-runner.d.ts +0 -1
- package/dist/server/dev-route-files.d.ts +0 -1
- package/dist/server/dev-server.d.ts +4 -8
- package/dist/server/dev-server.js +54 -105
- package/dist/server/dev-stack-sourcemap.d.ts +0 -1
- package/dist/server/document-initial-head.d.ts +12 -2
- package/dist/server/document-initial-head.js +17 -2
- package/dist/server/file-based-metadata.d.ts +0 -1
- package/dist/server/headers.d.ts +21 -2
- package/dist/server/headers.js +23 -2
- package/dist/server/http-conditional.d.ts +22 -0
- package/dist/server/http-conditional.js +117 -0
- package/dist/server/http-date.d.ts +5 -0
- package/dist/server/http-date.js +73 -0
- package/dist/server/http-error-responses.d.ts +3 -2
- package/dist/server/http-error-responses.js +21 -4
- package/dist/server/http-range.d.ts +25 -0
- package/dist/server/http-range.js +67 -0
- package/dist/server/image-optimization.d.ts +14 -6
- package/dist/server/image-optimization.js +0 -1
- package/dist/server/instrumentation.d.ts +7 -4
- package/dist/server/isr-cache.d.ts +28 -6
- package/dist/server/isr-cache.js +19 -13
- package/dist/server/isr-decision.d.ts +6 -4
- package/dist/server/metadata-route-build-data.d.ts +0 -1
- package/dist/server/metadata-route-build-data.js +1 -1
- package/dist/server/metadata-route-cache-policy.d.ts +6 -0
- package/dist/server/metadata-route-cache-policy.js +6 -0
- package/dist/server/metadata-route-response.d.ts +26 -2
- package/dist/server/metadata-route-response.js +225 -11
- package/dist/server/metadata-routes.d.ts +34 -16
- package/dist/server/metadata-routes.js +1 -1
- package/dist/server/middleware-matcher-pattern.d.ts +0 -1
- package/dist/server/middleware-matcher.d.ts +8 -3
- package/dist/server/middleware-matcher.js +23 -18
- package/dist/server/middleware-response-headers.js +4 -2
- package/dist/server/middleware-runtime.d.ts +6 -1
- package/dist/server/middleware-runtime.js +91 -28
- package/dist/server/middleware.d.ts +0 -1
- package/dist/server/navigation-planner.d.ts +1 -1
- package/dist/server/next-error-digest.d.ts +0 -1
- package/dist/server/pages-api-route.d.ts +0 -1
- package/dist/server/pages-api-route.js +30 -5
- package/dist/server/pages-asset-tags.d.ts +2 -1
- package/dist/server/pages-data-route.d.ts +14 -6
- package/dist/server/pages-data-route.js +19 -10
- package/dist/server/pages-dev-hydration.js +14 -4
- package/dist/server/pages-dev-stylesheets.d.ts +10 -0
- package/dist/server/pages-dev-stylesheets.js +150 -0
- package/dist/server/pages-document-initial-props.d.ts +10 -6
- package/dist/server/pages-get-initial-props.d.ts +2 -2
- package/dist/server/pages-i18n.d.ts +1 -7
- package/dist/server/pages-node-compat.d.ts +11 -2
- package/dist/server/pages-node-compat.js +49 -2
- package/dist/server/pages-page-data.d.ts +21 -9
- package/dist/server/pages-page-data.js +109 -30
- package/dist/server/pages-page-handler.d.ts +72 -33
- package/dist/server/pages-page-handler.js +25 -20
- package/dist/server/pages-page-response.d.ts +7 -13
- package/dist/server/pages-page-response.js +16 -23
- package/dist/server/pages-readiness.d.ts +0 -1
- package/dist/server/pages-request-pipeline.d.ts +20 -6
- package/dist/server/pages-request-pipeline.js +40 -20
- package/dist/server/pages-revalidate.d.ts +0 -1
- package/dist/server/pages-revalidate.js +1 -1
- package/dist/server/pages-router-entry.js +13 -9
- package/dist/server/prerender-cache-life-header.d.ts +11 -0
- package/dist/server/prerender-cache-life-header.js +18 -0
- package/dist/server/prerender-manifest.d.ts +11 -2
- package/dist/server/prerender-manifest.js +4 -1
- package/dist/server/prod-server.d.ts +13 -7
- package/dist/server/prod-server.js +280 -92
- package/dist/server/proxy-trust.d.ts +0 -1
- package/dist/server/request-log.d.ts +7 -11
- package/dist/server/request-pipeline.d.ts +13 -4
- package/dist/server/request-pipeline.js +30 -20
- package/dist/server/revalidation-host.d.ts +0 -1
- package/dist/server/revalidation-host.js +1 -1
- package/dist/server/rsc-completion-metadata.d.ts +15 -0
- package/dist/server/rsc-completion-metadata.js +183 -0
- package/dist/server/seed-cache.d.ts +6 -2
- package/dist/server/seed-cache.js +35 -8
- package/dist/server/skip-cache-proof.d.ts +0 -1
- package/dist/server/static-file-cache.d.ts +23 -9
- package/dist/server/static-file-cache.js +47 -23
- package/dist/server/static-layout-client-reuse-proof.d.ts +0 -1
- package/dist/server/worker-revalidation-context.d.ts +0 -1
- package/dist/server/worker-utils.d.ts +3 -1
- package/dist/server/worker-utils.js +12 -3
- package/dist/shims/app-router-scroll.d.ts +2 -8
- package/dist/shims/app.d.ts +1 -5
- package/dist/shims/before-interactive-context.d.ts +5 -3
- package/dist/shims/cache-callable-runtime.d.ts +11 -0
- package/dist/shims/cache-callable-runtime.js +30 -0
- package/dist/shims/cache-handler.d.ts +6 -1
- package/dist/shims/cache-handler.js +4 -2
- package/dist/shims/cache-request-state.d.ts +15 -1
- package/dist/shims/cache-request-state.js +27 -1
- package/dist/shims/cache-runtime.d.ts +15 -6
- package/dist/shims/cache-runtime.js +129 -29
- package/dist/shims/cache.d.ts +2 -3
- package/dist/shims/cache.js +2 -2
- package/dist/shims/cdn-cache.d.ts +18 -7
- package/dist/shims/cdn-cache.js +4 -2
- package/dist/shims/client-locale.d.ts +1 -6
- package/dist/shims/client-only.d.ts +1 -1
- package/dist/shims/compat-router.d.ts +0 -1
- package/dist/shims/constants.d.ts +1 -1
- package/dist/shims/default-global-error.d.ts +1 -4
- package/dist/shims/default-not-found.d.ts +0 -1
- package/dist/shims/document.d.ts +0 -1
- package/dist/shims/document.js +2 -1
- package/dist/shims/dynamic-preload-chunks.d.ts +0 -1
- package/dist/shims/dynamic.d.ts +0 -1
- package/dist/shims/error-boundary-navigation.d.ts +0 -1
- package/dist/shims/error-boundary.d.ts +7 -32
- package/dist/shims/error.d.ts +1 -6
- package/dist/shims/fetch-cache.js +115 -65
- package/dist/shims/font-google-base.d.ts +0 -1
- package/dist/shims/font-local.d.ts +0 -1
- package/dist/shims/font-local.js +3 -3
- package/dist/shims/form.d.ts +5 -3
- package/dist/shims/head-state.d.ts +0 -1
- package/dist/shims/head.d.ts +17 -5
- package/dist/shims/head.js +70 -8
- package/dist/shims/headers.d.ts +2 -2
- package/dist/shims/headers.js +1 -1
- package/dist/shims/i18n-context.d.ts +0 -1
- package/dist/shims/i18n-state.d.ts +0 -1
- package/dist/shims/image.d.ts +0 -1
- package/dist/shims/image.js +1 -2
- package/dist/shims/internal/als-registry.d.ts +31 -2
- package/dist/shims/internal/als-registry.js +50 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +17 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.js +69 -7
- package/dist/shims/internal/app-route-detection.d.ts +0 -1
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +33 -0
- package/dist/shims/internal/app-route-prefetch-policy.js +63 -0
- package/dist/shims/internal/app-router-context.d.ts +0 -1
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +1 -5
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +0 -1
- package/dist/shims/internal/hybrid-client-route-owner.js +6 -8
- package/dist/shims/internal/interpolate-as.d.ts +3 -2
- package/dist/shims/internal/pages-data-target.d.ts +22 -11
- package/dist/shims/internal/pages-data-target.js +19 -6
- package/dist/shims/internal/pages-data-url.d.ts +3 -1
- package/dist/shims/internal/router-context.d.ts +0 -1
- package/dist/shims/internal/work-unit-async-storage.d.ts +4 -3
- package/dist/shims/internal/work-unit-async-storage.js +2 -0
- package/dist/shims/layout-segment-context.d.ts +2 -6
- package/dist/shims/legacy-image.d.ts +0 -1
- package/dist/shims/link.d.ts +29 -23
- package/dist/shims/link.js +59 -150
- package/dist/shims/metadata.d.ts +2 -10
- package/dist/shims/navigation-context-state.d.ts +4 -1
- package/dist/shims/navigation-state.d.ts +1 -0
- package/dist/shims/navigation.d.ts +65 -6
- package/dist/shims/navigation.js +360 -71
- package/dist/shims/navigation.react-server.d.ts +1 -0
- package/dist/shims/og.d.ts +0 -1
- package/dist/shims/request-context.d.ts +8 -4
- package/dist/shims/request-state-types.d.ts +1 -0
- package/dist/shims/root-params.d.ts +3 -1
- package/dist/shims/root-params.js +7 -1
- package/dist/shims/router.d.ts +44 -23
- package/dist/shims/router.js +184 -82
- package/dist/shims/script-nonce-context.d.ts +0 -1
- package/dist/shims/script.d.ts +25 -13
- package/dist/shims/server-only.d.ts +1 -1
- package/dist/shims/server.d.ts +1 -3
- package/dist/shims/server.js +7 -7
- package/dist/shims/slot.d.ts +22 -11
- package/dist/shims/slot.js +99 -19
- package/dist/shims/streamed-icons.d.ts +1 -3
- package/dist/shims/unified-request-context.d.ts +44 -4
- package/dist/shims/unified-request-context.js +56 -2
- package/dist/shims/use-merged-ref.d.ts +0 -1
- package/dist/shims/web-vitals.d.ts +0 -1
- package/dist/typegen.d.ts +1 -2
- package/dist/typegen.js +1 -1
- package/dist/utils/cache-control-metadata.d.ts +13 -1
- package/dist/utils/cache-control-metadata.js +17 -1
- package/dist/utils/client-build-manifest.d.ts +0 -1
- package/dist/utils/domain-locale.d.ts +1 -5
- package/dist/utils/encode-cache-tag.d.ts +1 -1
- package/dist/utils/encode-cache-tag.js +1 -1
- package/dist/utils/html-limited-bots.js +1 -1
- package/dist/utils/middleware-request-headers.d.ts +17 -5
- package/dist/utils/middleware-request-headers.js +32 -23
- package/dist/utils/precompressed-variant.d.ts +9 -0
- package/dist/utils/precompressed-variant.js +15 -0
- package/dist/utils/prerender-output-paths.d.ts +3 -1
- package/dist/utils/prerender-output-paths.js +6 -1
- package/dist/utils/project.d.ts +12 -7
- package/dist/utils/public-file-path.d.ts +5 -0
- package/dist/utils/public-file-path.js +12 -0
- package/dist/utils/public-routes.d.ts +1 -1
- package/dist/utils/public-routes.js +6 -5
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -367,6 +367,49 @@ export default defineConfig({
|
|
|
367
367
|
> Adding an explicit `rsc()` call fails the build with `[vinext] Duplicate @vitejs/plugin-rsc detected`.
|
|
368
368
|
> Pass `rsc: false` to `vinext()` only if you want to own that registration.
|
|
369
369
|
|
|
370
|
+
#### Module Federation (client-side)
|
|
371
|
+
|
|
372
|
+
For client-side Module Federation, configure React and React DOM as singleton shared modules in both the host and remotes:
|
|
373
|
+
|
|
374
|
+
```ts
|
|
375
|
+
import { federation } from "@module-federation/vite";
|
|
376
|
+
import { defineConfig } from "vite";
|
|
377
|
+
import vinext from "vinext";
|
|
378
|
+
|
|
379
|
+
export default defineConfig({
|
|
380
|
+
plugins: [
|
|
381
|
+
federation({
|
|
382
|
+
name: "host",
|
|
383
|
+
shared: {
|
|
384
|
+
react: { singleton: true },
|
|
385
|
+
"react/": { singleton: true },
|
|
386
|
+
"react-dom": { singleton: true },
|
|
387
|
+
"react-dom/": { singleton: true },
|
|
388
|
+
},
|
|
389
|
+
}),
|
|
390
|
+
vinext(),
|
|
391
|
+
],
|
|
392
|
+
});
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
In a remote client component, use `getVinextReact()` before reading React hooks. vinext registers the host's browser React instance before application modules execute, and the first registration remains stable across remote evaluation and HMR:
|
|
396
|
+
|
|
397
|
+
```tsx
|
|
398
|
+
"use client";
|
|
399
|
+
|
|
400
|
+
import * as React from "react";
|
|
401
|
+
import { getVinextReact } from "vinext/client";
|
|
402
|
+
|
|
403
|
+
const { useState } = getVinextReact(React);
|
|
404
|
+
|
|
405
|
+
export function RemoteCounter() {
|
|
406
|
+
const [count, setCount] = useState(0);
|
|
407
|
+
return <button onClick={() => setCount((value) => value + 1)}>{count}</button>;
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
This bridge is browser-only. It does not provide App Router Module Federation SSR or transparently replace React imports inside third-party packages; compatible React versions remain the responsibility of the Module Federation `shared` configuration.
|
|
412
|
+
|
|
370
413
|
See the [examples](#live-examples) for complete working configurations.
|
|
371
414
|
|
|
372
415
|
### Other platforms (via Nitro)
|
|
@@ -638,9 +681,7 @@ vinext({
|
|
|
638
681
|
cache: {
|
|
639
682
|
data: {
|
|
640
683
|
adapter: require.resolve("./my-adapter.js"),
|
|
641
|
-
options: {
|
|
642
|
-
/* … */
|
|
643
|
-
},
|
|
684
|
+
options: {/* … */},
|
|
644
685
|
},
|
|
645
686
|
},
|
|
646
687
|
});
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
//#region src/build/google-fonts/build-url.d.ts
|
|
2
2
|
type FontAxes = {
|
|
3
|
-
/** Weight values: explicit faces ("400") or a variable range ("400..800"). */
|
|
4
|
-
|
|
3
|
+
/** Weight values: explicit faces ("400") or a variable range ("400..800"). */
|
|
4
|
+
wght?: string[];
|
|
5
|
+
/** Ital values, "0" (normal) and/or "1" (italic). */
|
|
6
|
+
ital?: string[];
|
|
7
|
+
/** Other variable axes the caller wants to include, e.g. `[["opsz","14..32"]]`. */
|
|
5
8
|
variableAxes?: [string, string][];
|
|
6
9
|
};
|
|
7
10
|
declare function buildGoogleFontsUrl(fontFamily: string, axes: FontAxes, display: string): string;
|
|
@@ -6,9 +6,13 @@ type VariableAxisDescriptor = {
|
|
|
6
6
|
defaultValue: number;
|
|
7
7
|
};
|
|
8
8
|
type FontFamilyMetadata = {
|
|
9
|
-
/** Available weight values, plus the literal "variable" if a variable face exists. */
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/** Available weight values, plus the literal "variable" if a variable face exists. */
|
|
10
|
+
weights: string[];
|
|
11
|
+
/** Available styles, e.g. ["normal"], ["italic"], or both. */
|
|
12
|
+
styles: string[];
|
|
13
|
+
/** Variable axes for this family. Absent when the family has no variable face. */
|
|
14
|
+
axes?: VariableAxisDescriptor[];
|
|
15
|
+
/** Preloadable subsets (e.g. "latin", "latin-ext", "vietnamese"). */
|
|
12
16
|
subsets: string[];
|
|
13
17
|
};
|
|
14
18
|
declare const googleFontsMetadata: Record<string, FontFamilyMetadata>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ClassificationReason, LayoutBuildClassification, ModuleGraphStaticReason } from "./layout-classification-types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/build/layout-classification.d.ts
|
|
4
3
|
type ModuleGraphClassification = "static" | "needs-probe";
|
|
5
4
|
type ModuleGraphClassificationResult = {
|
|
6
|
-
result: ModuleGraphClassification;
|
|
5
|
+
result: ModuleGraphClassification;
|
|
6
|
+
/** First dynamic shim module ID encountered during BFS, when any. */
|
|
7
7
|
firstShimMatch?: string;
|
|
8
8
|
};
|
|
9
9
|
type ModuleInfoProvider = {
|
|
@@ -13,8 +13,11 @@ type ModuleInfoProvider = {
|
|
|
13
13
|
} | null;
|
|
14
14
|
};
|
|
15
15
|
type LayoutEntry = {
|
|
16
|
-
/** Rollup/Vite module ID for the layout file. */
|
|
17
|
-
|
|
16
|
+
/** Rollup/Vite module ID for the layout file. */
|
|
17
|
+
moduleId: string;
|
|
18
|
+
/** Directory depth from the app root, used to build the stable layout ID. */
|
|
19
|
+
treePosition: number;
|
|
20
|
+
/** Segment config source code extracted at build time, or null when absent. */
|
|
18
21
|
segmentConfig?: {
|
|
19
22
|
code: string;
|
|
20
23
|
} | null;
|
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
+
import { toClientRewrites } from "../client/client-rewrites.js";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
//#region src/build/next-client-runtime-manifests.ts
|
|
4
|
-
function normalizeRewriteForClientManifest(rewrite) {
|
|
5
|
-
if (rewrite.destination.startsWith("/")) return {
|
|
6
|
-
has: rewrite.has,
|
|
7
|
-
source: rewrite.source,
|
|
8
|
-
destination: rewrite.destination
|
|
9
|
-
};
|
|
10
|
-
return {
|
|
11
|
-
has: rewrite.has,
|
|
12
|
-
source: rewrite.source
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function normalizeRewritesForClientManifest(rewrites) {
|
|
16
|
-
return {
|
|
17
|
-
beforeFiles: rewrites.beforeFiles.map(normalizeRewriteForClientManifest),
|
|
18
|
-
afterFiles: rewrites.afterFiles.map(normalizeRewriteForClientManifest),
|
|
19
|
-
fallback: rewrites.fallback.map(normalizeRewriteForClientManifest)
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
5
|
function buildNextClientBuildManifestContent(rewrites) {
|
|
23
6
|
const manifest = {
|
|
24
|
-
__rewrites:
|
|
7
|
+
__rewrites: toClientRewrites(rewrites),
|
|
25
8
|
sortedPages: []
|
|
26
9
|
};
|
|
27
10
|
return `self.__BUILD_MANIFEST = ${JSON.stringify(manifest)};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()`;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PagesClientAssets } from "../server/pages-client-assets.js";
|
|
2
|
-
|
|
3
2
|
//#region src/build/pages-client-assets-module.d.ts
|
|
4
3
|
declare const PAGES_CLIENT_ASSETS_MODULE = "vinext-client-assets.js";
|
|
5
4
|
declare function buildPagesClientAssetsModule(assets: PagesClientAssets): string;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
//#region src/build/precompress.d.ts
|
|
2
2
|
type PrecompressResult = {
|
|
3
3
|
filesCompressed: number;
|
|
4
|
-
totalOriginalBytes: number;
|
|
4
|
+
totalOriginalBytes: number;
|
|
5
|
+
/**
|
|
6
|
+
* Sum of the representation sizes Brotli negotiation would serve. Falls
|
|
7
|
+
* back to the original size when Brotli is not beneficial for a file.
|
|
8
|
+
*/
|
|
5
9
|
totalBrotliBytes: number;
|
|
6
10
|
};
|
|
7
11
|
/**
|
|
@@ -20,7 +24,8 @@ type PrecompressResult = {
|
|
|
20
24
|
* emit zero compressed variants.
|
|
21
25
|
*/
|
|
22
26
|
declare function precompressAssets(clientDir: string, options?: {
|
|
23
|
-
/** Subdirectory under `clientDir` containing hashed assets. Defaults to `"_next/static"`. */
|
|
27
|
+
/** Subdirectory under `clientDir` containing hashed assets. Defaults to `"_next/static"`. */
|
|
28
|
+
assetsDir?: string;
|
|
24
29
|
onProgress?: (completed: number, total: number, file: string) => void;
|
|
25
30
|
}): Promise<PrecompressResult>;
|
|
26
31
|
//#endregion
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { ASSET_PREFIX_URL_DIR } from "../utils/asset-prefix.js";
|
|
3
|
+
import { isPrecompressedVariantBeneficial } from "../utils/precompressed-variant.js";
|
|
3
4
|
import fsp from "node:fs/promises";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
4
6
|
import { promisify } from "node:util";
|
|
5
7
|
import os from "node:os";
|
|
6
8
|
import zlib from "node:zlib";
|
|
@@ -90,21 +92,53 @@ async function precompressAssets(clientDir, options = {}) {
|
|
|
90
92
|
const chunk = filePaths.slice(i, i + CONCURRENCY);
|
|
91
93
|
await Promise.all(chunk.map(async (fullPath) => {
|
|
92
94
|
const content = await fsp.readFile(fullPath);
|
|
93
|
-
if (content.length < MIN_SIZE)
|
|
95
|
+
if (content.length < MIN_SIZE) {
|
|
96
|
+
await removeCompressedVariants(fullPath);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
94
99
|
const compressions = [brotliCompress(content, { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 5 } }), gzip(content, { level: 8 })];
|
|
95
100
|
if (zstdCompress) compressions.push(zstdCompress(content, { params: { [zlib.constants.ZSTD_c_compressionLevel]: 8 } }));
|
|
96
101
|
const [brContent, gzContent, zstdContent] = await Promise.all(compressions);
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
const outcomes = await Promise.all([
|
|
103
|
+
writeBeneficialVariant(fullPath + ".br", brContent, content.length, "br"),
|
|
104
|
+
writeBeneficialVariant(fullPath + ".gz", gzContent, content.length, "gzip"),
|
|
105
|
+
zstdContent ? writeBeneficialVariant(fullPath + ".zst", zstdContent, content.length, "zstd") : removeFileIfPresent(fullPath + ".zst").then(() => false)
|
|
106
|
+
]);
|
|
107
|
+
if (outcomes.some(Boolean)) {
|
|
108
|
+
result.filesCompressed++;
|
|
109
|
+
result.totalOriginalBytes += content.length;
|
|
110
|
+
result.totalBrotliBytes += outcomes[0] ? brContent.length : content.length;
|
|
111
|
+
}
|
|
103
112
|
}));
|
|
104
113
|
processed += chunk.length;
|
|
105
114
|
onProgress?.(processed, filePaths.length, path.basename(chunk[chunk.length - 1]));
|
|
106
115
|
}
|
|
107
116
|
return result;
|
|
108
117
|
}
|
|
118
|
+
async function writeBeneficialVariant(destination, compressed, originalSize, encoding) {
|
|
119
|
+
if (!isPrecompressedVariantBeneficial(compressed.length, originalSize, encoding)) {
|
|
120
|
+
await removeFileIfPresent(destination);
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
const temporary = `${destination}.${process.pid}.${randomUUID()}.tmp`;
|
|
124
|
+
try {
|
|
125
|
+
await fsp.writeFile(temporary, compressed);
|
|
126
|
+
await fsp.rename(temporary, destination);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
await removeFileIfPresent(temporary);
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
async function removeCompressedVariants(fullPath) {
|
|
134
|
+
await Promise.all([
|
|
135
|
+
removeFileIfPresent(fullPath + ".br"),
|
|
136
|
+
removeFileIfPresent(fullPath + ".gz"),
|
|
137
|
+
removeFileIfPresent(fullPath + ".zst")
|
|
138
|
+
]);
|
|
139
|
+
}
|
|
140
|
+
async function removeFileIfPresent(filePath) {
|
|
141
|
+
await fsp.rm(filePath, { force: true });
|
|
142
|
+
}
|
|
109
143
|
//#endregion
|
|
110
144
|
export { precompressAssets };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ResolvedNextConfig } from "../config/next-config.js";
|
|
2
2
|
import { VinextRouteRootConfig } from "../config/prerender.js";
|
|
3
|
-
|
|
4
3
|
//#region src/build/prerender-paths.d.ts
|
|
5
4
|
type PrerenderPathManifest = {
|
|
6
5
|
buildId?: string;
|
|
@@ -10,7 +9,8 @@ type PrerenderPathManifest = {
|
|
|
10
9
|
declare const PRERENDER_PATH_DISCOVERY_ENV = "__VINEXT_PRERENDER_PATH_DISCOVERY";
|
|
11
10
|
declare const PRERENDER_PATHS_MANIFEST = "vinext-prerender-paths.json";
|
|
12
11
|
type EmitPrerenderPathManifestOptions = {
|
|
13
|
-
root: string;
|
|
12
|
+
root: string;
|
|
13
|
+
/** Fully resolved Next.js config. Loaded from disk when omitted. */
|
|
14
14
|
nextConfig?: ResolvedNextConfig;
|
|
15
15
|
appDir?: string | null;
|
|
16
16
|
pagesDir?: string | null;
|
|
@@ -9,6 +9,7 @@ import { BLOCKED_PAGES, PHASE_PRODUCTION_BUILD } from "../shims/constants.js";
|
|
|
9
9
|
import { loadNextConfig, resolveNextConfig } from "../config/next-config.js";
|
|
10
10
|
import { readPrerenderSecret } from "./server-manifest.js";
|
|
11
11
|
import { startProdServer } from "../server/prod-server.js";
|
|
12
|
+
import { enterPrerenderPhase } from "./prerender-phase.js";
|
|
12
13
|
import { buildUrlFromParams, resolveParentParams } from "./prerender.js";
|
|
13
14
|
import fs from "node:fs";
|
|
14
15
|
//#region src/build/prerender-paths.ts
|
|
@@ -96,15 +97,13 @@ async function shouldStartPathDiscoveryServer(options) {
|
|
|
96
97
|
return false;
|
|
97
98
|
}
|
|
98
99
|
async function withPrerenderEndpoints(fn) {
|
|
99
|
-
const
|
|
100
|
+
const restorePrerenderPhase = enterPrerenderPhase();
|
|
100
101
|
const previousPathDiscoveryFlag = process.env[PRERENDER_PATH_DISCOVERY_ENV];
|
|
101
|
-
process.env.VINEXT_PRERENDER = "1";
|
|
102
102
|
process.env[PRERENDER_PATH_DISCOVERY_ENV] = "1";
|
|
103
103
|
try {
|
|
104
104
|
return await fn();
|
|
105
105
|
} finally {
|
|
106
|
-
|
|
107
|
-
else process.env.VINEXT_PRERENDER = previousPrerenderFlag;
|
|
106
|
+
restorePrerenderPhase();
|
|
108
107
|
if (previousPathDiscoveryFlag === void 0) delete process.env[PRERENDER_PATH_DISCOVERY_ENV];
|
|
109
108
|
else process.env[PRERENDER_PATH_DISCOVERY_ENV] = previousPathDiscoveryFlag;
|
|
110
109
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/build/prerender-phase.d.ts
|
|
2
|
+
type PrerenderPhaseEnv = {
|
|
3
|
+
NEXT_PHASE?: string;
|
|
4
|
+
NODE_ENV?: string;
|
|
5
|
+
VINEXT_PRERENDER?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Enter the same process environment phase that Next.js exposes while its
|
|
9
|
+
* static workers execute application code. The returned cleanup is nest-safe:
|
|
10
|
+
* direct prerender helpers can run inside the CLI's broader build scope without
|
|
11
|
+
* overwriting the caller's prior phase when they finish.
|
|
12
|
+
*/
|
|
13
|
+
declare function enterPrerenderPhase(env?: PrerenderPhaseEnv): () => void;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { enterPrerenderPhase };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PHASE_PRODUCTION_BUILD } from "../shims/constants.js";
|
|
2
|
+
//#region src/build/prerender-phase.ts
|
|
3
|
+
const activePrerenderPhases = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
/**
|
|
5
|
+
* Enter the same process environment phase that Next.js exposes while its
|
|
6
|
+
* static workers execute application code. The returned cleanup is nest-safe:
|
|
7
|
+
* direct prerender helpers can run inside the CLI's broader build scope without
|
|
8
|
+
* overwriting the caller's prior phase when they finish.
|
|
9
|
+
*/
|
|
10
|
+
function enterPrerenderPhase(env = process.env) {
|
|
11
|
+
let state = activePrerenderPhases.get(env);
|
|
12
|
+
if (state) state.depth += 1;
|
|
13
|
+
else {
|
|
14
|
+
state = {
|
|
15
|
+
depth: 1,
|
|
16
|
+
previousPrerenderFlag: env.VINEXT_PRERENDER,
|
|
17
|
+
previousNextPhase: env.NEXT_PHASE
|
|
18
|
+
};
|
|
19
|
+
activePrerenderPhases.set(env, state);
|
|
20
|
+
}
|
|
21
|
+
let restored = false;
|
|
22
|
+
env.VINEXT_PRERENDER = "1";
|
|
23
|
+
env.NEXT_PHASE = PHASE_PRODUCTION_BUILD;
|
|
24
|
+
return () => {
|
|
25
|
+
if (restored) return;
|
|
26
|
+
restored = true;
|
|
27
|
+
state.depth -= 1;
|
|
28
|
+
if (state.depth > 0) return;
|
|
29
|
+
activePrerenderPhases.delete(env);
|
|
30
|
+
if (state.previousPrerenderFlag === void 0) delete env.VINEXT_PRERENDER;
|
|
31
|
+
else env.VINEXT_PRERENDER = state.previousPrerenderFlag;
|
|
32
|
+
if (state.previousNextPhase === void 0) delete env.NEXT_PHASE;
|
|
33
|
+
else env.NEXT_PHASE = state.previousNextPhase;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { enterPrerenderPhase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
|
@@ -11,9 +11,9 @@ import { startProdServer } from "../server/prod-server.js";
|
|
|
11
11
|
* vinext production server on an ephemeral port and reports it to the parent
|
|
12
12
|
* over IPC. The parent then load-balances per-route fetches across the pool.
|
|
13
13
|
*
|
|
14
|
-
* `VINEXT_PRERENDER` / `VINEXT_PRERENDER_OUTDIR` are passed via
|
|
15
|
-
* they are set before any module loads (some server
|
|
16
|
-
* import time).
|
|
14
|
+
* `VINEXT_PRERENDER` / `NEXT_PHASE` / `VINEXT_PRERENDER_OUTDIR` are passed via
|
|
15
|
+
* the fork env so they are set before any module loads (some server and user
|
|
16
|
+
* modules read the phase at import time).
|
|
17
17
|
*/
|
|
18
18
|
async function main() {
|
|
19
19
|
const outDir = process.env.VINEXT_PRERENDER_OUTDIR;
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
declare function prerenderPoolAvailable(): boolean;
|
|
9
9
|
type PrerenderServerPool = {
|
|
10
|
-
/** Ports of the forked render servers, for round-robin per-route fetches. */
|
|
10
|
+
/** Ports of the forked render servers, for round-robin per-route fetches. */
|
|
11
|
+
ports: number[];
|
|
11
12
|
/**
|
|
12
13
|
* Throw if any worker exited unexpectedly (i.e. not via `close()`). The
|
|
13
14
|
* caller MUST call this after the render loop: a crashed worker makes every
|
|
@@ -21,7 +22,8 @@ type PrerenderServerPool = {
|
|
|
21
22
|
* Record a failed fetch to a render worker. This closes the tiny ordering gap
|
|
22
23
|
* where the request can fail before Node has delivered the child `exit` event.
|
|
23
24
|
*/
|
|
24
|
-
recordRenderError: (err: unknown) => void;
|
|
25
|
+
recordRenderError: (err: unknown) => void;
|
|
26
|
+
/** Kill every forked server. Safe to call more than once. */
|
|
25
27
|
close: () => Promise<void>;
|
|
26
28
|
};
|
|
27
29
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
+
import { PHASE_PRODUCTION_BUILD } from "../shims/constants.js";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
import os from "node:os";
|
|
@@ -105,6 +106,7 @@ async function startPrerenderServerPool(outDir, size, entry = WORKER_ENTRY) {
|
|
|
105
106
|
env: {
|
|
106
107
|
...process.env,
|
|
107
108
|
VINEXT_PRERENDER: "1",
|
|
109
|
+
NEXT_PHASE: PHASE_PRODUCTION_BUILD,
|
|
108
110
|
VINEXT_PRERENDER_OUTDIR: outDir
|
|
109
111
|
},
|
|
110
112
|
stdio: [
|
|
@@ -4,27 +4,39 @@ import { AppRoute } from "../routing/app-route-graph.js";
|
|
|
4
4
|
import { MetadataFileRoute } from "../server/metadata-routes.js";
|
|
5
5
|
import { readPrerenderSecret } from "./server-manifest.js";
|
|
6
6
|
import { Server } from "node:http";
|
|
7
|
-
|
|
8
7
|
//#region src/build/prerender.d.ts
|
|
9
8
|
type PrerenderResult = {
|
|
10
|
-
/** One entry per route (including skipped/error routes). */
|
|
9
|
+
/** One entry per route (including skipped/error routes). */
|
|
10
|
+
routes: PrerenderRouteResult[];
|
|
11
|
+
/** Additional generated files that are not represented as route entries. */
|
|
11
12
|
outputFiles?: string[];
|
|
12
13
|
};
|
|
13
14
|
type PrerenderRouteResult = {
|
|
14
|
-
/** The route's file-system pattern, e.g. `/blog/:slug`. */
|
|
15
|
+
/** The route's file-system pattern, e.g. `/blog/:slug`. */
|
|
16
|
+
route: string;
|
|
15
17
|
status: "rendered";
|
|
16
18
|
outputFiles: string[];
|
|
17
19
|
revalidate: number | false;
|
|
18
20
|
expire?: number;
|
|
21
|
+
/** Client-router reuse bound resolved from the prerender's `cacheLife`. */
|
|
22
|
+
stale?: number;
|
|
19
23
|
/**
|
|
20
24
|
* The concrete prerendered URL path, e.g. `/blog/hello-world`.
|
|
21
25
|
* Only present when the route is dynamic and `path` differs from `route`.
|
|
22
26
|
* Omitted for non-dynamic routes where pattern === path.
|
|
23
27
|
*/
|
|
24
|
-
path?: string;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
path?: string;
|
|
29
|
+
/** Which router produced this route. Used by cache seeding. */
|
|
30
|
+
router: "app" | "pages" | "metadata";
|
|
31
|
+
/** Response headers that must be replayed with the prerendered artifact. */
|
|
32
|
+
headers?: Record<string, string | string[]>;
|
|
33
|
+
/** Original HTTP status for prerendered App Route-style responses. */
|
|
34
|
+
responseStatus?: number;
|
|
35
|
+
/** Cache tags collected while rendering this route. */
|
|
36
|
+
tags?: string[];
|
|
37
|
+
/** Raw app-tree segments used to derive App Route implicit tags. */
|
|
38
|
+
routeSegments?: string[];
|
|
39
|
+
/** Set to true when this is a PPR fallback shell. */
|
|
28
40
|
fallback?: boolean;
|
|
29
41
|
} | {
|
|
30
42
|
route: string;
|
|
@@ -44,9 +56,13 @@ type PrerenderRouteResult = {
|
|
|
44
56
|
};
|
|
45
57
|
/** Called after each route is resolved (rendered, skipped, or error). */
|
|
46
58
|
type PrerenderProgressCallback = (update: {
|
|
47
|
-
/** Routes completed so far (rendered + skipped + error). */
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
/** Routes completed so far (rendered + skipped + error). */
|
|
60
|
+
completed: number;
|
|
61
|
+
/** Total routes queued for rendering. */
|
|
62
|
+
total: number;
|
|
63
|
+
/** The route URL that just finished. */
|
|
64
|
+
route: string;
|
|
65
|
+
/** Its final status. */
|
|
50
66
|
status: PrerenderRouteResult["status"];
|
|
51
67
|
}) => void;
|
|
52
68
|
type PrerenderOptions = {
|
|
@@ -54,7 +70,8 @@ type PrerenderOptions = {
|
|
|
54
70
|
* 'default' — prerender static/ISR routes; skip SSR routes
|
|
55
71
|
* 'export' — same as default but SSR routes are errors
|
|
56
72
|
*/
|
|
57
|
-
mode: "default" | "export";
|
|
73
|
+
mode: "default" | "export";
|
|
74
|
+
/** Output directory for generated HTML/RSC files. */
|
|
58
75
|
outDir: string;
|
|
59
76
|
/**
|
|
60
77
|
* Directory where `vinext-prerender.json` is written.
|
|
@@ -62,7 +79,8 @@ type PrerenderOptions = {
|
|
|
62
79
|
* Set this when the manifest should land in a different location than the
|
|
63
80
|
* generated HTML/RSC files (e.g. `dist/server/` while HTML goes to `dist/server/prerendered-routes/`).
|
|
64
81
|
*/
|
|
65
|
-
manifestDir?: string;
|
|
82
|
+
manifestDir?: string;
|
|
83
|
+
/** Resolved next.config.js. */
|
|
66
84
|
config: ResolvedNextConfig;
|
|
67
85
|
/**
|
|
68
86
|
* Maximum number of routes rendered in parallel.
|
|
@@ -82,8 +100,11 @@ type PrerenderOptions = {
|
|
|
82
100
|
skipManifest?: boolean;
|
|
83
101
|
};
|
|
84
102
|
type PrerenderPagesOptions = {
|
|
85
|
-
/** Discovered page routes (non-API). */
|
|
86
|
-
|
|
103
|
+
/** Discovered page routes (non-API). */
|
|
104
|
+
routes: Route[];
|
|
105
|
+
/** Discovered API routes. */
|
|
106
|
+
apiRoutes: Route[];
|
|
107
|
+
/** Pages directory path. */
|
|
87
108
|
pagesDir: string;
|
|
88
109
|
/**
|
|
89
110
|
* Absolute path to the pre-built Pages Router server bundle
|
|
@@ -95,7 +116,9 @@ type PrerenderPagesOptions = {
|
|
|
95
116
|
pagesBundlePath?: string;
|
|
96
117
|
} & PrerenderOptions;
|
|
97
118
|
type PrerenderAppOptions = {
|
|
98
|
-
/** Discovered app routes. */
|
|
119
|
+
/** Discovered app routes. */
|
|
120
|
+
routes: AppRoute[];
|
|
121
|
+
/** Discovered file-based metadata routes. Used by static export. */
|
|
99
122
|
metadataRoutes?: readonly MetadataFileRoute[];
|
|
100
123
|
/**
|
|
101
124
|
* Absolute path to the pre-built RSC handler bundle (e.g. `dist/server/index.js`).
|
|
@@ -172,15 +195,7 @@ declare function resolveParentParams(childRoute: AppRoute, staticParamsMap: Stat
|
|
|
172
195
|
* Writes HTML files to `outDir`. If `manifestDir` is set, writes
|
|
173
196
|
* `vinext-prerender.json` there; otherwise writes it to `outDir`.
|
|
174
197
|
*/
|
|
175
|
-
declare function prerenderPages({
|
|
176
|
-
routes,
|
|
177
|
-
apiRoutes,
|
|
178
|
-
pagesDir,
|
|
179
|
-
outDir,
|
|
180
|
-
config,
|
|
181
|
-
mode,
|
|
182
|
-
...options
|
|
183
|
-
}: PrerenderPagesOptionsInternal): Promise<PrerenderResult>;
|
|
198
|
+
declare function prerenderPages({ routes, apiRoutes, pagesDir, outDir, config, mode, ...options }: PrerenderPagesOptionsInternal): Promise<PrerenderResult>;
|
|
184
199
|
/**
|
|
185
200
|
* Run the prerender phase for App Router.
|
|
186
201
|
*
|
|
@@ -198,15 +213,7 @@ declare function prerenderPages({
|
|
|
198
213
|
* If they succeed, they are marked as rendered. If they throw a DynamicUsageError
|
|
199
214
|
* or fail, they are marked as skipped with reason 'dynamic'.
|
|
200
215
|
*/
|
|
201
|
-
declare function prerenderApp({
|
|
202
|
-
routes,
|
|
203
|
-
metadataRoutes,
|
|
204
|
-
outDir,
|
|
205
|
-
config,
|
|
206
|
-
mode,
|
|
207
|
-
rscBundlePath,
|
|
208
|
-
...options
|
|
209
|
-
}: PrerenderAppOptionsInternal): Promise<PrerenderResult>;
|
|
216
|
+
declare function prerenderApp({ routes, metadataRoutes, outDir, config, mode, rscBundlePath, ...options }: PrerenderAppOptionsInternal): Promise<PrerenderResult>;
|
|
210
217
|
/**
|
|
211
218
|
* Write `vinext-prerender.json` to `outDir`.
|
|
212
219
|
*
|