vinext 1.2.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -9
- package/dist/_virtual/_rolldown/runtime.js +1 -1
- package/dist/build/action-owner-manifest.d.ts +3 -2
- package/dist/build/action-owner-manifest.js +18 -2
- package/dist/build/app-page-static-eligibility.d.ts +17 -1
- package/dist/build/app-page-static-eligibility.js +80 -13
- package/dist/build/clean-output.d.ts +2 -1
- package/dist/build/client-build-config.d.ts +77 -6
- package/dist/build/client-build-config.js +176 -12
- package/dist/build/client-reference-async.d.ts +48 -0
- package/dist/build/client-reference-async.js +123 -0
- package/dist/build/client-reference-chunks.d.ts +32 -0
- package/dist/build/client-reference-chunks.js +111 -0
- package/dist/build/client-reference-groups.d.ts +171 -0
- package/dist/build/client-reference-groups.js +572 -0
- package/dist/build/css-url-assets.d.ts +2 -1
- package/dist/build/google-fonts/fallback-metrics.d.ts +2 -1
- package/dist/build/google-fonts/find-font-files-in-css.d.ts +1 -0
- package/dist/build/google-fonts/find-font-files-in-css.js +17 -4
- package/dist/build/google-fonts/font-metadata.d.ts +2 -1
- package/dist/build/google-fonts/validate.d.ts +2 -1
- package/dist/build/inline-css.d.ts +2 -1
- package/dist/build/layout-classification.d.ts +2 -1
- package/dist/build/module-dependency-cache.d.ts +33 -1
- package/dist/build/module-dependency-cache.js +51 -1
- package/dist/build/next-client-runtime-manifests.d.ts +12 -2
- package/dist/build/next-client-runtime-manifests.js +19 -4
- package/dist/build/nitro-public-files.d.ts +24 -0
- package/dist/build/nitro-public-files.js +60 -0
- package/dist/build/pages-client-assets-module.js +1 -1
- package/dist/build/precompress.d.ts +2 -1
- package/dist/build/precompress.js +1 -1
- package/dist/build/prerender-paths.d.ts +2 -1
- package/dist/build/prerender-paths.js +5 -2
- package/dist/build/prerender-phase.d.ts +2 -1
- package/dist/build/prerender-server-pool.js +1 -1
- package/dist/build/prerender.d.ts +3 -2
- package/dist/build/prerender.js +5 -4
- package/dist/build/report.d.ts +2 -1
- package/dist/build/route-classification-injector.d.ts +2 -1
- package/dist/build/route-classification-manifest.d.ts +2 -1
- package/dist/build/run-prerender.d.ts +2 -1
- package/dist/build/server-actions-encryption-key.d.ts +24 -0
- package/dist/build/server-actions-encryption-key.js +101 -0
- package/dist/build/ssr-manifest.d.ts +3 -0
- package/dist/build/ssr-manifest.js +34 -2
- package/dist/build/standalone.d.ts +2 -1
- package/dist/cache/cache-adapters-virtual.d.ts +2 -1
- package/dist/cache.js +1 -2
- package/dist/check.d.ts +2 -1
- package/dist/check.js +4 -0
- package/dist/cli-args.d.ts +2 -1
- package/dist/cli.js +2 -0
- package/dist/client/client-redirect-matcher.js +2 -1
- package/dist/client/client-redirects.d.ts +4 -3
- package/dist/client/client-redirects.js +2 -1
- package/dist/client/client-rewrite-params.d.ts +9 -0
- package/dist/client/client-rewrite-params.js +20 -0
- package/dist/client/client-rewrites.d.ts +2 -1
- package/dist/client/dev-error-overlay-store.d.ts +2 -1
- package/dist/client/dev-error-overlay.js +2 -1
- package/dist/client/index.js +1 -2
- package/dist/client/instrumentation-client-state.js +5 -5
- package/dist/client/navigation-runtime.d.ts +28 -3
- package/dist/client/navigation-runtime.js +42 -11
- package/dist/client/pages-router-link-navigation.d.ts +2 -1
- package/dist/client/vinext-next-data.d.ts +25 -2
- package/dist/client/window-next.d.ts +2 -1
- package/dist/config/config-matchers.d.ts +27 -41
- package/dist/config/config-matchers.js +293 -270
- package/dist/config/config-source.d.ts +34 -0
- package/dist/config/config-source.js +141 -0
- package/dist/config/dotenv.d.ts +2 -1
- package/dist/config/header-params.d.ts +29 -0
- package/dist/config/header-params.js +106 -0
- package/dist/config/next-config.d.ts +20 -6
- package/dist/config/next-config.js +149 -11
- package/dist/config/tsconfig-paths.d.ts +2 -1
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/detector.js +23 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/index.js +2 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/lookup.js +25 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/bmp.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/cur.js +15 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/dds.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/gif.js +12 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/heif.js +55 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/icns.js +76 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ico.js +39 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/index.js +46 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/j2c.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jp2.js +21 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jpg.js +71 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl-stream.js +42 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl.js +46 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ktx.js +19 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/png.js +28 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/pnm.js +54 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/psd.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/svg.js +79 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tga.js +15 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tiff.js +96 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/utils.js +53 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/webp.js +45 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/utils/bit-reader.js +38 -0
- package/dist/deps/.pnpm/ua-parser-js@1.0.35/deps/ua-parser-js/src/ua-parser.js +2 -2
- package/dist/entries/app-browser-entry.d.ts +34 -6
- package/dist/entries/app-browser-entry.js +103 -40
- package/dist/entries/app-rsc-entry.d.ts +4 -1
- package/dist/entries/app-rsc-entry.js +131 -66
- package/dist/entries/app-rsc-manifest.d.ts +12 -1
- package/dist/entries/app-rsc-manifest.js +73 -1
- package/dist/entries/app-ssr-entry.d.ts +4 -1
- package/dist/entries/app-ssr-entry.js +9 -2
- package/dist/entries/pages-client-entry.d.ts +1 -0
- package/dist/entries/pages-client-entry.js +6 -6
- package/dist/entries/pages-entry-helpers.js +1 -2
- package/dist/entries/pages-server-entry.d.ts +2 -1
- package/dist/entries/pages-server-entry.js +18 -15
- package/dist/entries/runtime-entry-module.d.ts +1 -0
- package/dist/entries/runtime-entry-module.js +4 -1
- package/dist/image/image-adapters-virtual.d.ts +2 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +340 -116
- package/dist/init.js +17 -0
- package/dist/plugins/client-compile-hints.d.ts +30 -0
- package/dist/plugins/client-compile-hints.js +88 -0
- package/dist/plugins/client-reference-dedup.d.ts +2 -1
- package/dist/plugins/cloudflare-dev-module-urls.d.ts +2 -1
- package/dist/plugins/dynamic-preload-metadata.d.ts +3 -1
- package/dist/plugins/dynamic-preload-metadata.js +1 -1
- package/dist/plugins/environment.d.ts +2 -1
- package/dist/plugins/fonts.js +9 -12
- package/dist/plugins/ignore-dynamic-requests.d.ts +2 -1
- package/dist/plugins/import-meta-url.d.ts +2 -1
- package/dist/plugins/og-assets.d.ts +2 -1
- package/dist/plugins/og-assets.js +2 -3
- package/dist/plugins/optimize-imports.d.ts +27 -3
- package/dist/plugins/optimize-imports.js +106 -20
- package/dist/plugins/pages-node-externals.d.ts +2 -1
- package/dist/plugins/remove-console.d.ts +2 -1
- package/dist/plugins/require-condition-resolution.d.ts +2 -1
- package/dist/plugins/rsc-client-reference-loaders.d.ts +53 -1
- package/dist/plugins/rsc-client-reference-loaders.js +447 -27
- package/dist/plugins/rsc-client-shim-excludes.js +2 -0
- package/dist/plugins/sass.d.ts +2 -1
- package/dist/plugins/strip-server-exports.d.ts +2 -1
- package/dist/plugins/styled-jsx.d.ts +2 -1
- package/dist/plugins/transform-result.d.ts +2 -1
- package/dist/plugins/typeof-window.d.ts +2 -1
- package/dist/plugins/use-cache-callable.d.ts +5 -0
- package/dist/plugins/use-cache-callable.js +30 -8
- package/dist/plugins/worker-image-imports.d.ts +1 -0
- package/dist/plugins/worker-image-imports.js +2 -2
- package/dist/plugins/worker-use-server.d.ts +2 -1
- package/dist/routing/app-route-graph.d.ts +41 -1
- package/dist/routing/app-route-graph.js +122 -50
- package/dist/routing/browser-route-manifest.d.ts +44 -0
- package/dist/routing/browser-route-manifest.js +195 -0
- package/dist/routing/hashed-route-patterns.d.ts +4 -0
- package/dist/routing/hashed-route-patterns.js +22 -0
- package/dist/routing/optimistic-route-trie.d.ts +28 -0
- package/dist/routing/optimistic-route-trie.js +102 -0
- package/dist/routing/route-matching.d.ts +2 -1
- package/dist/routing/route-pattern.d.ts +2 -1
- package/dist/routing/route-validation.d.ts +6 -1
- package/dist/routing/route-validation.js +26 -10
- package/dist/server/accept-encoding.d.ts +2 -1
- package/dist/server/app-action-forwarding.d.ts +10 -1
- package/dist/server/app-action-forwarding.js +15 -1
- package/dist/server/app-bfcache-identity.d.ts +2 -1
- package/dist/server/app-browser-action-result.d.ts +2 -1
- package/dist/server/app-browser-client-reuse-manifest.d.ts +2 -1
- package/dist/server/app-browser-entry.js +175 -64
- package/dist/server/app-browser-error.d.ts +5 -2
- package/dist/server/app-browser-error.js +7 -2
- package/dist/server/app-browser-history-controller.d.ts +2 -1
- package/dist/server/app-browser-hydration.d.ts +2 -1
- package/dist/server/app-browser-interception-context.d.ts +4 -3
- package/dist/server/app-browser-mpa-navigation.d.ts +1 -0
- package/dist/server/app-browser-mpa-navigation.js +6 -5
- package/dist/server/app-browser-navigation-controller.d.ts +17 -6
- package/dist/server/app-browser-navigation-controller.js +103 -36
- package/dist/server/app-browser-popstate.d.ts +2 -1
- package/dist/server/app-browser-rsc-redirect.d.ts +2 -1
- package/dist/server/app-browser-server-action-client.d.ts +2 -1
- package/dist/server/app-browser-state.d.ts +2 -2
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-stream.d.ts +2 -1
- package/dist/server/app-browser-visible-commit.d.ts +6 -5
- package/dist/server/app-client-reference-manifest.d.ts +31 -0
- package/dist/server/app-client-reference-manifest.js +46 -0
- package/dist/server/app-client-reference-preloader.d.ts +45 -2
- package/dist/server/app-client-reference-preloader.js +48 -10
- package/dist/server/app-elements-wire.d.ts +2 -1
- package/dist/server/app-elements.d.ts +2 -0
- package/dist/server/app-elements.js +3 -1
- package/dist/server/app-fallback-renderer.d.ts +9 -2
- package/dist/server/app-fallback-renderer.js +6 -2
- package/dist/server/app-history-state.d.ts +2 -1
- package/dist/server/app-inline-css-client.d.ts +2 -1
- package/dist/server/app-layout-param-observation.d.ts +2 -1
- package/dist/server/app-metadata-tracing.d.ts +2 -1
- package/dist/server/app-middleware.d.ts +6 -0
- package/dist/server/app-middleware.js +8 -10
- package/dist/server/app-optimistic-routing.d.ts +26 -11
- package/dist/server/app-optimistic-routing.js +38 -96
- package/dist/server/app-page-boundary-render.d.ts +20 -2
- package/dist/server/app-page-boundary-render.js +229 -39
- package/dist/server/app-page-boundary.d.ts +34 -5
- package/dist/server/app-page-boundary.js +40 -7
- package/dist/server/app-page-cache-finalizer.d.ts +2 -1
- package/dist/server/app-page-cache-finalizer.js +1 -1
- package/dist/server/app-page-cache-render.d.ts +10 -2
- package/dist/server/app-page-cache-render.js +15 -2
- package/dist/server/app-page-cache.js +2 -2
- package/dist/server/app-page-dispatch.d.ts +34 -1
- package/dist/server/app-page-dispatch.js +165 -34
- package/dist/server/app-page-element-builder.d.ts +17 -1
- package/dist/server/app-page-element-builder.js +187 -66
- package/dist/server/app-page-execution.d.ts +28 -1
- package/dist/server/app-page-execution.js +114 -5
- package/dist/server/app-page-head.d.ts +95 -3
- package/dist/server/app-page-head.js +307 -152
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +48 -2
- package/dist/server/app-page-http-access-fallback-metadata.js +76 -1
- package/dist/server/app-page-method.d.ts +2 -1
- package/dist/server/app-page-probe.d.ts +2 -1
- package/dist/server/app-page-render-identity.d.ts +2 -1
- package/dist/server/app-page-render.d.ts +7 -1
- package/dist/server/app-page-render.js +38 -11
- package/dist/server/app-page-request.d.ts +14 -1
- package/dist/server/app-page-request.js +1 -1
- package/dist/server/app-page-route-wiring.d.ts +52 -2
- package/dist/server/app-page-route-wiring.js +197 -47
- package/dist/server/app-page-rsc-render-status.d.ts +3 -1
- package/dist/server/app-page-rsc-render-status.js +1 -0
- package/dist/server/app-page-search-params-observation.d.ts +8 -6
- package/dist/server/app-page-search-params-observation.js +16 -11
- package/dist/server/app-page-segment-plan.d.ts +2 -1
- package/dist/server/app-page-stream.d.ts +38 -1
- package/dist/server/app-page-stream.js +24 -4
- package/dist/server/app-pages-bridge.d.ts +4 -2
- package/dist/server/app-pages-bridge.js +11 -7
- package/dist/server/app-ppr-fallback-shell-render.d.ts +2 -1
- package/dist/server/app-ppr-fallback-shell.d.ts +2 -1
- package/dist/server/app-prerender-endpoints.d.ts +2 -1
- package/dist/server/app-prerender-static-params.d.ts +2 -1
- package/dist/server/app-prerender-static-params.js +3 -2
- package/dist/server/app-render-dependency.d.ts +11 -1
- package/dist/server/app-render-dependency.js +65 -6
- package/dist/server/app-request-stage-independent-entry.d.ts +2 -1
- package/dist/server/app-request-stage-independent-entry.js +2 -2
- package/dist/server/app-response-stage-entry.d.ts +2 -1
- package/dist/server/app-response-stage-entry.js +3 -3
- package/dist/server/app-route-handler-cache.d.ts +2 -1
- package/dist/server/app-route-handler-dispatch.d.ts +2 -1
- package/dist/server/app-route-handler-dispatch.js +4 -2
- package/dist/server/app-route-handler-execution.d.ts +4 -1
- package/dist/server/app-route-handler-execution.js +9 -2
- package/dist/server/app-route-handler-middleware-context.d.ts +2 -1
- package/dist/server/app-route-handler-middleware-context.js +3 -3
- package/dist/server/app-route-handler-response.d.ts +4 -2
- package/dist/server/app-route-handler-response.js +2 -2
- package/dist/server/app-route-handler-runtime.d.ts +4 -1
- package/dist/server/app-route-handler-runtime.js +20 -3
- package/dist/server/app-route-module-loader.d.ts +18 -1
- package/dist/server/app-route-module-loader.js +15 -6
- package/dist/server/app-route-tree-prefetch.d.ts +2 -1
- package/dist/server/app-route-tree.d.ts +20 -0
- package/dist/server/app-route-tree.js +18 -0
- package/dist/server/app-router-entry.js +2 -2
- package/dist/server/app-rsc-combined-handler.js +8 -1
- package/dist/server/app-rsc-error-handler.d.ts +2 -1
- package/dist/server/app-rsc-errors.d.ts +9 -1
- package/dist/server/app-rsc-errors.js +9 -2
- package/dist/server/app-rsc-handler.d.ts +6 -2
- package/dist/server/app-rsc-handler.js +152 -140
- package/dist/server/app-rsc-response-finalizer.d.ts +7 -1
- package/dist/server/app-rsc-response-finalizer.js +4 -1
- package/dist/server/app-rsc-response-stage.js +3 -1
- package/dist/server/app-rsc-route-matching.d.ts +39 -1
- package/dist/server/app-rsc-route-matching.js +25 -1
- package/dist/server/app-segment-config.d.ts +2 -1
- package/dist/server/app-segment-config.js +1 -14
- package/dist/server/app-server-action-execution.d.ts +25 -7
- package/dist/server/app-server-action-execution.js +53 -59
- package/dist/server/app-ssr-entry.d.ts +12 -0
- package/dist/server/app-ssr-entry.js +104 -48
- package/dist/server/app-ssr-error-meta.d.ts +2 -1
- package/dist/server/app-ssr-search-params-gate.d.ts +2 -1
- package/dist/server/app-ssr-stream.d.ts +29 -10
- package/dist/server/app-ssr-stream.js +311 -67
- package/dist/server/app-static-generation.d.ts +2 -1
- package/dist/server/app-streamed-client-references.d.ts +39 -0
- package/dist/server/app-streamed-client-references.js +156 -0
- package/dist/server/app-visited-response-cache.d.ts +2 -1
- package/dist/server/app-worker-stages.d.ts +2 -1
- package/dist/server/artifact-compatibility.d.ts +2 -1
- package/dist/server/bfcache-identity.d.ts +2 -1
- package/dist/server/cache-headers.d.ts +2 -1
- package/dist/server/cacheability-request.d.ts +2 -1
- package/dist/server/client-reuse-manifest.d.ts +2 -1
- package/dist/server/config-headers.d.ts +2 -1
- package/dist/server/config-headers.js +12 -3
- package/dist/server/csp.d.ts +2 -1
- package/dist/server/default-global-not-found-module.d.ts +2 -1
- package/dist/server/default-http-access-fallback-modules.d.ts +33 -0
- package/dist/server/default-http-access-fallback-modules.js +31 -0
- package/dist/server/defer-until-stream-consumed.d.ts +34 -0
- package/dist/server/defer-until-stream-consumed.js +154 -21
- package/dist/server/dev-lockfile.d.ts +32 -2
- package/dist/server/dev-lockfile.js +46 -2
- package/dist/server/dev-module-runner.d.ts +2 -1
- package/dist/server/dev-server.js +10 -3
- package/dist/server/fetch-handler.js +1 -2
- package/dist/server/file-based-metadata.d.ts +2 -1
- package/dist/server/framework-tracer.d.ts +2 -1
- package/dist/server/html.d.ts +1 -0
- package/dist/server/html.js +19 -1
- package/dist/server/http-conditional.d.ts +2 -1
- package/dist/server/http-error-responses.d.ts +2 -1
- package/dist/server/implicit-tags.d.ts +2 -1
- package/dist/server/isolate-shared-promise.d.ts +10 -0
- package/dist/server/isolate-shared-promise.js +33 -0
- package/dist/server/isr-cache.js +3 -2
- package/dist/server/metadata-route-build-data.d.ts +2 -1
- package/dist/server/metadata-route-build-data.js +1 -1
- package/dist/server/metadata-route-response.d.ts +2 -1
- package/dist/server/metadata-route-response.js +1 -1
- package/dist/server/metadata-routes.d.ts +2 -1
- package/dist/server/middleware-matcher-pattern.d.ts +0 -1
- package/dist/server/middleware-matcher-pattern.js +11 -140
- package/dist/server/middleware-matcher.js +5 -6
- package/dist/server/middleware-response-headers.d.ts +31 -0
- package/dist/server/middleware-response-headers.js +57 -1
- package/dist/server/middleware-runtime.d.ts +2 -1
- package/dist/server/middleware-runtime.js +26 -13
- package/dist/server/navigation-planner.d.ts +2 -2
- package/dist/server/navigation-trace.d.ts +2 -1
- package/dist/server/next-error-digest.d.ts +2 -1
- package/dist/server/nitro-public-files-plugin.d.ts +39 -0
- package/dist/server/nitro-public-files-plugin.js +106 -0
- package/dist/server/nitro-public-files.d.ts +22 -0
- package/dist/server/nitro-public-files.js +39 -0
- package/dist/server/opentelemetry-api.d.ts +2 -1
- package/dist/server/operation-token.d.ts +2 -1
- package/dist/server/pages-api-route.d.ts +2 -1
- package/dist/server/pages-asset-tags.d.ts +7 -1
- package/dist/server/pages-asset-tags.js +9 -2
- package/dist/server/pages-body-parser-config.d.ts +2 -1
- package/dist/server/pages-client-assets.d.ts +8 -1
- package/dist/server/pages-data-route.d.ts +2 -1
- package/dist/server/pages-document-asset-props.d.ts +2 -1
- package/dist/server/pages-document-initial-props.d.ts +2 -1
- package/dist/server/pages-execution-tracing.d.ts +2 -1
- package/dist/server/pages-execution-tracing.js +1 -1
- package/dist/server/pages-get-initial-props.d.ts +2 -1
- package/dist/server/pages-i18n.d.ts +18 -0
- package/dist/server/pages-i18n.js +18 -2
- package/dist/server/pages-node-compat.d.ts +5 -3
- package/dist/server/pages-node-compat.js +35 -16
- package/dist/server/pages-page-data.d.ts +7 -1
- package/dist/server/pages-page-data.js +35 -12
- package/dist/server/pages-page-handler.d.ts +3 -2
- package/dist/server/pages-page-handler.js +16 -7
- package/dist/server/pages-page-method.d.ts +2 -1
- package/dist/server/pages-page-response.d.ts +2 -1
- package/dist/server/pages-preview.d.ts +2 -1
- package/dist/server/pages-readiness.d.ts +2 -1
- package/dist/server/pages-request-pipeline.d.ts +8 -2
- package/dist/server/pages-request-pipeline.js +35 -40
- package/dist/server/pages-request-stage-entry.d.ts +2 -1
- package/dist/server/pages-request-stage-entry.js +16 -6
- package/dist/server/pages-response-stage-entry.d.ts +2 -1
- package/dist/server/pages-response-stage-entry.js +1 -1
- package/dist/server/pages-revalidate.js +1 -0
- package/dist/server/pages-route-data-kind.d.ts +2 -1
- package/dist/server/pages-router-entry.js +1 -1
- package/dist/server/prerender-cache-life-header.d.ts +2 -1
- package/dist/server/prerender-route-params.d.ts +2 -1
- package/dist/server/prod-server.d.ts +2 -2
- package/dist/server/prod-server.js +80 -36
- package/dist/server/proxy-trust.d.ts +6 -0
- package/dist/server/proxy-trust.js +12 -6
- package/dist/server/request-log.d.ts +2 -1
- package/dist/server/request-pipeline.d.ts +5 -0
- package/dist/server/request-pipeline.js +12 -1
- package/dist/server/request-tracing.d.ts +2 -1
- package/dist/server/request-tracing.js +1 -1
- package/dist/server/response-start-tracing.js +7 -29
- package/dist/server/rsc-render-stream.d.ts +4 -0
- package/dist/server/rsc-render-stream.js +25 -0
- package/dist/server/seed-cache.d.ts +2 -1
- package/dist/server/seed-cache.js +1 -1
- package/dist/server/server-reference-loader.js +10 -1
- package/dist/server/static-file-cache.d.ts +2 -1
- package/dist/server/static-file-cache.js +16 -3
- package/dist/server/static-layout-client-reuse-proof.d.ts +2 -1
- package/dist/server/worker-revalidation-context.d.ts +2 -1
- package/dist/server/worker-stages.d.ts +2 -1
- package/dist/server/worker-utils.js +1 -1
- package/dist/shims/app.d.ts +2 -1
- package/dist/shims/cache-callable-runtime.d.ts +2 -1
- package/dist/shims/cache-handler.d.ts +8 -3
- package/dist/shims/cache-handler.js +32 -11
- package/dist/shims/cache-request-state.d.ts +40 -3
- package/dist/shims/cache-request-state.js +70 -5
- package/dist/shims/cache-runtime.js +47 -19
- package/dist/shims/cache.d.ts +2 -2
- package/dist/shims/cache.js +17 -8
- package/dist/shims/caught-not-found-boundaries.d.ts +15 -0
- package/dist/shims/caught-not-found-boundaries.js +48 -0
- package/dist/shims/cdn-purge-routes.d.ts +25 -0
- package/dist/shims/cdn-purge-routes.js +77 -0
- package/dist/shims/client-locale.js +2 -1
- package/dist/shims/client-page-root.d.ts +2 -1
- package/dist/shims/config.d.ts +2 -1
- package/dist/shims/default-forbidden.d.ts +4 -0
- package/dist/shims/default-forbidden.js +18 -0
- package/dist/shims/default-not-found.d.ts +0 -5
- package/dist/shims/default-not-found.js +5 -41
- package/dist/shims/default-unauthorized.d.ts +4 -0
- package/dist/shims/default-unauthorized.js +18 -0
- package/dist/shims/dynamic.js +17 -4
- package/dist/shims/error-boundary.d.ts +39 -3
- package/dist/shims/error-boundary.js +31 -16
- package/dist/shims/font-google.js +1 -2
- package/dist/shims/font-utils.d.ts +3 -2
- package/dist/shims/font-utils.js +5 -3
- package/dist/shims/form.js +9 -4
- package/dist/shims/http-access-error-fallback.d.ts +7 -0
- package/dist/shims/http-access-error-fallback.js +47 -0
- package/dist/shims/image-props.d.ts +93 -0
- package/dist/shims/image-props.js +323 -0
- package/dist/shims/image.d.ts +4 -39
- package/dist/shims/image.js +4 -319
- package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +22 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.js +71 -18
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +14 -3
- package/dist/shims/internal/app-route-prefetch-policy.js +29 -4
- package/dist/shims/internal/cache-context-accessor.d.ts +2 -1
- package/dist/shims/internal/client-reference-loader.d.ts +7 -0
- package/dist/shims/internal/client-reference-loader.js +91 -0
- package/dist/shims/internal/cookie-serialize.d.ts +2 -1
- package/dist/shims/internal/cookies.js +1 -2
- package/dist/shims/internal/headers-state.d.ts +9 -0
- package/dist/shims/internal/headers-state.js +19 -2
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +6 -2
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +31 -14
- package/dist/shims/internal/hybrid-client-route-owner.js +8 -8
- package/dist/shims/internal/interpolate-as.d.ts +2 -1
- package/dist/shims/internal/pages-data-target.d.ts +2 -1
- package/dist/shims/internal/pages-data-url.d.ts +2 -1
- package/dist/shims/internal/thenable-well-known-properties.d.ts +2 -1
- package/dist/shims/link.js +198 -53
- package/dist/shims/metadata.d.ts +32 -11
- package/dist/shims/metadata.js +88 -26
- package/dist/shims/navigation-errors.d.ts +2 -1
- package/dist/shims/navigation.d.ts +23 -3
- package/dist/shims/navigation.js +91 -25
- package/dist/shims/og.js +35 -10
- package/dist/shims/pages-router-runtime.d.ts +2 -1
- package/dist/shims/ppr-fallback-shell.d.ts +2 -1
- package/dist/shims/request-context.d.ts +13 -0
- package/dist/shims/router.js +33 -43
- package/dist/shims/server.d.ts +31 -4
- package/dist/shims/server.js +58 -10
- package/dist/shims/thenable-params.d.ts +6 -1
- package/dist/shims/thenable-params.js +11 -2
- package/dist/shims/unified-request-context.d.ts +5 -0
- package/dist/shims/unified-request-context.js +5 -3
- package/dist/typegen.d.ts +2 -1
- package/dist/utils/asset-prefix.d.ts +7 -0
- package/dist/utils/asset-prefix.js +10 -1
- package/dist/utils/client-build-manifest.d.ts +4 -1
- package/dist/utils/client-build-manifest.js +20 -6
- package/dist/utils/client-entry-manifest.d.ts +13 -0
- package/dist/utils/client-entry-manifest.js +20 -1
- package/dist/utils/client-reference-chunks.d.ts +45 -0
- package/dist/utils/client-reference-chunks.js +30 -0
- package/dist/utils/client-runtime-metadata.d.ts +10 -1
- package/dist/utils/client-runtime-metadata.js +53 -9
- package/dist/utils/compare.d.ts +9 -0
- package/dist/utils/compare.js +15 -1
- package/dist/utils/lazy-chunks.d.ts +18 -0
- package/dist/utils/lazy-chunks.js +27 -1
- package/dist/utils/manifest-paths.d.ts +14 -0
- package/dist/utils/manifest-paths.js +22 -1
- package/dist/utils/middleware-request-headers.d.ts +2 -1
- package/dist/utils/path-to-regexp.d.ts +21 -0
- package/dist/{server/middleware-path-to-regexp.js → utils/path-to-regexp.js} +14 -11
- package/dist/utils/plugin-react-version.d.ts +15 -0
- package/dist/utils/plugin-react-version.js +64 -0
- package/dist/utils/project.d.ts +2 -1
- package/dist/utils/project.js +9 -1
- package/dist/utils/public-routes.d.ts +2 -0
- package/dist/utils/public-routes.js +18 -7
- package/dist/utils/query.d.ts +2 -1
- package/dist/utils/sorted-array.d.ts +2 -1
- package/dist/utils/vite-cli-invocation.d.ts +2 -1
- package/package.json +5 -5
- package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +0 -808
- package/dist/server/default-not-found-module.d.ts +0 -19
- package/dist/server/default-not-found-module.js +0 -18
- package/dist/server/middleware-path-to-regexp.d.ts +0 -13
- package/dist/server/rsc-stream-hints.d.ts +0 -21
- package/dist/server/rsc-stream-hints.js +0 -227
- package/dist/utils/regex-safety.d.ts +0 -17
- package/dist/utils/regex-safety.js +0 -789
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region src/build/client-reference-async.d.ts
|
|
2
|
+
type AsyncModuleGraphInfo = {
|
|
3
|
+
code: string | null;
|
|
4
|
+
importedIds: readonly string[];
|
|
5
|
+
};
|
|
6
|
+
/** A chunk of the emitted output, as `renderChunk`'s `meta.chunks` lists it. */
|
|
7
|
+
export type EmittedChunk = {
|
|
8
|
+
fileName: string;
|
|
9
|
+
/** The chunks it imports statically, by file name, and its externals. */
|
|
10
|
+
imports: readonly string[];
|
|
11
|
+
/** Its modules, with their code after tree-shaking. */
|
|
12
|
+
modules: Readonly<Record<string, {
|
|
13
|
+
code: string | null;
|
|
14
|
+
renderedLength: number;
|
|
15
|
+
}>>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Whether `code` awaits at the top level of the module: an `await`, a
|
|
19
|
+
* `for await` or an `await using` outside any function. Code that fails to
|
|
20
|
+
* parse counts as synchronous.
|
|
21
|
+
*/
|
|
22
|
+
export declare function hasTopLevelAwait(code: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The `roots` whose evaluation is asynchronous in the emitted output: the
|
|
25
|
+
* module, or a module it imports at any depth, awaits at its top level. Webpack
|
|
26
|
+
* calls these async modules, and React's Flight client suspends on them as they
|
|
27
|
+
* load. Only what the output keeps counts: modules tree-shaking dropped don't
|
|
28
|
+
* make a module async. Neither do imports of a module in a chunk the
|
|
29
|
+
* importer's chunks never load, nor of one `declaresSideEffects` reports, which
|
|
30
|
+
* the output drops when unused. Other imports stay: the imported module's side
|
|
31
|
+
* effects, its await included, run before the importer.
|
|
32
|
+
*/
|
|
33
|
+
export declare function collectAsyncModules(options: {
|
|
34
|
+
roots: readonly string[];
|
|
35
|
+
getModuleInfo: (id: string) => AsyncModuleGraphInfo | null;
|
|
36
|
+
chunks: readonly EmittedChunk[];
|
|
37
|
+
declaresSideEffects?: (id: string) => boolean;
|
|
38
|
+
}): Set<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Whether a module's package declares which of its modules have side effects
|
|
41
|
+
* (`sideEffects` other than `true` in the nearest package.json naming a
|
|
42
|
+
* package or declaring it). A bundler drops an unused import of a module the
|
|
43
|
+
* declaration marks side-effect-free, which Rolldown's module info doesn't
|
|
44
|
+
* report, so an import into such a package may not survive.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createSideEffectsDeclarationCheck(): (id: string) => boolean;
|
|
47
|
+
//#endregion
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
+
import { parseProgram, walkAst } from "../plugins/ast-utils.js";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
//#region src/build/client-reference-async.ts
|
|
5
|
+
/**
|
|
6
|
+
* Whether `code` awaits at the top level of the module: an `await`, a
|
|
7
|
+
* `for await` or an `await using` outside any function. Code that fails to
|
|
8
|
+
* parse counts as synchronous.
|
|
9
|
+
*/
|
|
10
|
+
function hasTopLevelAwait(code) {
|
|
11
|
+
if (!code.includes("await")) return false;
|
|
12
|
+
let program;
|
|
13
|
+
try {
|
|
14
|
+
program = parseProgram(code, { sourceType: "module" });
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
let found = false;
|
|
19
|
+
walkAst(program, (node) => {
|
|
20
|
+
if (found) return false;
|
|
21
|
+
if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") return false;
|
|
22
|
+
if (node.type === "AwaitExpression") {
|
|
23
|
+
found = true;
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (node.type === "ForOfStatement" && node.await || node.type === "VariableDeclaration" && node.kind === "await using") found = true;
|
|
27
|
+
});
|
|
28
|
+
return found;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The `roots` whose evaluation is asynchronous in the emitted output: the
|
|
32
|
+
* module, or a module it imports at any depth, awaits at its top level. Webpack
|
|
33
|
+
* calls these async modules, and React's Flight client suspends on them as they
|
|
34
|
+
* load. Only what the output keeps counts: modules tree-shaking dropped don't
|
|
35
|
+
* make a module async. Neither do imports of a module in a chunk the
|
|
36
|
+
* importer's chunks never load, nor of one `declaresSideEffects` reports, which
|
|
37
|
+
* the output drops when unused. Other imports stay: the imported module's side
|
|
38
|
+
* effects, its await included, run before the importer.
|
|
39
|
+
*/
|
|
40
|
+
function collectAsyncModules(options) {
|
|
41
|
+
const chunkOf = /* @__PURE__ */ new Map();
|
|
42
|
+
for (const chunk of options.chunks) for (const [id, module] of Object.entries(chunk.modules)) if (module.renderedLength > 0) chunkOf.set(id, chunk);
|
|
43
|
+
const chunksByFile = new Map(options.chunks.map((chunk) => [chunk.fileName, chunk]));
|
|
44
|
+
const loadedChunks = /* @__PURE__ */ new Map();
|
|
45
|
+
const chunksLoadedWith = (chunk) => {
|
|
46
|
+
let files = loadedChunks.get(chunk);
|
|
47
|
+
if (files) return files;
|
|
48
|
+
files = /* @__PURE__ */ new Set([chunk.fileName]);
|
|
49
|
+
const queue = [chunk];
|
|
50
|
+
for (let index = 0; index < queue.length; index++) for (const file of queue[index].imports) {
|
|
51
|
+
const imported = chunksByFile.get(file);
|
|
52
|
+
if (!imported || files.has(file)) continue;
|
|
53
|
+
files.add(file);
|
|
54
|
+
queue.push(imported);
|
|
55
|
+
}
|
|
56
|
+
loadedChunks.set(chunk, files);
|
|
57
|
+
return files;
|
|
58
|
+
};
|
|
59
|
+
const importers = /* @__PURE__ */ new Map();
|
|
60
|
+
const awaiting = [];
|
|
61
|
+
const visited = /* @__PURE__ */ new Set();
|
|
62
|
+
const stack = options.roots.filter((id) => chunkOf.has(id));
|
|
63
|
+
while (stack.length > 0) {
|
|
64
|
+
const id = stack.pop();
|
|
65
|
+
if (visited.has(id)) continue;
|
|
66
|
+
visited.add(id);
|
|
67
|
+
const chunk = chunkOf.get(id);
|
|
68
|
+
const info = options.getModuleInfo(id);
|
|
69
|
+
const code = chunk.modules[id].code ?? info?.code ?? null;
|
|
70
|
+
if (code !== null && hasTopLevelAwait(code)) awaiting.push(id);
|
|
71
|
+
const loaded = chunksLoadedWith(chunk);
|
|
72
|
+
for (const imported of info?.importedIds ?? []) {
|
|
73
|
+
const importedChunk = chunkOf.get(imported);
|
|
74
|
+
if (!importedChunk || !loaded.has(importedChunk.fileName)) continue;
|
|
75
|
+
if (options.declaresSideEffects?.(imported)) continue;
|
|
76
|
+
let list = importers.get(imported);
|
|
77
|
+
if (!list) importers.set(imported, list = []);
|
|
78
|
+
list.push(id);
|
|
79
|
+
stack.push(imported);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const asyncModules = new Set(awaiting);
|
|
83
|
+
for (let index = 0; index < awaiting.length; index++) for (const importer of importers.get(awaiting[index]) ?? []) {
|
|
84
|
+
if (asyncModules.has(importer)) continue;
|
|
85
|
+
asyncModules.add(importer);
|
|
86
|
+
awaiting.push(importer);
|
|
87
|
+
}
|
|
88
|
+
return new Set(options.roots.filter((id) => asyncModules.has(id)));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Whether a module's package declares which of its modules have side effects
|
|
92
|
+
* (`sideEffects` other than `true` in the nearest package.json naming a
|
|
93
|
+
* package or declaring it). A bundler drops an unused import of a module the
|
|
94
|
+
* declaration marks side-effect-free, which Rolldown's module info doesn't
|
|
95
|
+
* report, so an import into such a package may not survive.
|
|
96
|
+
*/
|
|
97
|
+
function createSideEffectsDeclarationCheck() {
|
|
98
|
+
const byDirectory = /* @__PURE__ */ new Map();
|
|
99
|
+
const declares = (directory) => {
|
|
100
|
+
const cached = byDirectory.get(directory);
|
|
101
|
+
if (cached !== void 0) return cached;
|
|
102
|
+
let pkg;
|
|
103
|
+
try {
|
|
104
|
+
pkg = JSON.parse(fs.readFileSync(path.join(directory, "package.json"), "utf8"));
|
|
105
|
+
} catch {
|
|
106
|
+
pkg = void 0;
|
|
107
|
+
}
|
|
108
|
+
let result;
|
|
109
|
+
if (pkg && typeof pkg === "object" && ("sideEffects" in pkg || "name" in pkg)) result = "sideEffects" in pkg && pkg.sideEffects !== true;
|
|
110
|
+
else {
|
|
111
|
+
const parent = path.dirname(directory);
|
|
112
|
+
result = parent !== directory && declares(parent);
|
|
113
|
+
}
|
|
114
|
+
byDirectory.set(directory, result);
|
|
115
|
+
return result;
|
|
116
|
+
};
|
|
117
|
+
return (id) => {
|
|
118
|
+
const file = id.split("?")[0];
|
|
119
|
+
return !id.startsWith("\0") && path.isAbsolute(file) && declares(path.dirname(file));
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { collectAsyncModules, createSideEffectsDeclarationCheck, hasTopLevelAwait };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ClientReferenceChunks } from "../utils/client-reference-chunks.js";
|
|
2
|
+
import { ResolvedConfig, Rollup } from "vite";
|
|
3
|
+
//#region src/build/client-reference-chunks.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Collect what each App Router client reference loads in the browser from the
|
|
6
|
+
* client bundle: the chunk holding the module that registers it (see
|
|
7
|
+
* plugins/rsc-client-reference-loaders.ts), and the JS chunks and stylesheets
|
|
8
|
+
* that chunk needs, as Vite's preload helper would load them for a dynamic
|
|
9
|
+
* import. JS chunks the App browser entry imports statically have loaded
|
|
10
|
+
* before any Flight row decodes, so they are left out.
|
|
11
|
+
*
|
|
12
|
+
* @param moduleKeys Client reference modules by resolved id, with the keys of
|
|
13
|
+
* the references each registers.
|
|
14
|
+
* @param modulePreload The client build's `build.modulePreload`, which picks
|
|
15
|
+
* the JS chunks to modulepreload, as it does for Vite's preload helper. Its
|
|
16
|
+
* `resolveDependencies` sees the chunk that dynamically imports each
|
|
17
|
+
* registering module as the host, as Vite passes it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function collectClientReferenceChunks(bundle: Rollup.OutputBundle, moduleKeys: ReadonlyMap<string, readonly string[]>, appBrowserEntry: Rollup.OutputChunk | undefined, modulePreload?: ResolvedConfig["build"]["modulePreload"]): ClientReferenceChunks | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Vite's build manifest keys a dynamic import by the module it imports, and
|
|
22
|
+
* next/dynamic's SSR preloads look up the module a boundary imports (see
|
|
23
|
+
* shims/dynamic-preload-chunks.tsx). The client build imports a client
|
|
24
|
+
* reference outside every group through the module that registers it, not
|
|
25
|
+
* the reference's own module, so map the reference's module to the chunk of
|
|
26
|
+
* the module that registers it, keyed as Vite keys a manifest entry.
|
|
27
|
+
*
|
|
28
|
+
* @param getImportedIds A module's static imports, as the bundler resolved
|
|
29
|
+
* them.
|
|
30
|
+
*/
|
|
31
|
+
export declare function collectClientReferenceSources(bundle: Rollup.OutputBundle, getImportedIds: (moduleId: string) => readonly string[] | undefined, root: string): Record<string, string> | undefined;
|
|
32
|
+
//#endregion
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import "../plugins/rsc-client-reference-loaders.js";
|
|
2
|
+
import { toManifestModuleId } from "../plugins/dynamic-preload-metadata.js";
|
|
3
|
+
//#region src/build/client-reference-chunks.ts
|
|
4
|
+
/** As Vite's preload helper tells a stylesheet: by its URL's path. */
|
|
5
|
+
function isStylesheet(file) {
|
|
6
|
+
return new URL(file, "http://vinext.local/").pathname.endsWith(".css");
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Collect what each App Router client reference loads in the browser from the
|
|
10
|
+
* client bundle: the chunk holding the module that registers it (see
|
|
11
|
+
* plugins/rsc-client-reference-loaders.ts), and the JS chunks and stylesheets
|
|
12
|
+
* that chunk needs, as Vite's preload helper would load them for a dynamic
|
|
13
|
+
* import. JS chunks the App browser entry imports statically have loaded
|
|
14
|
+
* before any Flight row decodes, so they are left out.
|
|
15
|
+
*
|
|
16
|
+
* @param moduleKeys Client reference modules by resolved id, with the keys of
|
|
17
|
+
* the references each registers.
|
|
18
|
+
* @param modulePreload The client build's `build.modulePreload`, which picks
|
|
19
|
+
* the JS chunks to modulepreload, as it does for Vite's preload helper. Its
|
|
20
|
+
* `resolveDependencies` sees the chunk that dynamically imports each
|
|
21
|
+
* registering module as the host, as Vite passes it.
|
|
22
|
+
*/
|
|
23
|
+
function collectClientReferenceChunks(bundle, moduleKeys, appBrowserEntry, modulePreload) {
|
|
24
|
+
const chunks = /* @__PURE__ */ new Map();
|
|
25
|
+
let host;
|
|
26
|
+
for (const output of Object.values(bundle)) {
|
|
27
|
+
if (output.type !== "chunk") continue;
|
|
28
|
+
chunks.set(output.fileName, output);
|
|
29
|
+
if (output.facadeModuleId === "\0virtual:vinext-client-reference-chunks") host = output;
|
|
30
|
+
}
|
|
31
|
+
const staticImports = (chunk) => {
|
|
32
|
+
const seen = /* @__PURE__ */ new Set([chunk.fileName]);
|
|
33
|
+
const order = [chunk];
|
|
34
|
+
for (let i = 0; i < order.length; i++) for (const file of order[i].imports) {
|
|
35
|
+
const imported = chunks.get(file);
|
|
36
|
+
if (!imported || seen.has(file)) continue;
|
|
37
|
+
seen.add(file);
|
|
38
|
+
order.push(imported);
|
|
39
|
+
}
|
|
40
|
+
return order;
|
|
41
|
+
};
|
|
42
|
+
const eager = new Set(appBrowserEntry ? staticImports(appBrowserEntry).map((chunk) => chunk.fileName) : []);
|
|
43
|
+
const result = {
|
|
44
|
+
references: {},
|
|
45
|
+
modules: []
|
|
46
|
+
};
|
|
47
|
+
for (const chunk of chunks.values()) {
|
|
48
|
+
const keys = chunk.moduleIds.flatMap((moduleId) => moduleKeys.get(moduleId) ?? []);
|
|
49
|
+
if (keys.length === 0) continue;
|
|
50
|
+
const imports = [];
|
|
51
|
+
const css = /* @__PURE__ */ new Set();
|
|
52
|
+
const visited = /* @__PURE__ */ new Set();
|
|
53
|
+
const addDeps = (loaded) => {
|
|
54
|
+
if (visited.has(loaded.fileName)) return;
|
|
55
|
+
visited.add(loaded.fileName);
|
|
56
|
+
if (loaded !== chunk) imports.push(loaded.fileName);
|
|
57
|
+
for (const file of loaded.imports) {
|
|
58
|
+
const imported = chunks.get(file);
|
|
59
|
+
if (imported) addDeps(imported);
|
|
60
|
+
}
|
|
61
|
+
for (const file of loaded.viteMetadata?.importedCss ?? []) css.add(file);
|
|
62
|
+
};
|
|
63
|
+
addDeps(chunk);
|
|
64
|
+
let preloads = imports.length + css.size > 0 ? [chunk.fileName, ...imports] : [];
|
|
65
|
+
let stylesheets = [...css];
|
|
66
|
+
if (modulePreload === false) preloads = [];
|
|
67
|
+
else if (modulePreload?.resolveDependencies && host) {
|
|
68
|
+
const resolved = modulePreload.resolveDependencies(chunk.fileName, preloads, {
|
|
69
|
+
hostId: host.fileName,
|
|
70
|
+
hostType: "js"
|
|
71
|
+
});
|
|
72
|
+
preloads = resolved.filter((file) => !isStylesheet(file));
|
|
73
|
+
stylesheets = [.../* @__PURE__ */ new Set([...resolved.filter(isStylesheet), ...css])];
|
|
74
|
+
}
|
|
75
|
+
preloads = [...new Set(preloads)].filter((file) => !eager.has(file) && (file !== chunk.fileName || stylesheets.length > 0));
|
|
76
|
+
const index = result.modules.push({
|
|
77
|
+
file: chunk.fileName,
|
|
78
|
+
imports: preloads,
|
|
79
|
+
css: stylesheets
|
|
80
|
+
}) - 1;
|
|
81
|
+
for (const key of keys) result.references[key] = index;
|
|
82
|
+
}
|
|
83
|
+
return result.modules.length > 0 ? result : void 0;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Vite's build manifest keys a dynamic import by the module it imports, and
|
|
87
|
+
* next/dynamic's SSR preloads look up the module a boundary imports (see
|
|
88
|
+
* shims/dynamic-preload-chunks.tsx). The client build imports a client
|
|
89
|
+
* reference outside every group through the module that registers it, not
|
|
90
|
+
* the reference's own module, so map the reference's module to the chunk of
|
|
91
|
+
* the module that registers it, keyed as Vite keys a manifest entry.
|
|
92
|
+
*
|
|
93
|
+
* @param getImportedIds A module's static imports, as the bundler resolved
|
|
94
|
+
* them.
|
|
95
|
+
*/
|
|
96
|
+
function collectClientReferenceSources(bundle, getImportedIds, root) {
|
|
97
|
+
const sources = {};
|
|
98
|
+
for (const output of Object.values(bundle)) {
|
|
99
|
+
if (output.type !== "chunk") continue;
|
|
100
|
+
for (const moduleId of output.moduleIds) {
|
|
101
|
+
if (!moduleId.startsWith("\0virtual:vinext-client-reference-module/")) continue;
|
|
102
|
+
const source = getImportedIds(moduleId)?.at(-1);
|
|
103
|
+
if (source === void 0 || source.startsWith("\0")) continue;
|
|
104
|
+
const key = toManifestModuleId(root, source);
|
|
105
|
+
if (key) sources[key] = output.fileName;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return Object.keys(sources).length > 0 ? sources : void 0;
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { collectClientReferenceChunks, collectClientReferenceSources };
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { actionOwnerRouteEntryIds } from "./action-owner-manifest.js";
|
|
2
|
+
import { Rollup } from "vite";
|
|
3
|
+
//#region src/build/client-reference-groups.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Client references whose estimated group cost (see
|
|
6
|
+
* {@link measureClientReferenceGroupCosts}) is larger than this many
|
|
7
|
+
* transformed source bytes keep their own lazy chunk instead of joining a route
|
|
8
|
+
* group. Grouping makes every member load with the group, so a heavy component
|
|
9
|
+
* that a route can reach but rarely renders must not be pulled into that
|
|
10
|
+
* route's startup bundle.
|
|
11
|
+
*/
|
|
12
|
+
export declare const CLIENT_REFERENCE_GROUP_MAX_COST_BYTES: number;
|
|
13
|
+
type ClientReferenceGroupRoute = Parameters<typeof actionOwnerRouteEntryIds>[0];
|
|
14
|
+
type ModuleGraphInfo = Pick<Rollup.ModuleInfo, "dynamicallyImportedIds" | "importedIds">;
|
|
15
|
+
/**
|
|
16
|
+
* Map each client reference reachable from App Router route files to a
|
|
17
|
+
* signature naming the owners that reach it. A route owns its page, layouts,
|
|
18
|
+
* templates, boundaries and parallel slots, which render with it. Intercepting
|
|
19
|
+
* routes (which only render on soft navigation), global-error and
|
|
20
|
+
* global-not-found render on their own, so each is owned by its file, named by
|
|
21
|
+
* its path relative to `root`. References with the same signature are needed
|
|
22
|
+
* together, mirroring Next.js' per-route client entries. The map is in the
|
|
23
|
+
* order a depth-first walk in import order first reaches each reference from
|
|
24
|
+
* the route files in render order, which follows ES module evaluation order.
|
|
25
|
+
*
|
|
26
|
+
* References reachable from no route file (for example vinext's internal
|
|
27
|
+
* runtime references) are omitted and keep their own lazy chunk. So are
|
|
28
|
+
* references that route code reaches through a dynamic import (`next/dynamic`,
|
|
29
|
+
* `React.lazy`), directly or through the dynamically imported module's graph.
|
|
30
|
+
*/
|
|
31
|
+
export declare function collectClientReferenceRouteSignatures(options: {
|
|
32
|
+
canonicalizeModuleId?: (id: string) => string;
|
|
33
|
+
clientReferenceIds: ReadonlySet<string>;
|
|
34
|
+
getModuleInfo: (id: string) => ModuleGraphInfo | null;
|
|
35
|
+
root: string;
|
|
36
|
+
routes: readonly ClientReferenceGroupRoute[];
|
|
37
|
+
sharedRoots?: readonly string[];
|
|
38
|
+
}): Map<string, string>;
|
|
39
|
+
export type ClientReferencePreloadPlan = {
|
|
40
|
+
/**
|
|
41
|
+
* Client references any render may use: those reached from outside route
|
|
42
|
+
* files (vinext's runtime, server actions), those of `alwaysRoots`
|
|
43
|
+
* (global-error, the root boundaries), and those no walk reaches.
|
|
44
|
+
*/
|
|
45
|
+
always: string[];
|
|
46
|
+
/** The client references each route file reaches, through any import. */
|
|
47
|
+
files: string[][];
|
|
48
|
+
/** Each route pattern's files, as indices into `files`. */
|
|
49
|
+
routes: Map<string, number[]>;
|
|
50
|
+
/** The files of a render without a route, as indices into `files`. */
|
|
51
|
+
routeless: number[];
|
|
52
|
+
/**
|
|
53
|
+
* References route files reach only through static imports, outside
|
|
54
|
+
* `always`. A render may stream one whose module evaluates asynchronously
|
|
55
|
+
* instead of waiting for it; a reference any dynamic import reaches, such as
|
|
56
|
+
* a `next/dynamic` component, always loads first.
|
|
57
|
+
*/
|
|
58
|
+
staticOnly: string[];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Plan which client references SSR loads before rendering each route. A route
|
|
62
|
+
* preloads every client reference its page, layouts, templates, boundaries and
|
|
63
|
+
* parallel slots reach, statically or through dynamic imports (a
|
|
64
|
+
* `next/dynamic` component renders on the server), plus the `always` set.
|
|
65
|
+
* Intercepting routes only render on soft navigation, which SSR never
|
|
66
|
+
* renders, so they add to no set. `entryIds` are the RSC graph's entries:
|
|
67
|
+
* walking them up to route files finds what renders outside any route.
|
|
68
|
+
*/
|
|
69
|
+
export declare function collectClientReferencePreloadPlan(options: {
|
|
70
|
+
alwaysRoots?: readonly string[];
|
|
71
|
+
canonicalizeModuleId?: (id: string) => string;
|
|
72
|
+
clientReferenceIds: ReadonlySet<string>;
|
|
73
|
+
entryIds: readonly string[];
|
|
74
|
+
getModuleInfo: (id: string) => ModuleGraphInfo | null;
|
|
75
|
+
routelessFiles?: readonly string[];
|
|
76
|
+
routes: readonly ClientReferenceGroupRoute[];
|
|
77
|
+
}): ClientReferencePreloadPlan;
|
|
78
|
+
/** Export names an importer uses from a module, or `"*"` for all of them. */
|
|
79
|
+
type UsedNames = ReadonlySet<string> | "*";
|
|
80
|
+
type ModuleBindings = {
|
|
81
|
+
/** Transformed source bytes, not counting import and export-list statements. */
|
|
82
|
+
bytes: number;
|
|
83
|
+
/** Static imports, with the names each one uses. */
|
|
84
|
+
imports: ReadonlyArray<{
|
|
85
|
+
id: string;
|
|
86
|
+
names: UsedNames;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Re-exports: `export { a as b } from`, `export * from` (`exportName` and
|
|
90
|
+
* `importName` are `"*"`), `export * as ns from` (`importName` is `"*"`), and
|
|
91
|
+
* imported bindings that the module only re-exports.
|
|
92
|
+
*/
|
|
93
|
+
reexports: ReadonlyArray<{
|
|
94
|
+
id: string;
|
|
95
|
+
exportName: string;
|
|
96
|
+
importName: string;
|
|
97
|
+
}>;
|
|
98
|
+
};
|
|
99
|
+
type LoadedModule = {
|
|
100
|
+
code: string | null;
|
|
101
|
+
importedIds: readonly string[];
|
|
102
|
+
/**
|
|
103
|
+
* Without bindings, every static import of the module counts in full. With
|
|
104
|
+
* them, a side-effect-free module's re-exports only count for the names its
|
|
105
|
+
* importers use, as tree-shaking would keep them.
|
|
106
|
+
*/
|
|
107
|
+
bindings?: ModuleBindings;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Read a module's static imports and re-exports for
|
|
111
|
+
* {@link measureClientReferenceGroupCosts}. Returns undefined when the code does
|
|
112
|
+
* not parse or a specifier does not resolve to one of `importedIds`.
|
|
113
|
+
*/
|
|
114
|
+
export declare function readClientModuleBindings(options: {
|
|
115
|
+
code: string;
|
|
116
|
+
importedIds: readonly string[];
|
|
117
|
+
resolve: (specifier: string) => Promise<string | null>;
|
|
118
|
+
}): Promise<ModuleBindings | undefined>;
|
|
119
|
+
/**
|
|
120
|
+
* Estimate, in transformed source bytes, how much code each client reference
|
|
121
|
+
* would add to a route group's chunk: the modules only it uses, plus the cost
|
|
122
|
+
* of every client reference it statically imports (grouping a reference pulls
|
|
123
|
+
* those along). Modules shared with other client references are not charged
|
|
124
|
+
* to any one of them, so shared libraries do not block grouping. With
|
|
125
|
+
* {@link readClientModuleBindings}, a side-effect-free module only charges the
|
|
126
|
+
* re-exports that are imported from it, so a reference that imports one icon
|
|
127
|
+
* from a barrel is not charged for the whole library.
|
|
128
|
+
*
|
|
129
|
+
* `references` maps each client reference id to its module id in the client
|
|
130
|
+
* graph. `isSideEffectFree` reports a module's package `sideEffects` flag as
|
|
131
|
+
* the bundler resolved it. Traversal stops at modules for which `isExcluded`
|
|
132
|
+
* returns true (CSS, always-loaded framework chunks, virtual modules that must
|
|
133
|
+
* not be loaded re-entrantly). A reference whose import graph cannot be fully
|
|
134
|
+
* loaded is reported as `null` so callers keep it out of groups.
|
|
135
|
+
*/
|
|
136
|
+
export declare function measureClientReferenceGroupCosts(options: {
|
|
137
|
+
references: ReadonlyMap<string, string>;
|
|
138
|
+
loadModule: (id: string) => Promise<LoadedModule>;
|
|
139
|
+
isExcluded: (id: string) => boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Whether a module has no side effects. A side-effect-free module is not
|
|
142
|
+
* loaded until a reference uses one of its exports.
|
|
143
|
+
*/
|
|
144
|
+
isSideEffectFree: (id: string) => boolean;
|
|
145
|
+
}): Promise<Map<string, number | null>>;
|
|
146
|
+
export type ClientReferenceGroup = {
|
|
147
|
+
/** Stable, filename-safe identifier derived from the route signature. */
|
|
148
|
+
key: string;
|
|
149
|
+
/**
|
|
150
|
+
* Member client reference ids in signature (route walk) order, which sets
|
|
151
|
+
* module evaluation and CSS order inside the group chunk.
|
|
152
|
+
*/
|
|
153
|
+
referenceIds: string[];
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Group client references that share a route signature. References without a
|
|
157
|
+
* signature, references whose cost is unknown or above `maxCostBytes`, and
|
|
158
|
+
* signatures with a single member stay ungrouped. Group keys derive from the
|
|
159
|
+
* members' `referenceKeys`, so a group keeps its chunk name when routes change
|
|
160
|
+
* but its members do not.
|
|
161
|
+
*/
|
|
162
|
+
export declare function planClientReferenceGroups(options: {
|
|
163
|
+
referenceIds: ReadonlySet<string>;
|
|
164
|
+
/** Stable, machine-independent key of each client reference. */
|
|
165
|
+
referenceKeys: ReadonlyMap<string, string>;
|
|
166
|
+
signatures: ReadonlyMap<string, string>;
|
|
167
|
+
costs: ReadonlyMap<string, number | null>;
|
|
168
|
+
maxCostBytes: number;
|
|
169
|
+
}): ClientReferenceGroup[];
|
|
170
|
+
//#endregion
|
|
171
|
+
export {};
|