@qzsy/vinext 0.1.7
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/LICENSE +21 -0
- package/README.md +773 -0
- package/dist/build/assets-ignore.d.ts +32 -0
- package/dist/build/assets-ignore.js +48 -0
- package/dist/build/clean-output.d.ts +13 -0
- package/dist/build/clean-output.js +34 -0
- package/dist/build/client-build-config.d.ts +171 -0
- package/dist/build/client-build-config.js +270 -0
- package/dist/build/css-url-assets.d.ts +29 -0
- package/dist/build/css-url-assets.js +213 -0
- package/dist/build/google-fonts/build-url.d.ts +9 -0
- package/dist/build/google-fonts/build-url.js +28 -0
- package/dist/build/google-fonts/fallback-metrics-data.js +14029 -0
- package/dist/build/google-fonts/fallback-metrics.d.ts +12 -0
- package/dist/build/google-fonts/fallback-metrics.js +44 -0
- package/dist/build/google-fonts/find-font-files-in-css.d.ts +16 -0
- package/dist/build/google-fonts/find-font-files-in-css.js +28 -0
- package/dist/build/google-fonts/font-data.js +24983 -0
- package/dist/build/google-fonts/font-metadata.d.ts +16 -0
- package/dist/build/google-fonts/font-metadata.js +5 -0
- package/dist/build/google-fonts/get-axes.d.ts +6 -0
- package/dist/build/google-fonts/get-axes.js +37 -0
- package/dist/build/google-fonts/sort-variants.d.ts +4 -0
- package/dist/build/google-fonts/sort-variants.js +12 -0
- package/dist/build/google-fonts/validate.d.ts +27 -0
- package/dist/build/google-fonts/validate.js +54 -0
- package/dist/build/inline-css.d.ts +6 -0
- package/dist/build/inline-css.js +48 -0
- package/dist/build/layout-classification-types.d.ts +61 -0
- package/dist/build/layout-classification-types.js +1 -0
- package/dist/build/layout-classification.d.ts +59 -0
- package/dist/build/layout-classification.js +98 -0
- package/dist/build/next-client-runtime-manifests.d.ts +14 -0
- package/dist/build/next-client-runtime-manifests.js +39 -0
- package/dist/build/nitro-route-rules.d.ts +49 -0
- package/dist/build/nitro-route-rules.js +79 -0
- package/dist/build/precompress.d.ts +27 -0
- package/dist/build/precompress.js +110 -0
- package/dist/build/prerender.d.ts +209 -0
- package/dist/build/prerender.js +932 -0
- package/dist/build/report.d.ts +132 -0
- package/dist/build/report.js +504 -0
- package/dist/build/route-classification-injector.d.ts +34 -0
- package/dist/build/route-classification-injector.js +59 -0
- package/dist/build/route-classification-manifest.d.ts +52 -0
- package/dist/build/route-classification-manifest.js +143 -0
- package/dist/build/run-prerender.d.ts +61 -0
- package/dist/build/run-prerender.js +224 -0
- package/dist/build/server-manifest.d.ts +18 -0
- package/dist/build/server-manifest.js +22 -0
- package/dist/build/ssr-manifest.d.ts +18 -0
- package/dist/build/ssr-manifest.js +69 -0
- package/dist/build/standalone.d.ts +31 -0
- package/dist/build/standalone.js +203 -0
- package/dist/build/static-export.d.ts +55 -0
- package/dist/build/static-export.js +60 -0
- package/dist/cache/cache-adapters-virtual.d.ts +50 -0
- package/dist/cache/cache-adapters-virtual.js +45 -0
- package/dist/cache.d.ts +2 -0
- package/dist/cache.js +2 -0
- package/dist/check.d.ts +87 -0
- package/dist/check.js +1037 -0
- package/dist/cli-args.d.ts +33 -0
- package/dist/cli-args.js +124 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +744 -0
- package/dist/client/app-nav-failure-handler.d.ts +8 -0
- package/dist/client/app-nav-failure-handler.js +44 -0
- package/dist/client/empty-module.d.ts +1 -0
- package/dist/client/empty-module.js +1 -0
- package/dist/client/instrumentation-client-inject.d.ts +33 -0
- package/dist/client/instrumentation-client-inject.js +55 -0
- package/dist/client/instrumentation-client-state.d.ts +9 -0
- package/dist/client/instrumentation-client-state.js +17 -0
- package/dist/client/instrumentation-client.d.ts +7 -0
- package/dist/client/instrumentation-client.js +6 -0
- package/dist/client/navigation-runtime.d.ts +70 -0
- package/dist/client/navigation-runtime.js +169 -0
- package/dist/client/pages-router-link-navigation.d.ts +61 -0
- package/dist/client/pages-router-link-navigation.js +42 -0
- package/dist/client/validate-module-path.d.ts +17 -0
- package/dist/client/validate-module-path.js +24 -0
- package/dist/client/vinext-next-data.d.ts +44 -0
- package/dist/client/vinext-next-data.js +50 -0
- package/dist/client/window-next.d.ts +168 -0
- package/dist/client/window-next.js +57 -0
- package/dist/cloudflare/index.d.ts +3 -0
- package/dist/cloudflare/index.js +3 -0
- package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +102 -0
- package/dist/cloudflare/src/cache/kv-data-adapter.runtime.d.ts +126 -0
- package/dist/cloudflare/src/cache/kv-data-adapter.runtime.js +435 -0
- package/dist/cloudflare/src/utils/cache-control-metadata.js +20 -0
- package/dist/cloudflare/tpr.d.ts +82 -0
- package/dist/cloudflare/tpr.js +558 -0
- package/dist/config/config-matchers.d.ts +257 -0
- package/dist/config/config-matchers.js +1046 -0
- package/dist/config/dotenv.d.ts +56 -0
- package/dist/config/dotenv.js +88 -0
- package/dist/config/next-config.d.ts +540 -0
- package/dist/config/next-config.js +1050 -0
- package/dist/config/tsconfig-paths.d.ts +21 -0
- package/dist/config/tsconfig-paths.js +157 -0
- package/dist/deploy.d.ts +190 -0
- package/dist/deploy.js +1033 -0
- package/dist/entries/app-browser-entry.d.ts +29 -0
- package/dist/entries/app-browser-entry.js +83 -0
- package/dist/entries/app-rsc-entry.d.ts +81 -0
- package/dist/entries/app-rsc-entry.js +943 -0
- package/dist/entries/app-rsc-manifest.d.ts +53 -0
- package/dist/entries/app-rsc-manifest.js +294 -0
- package/dist/entries/app-ssr-entry.d.ts +15 -0
- package/dist/entries/app-ssr-entry.js +24 -0
- package/dist/entries/pages-client-entry.d.ts +11 -0
- package/dist/entries/pages-client-entry.js +204 -0
- package/dist/entries/pages-entry-helpers.d.ts +2 -0
- package/dist/entries/pages-entry-helpers.js +2 -0
- package/dist/entries/pages-server-entry.d.ts +11 -0
- package/dist/entries/pages-server-entry.js +398 -0
- package/dist/entries/runtime-entry-module.d.ts +25 -0
- package/dist/entries/runtime-entry-module.js +46 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +2661 -0
- package/dist/init.d.ts +69 -0
- package/dist/init.js +253 -0
- package/dist/plugins/ast-utils.d.ts +20 -0
- package/dist/plugins/ast-utils.js +78 -0
- package/dist/plugins/async-hooks-stub.d.ts +18 -0
- package/dist/plugins/async-hooks-stub.js +40 -0
- package/dist/plugins/client-reference-dedup.d.ts +35 -0
- package/dist/plugins/client-reference-dedup.js +189 -0
- package/dist/plugins/css-data-url.d.ts +6 -0
- package/dist/plugins/css-data-url.js +83 -0
- package/dist/plugins/dynamic-preload-metadata.d.ts +13 -0
- package/dist/plugins/dynamic-preload-metadata.js +413 -0
- package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
- package/dist/plugins/extensionless-dynamic-import.js +155 -0
- package/dist/plugins/fonts.d.ts +95 -0
- package/dist/plugins/fonts.js +711 -0
- package/dist/plugins/import-meta-url.d.ts +16 -0
- package/dist/plugins/import-meta-url.js +353 -0
- package/dist/plugins/instrumentation-client.d.ts +6 -0
- package/dist/plugins/instrumentation-client.js +27 -0
- package/dist/plugins/middleware-export-validation.d.ts +5 -0
- package/dist/plugins/middleware-export-validation.js +36 -0
- package/dist/plugins/middleware-server-only.d.ts +53 -0
- package/dist/plugins/middleware-server-only.js +90 -0
- package/dist/plugins/og-asset-ownership.d.ts +27 -0
- package/dist/plugins/og-asset-ownership.js +285 -0
- package/dist/plugins/og-assets.d.ts +50 -0
- package/dist/plugins/og-assets.js +229 -0
- package/dist/plugins/optimize-imports.d.ts +42 -0
- package/dist/plugins/optimize-imports.js +587 -0
- package/dist/plugins/postcss.d.ts +26 -0
- package/dist/plugins/postcss.js +96 -0
- package/dist/plugins/remove-console.d.ts +21 -0
- package/dist/plugins/remove-console.js +177 -0
- package/dist/plugins/require-context.d.ts +6 -0
- package/dist/plugins/require-context.js +185 -0
- package/dist/plugins/rsc-client-reference-loaders.d.ts +6 -0
- package/dist/plugins/rsc-client-reference-loaders.js +46 -0
- package/dist/plugins/rsc-client-shim-excludes.d.ts +6 -0
- package/dist/plugins/rsc-client-shim-excludes.js +35 -0
- package/dist/plugins/sass.d.ts +62 -0
- package/dist/plugins/sass.js +268 -0
- package/dist/plugins/server-externals-manifest.d.ts +26 -0
- package/dist/plugins/server-externals-manifest.js +81 -0
- package/dist/plugins/strip-server-exports.d.ts +21 -0
- package/dist/plugins/strip-server-exports.js +519 -0
- package/dist/plugins/typeof-window.d.ts +14 -0
- package/dist/plugins/typeof-window.js +150 -0
- package/dist/plugins/wasm-module-import.d.ts +15 -0
- package/dist/plugins/wasm-module-import.js +50 -0
- package/dist/routing/app-route-graph.d.ts +336 -0
- package/dist/routing/app-route-graph.js +1518 -0
- package/dist/routing/app-router.d.ts +30 -0
- package/dist/routing/app-router.js +59 -0
- package/dist/routing/file-matcher.d.ts +60 -0
- package/dist/routing/file-matcher.js +147 -0
- package/dist/routing/pages-router.d.ts +48 -0
- package/dist/routing/pages-router.js +163 -0
- package/dist/routing/route-matching.d.ts +27 -0
- package/dist/routing/route-matching.js +42 -0
- package/dist/routing/route-pattern.d.ts +64 -0
- package/dist/routing/route-pattern.js +165 -0
- package/dist/routing/route-trie.d.ts +67 -0
- package/dist/routing/route-trie.js +143 -0
- package/dist/routing/route-validation.d.ts +10 -0
- package/dist/routing/route-validation.js +101 -0
- package/dist/routing/utils.d.ts +117 -0
- package/dist/routing/utils.js +242 -0
- package/dist/server/accept-encoding.d.ts +29 -0
- package/dist/server/accept-encoding.js +95 -0
- package/dist/server/api-handler.d.ts +17 -0
- package/dist/server/api-handler.js +276 -0
- package/dist/server/app-action-request.d.ts +4 -0
- package/dist/server/app-action-request.js +9 -0
- package/dist/server/app-bfcache-id.d.ts +5 -0
- package/dist/server/app-bfcache-id.js +5 -0
- package/dist/server/app-bfcache-identity.d.ts +36 -0
- package/dist/server/app-bfcache-identity.js +156 -0
- package/dist/server/app-browser-action-result.d.ts +64 -0
- package/dist/server/app-browser-action-result.js +111 -0
- package/dist/server/app-browser-client-reuse-manifest.d.ts +12 -0
- package/dist/server/app-browser-client-reuse-manifest.js +101 -0
- package/dist/server/app-browser-entry.d.ts +1 -0
- package/dist/server/app-browser-entry.js +1087 -0
- package/dist/server/app-browser-error.d.ts +13 -0
- package/dist/server/app-browser-error.js +52 -0
- package/dist/server/app-browser-history-controller.d.ts +104 -0
- package/dist/server/app-browser-history-controller.js +210 -0
- package/dist/server/app-browser-hydration.d.ts +32 -0
- package/dist/server/app-browser-hydration.js +29 -0
- package/dist/server/app-browser-interception-context.d.ts +24 -0
- package/dist/server/app-browser-interception-context.js +43 -0
- package/dist/server/app-browser-mpa-navigation.d.ts +16 -0
- package/dist/server/app-browser-mpa-navigation.js +42 -0
- package/dist/server/app-browser-navigation-controller.d.ts +109 -0
- package/dist/server/app-browser-navigation-controller.js +465 -0
- package/dist/server/app-browser-popstate.d.ts +26 -0
- package/dist/server/app-browser-popstate.js +44 -0
- package/dist/server/app-browser-rsc-redirect.d.ts +38 -0
- package/dist/server/app-browser-rsc-redirect.js +64 -0
- package/dist/server/app-browser-server-action-client.d.ts +32 -0
- package/dist/server/app-browser-server-action-client.js +128 -0
- package/dist/server/app-browser-server-action-navigation.d.ts +6 -0
- package/dist/server/app-browser-server-action-navigation.js +9 -0
- package/dist/server/app-browser-state.d.ts +140 -0
- package/dist/server/app-browser-state.js +315 -0
- package/dist/server/app-browser-stream.d.ts +28 -0
- package/dist/server/app-browser-stream.js +122 -0
- package/dist/server/app-browser-visible-commit.d.ts +78 -0
- package/dist/server/app-browser-visible-commit.js +241 -0
- package/dist/server/app-client-reference-preloader.d.ts +14 -0
- package/dist/server/app-client-reference-preloader.js +44 -0
- package/dist/server/app-elements-wire.d.ts +192 -0
- package/dist/server/app-elements-wire.js +443 -0
- package/dist/server/app-elements.d.ts +9 -0
- package/dist/server/app-elements.js +18 -0
- package/dist/server/app-fallback-renderer.d.ts +89 -0
- package/dist/server/app-fallback-renderer.js +136 -0
- package/dist/server/app-history-state.d.ts +85 -0
- package/dist/server/app-history-state.js +223 -0
- package/dist/server/app-hook-warning-suppression.d.ts +6 -0
- package/dist/server/app-hook-warning-suppression.js +10 -0
- package/dist/server/app-inline-css-client.d.ts +6 -0
- package/dist/server/app-inline-css-client.js +35 -0
- package/dist/server/app-interception-context-header.d.ts +32 -0
- package/dist/server/app-interception-context-header.js +42 -0
- package/dist/server/app-layout-param-observation.d.ts +43 -0
- package/dist/server/app-layout-param-observation.js +168 -0
- package/dist/server/app-middleware.d.ts +46 -0
- package/dist/server/app-middleware.js +168 -0
- package/dist/server/app-mounted-slots-header.d.ts +35 -0
- package/dist/server/app-mounted-slots-header.js +58 -0
- package/dist/server/app-optimistic-routing.d.ts +53 -0
- package/dist/server/app-optimistic-routing.js +227 -0
- package/dist/server/app-page-boundary-render.d.ts +85 -0
- package/dist/server/app-page-boundary-render.js +305 -0
- package/dist/server/app-page-boundary.d.ts +102 -0
- package/dist/server/app-page-boundary.js +120 -0
- package/dist/server/app-page-cache-finalizer.d.ts +62 -0
- package/dist/server/app-page-cache-finalizer.js +122 -0
- package/dist/server/app-page-cache-render.d.ts +53 -0
- package/dist/server/app-page-cache-render.js +91 -0
- package/dist/server/app-page-cache.d.ts +83 -0
- package/dist/server/app-page-cache.js +272 -0
- package/dist/server/app-page-dispatch.d.ts +223 -0
- package/dist/server/app-page-dispatch.js +610 -0
- package/dist/server/app-page-element-builder.d.ts +96 -0
- package/dist/server/app-page-element-builder.js +205 -0
- package/dist/server/app-page-execution.d.ts +138 -0
- package/dist/server/app-page-execution.js +328 -0
- package/dist/server/app-page-head.d.ts +65 -0
- package/dist/server/app-page-head.js +228 -0
- package/dist/server/app-page-method.d.ts +15 -0
- package/dist/server/app-page-method.js +25 -0
- package/dist/server/app-page-params.d.ts +8 -0
- package/dist/server/app-page-params.js +39 -0
- package/dist/server/app-page-ppr-runtime.d.ts +7 -0
- package/dist/server/app-page-ppr-runtime.js +70 -0
- package/dist/server/app-page-probe.d.ts +134 -0
- package/dist/server/app-page-probe.js +276 -0
- package/dist/server/app-page-render-identity.d.ts +21 -0
- package/dist/server/app-page-render-identity.js +40 -0
- package/dist/server/app-page-render-observation.d.ts +36 -0
- package/dist/server/app-page-render-observation.js +82 -0
- package/dist/server/app-page-render.d.ts +111 -0
- package/dist/server/app-page-render.js +602 -0
- package/dist/server/app-page-request.d.ts +137 -0
- package/dist/server/app-page-request.js +216 -0
- package/dist/server/app-page-response.d.ts +68 -0
- package/dist/server/app-page-response.js +120 -0
- package/dist/server/app-page-route-wiring.d.ts +151 -0
- package/dist/server/app-page-route-wiring.js +452 -0
- package/dist/server/app-page-search-params-observation.d.ts +10 -0
- package/dist/server/app-page-search-params-observation.js +20 -0
- package/dist/server/app-page-segment-state.d.ts +9 -0
- package/dist/server/app-page-segment-state.js +80 -0
- package/dist/server/app-page-stream.d.ts +151 -0
- package/dist/server/app-page-stream.js +143 -0
- package/dist/server/app-pages-bridge.d.ts +63 -0
- package/dist/server/app-pages-bridge.js +63 -0
- package/dist/server/app-post-middleware-context.d.ts +15 -0
- package/dist/server/app-post-middleware-context.js +26 -0
- package/dist/server/app-ppr-fallback-shell-render.d.ts +18 -0
- package/dist/server/app-ppr-fallback-shell-render.js +26 -0
- package/dist/server/app-ppr-fallback-shell.d.ts +33 -0
- package/dist/server/app-ppr-fallback-shell.js +89 -0
- package/dist/server/app-prerender-endpoints.d.ts +18 -0
- package/dist/server/app-prerender-endpoints.js +94 -0
- package/dist/server/app-prerender-static-params.d.ts +30 -0
- package/dist/server/app-prerender-static-params.js +81 -0
- package/dist/server/app-render-dependency.d.ts +14 -0
- package/dist/server/app-render-dependency.js +41 -0
- package/dist/server/app-request-context.d.ts +20 -0
- package/dist/server/app-request-context.js +29 -0
- package/dist/server/app-route-handler-cache.d.ts +46 -0
- package/dist/server/app-route-handler-cache.js +78 -0
- package/dist/server/app-route-handler-dispatch.d.ts +49 -0
- package/dist/server/app-route-handler-dispatch.js +163 -0
- package/dist/server/app-route-handler-execution.d.ts +86 -0
- package/dist/server/app-route-handler-execution.js +128 -0
- package/dist/server/app-route-handler-policy.d.ts +55 -0
- package/dist/server/app-route-handler-policy.js +58 -0
- package/dist/server/app-route-handler-response.d.ts +28 -0
- package/dist/server/app-route-handler-response.js +145 -0
- package/dist/server/app-route-handler-runtime.d.ts +39 -0
- package/dist/server/app-route-handler-runtime.js +250 -0
- package/dist/server/app-route-module-loader.d.ts +91 -0
- package/dist/server/app-route-module-loader.js +83 -0
- package/dist/server/app-router-entry.d.ts +13 -0
- package/dist/server/app-router-entry.js +49 -0
- package/dist/server/app-rsc-cache-busting.d.ts +64 -0
- package/dist/server/app-rsc-cache-busting.js +206 -0
- package/dist/server/app-rsc-embedded-chunks.d.ts +8 -0
- package/dist/server/app-rsc-embedded-chunks.js +32 -0
- package/dist/server/app-rsc-error-handler.d.ts +20 -0
- package/dist/server/app-rsc-error-handler.js +28 -0
- package/dist/server/app-rsc-errors.d.ts +40 -0
- package/dist/server/app-rsc-errors.js +60 -0
- package/dist/server/app-rsc-handler.d.ts +201 -0
- package/dist/server/app-rsc-handler.js +538 -0
- package/dist/server/app-rsc-render-mode.d.ts +11 -0
- package/dist/server/app-rsc-render-mode.js +25 -0
- package/dist/server/app-rsc-request-normalization.d.ts +48 -0
- package/dist/server/app-rsc-request-normalization.js +75 -0
- package/dist/server/app-rsc-response-finalizer.d.ts +37 -0
- package/dist/server/app-rsc-response-finalizer.js +54 -0
- package/dist/server/app-rsc-route-matching.d.ts +93 -0
- package/dist/server/app-rsc-route-matching.js +134 -0
- package/dist/server/app-segment-config.d.ts +46 -0
- package/dist/server/app-segment-config.js +113 -0
- package/dist/server/app-server-action-execution.d.ts +219 -0
- package/dist/server/app-server-action-execution.js +767 -0
- package/dist/server/app-ssr-entry.d.ts +52 -0
- package/dist/server/app-ssr-entry.js +295 -0
- package/dist/server/app-ssr-error-meta.d.ts +13 -0
- package/dist/server/app-ssr-error-meta.js +48 -0
- package/dist/server/app-ssr-router-instance.d.ts +6 -0
- package/dist/server/app-ssr-router-instance.js +24 -0
- package/dist/server/app-ssr-stream.d.ts +60 -0
- package/dist/server/app-ssr-stream.js +408 -0
- package/dist/server/app-static-generation.d.ts +15 -0
- package/dist/server/app-static-generation.js +19 -0
- package/dist/server/app-visited-response-cache.d.ts +23 -0
- package/dist/server/app-visited-response-cache.js +19 -0
- package/dist/server/artifact-compatibility.d.ts +54 -0
- package/dist/server/artifact-compatibility.js +91 -0
- package/dist/server/before-interactive-head.d.ts +17 -0
- package/dist/server/before-interactive-head.js +35 -0
- package/dist/server/cache-control.d.ts +37 -0
- package/dist/server/cache-control.js +56 -0
- package/dist/server/cache-headers.d.ts +6 -0
- package/dist/server/cache-headers.js +17 -0
- package/dist/server/cache-proof.d.ts +364 -0
- package/dist/server/cache-proof.js +794 -0
- package/dist/server/client-reuse-manifest.d.ts +104 -0
- package/dist/server/client-reuse-manifest.js +209 -0
- package/dist/server/client-trace-metadata.d.ts +30 -0
- package/dist/server/client-trace-metadata.js +81 -0
- package/dist/server/cookie-utils.d.ts +12 -0
- package/dist/server/cookie-utils.js +18 -0
- package/dist/server/csp.d.ts +10 -0
- package/dist/server/csp.js +41 -0
- package/dist/server/default-global-error-module.d.ts +19 -0
- package/dist/server/default-global-error-module.js +18 -0
- package/dist/server/default-not-found-module.d.ts +19 -0
- package/dist/server/default-not-found-module.js +18 -0
- package/dist/server/defer-until-stream-consumed.d.ts +7 -0
- package/dist/server/defer-until-stream-consumed.js +34 -0
- package/dist/server/dev-error-overlay-store.d.ts +39 -0
- package/dist/server/dev-error-overlay-store.js +86 -0
- package/dist/server/dev-error-overlay.d.ts +51 -0
- package/dist/server/dev-error-overlay.js +1341 -0
- package/dist/server/dev-initial-server-error.d.ts +9 -0
- package/dist/server/dev-initial-server-error.js +26 -0
- package/dist/server/dev-lockfile.d.ts +109 -0
- package/dist/server/dev-lockfile.js +179 -0
- package/dist/server/dev-module-runner.d.ts +30 -0
- package/dist/server/dev-module-runner.js +91 -0
- package/dist/server/dev-origin-check.d.ts +62 -0
- package/dist/server/dev-origin-check.js +156 -0
- package/dist/server/dev-route-files.d.ts +6 -0
- package/dist/server/dev-route-files.js +71 -0
- package/dist/server/dev-server.d.ts +58 -0
- package/dist/server/dev-server.js +1114 -0
- package/dist/server/dev-stack-sourcemap-endpoint.d.ts +4 -0
- package/dist/server/dev-stack-sourcemap-endpoint.js +4 -0
- package/dist/server/dev-stack-sourcemap.d.ts +43 -0
- package/dist/server/dev-stack-sourcemap.js +443 -0
- package/dist/server/document-initial-head.d.ts +6 -0
- package/dist/server/document-initial-head.js +33 -0
- package/dist/server/edge-api-runtime.d.ts +4 -0
- package/dist/server/edge-api-runtime.js +6 -0
- package/dist/server/file-based-metadata.d.ts +29 -0
- package/dist/server/file-based-metadata.js +401 -0
- package/dist/server/headers.d.ts +114 -0
- package/dist/server/headers.js +136 -0
- package/dist/server/html.d.ts +28 -0
- package/dist/server/html.js +41 -0
- package/dist/server/http-error-responses.d.ts +91 -0
- package/dist/server/http-error-responses.js +105 -0
- package/dist/server/hybrid-route-priority.d.ts +22 -0
- package/dist/server/hybrid-route-priority.js +33 -0
- package/dist/server/image-optimization.d.ts +130 -0
- package/dist/server/image-optimization.js +247 -0
- package/dist/server/implicit-tags.d.ts +6 -0
- package/dist/server/implicit-tags.js +44 -0
- package/dist/server/instrumentation-runtime.d.ts +49 -0
- package/dist/server/instrumentation-runtime.js +35 -0
- package/dist/server/instrumentation.d.ts +85 -0
- package/dist/server/instrumentation.js +130 -0
- package/dist/server/isr-cache.d.ts +127 -0
- package/dist/server/isr-cache.js +282 -0
- package/dist/server/isr-decision.d.ts +79 -0
- package/dist/server/isr-decision.js +70 -0
- package/dist/server/metadata-route-build-data.d.ts +24 -0
- package/dist/server/metadata-route-build-data.js +148 -0
- package/dist/server/metadata-route-response.d.ts +16 -0
- package/dist/server/metadata-route-response.js +205 -0
- package/dist/server/metadata-routes.d.ts +139 -0
- package/dist/server/metadata-routes.js +433 -0
- package/dist/server/middleware-matcher.d.ts +14 -0
- package/dist/server/middleware-matcher.js +111 -0
- package/dist/server/middleware-request-headers.d.ts +11 -0
- package/dist/server/middleware-request-headers.js +65 -0
- package/dist/server/middleware-response-headers.d.ts +12 -0
- package/dist/server/middleware-response-headers.js +42 -0
- package/dist/server/middleware-runtime.d.ts +67 -0
- package/dist/server/middleware-runtime.js +240 -0
- package/dist/server/middleware.d.ts +62 -0
- package/dist/server/middleware.js +114 -0
- package/dist/server/navigation-planner.d.ts +308 -0
- package/dist/server/navigation-planner.js +831 -0
- package/dist/server/navigation-trace.d.ts +68 -0
- package/dist/server/navigation-trace.js +71 -0
- package/dist/server/next-error-digest.d.ts +44 -0
- package/dist/server/next-error-digest.js +40 -0
- package/dist/server/normalize-path.d.ts +38 -0
- package/dist/server/normalize-path.js +70 -0
- package/dist/server/open-redirect.d.ts +12 -0
- package/dist/server/open-redirect.js +21 -0
- package/dist/server/operation-token.d.ts +40 -0
- package/dist/server/operation-token.js +85 -0
- package/dist/server/otel-tracer-extension.d.ts +45 -0
- package/dist/server/otel-tracer-extension.js +89 -0
- package/dist/server/pages-api-route.d.ts +83 -0
- package/dist/server/pages-api-route.js +75 -0
- package/dist/server/pages-asset-tags.d.ts +78 -0
- package/dist/server/pages-asset-tags.js +126 -0
- package/dist/server/pages-body-parser-config.d.ts +59 -0
- package/dist/server/pages-body-parser-config.js +77 -0
- package/dist/server/pages-data-route.d.ts +121 -0
- package/dist/server/pages-data-route.js +157 -0
- package/dist/server/pages-default-404.d.ts +30 -0
- package/dist/server/pages-default-404.js +38 -0
- package/dist/server/pages-dev-module-url.d.ts +4 -0
- package/dist/server/pages-dev-module-url.js +15 -0
- package/dist/server/pages-document-initial-props.d.ts +77 -0
- package/dist/server/pages-document-initial-props.js +109 -0
- package/dist/server/pages-get-initial-props.d.ts +67 -0
- package/dist/server/pages-get-initial-props.js +92 -0
- package/dist/server/pages-i18n.d.ts +106 -0
- package/dist/server/pages-i18n.js +183 -0
- package/dist/server/pages-media-type.d.ts +15 -0
- package/dist/server/pages-media-type.js +24 -0
- package/dist/server/pages-node-compat.d.ts +55 -0
- package/dist/server/pages-node-compat.js +235 -0
- package/dist/server/pages-page-data.d.ts +223 -0
- package/dist/server/pages-page-data.js +484 -0
- package/dist/server/pages-page-handler.d.ts +100 -0
- package/dist/server/pages-page-handler.js +403 -0
- package/dist/server/pages-page-method.d.ts +47 -0
- package/dist/server/pages-page-method.js +17 -0
- package/dist/server/pages-page-response.d.ts +138 -0
- package/dist/server/pages-page-response.js +285 -0
- package/dist/server/pages-readiness.d.ts +36 -0
- package/dist/server/pages-readiness.js +21 -0
- package/dist/server/pages-request-pipeline.d.ts +116 -0
- package/dist/server/pages-request-pipeline.js +311 -0
- package/dist/server/pages-revalidate.d.ts +15 -0
- package/dist/server/pages-revalidate.js +19 -0
- package/dist/server/pages-serializable-props.d.ts +24 -0
- package/dist/server/pages-serializable-props.js +67 -0
- package/dist/server/pregenerated-concrete-paths.d.ts +16 -0
- package/dist/server/pregenerated-concrete-paths.js +61 -0
- package/dist/server/prerender-manifest.d.ts +33 -0
- package/dist/server/prerender-manifest.js +54 -0
- package/dist/server/prerender-route-params.d.ts +23 -0
- package/dist/server/prerender-route-params.js +113 -0
- package/dist/server/prerender-work-unit-setup.d.ts +6 -0
- package/dist/server/prerender-work-unit-setup.js +28 -0
- package/dist/server/prod-server.d.ts +148 -0
- package/dist/server/prod-server.js +1136 -0
- package/dist/server/proxy-trust.d.ts +40 -0
- package/dist/server/proxy-trust.js +68 -0
- package/dist/server/request-log.d.ts +39 -0
- package/dist/server/request-log.js +56 -0
- package/dist/server/request-pipeline.d.ts +187 -0
- package/dist/server/request-pipeline.js +447 -0
- package/dist/server/rsc-stream-hints.d.ts +10 -0
- package/dist/server/rsc-stream-hints.js +41 -0
- package/dist/server/seed-cache.d.ts +29 -0
- package/dist/server/seed-cache.js +125 -0
- package/dist/server/server-action-not-found.d.ts +21 -0
- package/dist/server/server-action-not-found.js +62 -0
- package/dist/server/server-globals.d.ts +4 -0
- package/dist/server/server-globals.js +35 -0
- package/dist/server/skip-cache-proof.d.ts +61 -0
- package/dist/server/skip-cache-proof.js +168 -0
- package/dist/server/socket-error-backstop.d.ts +34 -0
- package/dist/server/socket-error-backstop.js +200 -0
- package/dist/server/static-file-cache.d.ts +56 -0
- package/dist/server/static-file-cache.js +231 -0
- package/dist/server/static-layout-client-reuse-proof.d.ts +15 -0
- package/dist/server/static-layout-client-reuse-proof.js +33 -0
- package/dist/server/streaming-metadata.d.ts +4 -0
- package/dist/server/streaming-metadata.js +8 -0
- package/dist/server/worker-utils.d.ts +7 -0
- package/dist/server/worker-utils.js +99 -0
- package/dist/shims/amp.d.ts +19 -0
- package/dist/shims/amp.js +23 -0
- package/dist/shims/app-router-scroll-state.d.ts +15 -0
- package/dist/shims/app-router-scroll-state.js +61 -0
- package/dist/shims/app-router-scroll.d.ts +29 -0
- package/dist/shims/app-router-scroll.js +141 -0
- package/dist/shims/app.d.ts +42 -0
- package/dist/shims/app.js +48 -0
- package/dist/shims/before-interactive-context.d.ts +40 -0
- package/dist/shims/before-interactive-context.js +8 -0
- package/dist/shims/cache-for-request.d.ts +57 -0
- package/dist/shims/cache-for-request.js +72 -0
- package/dist/shims/cache-handler.d.ts +106 -0
- package/dist/shims/cache-handler.js +176 -0
- package/dist/shims/cache-request-state.d.ts +47 -0
- package/dist/shims/cache-request-state.js +126 -0
- package/dist/shims/cache-runtime.d.ts +83 -0
- package/dist/shims/cache-runtime.js +452 -0
- package/dist/shims/cache.d.ts +145 -0
- package/dist/shims/cache.js +401 -0
- package/dist/shims/cdn-cache.d.ts +125 -0
- package/dist/shims/cdn-cache.js +100 -0
- package/dist/shims/client-hook-error.d.ts +13 -0
- package/dist/shims/client-hook-error.js +17 -0
- package/dist/shims/client-locale.d.ts +14 -0
- package/dist/shims/client-locale.js +11 -0
- package/dist/shims/client-only.d.ts +1 -0
- package/dist/shims/client-only.js +1 -0
- package/dist/shims/compat-router.d.ts +16 -0
- package/dist/shims/compat-router.js +25 -0
- package/dist/shims/config.d.ts +28 -0
- package/dist/shims/config.js +21 -0
- package/dist/shims/constants.d.ts +130 -0
- package/dist/shims/constants.js +167 -0
- package/dist/shims/default-global-error.d.ts +31 -0
- package/dist/shims/default-global-error.js +179 -0
- package/dist/shims/default-not-found.d.ts +11 -0
- package/dist/shims/default-not-found.js +59 -0
- package/dist/shims/document.d.ts +92 -0
- package/dist/shims/document.js +76 -0
- package/dist/shims/dynamic-preload-chunks.d.ts +8 -0
- package/dist/shims/dynamic-preload-chunks.js +79 -0
- package/dist/shims/dynamic.d.ts +35 -0
- package/dist/shims/dynamic.js +204 -0
- package/dist/shims/error-boundary-navigation.d.ts +7 -0
- package/dist/shims/error-boundary-navigation.js +44 -0
- package/dist/shims/error-boundary.d.ts +155 -0
- package/dist/shims/error-boundary.js +342 -0
- package/dist/shims/error.d.ts +31 -0
- package/dist/shims/error.js +123 -0
- package/dist/shims/error.react-server.d.ts +9 -0
- package/dist/shims/error.react-server.js +6 -0
- package/dist/shims/fetch-cache.d.ts +136 -0
- package/dist/shims/fetch-cache.js +766 -0
- package/dist/shims/font-google-base.d.ts +83 -0
- package/dist/shims/font-google-base.js +290 -0
- package/dist/shims/font-google.d.ts +2 -0
- package/dist/shims/font-google.js +2 -0
- package/dist/shims/font-local.d.ts +50 -0
- package/dist/shims/font-local.js +195 -0
- package/dist/shims/font-utils.d.ts +56 -0
- package/dist/shims/font-utils.js +107 -0
- package/dist/shims/form.d.ts +19 -0
- package/dist/shims/form.js +236 -0
- package/dist/shims/hash-scroll.d.ts +10 -0
- package/dist/shims/hash-scroll.js +47 -0
- package/dist/shims/head-state.d.ts +16 -0
- package/dist/shims/head-state.js +43 -0
- package/dist/shims/head.d.ts +73 -0
- package/dist/shims/head.js +340 -0
- package/dist/shims/headers.d.ts +253 -0
- package/dist/shims/headers.js +754 -0
- package/dist/shims/i18n-context.d.ts +22 -0
- package/dist/shims/i18n-context.js +42 -0
- package/dist/shims/i18n-state.d.ts +14 -0
- package/dist/shims/i18n-state.js +38 -0
- package/dist/shims/image-config.d.ts +45 -0
- package/dist/shims/image-config.js +85 -0
- package/dist/shims/image.d.ts +55 -0
- package/dist/shims/image.js +582 -0
- package/dist/shims/internal/als-registry.d.ts +14 -0
- package/dist/shims/internal/als-registry.js +80 -0
- package/dist/shims/internal/api-utils.d.ts +14 -0
- package/dist/shims/internal/api-utils.js +1 -0
- package/dist/shims/internal/app-page-props-cache-key.d.ts +5 -0
- package/dist/shims/internal/app-page-props-cache-key.js +16 -0
- package/dist/shims/internal/app-route-detection.d.ts +39 -0
- package/dist/shims/internal/app-route-detection.js +62 -0
- package/dist/shims/internal/app-router-context.d.ts +31 -0
- package/dist/shims/internal/app-router-context.js +28 -0
- package/dist/shims/internal/cookie-serialize.d.ts +45 -0
- package/dist/shims/internal/cookie-serialize.js +49 -0
- package/dist/shims/internal/cookies.d.ts +2 -0
- package/dist/shims/internal/cookies.js +2 -0
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +31 -0
- package/dist/shims/internal/hybrid-client-route-owner.js +143 -0
- package/dist/shims/internal/interpolate-as.d.ts +25 -0
- package/dist/shims/internal/interpolate-as.js +196 -0
- package/dist/shims/internal/link-status-registry.d.ts +43 -0
- package/dist/shims/internal/link-status-registry.js +42 -0
- package/dist/shims/internal/make-hanging-promise.d.ts +15 -0
- package/dist/shims/internal/make-hanging-promise.js +44 -0
- package/dist/shims/internal/navigation-untracked.d.ts +35 -0
- package/dist/shims/internal/navigation-untracked.js +56 -0
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +54 -0
- package/dist/shims/internal/pages-data-fetch-dedup.js +121 -0
- package/dist/shims/internal/pages-data-target.d.ts +62 -0
- package/dist/shims/internal/pages-data-target.js +98 -0
- package/dist/shims/internal/pages-data-url.d.ts +41 -0
- package/dist/shims/internal/pages-data-url.js +71 -0
- package/dist/shims/internal/pages-router-accessor.d.ts +19 -0
- package/dist/shims/internal/pages-router-accessor.js +13 -0
- package/dist/shims/internal/route-pattern-for-warning.d.ts +27 -0
- package/dist/shims/internal/route-pattern-for-warning.js +40 -0
- package/dist/shims/internal/router-context.d.ts +7 -0
- package/dist/shims/internal/router-context.js +13 -0
- package/dist/shims/internal/utils.d.ts +52 -0
- package/dist/shims/internal/utils.js +27 -0
- package/dist/shims/internal/work-unit-async-storage.d.ts +30 -0
- package/dist/shims/internal/work-unit-async-storage.js +17 -0
- package/dist/shims/layout-segment-context.d.ts +24 -0
- package/dist/shims/layout-segment-context.js +39 -0
- package/dist/shims/legacy-image.d.ts +41 -0
- package/dist/shims/legacy-image.js +49 -0
- package/dist/shims/link-prefetch.d.ts +41 -0
- package/dist/shims/link-prefetch.js +43 -0
- package/dist/shims/link.d.ts +102 -0
- package/dist/shims/link.js +687 -0
- package/dist/shims/metadata.d.ts +285 -0
- package/dist/shims/metadata.js +820 -0
- package/dist/shims/navigation-context-state.d.ts +40 -0
- package/dist/shims/navigation-context-state.js +116 -0
- package/dist/shims/navigation-errors.d.ts +55 -0
- package/dist/shims/navigation-errors.js +110 -0
- package/dist/shims/navigation-server.d.ts +3 -0
- package/dist/shims/navigation-server.js +3 -0
- package/dist/shims/navigation-state.d.ts +25 -0
- package/dist/shims/navigation-state.js +66 -0
- package/dist/shims/navigation.d.ts +286 -0
- package/dist/shims/navigation.js +1206 -0
- package/dist/shims/navigation.react-server.d.ts +14 -0
- package/dist/shims/navigation.react-server.js +32 -0
- package/dist/shims/offline.d.ts +4 -0
- package/dist/shims/offline.js +15 -0
- package/dist/shims/og.d.ts +17 -0
- package/dist/shims/og.js +48 -0
- package/dist/shims/pages-router-runtime.d.ts +12 -0
- package/dist/shims/pages-router-runtime.js +24 -0
- package/dist/shims/ppr-fallback-shell.d.ts +33 -0
- package/dist/shims/ppr-fallback-shell.js +170 -0
- package/dist/shims/readonly-url-search-params.d.ts +13 -0
- package/dist/shims/readonly-url-search-params.js +26 -0
- package/dist/shims/request-context.d.ts +58 -0
- package/dist/shims/request-context.js +45 -0
- package/dist/shims/request-state-types.d.ts +12 -0
- package/dist/shims/request-state-types.js +1 -0
- package/dist/shims/root-params.d.ts +12 -0
- package/dist/shims/root-params.js +30 -0
- package/dist/shims/router-state.d.ts +32 -0
- package/dist/shims/router-state.js +39 -0
- package/dist/shims/router.d.ts +192 -0
- package/dist/shims/router.js +1786 -0
- package/dist/shims/script-nonce-context.d.ts +11 -0
- package/dist/shims/script-nonce-context.js +23 -0
- package/dist/shims/script.d.ts +43 -0
- package/dist/shims/script.js +370 -0
- package/dist/shims/server-only.d.ts +1 -0
- package/dist/shims/server-only.js +1 -0
- package/dist/shims/server.d.ts +323 -0
- package/dist/shims/server.js +729 -0
- package/dist/shims/slot.d.ts +45 -0
- package/dist/shims/slot.js +230 -0
- package/dist/shims/thenable-params.d.ts +11 -0
- package/dist/shims/thenable-params.js +176 -0
- package/dist/shims/unified-request-context.d.ts +68 -0
- package/dist/shims/unified-request-context.js +86 -0
- package/dist/shims/unrecognized-action-error.d.ts +34 -0
- package/dist/shims/unrecognized-action-error.js +39 -0
- package/dist/shims/url-safety.d.ts +34 -0
- package/dist/shims/url-safety.js +70 -0
- package/dist/shims/url-utils.d.ts +51 -0
- package/dist/shims/url-utils.js +156 -0
- package/dist/shims/use-merged-ref.d.ts +6 -0
- package/dist/shims/use-merged-ref.js +38 -0
- package/dist/shims/web-vitals.d.ts +8 -0
- package/dist/shims/web-vitals.js +22 -0
- package/dist/typegen.d.ts +9 -0
- package/dist/typegen.js +228 -0
- package/dist/utils/asset-prefix.d.ts +96 -0
- package/dist/utils/asset-prefix.js +122 -0
- package/dist/utils/base-path.d.ts +31 -0
- package/dist/utils/base-path.js +45 -0
- package/dist/utils/built-asset-url.d.ts +4 -0
- package/dist/utils/built-asset-url.js +11 -0
- package/dist/utils/cache-control-metadata.d.ts +4 -0
- package/dist/utils/cache-control-metadata.js +12 -0
- package/dist/utils/client-build-manifest.d.ts +21 -0
- package/dist/utils/client-build-manifest.js +87 -0
- package/dist/utils/client-entry-manifest.d.ts +11 -0
- package/dist/utils/client-entry-manifest.js +29 -0
- package/dist/utils/client-runtime-metadata.d.ts +45 -0
- package/dist/utils/client-runtime-metadata.js +63 -0
- package/dist/utils/commonjs-loader.d.ts +16 -0
- package/dist/utils/commonjs-loader.js +100 -0
- package/dist/utils/compare.d.ts +4 -0
- package/dist/utils/compare.js +8 -0
- package/dist/utils/deployment-id.d.ts +8 -0
- package/dist/utils/deployment-id.js +22 -0
- package/dist/utils/dev-error-recovery-event.d.ts +4 -0
- package/dist/utils/dev-error-recovery-event.js +4 -0
- package/dist/utils/domain-locale.d.ts +26 -0
- package/dist/utils/domain-locale.js +50 -0
- package/dist/utils/encode-cache-tag.d.ts +30 -0
- package/dist/utils/encode-cache-tag.js +36 -0
- package/dist/utils/error-cause.d.ts +4 -0
- package/dist/utils/error-cause.js +95 -0
- package/dist/utils/has-trailing-comma.d.ts +24 -0
- package/dist/utils/has-trailing-comma.js +62 -0
- package/dist/utils/hash.d.ts +24 -0
- package/dist/utils/hash.js +55 -0
- package/dist/utils/html-limited-bots.d.ts +21 -0
- package/dist/utils/html-limited-bots.js +35 -0
- package/dist/utils/lazy-chunks.d.ts +59 -0
- package/dist/utils/lazy-chunks.js +112 -0
- package/dist/utils/manifest-paths.d.ts +30 -0
- package/dist/utils/manifest-paths.js +66 -0
- package/dist/utils/mdx-scan.d.ts +9 -0
- package/dist/utils/mdx-scan.js +34 -0
- package/dist/utils/navigation-signal.d.ts +4 -0
- package/dist/utils/navigation-signal.js +12 -0
- package/dist/utils/number.d.ts +4 -0
- package/dist/utils/number.js +6 -0
- package/dist/utils/parse-cookie.d.ts +13 -0
- package/dist/utils/parse-cookie.js +52 -0
- package/dist/utils/path.d.ts +22 -0
- package/dist/utils/path.js +30 -0
- package/dist/utils/prerender-output-paths.d.ts +14 -0
- package/dist/utils/prerender-output-paths.js +22 -0
- package/dist/utils/project.d.ts +76 -0
- package/dist/utils/project.js +213 -0
- package/dist/utils/promise.d.ts +4 -0
- package/dist/utils/promise.js +6 -0
- package/dist/utils/public-routes.d.ts +4 -0
- package/dist/utils/public-routes.js +48 -0
- package/dist/utils/query.d.ts +49 -0
- package/dist/utils/query.js +122 -0
- package/dist/utils/record.d.ts +4 -0
- package/dist/utils/record.js +6 -0
- package/dist/utils/regex.d.ts +4 -0
- package/dist/utils/regex.js +6 -0
- package/dist/utils/safe-json-file.d.ts +17 -0
- package/dist/utils/safe-json-file.js +23 -0
- package/dist/utils/sorted-array.d.ts +8 -0
- package/dist/utils/sorted-array.js +20 -0
- package/dist/utils/text-stream.d.ts +28 -0
- package/dist/utils/text-stream.js +64 -0
- package/dist/utils/vinext-root.d.ts +23 -0
- package/dist/utils/vinext-root.js +29 -0
- package/dist/utils/virtual-module.d.ts +5 -0
- package/dist/utils/virtual-module.js +0 -0
- package/dist/utils/vite-version.d.ts +21 -0
- package/dist/utils/vite-version.js +42 -0
- package/package.json +145 -0
|
@@ -0,0 +1,1050 @@
|
|
|
1
|
+
import { normalizePageExtensions } from "../routing/file-matcher.js";
|
|
2
|
+
import { applyLocaleToRoutes, isExternalUrl } from "./config-matchers.js";
|
|
3
|
+
import { isUnknownRecord } from "../utils/record.js";
|
|
4
|
+
import { getHtmlLimitedBotRegex } from "../utils/html-limited-bots.js";
|
|
5
|
+
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "../shims/constants.js";
|
|
6
|
+
import { loadTsconfigResolutionForRoot } from "./tsconfig-paths.js";
|
|
7
|
+
import { getViteMajorVersion } from "../utils/vite-version.js";
|
|
8
|
+
import { loadCommonJsModule, shouldRetryAsCommonJs } from "../utils/commonjs-loader.js";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { randomUUID } from "node:crypto";
|
|
14
|
+
import commonjs from "vite-plugin-commonjs";
|
|
15
|
+
//#region src/config/next-config.ts
|
|
16
|
+
/**
|
|
17
|
+
* next.config.js / next.config.mjs / next.config.ts parser
|
|
18
|
+
*
|
|
19
|
+
* Loads the Next.js config file (if present) and extracts supported options.
|
|
20
|
+
* Unsupported options are logged as warnings.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Parse a body size limit value (string or number) into bytes.
|
|
24
|
+
* Accepts Next.js-style strings like "1mb", "500kb", "10mb", bare number strings like "1048576" (bytes),
|
|
25
|
+
* and numeric values. Supports b, kb, mb, gb, tb, pb units.
|
|
26
|
+
* Returns the default 1MB if the value is not provided or invalid.
|
|
27
|
+
* Throws if the parsed value is less than 1.
|
|
28
|
+
*/
|
|
29
|
+
function parseBodySizeLimit(value) {
|
|
30
|
+
if (value === void 0 || value === null) return 1 * 1024 * 1024;
|
|
31
|
+
if (typeof value === "number") {
|
|
32
|
+
if (value < 1) throw new Error(`Body size limit must be a positive number, got ${value}`);
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
const match = value.trim().match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb|tb|pb)?$/i);
|
|
36
|
+
if (!match) {
|
|
37
|
+
console.warn(`[vinext] Invalid bodySizeLimit value: "${value}". Expected a number or a string like "1mb", "500kb". Falling back to 1MB.`);
|
|
38
|
+
return 1 * 1024 * 1024;
|
|
39
|
+
}
|
|
40
|
+
const num = parseFloat(match[1]);
|
|
41
|
+
const unit = (match[2] ?? "b").toLowerCase();
|
|
42
|
+
let bytes;
|
|
43
|
+
switch (unit) {
|
|
44
|
+
case "b":
|
|
45
|
+
bytes = Math.floor(num);
|
|
46
|
+
break;
|
|
47
|
+
case "kb":
|
|
48
|
+
bytes = Math.floor(num * 1024);
|
|
49
|
+
break;
|
|
50
|
+
case "mb":
|
|
51
|
+
bytes = Math.floor(num * 1024 * 1024);
|
|
52
|
+
break;
|
|
53
|
+
case "gb":
|
|
54
|
+
bytes = Math.floor(num * 1024 * 1024 * 1024);
|
|
55
|
+
break;
|
|
56
|
+
case "tb":
|
|
57
|
+
bytes = Math.floor(num * 1024 * 1024 * 1024 * 1024);
|
|
58
|
+
break;
|
|
59
|
+
case "pb":
|
|
60
|
+
bytes = Math.floor(num * 1024 * 1024 * 1024 * 1024 * 1024);
|
|
61
|
+
break;
|
|
62
|
+
default: return 1 * 1024 * 1024;
|
|
63
|
+
}
|
|
64
|
+
if (bytes < 1) throw new Error(`Body size limit must be a positive number, got ${bytes}`);
|
|
65
|
+
return bytes;
|
|
66
|
+
}
|
|
67
|
+
const CONFIG_FILES = [
|
|
68
|
+
"next.config.ts",
|
|
69
|
+
"next.config.mts",
|
|
70
|
+
"next.config.mjs",
|
|
71
|
+
"next.config.js",
|
|
72
|
+
"next.config.cjs"
|
|
73
|
+
];
|
|
74
|
+
const DEFAULT_EXPIRE_TIME = 31536e3;
|
|
75
|
+
/**
|
|
76
|
+
* Default cap for the App Router preload `Link` header length, matching the
|
|
77
|
+
* Next.js `defaultConfig.reactMaxHeadersLength`.
|
|
78
|
+
* @see https://nextjs.org/docs/app/api-reference/config/next-config-js/reactMaxHeadersLength
|
|
79
|
+
*/
|
|
80
|
+
const DEFAULT_REACT_MAX_HEADERS_LENGTH = 6e3;
|
|
81
|
+
/**
|
|
82
|
+
* Check whether an error indicates a CJS module was loaded in an ESM context
|
|
83
|
+
* (i.e. the file uses `require()` which is not available in ESM).
|
|
84
|
+
*/
|
|
85
|
+
function isCjsError(e) {
|
|
86
|
+
if (!(e instanceof Error)) return false;
|
|
87
|
+
const msg = e.message;
|
|
88
|
+
return msg.includes("require is not a function") || msg.includes("require is not defined") || msg.includes("exports is not defined") || msg.includes("module is not defined") || msg.includes("__dirname is not defined") || msg.includes("__filename is not defined");
|
|
89
|
+
}
|
|
90
|
+
const DEFAULT_PHASE = PHASE_DEVELOPMENT_SERVER;
|
|
91
|
+
/**
|
|
92
|
+
* Emit a warning when config loading fails, with a targeted hint for
|
|
93
|
+
* known plugin wrappers that are unnecessary in vinext.
|
|
94
|
+
*/
|
|
95
|
+
function warnConfigLoadFailure(filename, err) {
|
|
96
|
+
const msg = err.message ?? "";
|
|
97
|
+
const stack = err.stack ?? "";
|
|
98
|
+
const isNextIntlPlugin = msg.includes("next-intl") || stack.includes("next-intl/plugin") || stack.includes("next-intl/dist");
|
|
99
|
+
console.log();
|
|
100
|
+
console.error(`[vinext] Failed to load ${filename}: ${msg}`);
|
|
101
|
+
console.log();
|
|
102
|
+
if (isNextIntlPlugin) console.warn("[vinext] Hint: createNextIntlPlugin() is not needed with vinext. Remove the next-intl/plugin wrapper from your next.config — vinext auto-detects next-intl and registers the i18n config alias automatically.");
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Resolve a Next-style config value, calling it if it's a function-form config
|
|
106
|
+
* (Next.js supports `module.exports = (phase, opts) => config`).
|
|
107
|
+
*/
|
|
108
|
+
async function resolveConfigValue(config, phase = DEFAULT_PHASE) {
|
|
109
|
+
if (typeof config === "function") return await config(phase, { defaultConfig: {} });
|
|
110
|
+
return config;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Named export attached by `cjsGlobalsInjectorPlugin` when the source
|
|
114
|
+
* statically looks like it assigns to `module.exports`. Holds the wrapper
|
|
115
|
+
* `module` object so {@link unwrapConfig} can read back the user's CJS-style
|
|
116
|
+
* export. Pure-ESM configs skip the wrapper entirely and rely on the ESM
|
|
117
|
+
* `default` export instead.
|
|
118
|
+
*/
|
|
119
|
+
const VINEXT_CJS_EXPORTS_KEY = "__vinext_cjs_exports";
|
|
120
|
+
/**
|
|
121
|
+
* Companion named export pointing at the initial empty `{}` that the wrapper
|
|
122
|
+
* is constructed with. Lets {@link unwrapConfig} distinguish "user reassigned
|
|
123
|
+
* or mutated module.exports" from "module.exports is still the untouched
|
|
124
|
+
* empty wrapper" — the latter happens when {@link reassignsModuleExports}
|
|
125
|
+
* matches inside a string or comment (a harmless false positive that should
|
|
126
|
+
* still fall through to the ESM `default` export).
|
|
127
|
+
*/
|
|
128
|
+
const VINEXT_CJS_INITIAL_KEY = "__vinext_cjs_initial_exports";
|
|
129
|
+
/**
|
|
130
|
+
* Unwrap the config value from a loaded module namespace.
|
|
131
|
+
*
|
|
132
|
+
* Prefers `module.exports` (CJS style) when the config file reassigned it,
|
|
133
|
+
* otherwise falls back to `default`/the namespace itself. Mirrors Next.js's
|
|
134
|
+
* behaviour, where the config is loaded through `Module._compile` and CJS
|
|
135
|
+
* assignments override any ESM-style exports.
|
|
136
|
+
*
|
|
137
|
+
* The presence of the `__vinext_cjs_exports` named export is the static
|
|
138
|
+
* signal (set by `cjsGlobalsInjectorPlugin` when `reassignsModuleExports`
|
|
139
|
+
* matched) that this file might use CJS-style exports. We then disambiguate
|
|
140
|
+
* "user actually touched module.exports" from "static heuristic was a false
|
|
141
|
+
* positive" by comparing identity against the initial empty wrapper: if
|
|
142
|
+
* `module.exports` is still the original `{}`, fall back to ESM `default`.
|
|
143
|
+
*/
|
|
144
|
+
async function unwrapConfig(mod, phase = PHASE_DEVELOPMENT_SERVER) {
|
|
145
|
+
const cjsExports = (mod?.[VINEXT_CJS_EXPORTS_KEY])?.exports;
|
|
146
|
+
const cjsInitial = mod?.[VINEXT_CJS_INITIAL_KEY];
|
|
147
|
+
if (cjsExports !== void 0 && cjsExports !== null && (cjsExports !== cjsInitial || typeof cjsExports === "object" && Object.keys(cjsExports).length > 0)) return await resolveConfigValue(cjsExports, phase);
|
|
148
|
+
return await resolveConfigValue(mod.default ?? mod, phase);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Resolve a path through filesystem symlinks, falling back to the original
|
|
152
|
+
* path when the file does not exist (e.g. virtual ids, query-suffixed ids).
|
|
153
|
+
*/
|
|
154
|
+
function safeRealpath(p) {
|
|
155
|
+
try {
|
|
156
|
+
return fs.realpathSync(p);
|
|
157
|
+
} catch {
|
|
158
|
+
return p;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Whole-word substring check for any of the CJS-style globals that the
|
|
163
|
+
* injector plugin would shim. Used to skip the transform entirely for the
|
|
164
|
+
* common case where the config is pure ESM (no `__filename`, `__dirname`,
|
|
165
|
+
* `require`, `module`, or `exports` references).
|
|
166
|
+
*
|
|
167
|
+
* False positives are harmless: a comment, string literal, or unrelated
|
|
168
|
+
* identifier like `node:module` will trigger the transform unnecessarily,
|
|
169
|
+
* but the resulting injection is idempotent and the loaded config is
|
|
170
|
+
* unaffected. False negatives would be a correctness bug, so we err on the
|
|
171
|
+
* side of matching too eagerly.
|
|
172
|
+
*
|
|
173
|
+
* Note: `\bexports\b` does not match `export default` (different word
|
|
174
|
+
* boundaries), and `\brequire\b` does not match `requireSomething`.
|
|
175
|
+
*/
|
|
176
|
+
function referencesCjsGlobals(source) {
|
|
177
|
+
return /\b(?:__filename|__dirname|require|module|exports)\b/.test(source);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Static heuristic: returns true when the source appears to assign to
|
|
181
|
+
* `module.exports` — either via `module.exports = …`, `module.exports.foo = …`,
|
|
182
|
+
* or `module.exports[…] = …`. Used to decide whether the injector plugin
|
|
183
|
+
* needs to wire up the wrapper `module` object so {@link unwrapConfig} can
|
|
184
|
+
* read back the user's CJS-style export.
|
|
185
|
+
*
|
|
186
|
+
* Pure-ESM configs skip the wrapper entirely, which means a faster transform
|
|
187
|
+
* (no extra `export const` line) and a simpler unwrap path (no need to
|
|
188
|
+
* disambiguate "initial empty object" from "user reassigned to {}").
|
|
189
|
+
*
|
|
190
|
+
* Like {@link referencesCjsGlobals}, false positives are harmless: at worst
|
|
191
|
+
* we emit an unused `__vinext_cjs_exports` named export, and `unwrapConfig`
|
|
192
|
+
* still prefers it (it points at an empty object, which then gets treated
|
|
193
|
+
* as the config — equivalent to today's sentinel logic for pure-ESM files
|
|
194
|
+
* that happen to mention `module.exports` only in a string).
|
|
195
|
+
*/
|
|
196
|
+
function reassignsModuleExports(source) {
|
|
197
|
+
return /\bmodule\s*\.\s*exports\b\s*(?:=(?!=)|\.\s*[A-Za-z_$][\w$]*\s*=(?!=)|\[)/.test(source);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Vite plugin that prepends CJS-style globals (`__filename`, `__dirname`,
|
|
201
|
+
* `module`, `exports`, `require`) to the next.config.* source before
|
|
202
|
+
* Vite's module runner evaluates it.
|
|
203
|
+
*
|
|
204
|
+
* Next.js's `next.config.ts` loader (packages/next/src/build/next-config-ts/
|
|
205
|
+
* transpile-config.ts → require-hook.ts) feeds the file through Node's
|
|
206
|
+
* `Module._compile`, which provides these CJS globals even when the source
|
|
207
|
+
* uses ESM syntax. Upstream test fixtures in `test/e2e/app-dir/next-config-ts*`
|
|
208
|
+
* rely on that, e.g. `node-api-cjs/next.config.ts` reads
|
|
209
|
+
* `fs.readFileSync(path.join(__dirname, 'foo.txt'), 'utf8')`. vinext loads
|
|
210
|
+
* configs through Vite's ESM-only module runner, so we inject the same
|
|
211
|
+
* globals as plain `const` declarations.
|
|
212
|
+
*
|
|
213
|
+
* For configs that don't reference any CJS global (the common case — every
|
|
214
|
+
* upstream `next-config-ts` fixture except `node-api-cjs` is pure ESM) we
|
|
215
|
+
* skip the transform entirely; see {@link referencesCjsGlobals}.
|
|
216
|
+
*
|
|
217
|
+
* `module.exports` reassignment is preserved by exposing the injected
|
|
218
|
+
* `module` object as a named export (see {@link VINEXT_CJS_EXPORTS_KEY}) and
|
|
219
|
+
* reading it back in {@link unwrapConfig}.
|
|
220
|
+
*/
|
|
221
|
+
function cjsGlobalsInjectorPlugin(configPath) {
|
|
222
|
+
const normalizedTarget = safeRealpath(path.resolve(configPath));
|
|
223
|
+
return {
|
|
224
|
+
name: "vinext:next-config-cjs-globals",
|
|
225
|
+
enforce: "pre",
|
|
226
|
+
transform(code, id) {
|
|
227
|
+
const idPath = id.startsWith("file://") ? fileURLToPath(id) : id.split("?")[0];
|
|
228
|
+
if (safeRealpath(path.resolve(idPath)) !== normalizedTarget) return null;
|
|
229
|
+
if (!referencesCjsGlobals(code)) return null;
|
|
230
|
+
const dirname = path.dirname(normalizedTarget);
|
|
231
|
+
const filenameLiteral = JSON.stringify(normalizedTarget);
|
|
232
|
+
const dirnameLiteral = JSON.stringify(dirname);
|
|
233
|
+
const requireBaseLiteral = JSON.stringify(path.join(dirname, "package.json"));
|
|
234
|
+
const hasOwnDirname = /\b(?:const|let|var)\s+__dirname\b/.test(code);
|
|
235
|
+
const hasOwnFilename = /\b(?:const|let|var)\s+__filename\b/.test(code);
|
|
236
|
+
const hasOwnRequire = /\b(?:const|let|var)\s+require\b/.test(code);
|
|
237
|
+
const moduleLines = reassignsModuleExports(code) ? `const __vinextInitialExports = {};
|
|
238
|
+
const module = { exports: __vinextInitialExports };
|
|
239
|
+
const exports = module.exports;
|
|
240
|
+
export const ${VINEXT_CJS_EXPORTS_KEY} = module;\nexport const ${VINEXT_CJS_INITIAL_KEY} = __vinextInitialExports;\n` : "";
|
|
241
|
+
return {
|
|
242
|
+
code: (hasOwnRequire ? "" : `import { createRequire as __vinextCreateRequire } from "node:module";\n`) + (hasOwnFilename ? "" : `const __filename = ${filenameLiteral};\n`) + (hasOwnDirname ? "" : `const __dirname = ${dirnameLiteral};\n`) + (hasOwnRequire ? "" : `const require = __vinextCreateRequire(${requireBaseLiteral});\n`) + moduleLines + code,
|
|
243
|
+
map: null
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function findNextConfigPath(root) {
|
|
249
|
+
for (const filename of CONFIG_FILES) {
|
|
250
|
+
const configPath = path.join(root, filename);
|
|
251
|
+
if (fs.existsSync(configPath)) return configPath;
|
|
252
|
+
}
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
async function resolveNextConfigInput(config, phase = PHASE_DEVELOPMENT_SERVER) {
|
|
256
|
+
return await resolveConfigValue(config, phase);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Load a CJS-flavoured next.config.{js,cjs} via createRequire.
|
|
260
|
+
*
|
|
261
|
+
* For `.cjs` (or `.js` in a non-type-module package) Node's loader picks the
|
|
262
|
+
* right format automatically and `require()` just works. For `.js` in a
|
|
263
|
+
* `"type": "module"` package, retry through the shared in-memory CommonJS
|
|
264
|
+
* loader so nested local `.js` dependencies retain CommonJS semantics too.
|
|
265
|
+
*/
|
|
266
|
+
async function loadConfigViaRequire(configPath, root, phase) {
|
|
267
|
+
const require = createRequire(path.join(root, "package.json"));
|
|
268
|
+
try {
|
|
269
|
+
return await unwrapConfig(require(configPath), phase);
|
|
270
|
+
} catch (e) {
|
|
271
|
+
if (!shouldRetryAsCommonJs(e, configPath)) throw e;
|
|
272
|
+
return await unwrapConfig(loadCommonJsModule(configPath), phase);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Find and load the next.config file from the project root.
|
|
277
|
+
* Returns null if no config file is found.
|
|
278
|
+
*
|
|
279
|
+
* Attempts Vite's module runner first so TS configs and extensionless local
|
|
280
|
+
* imports (e.g. `import "./env"`) resolve consistently. If loading fails due
|
|
281
|
+
* to CJS constructs (`require`, `module.exports`), falls back to `createRequire`
|
|
282
|
+
* so common CJS plugin wrappers (nextra, @next/mdx, etc.) still work, including
|
|
283
|
+
* `next.config.js` files written in CJS syntax inside a `"type": "module"`
|
|
284
|
+
* package (the common shape after `vinext init`).
|
|
285
|
+
*/
|
|
286
|
+
async function loadNextConfig(root, phase = DEFAULT_PHASE) {
|
|
287
|
+
const configPath = findNextConfigPath(root);
|
|
288
|
+
if (!configPath) return null;
|
|
289
|
+
const filename = path.basename(configPath);
|
|
290
|
+
const isTypeScriptConfig = /\.[cm]?ts$/.test(configPath);
|
|
291
|
+
const tsconfigResolution = loadTsconfigResolutionForRoot(root);
|
|
292
|
+
const useNativeTsconfigPaths = !!(isTypeScriptConfig ? tsconfigResolution.baseUrl : null) && getViteMajorVersion() >= 8;
|
|
293
|
+
const normalizedConfigPath = safeRealpath(path.resolve(configPath));
|
|
294
|
+
try {
|
|
295
|
+
const { runnerImport } = await import("vite");
|
|
296
|
+
const { module: mod } = await runnerImport(configPath, {
|
|
297
|
+
root,
|
|
298
|
+
logLevel: "error",
|
|
299
|
+
clearScreen: false,
|
|
300
|
+
resolve: {
|
|
301
|
+
alias: tsconfigResolution.aliases,
|
|
302
|
+
...useNativeTsconfigPaths ? { tsconfigPaths: true } : {},
|
|
303
|
+
extensions: [
|
|
304
|
+
".mjs",
|
|
305
|
+
".js",
|
|
306
|
+
".cjs",
|
|
307
|
+
".mts",
|
|
308
|
+
".ts",
|
|
309
|
+
".cts",
|
|
310
|
+
".jsx",
|
|
311
|
+
".tsx",
|
|
312
|
+
".json"
|
|
313
|
+
]
|
|
314
|
+
},
|
|
315
|
+
plugins: [...isTypeScriptConfig ? [cjsGlobalsInjectorPlugin(configPath)] : [], commonjs({ filter: (id) => {
|
|
316
|
+
const idPath = id.startsWith("file://") ? fileURLToPath(id) : id.split("?")[0];
|
|
317
|
+
if (safeRealpath(path.resolve(idPath)) === normalizedConfigPath) return false;
|
|
318
|
+
return id.includes("node_modules") ? true : void 0;
|
|
319
|
+
} })]
|
|
320
|
+
});
|
|
321
|
+
return await unwrapConfig(mod, phase);
|
|
322
|
+
} catch (e) {
|
|
323
|
+
if (isCjsError(e) && (filename.endsWith(".js") || filename.endsWith(".cjs"))) try {
|
|
324
|
+
return await loadConfigViaRequire(configPath, root, phase);
|
|
325
|
+
} catch (e2) {
|
|
326
|
+
warnConfigLoadFailure(filename, e2);
|
|
327
|
+
throw e2;
|
|
328
|
+
}
|
|
329
|
+
warnConfigLoadFailure(filename, e);
|
|
330
|
+
throw e;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Generate a UUID that doesn't contain "ad" to avoid false-positive ad-blocker hits.
|
|
335
|
+
* Mirrors Next.js's own nanoid retry loop.
|
|
336
|
+
*/
|
|
337
|
+
function safeUUID() {
|
|
338
|
+
let id = randomUUID();
|
|
339
|
+
while (/ad/i.test(id)) id = randomUUID();
|
|
340
|
+
return id;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Call the user's generateBuildId function and validate its return value.
|
|
344
|
+
* Follows Next.js semantics: null return falls back to a random UUID; any
|
|
345
|
+
* other non-string throws. Leading/trailing whitespace is trimmed.
|
|
346
|
+
*
|
|
347
|
+
* @see https://nextjs.org/docs/app/api-reference/config/next-config-js/generateBuildId
|
|
348
|
+
*/
|
|
349
|
+
async function resolveBuildId(generate) {
|
|
350
|
+
if (!generate) return safeUUID();
|
|
351
|
+
const result = await generate();
|
|
352
|
+
if (result === null) return safeUUID();
|
|
353
|
+
if (typeof result !== "string") throw new Error("generateBuildId did not return a string. https://nextjs.org/docs/messages/generatebuildid-not-a-string");
|
|
354
|
+
const trimmed = result.trim();
|
|
355
|
+
if (trimmed.length === 0) throw new Error("generateBuildId returned an empty string. https://nextjs.org/docs/messages/generatebuildid-not-a-string");
|
|
356
|
+
return trimmed;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Normalize the `assetPrefix` option from next.config.
|
|
360
|
+
*
|
|
361
|
+
* Accepts both absolute URLs (`https://cdn.example.com[/subpath]`) and
|
|
362
|
+
* path prefixes (`/custom-asset-prefix`). Trailing slashes are trimmed.
|
|
363
|
+
* Empty/whitespace-only strings are treated as unset and return `""`.
|
|
364
|
+
*
|
|
365
|
+
* Path prefixes that omit the leading slash get one added so they always
|
|
366
|
+
* begin with `/` — this matches how Next.js routes match against them.
|
|
367
|
+
*
|
|
368
|
+
* Non-string values are rejected to surface config mistakes early.
|
|
369
|
+
*
|
|
370
|
+
* @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix
|
|
371
|
+
*/
|
|
372
|
+
function normalizeAssetPrefix(value) {
|
|
373
|
+
if (value === void 0 || value === null || value === "") return "";
|
|
374
|
+
if (typeof value !== "string") throw new Error(`Invalid \`assetPrefix\` configuration: must be a string, got ${typeof value}. Accepts a path prefix ("/custom-asset-prefix") or an absolute URL ("https://cdn.example.com").`);
|
|
375
|
+
let trimmed = value.trim();
|
|
376
|
+
while (trimmed.endsWith("/")) trimmed = trimmed.slice(0, -1);
|
|
377
|
+
if (trimmed === "") return "";
|
|
378
|
+
if (/^https?:\/\//i.test(trimmed)) {
|
|
379
|
+
if (!URL.canParse(trimmed)) throw new Error(`Invalid \`assetPrefix\` configuration: "${value}" is not a parseable URL.`);
|
|
380
|
+
return trimmed;
|
|
381
|
+
}
|
|
382
|
+
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
383
|
+
}
|
|
384
|
+
function resolveDeploymentId(configDeploymentId) {
|
|
385
|
+
const deploymentId = configDeploymentId !== void 0 ? configDeploymentId : process.env.NEXT_DEPLOYMENT_ID;
|
|
386
|
+
if (deploymentId === void 0 || deploymentId === "") return void 0;
|
|
387
|
+
if (typeof deploymentId !== "string") throw new Error("Invalid `deploymentId` configuration: must be a string. https://nextjs.org/docs/messages/deploymentid-not-a-string");
|
|
388
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(deploymentId)) throw new Error("Invalid `deploymentId` configuration: contains invalid characters. Only alphanumeric characters, hyphens, and underscores are allowed. https://nextjs.org/docs/messages/deploymentid-invalid-characters");
|
|
389
|
+
return deploymentId;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Resolve the App Router RSC compatibility identity for a build.
|
|
393
|
+
*
|
|
394
|
+
* This token is baked into the client bundle and echoed by the server in the
|
|
395
|
+
* `X-Vinext-RSC-Compatibility-Id` response header; browser navigation rejects
|
|
396
|
+
* RSC payloads whose token differs (deploy skew) without exposing the raw
|
|
397
|
+
* build ID. When the user pins a `deploymentId` we reuse it (already stable
|
|
398
|
+
* across plugin instances); otherwise we mint a random UUID.
|
|
399
|
+
*
|
|
400
|
+
* NOTE: like `resolveBuildId`, this is non-deterministic in the no-deploymentId
|
|
401
|
+
* case, so a single `vinext build` that instantiates the plugin more than once
|
|
402
|
+
* (App Router `buildApp()` + the hybrid Pages Router `vite.build()`) must
|
|
403
|
+
* resolve it once and share it — see `__VINEXT_SHARED_RSC_COMPATIBILITY_ID`.
|
|
404
|
+
*/
|
|
405
|
+
function createRscCompatibilityId(nextConfig) {
|
|
406
|
+
if (nextConfig.deploymentId) return nextConfig.deploymentId;
|
|
407
|
+
return randomUUID();
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Converts a cache handler path to a filesystem path.
|
|
411
|
+
* ESM's import.meta.resolve() returns file:// URLs which break when concatenated
|
|
412
|
+
* with path operations like path.join or path.relative.
|
|
413
|
+
* @param filePath - Absolute path, relative path, or file:// URL (e.g. from import.meta.resolve)
|
|
414
|
+
* @returns A filesystem path suitable for path operations
|
|
415
|
+
*/
|
|
416
|
+
function resolveCacheHandlerPathToFilesystem(filePath) {
|
|
417
|
+
if (filePath.startsWith("file://")) return fileURLToPath(filePath);
|
|
418
|
+
return filePath;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Validate and resolve `images.loaderFile`, mirroring Next.js config normalization.
|
|
422
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/next/src/server/config.ts
|
|
423
|
+
*/
|
|
424
|
+
function resolveImagesConfig(images, root) {
|
|
425
|
+
if (!images) return void 0;
|
|
426
|
+
const resolved = { ...images };
|
|
427
|
+
if (!resolved.loader) resolved.loader = "default";
|
|
428
|
+
if (resolved.loaderFile) {
|
|
429
|
+
if (resolved.loader !== "default" && resolved.loader !== "custom") throw new Error(`Specified images.loader property (${resolved.loader}) cannot be used with images.loaderFile property. Please set images.loader to "custom".`);
|
|
430
|
+
const absolutePath = path.resolve(root, resolved.loaderFile);
|
|
431
|
+
if (!fs.existsSync(absolutePath)) throw new Error(`Specified images.loaderFile does not exist at "${absolutePath}".`);
|
|
432
|
+
resolved.loaderFile = absolutePath;
|
|
433
|
+
}
|
|
434
|
+
return resolved;
|
|
435
|
+
}
|
|
436
|
+
function resolveHtmlLimitedBots(value) {
|
|
437
|
+
const source = value instanceof RegExp ? value.source : typeof value === "string" ? value : void 0;
|
|
438
|
+
if (!source) return void 0;
|
|
439
|
+
try {
|
|
440
|
+
getHtmlLimitedBotRegex(source);
|
|
441
|
+
} catch (error) {
|
|
442
|
+
throw new Error("Invalid next.config option \"htmlLimitedBots\": expected a valid regular expression source", { cause: error });
|
|
443
|
+
}
|
|
444
|
+
return source;
|
|
445
|
+
}
|
|
446
|
+
function readOptionalRecord(value) {
|
|
447
|
+
return isUnknownRecord(value) ? value : void 0;
|
|
448
|
+
}
|
|
449
|
+
function readOptionalString(value) {
|
|
450
|
+
return typeof value === "string" ? value : void 0;
|
|
451
|
+
}
|
|
452
|
+
function readOptionalBodySizeLimit(value) {
|
|
453
|
+
return typeof value === "string" || typeof value === "number" ? value : void 0;
|
|
454
|
+
}
|
|
455
|
+
function readStringArray(value) {
|
|
456
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Convert lightningcss feature names from `experimental.lightningCssFeatures`
|
|
460
|
+
* into a numeric bitmask consumable by the `lightningcss` `transform()` /
|
|
461
|
+
* `bundle()` API (the `include` / `exclude` options).
|
|
462
|
+
*
|
|
463
|
+
* The mapping mirrors Next.js exactly so the same dash-case feature names
|
|
464
|
+
* accepted by `next.config` produce the same bits on both sides. See:
|
|
465
|
+
* - `.nextjs-ref/packages/next/src/server/config-shared.ts` (`LIGHTNINGCSS_FEATURE_NAMES`)
|
|
466
|
+
* - `.nextjs-ref/crates/next-core/src/next_config.rs` (`lightningcss_feature_names_to_mask`)
|
|
467
|
+
* - `lightningcss/node/targets.d.ts` (`Features` enum bits)
|
|
468
|
+
*
|
|
469
|
+
* Unknown names emit a warning (matching the Next.js Rust path, which errors;
|
|
470
|
+
* we warn instead so a stray name doesn't break the whole build).
|
|
471
|
+
*/
|
|
472
|
+
const LIGHTNINGCSS_FEATURE_BITS = {
|
|
473
|
+
nesting: 1,
|
|
474
|
+
"not-selector-list": 2,
|
|
475
|
+
"dir-selector": 4,
|
|
476
|
+
"lang-selector-list": 8,
|
|
477
|
+
"is-selector": 16,
|
|
478
|
+
"text-decoration-thickness-percent": 32,
|
|
479
|
+
"media-interval-syntax": 64,
|
|
480
|
+
"media-range-syntax": 128,
|
|
481
|
+
"custom-media-queries": 256,
|
|
482
|
+
"clamp-function": 512,
|
|
483
|
+
"color-function": 1024,
|
|
484
|
+
"oklab-colors": 2048,
|
|
485
|
+
"lab-colors": 4096,
|
|
486
|
+
"p3-colors": 8192,
|
|
487
|
+
"hex-alpha-colors": 16384,
|
|
488
|
+
"space-separated-color-notation": 32768,
|
|
489
|
+
"font-family-system-ui": 65536,
|
|
490
|
+
"double-position-gradients": 131072,
|
|
491
|
+
"vendor-prefixes": 262144,
|
|
492
|
+
"logical-properties": 524288,
|
|
493
|
+
"light-dark": 1048576,
|
|
494
|
+
selectors: 31,
|
|
495
|
+
"media-queries": 448,
|
|
496
|
+
colors: 1113088
|
|
497
|
+
};
|
|
498
|
+
function lightningCssFeatureNamesToMask(names) {
|
|
499
|
+
let mask = 0;
|
|
500
|
+
for (const name of names) {
|
|
501
|
+
const bit = LIGHTNINGCSS_FEATURE_BITS[name];
|
|
502
|
+
if (bit === void 0) {
|
|
503
|
+
console.warn(`[vinext] Unknown lightningcss feature name "${name}" in experimental.lightningCssFeatures — ignoring.`);
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
mask |= bit;
|
|
507
|
+
}
|
|
508
|
+
return mask;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Serialize a `compiler.define` / `compiler.defineServer` map into the
|
|
512
|
+
* Vite-friendly `Record<string, string>` shape where each value is already
|
|
513
|
+
* a JSON-encoded literal of source code. Entries whose values are not a
|
|
514
|
+
* string/number/boolean are silently dropped, matching how Next.js types
|
|
515
|
+
* the API (other shapes are not part of the contract).
|
|
516
|
+
*
|
|
517
|
+
* Mirrors Next.js: packages/next/src/build/define-env.ts (serializeDefineEnv).
|
|
518
|
+
*/
|
|
519
|
+
function serializeCompilerDefine(value) {
|
|
520
|
+
if (!isUnknownRecord(value)) return {};
|
|
521
|
+
const out = {};
|
|
522
|
+
for (const [key, raw] of Object.entries(value)) if (typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean") out[key] = JSON.stringify(raw);
|
|
523
|
+
return out;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Defaults for `experimental.staleTimes` (in seconds), matching Next.js'
|
|
527
|
+
* `config-shared.ts` defaults.
|
|
528
|
+
*/
|
|
529
|
+
const DEFAULT_STALE_TIMES = {
|
|
530
|
+
dynamic: 0,
|
|
531
|
+
static: 300
|
|
532
|
+
};
|
|
533
|
+
/**
|
|
534
|
+
* Parse `experimental.staleTimes` from a raw next.config object.
|
|
535
|
+
*
|
|
536
|
+
* Mirrors Next.js' `build/define-env.ts` parsing logic:
|
|
537
|
+
* - missing / NaN / negative values fall back to the documented defaults
|
|
538
|
+
* (`dynamic: 0`, `static: 300`) — matching Next.js parity and the
|
|
539
|
+
* non-negative guard in `resolvePrefetchCacheTtl`
|
|
540
|
+
* - all values are in seconds
|
|
541
|
+
*
|
|
542
|
+
* @see https://nextjs.org/docs/app/api-reference/config/next-config-js/staleTimes
|
|
543
|
+
*/
|
|
544
|
+
function resolveStaleTimes(experimental) {
|
|
545
|
+
const staleTimes = readOptionalRecord(experimental?.staleTimes);
|
|
546
|
+
const dynamicRaw = Number(staleTimes?.dynamic);
|
|
547
|
+
const staticRaw = Number(staleTimes?.static);
|
|
548
|
+
return {
|
|
549
|
+
dynamic: Number.isFinite(dynamicRaw) && dynamicRaw >= 0 ? dynamicRaw : DEFAULT_STALE_TIMES.dynamic,
|
|
550
|
+
static: Number.isFinite(staticRaw) && staticRaw >= 0 ? staticRaw : DEFAULT_STALE_TIMES.static
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Resolve a NextConfig into a fully-resolved ResolvedNextConfig.
|
|
555
|
+
* Awaits async functions for redirects/rewrites/headers.
|
|
556
|
+
*/
|
|
557
|
+
async function resolveNextConfig(config, root = process.cwd(), options = {}) {
|
|
558
|
+
if (!config) {
|
|
559
|
+
const buildId = await resolveBuildId(void 0);
|
|
560
|
+
const deploymentId = resolveDeploymentId(void 0);
|
|
561
|
+
const resolved = {
|
|
562
|
+
env: {},
|
|
563
|
+
basePath: "",
|
|
564
|
+
assetPrefix: "",
|
|
565
|
+
trailingSlash: false,
|
|
566
|
+
output: "",
|
|
567
|
+
pageExtensions: normalizePageExtensions(),
|
|
568
|
+
resolveExtensions: null,
|
|
569
|
+
serverResolveExtensions: null,
|
|
570
|
+
cacheComponents: false,
|
|
571
|
+
appNavFailHandling: false,
|
|
572
|
+
gestureTransition: false,
|
|
573
|
+
prefetchInlining: false,
|
|
574
|
+
redirects: [],
|
|
575
|
+
rewrites: {
|
|
576
|
+
beforeFiles: [],
|
|
577
|
+
afterFiles: [],
|
|
578
|
+
fallback: []
|
|
579
|
+
},
|
|
580
|
+
headers: [],
|
|
581
|
+
images: void 0,
|
|
582
|
+
i18n: null,
|
|
583
|
+
mdx: null,
|
|
584
|
+
aliases: {},
|
|
585
|
+
allowedDevOrigins: [],
|
|
586
|
+
serverActionsAllowedOrigins: [],
|
|
587
|
+
optimizePackageImports: [],
|
|
588
|
+
inlineCss: false,
|
|
589
|
+
serverActionsBodySizeLimit: 1 * 1024 * 1024,
|
|
590
|
+
serverActionsBodySizeLimitLabel: "1 MB",
|
|
591
|
+
expireTime: DEFAULT_EXPIRE_TIME,
|
|
592
|
+
reactMaxHeadersLength: DEFAULT_REACT_MAX_HEADERS_LENGTH,
|
|
593
|
+
htmlLimitedBots: void 0,
|
|
594
|
+
serverExternalPackages: [],
|
|
595
|
+
cacheHandler: void 0,
|
|
596
|
+
cacheMaxMemorySize: void 0,
|
|
597
|
+
enablePrerenderSourceMaps: true,
|
|
598
|
+
appShells: false,
|
|
599
|
+
hashSalt: process.env.NEXT_HASH_SALT ?? "",
|
|
600
|
+
buildId,
|
|
601
|
+
deploymentId,
|
|
602
|
+
sassOptions: null,
|
|
603
|
+
removeConsole: false,
|
|
604
|
+
disableOptimizedLoading: false,
|
|
605
|
+
scrollRestoration: false,
|
|
606
|
+
compilerDefine: {},
|
|
607
|
+
compilerDefineServer: {},
|
|
608
|
+
instrumentationClientInject: [],
|
|
609
|
+
clientTraceMetadata: void 0,
|
|
610
|
+
staleTimes: { ...DEFAULT_STALE_TIMES },
|
|
611
|
+
useLightningcss: false,
|
|
612
|
+
lightningCssFeatures: {
|
|
613
|
+
include: 0,
|
|
614
|
+
exclude: 0
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
detectNextIntlConfig(root, resolved);
|
|
618
|
+
return resolved;
|
|
619
|
+
}
|
|
620
|
+
let redirects = [];
|
|
621
|
+
if (config.redirects) {
|
|
622
|
+
const result = await config.redirects();
|
|
623
|
+
redirects = Array.isArray(result) ? result : [];
|
|
624
|
+
}
|
|
625
|
+
let rewrites = {
|
|
626
|
+
beforeFiles: [],
|
|
627
|
+
afterFiles: [],
|
|
628
|
+
fallback: []
|
|
629
|
+
};
|
|
630
|
+
if (config.rewrites) {
|
|
631
|
+
const result = await config.rewrites();
|
|
632
|
+
if (Array.isArray(result)) rewrites.afterFiles = result;
|
|
633
|
+
else rewrites = {
|
|
634
|
+
beforeFiles: result.beforeFiles ?? [],
|
|
635
|
+
afterFiles: result.afterFiles ?? [],
|
|
636
|
+
fallback: result.fallback ?? []
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
{
|
|
640
|
+
const externalRewrites = [
|
|
641
|
+
...rewrites.beforeFiles,
|
|
642
|
+
...rewrites.afterFiles,
|
|
643
|
+
...rewrites.fallback
|
|
644
|
+
].filter((rewrite) => isExternalUrl(rewrite.destination));
|
|
645
|
+
if (externalRewrites.length > 0) {
|
|
646
|
+
const noun = externalRewrites.length === 1 ? "external rewrite" : "external rewrites";
|
|
647
|
+
const listing = externalRewrites.map((rewrite) => ` ${rewrite.source} → ${rewrite.destination}`).join("\n");
|
|
648
|
+
console.warn(`[vinext] Found ${externalRewrites.length} ${noun} that proxy requests to external origins:\n${listing}\nRequest headers, including credential headers (cookie, authorization, proxy-authorization, x-api-key), are forwarded to the external origin to match Next.js behavior. If you do not want to forward credentials, use an API route or route handler where you control exactly which headers are sent.`);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
let headers = [];
|
|
652
|
+
if (config.headers) headers = await config.headers();
|
|
653
|
+
const webpackProbe = await probeWebpackConfig(config, root, options.dev ?? false);
|
|
654
|
+
const mdx = webpackProbe.mdx;
|
|
655
|
+
const aliases = {
|
|
656
|
+
...extractTurboAliases(config, root),
|
|
657
|
+
...webpackProbe.aliases
|
|
658
|
+
};
|
|
659
|
+
const allowedDevOrigins = Array.isArray(config.allowedDevOrigins) ? config.allowedDevOrigins : [];
|
|
660
|
+
const experimental = readOptionalRecord(config.experimental);
|
|
661
|
+
const serverActionsConfig = readOptionalRecord(experimental?.serverActions);
|
|
662
|
+
const serverActionsAllowedOrigins = readStringArray(serverActionsConfig?.allowedOrigins);
|
|
663
|
+
const serverActionsBodySizeLimitConfig = readOptionalBodySizeLimit(serverActionsConfig?.bodySizeLimit);
|
|
664
|
+
const serverActionsBodySizeLimit = parseBodySizeLimit(serverActionsBodySizeLimitConfig);
|
|
665
|
+
const serverActionsBodySizeLimitLabel = serverActionsBodySizeLimitConfig === void 0 ? "1 MB" : String(serverActionsBodySizeLimitConfig);
|
|
666
|
+
const hashSalt = (readOptionalString(experimental?.outputHashSalt) ?? "") + (process.env.NEXT_HASH_SALT ?? "");
|
|
667
|
+
const htmlLimitedBots = resolveHtmlLimitedBots(config.htmlLimitedBots);
|
|
668
|
+
const rawOptimize = experimental?.optimizePackageImports;
|
|
669
|
+
const optimizePackageImports = Array.isArray(rawOptimize) ? rawOptimize.filter((x) => typeof x === "string") : [];
|
|
670
|
+
const inlineCss = experimental?.inlineCss === true;
|
|
671
|
+
const prefetchInlining = experimental?.prefetchInlining === true || isUnknownRecord(experimental?.prefetchInlining);
|
|
672
|
+
const appShells = experimental?.appShells === true;
|
|
673
|
+
if (appShells) {
|
|
674
|
+
const missingCoFlags = [];
|
|
675
|
+
if (!config.cacheComponents) missingCoFlags.push("cacheComponents");
|
|
676
|
+
if (experimental?.prefetchInlining !== true) missingCoFlags.push("experimental.prefetchInlining");
|
|
677
|
+
if (experimental?.varyParams !== true) missingCoFlags.push("experimental.varyParams");
|
|
678
|
+
if (experimental?.optimisticRouting !== true) missingCoFlags.push("experimental.optimisticRouting");
|
|
679
|
+
if (experimental?.cachedNavigations !== true) missingCoFlags.push("experimental.cachedNavigations");
|
|
680
|
+
if (missingCoFlags.length > 0) console.warn(`[vinext] experimental.appShells is enabled but requires the following co-flags which are not yet supported or not enabled: ${missingCoFlags.join(", ")}. App Shell prefetching behavior is not implemented in vinext (see issue #1614). The flag will be accepted for config compatibility but has no functional effect.`);
|
|
681
|
+
}
|
|
682
|
+
const topLevelServerExternalPackages = Array.isArray(config.serverExternalPackages) ? readStringArray(config.serverExternalPackages) : void 0;
|
|
683
|
+
const legacyServerComponentsExternal = readStringArray(experimental?.serverComponentsExternalPackages);
|
|
684
|
+
const serverExternalPackages = topLevelServerExternalPackages ?? legacyServerComponentsExternal;
|
|
685
|
+
if (experimental?.swcEnvOptions !== void 0) console.warn("[vinext] next.config option \"experimental.swcEnvOptions\" is not applicable and will be ignored (vinext uses Vite, not SWC). A Vite-compatible polyfill solution may be explored in the future.");
|
|
686
|
+
if (experimental?.rootParams !== void 0) console.warn("[vinext] `experimental.rootParams` is no longer needed, because `next/root-params` is available by default. You can remove it from next.config.(js|mjs|ts).");
|
|
687
|
+
const useLightningcss = experimental?.useLightningcss === true;
|
|
688
|
+
const rawLightningCssFeatures = readOptionalRecord(experimental?.lightningCssFeatures);
|
|
689
|
+
const lightningCssFeatures = {
|
|
690
|
+
include: lightningCssFeatureNamesToMask(readStringArray(rawLightningCssFeatures?.include)),
|
|
691
|
+
exclude: lightningCssFeatureNamesToMask(readStringArray(rawLightningCssFeatures?.exclude))
|
|
692
|
+
};
|
|
693
|
+
if (rawLightningCssFeatures && !useLightningcss) console.warn("[vinext] experimental.lightningCssFeatures is set but experimental.useLightningcss is not enabled. The lightningCssFeatures option has no effect without useLightningcss.");
|
|
694
|
+
if (experimental?.cachedNavigations === true && !config.cacheComponents) console.warn("[vinext] `experimental.cachedNavigations` requires `cacheComponents: true` to have any effect. Set `cacheComponents: true` in your next.config, or remove `experimental.cachedNavigations`.");
|
|
695
|
+
if (config.webpack !== void 0) if (mdx || Object.keys(webpackProbe.aliases).length > 0 || webpackProbe.resolveExtensionsCustomized) console.warn("[vinext] next.config option \"webpack\" is only partially supported. vinext preserves resolve.alias, resolve.extensions, and MDX loader settings, but other webpack customization is ignored");
|
|
696
|
+
else console.warn("[vinext] next.config option \"webpack\" is not yet supported and will be ignored");
|
|
697
|
+
const output = readOptionalString(config.output) ?? "";
|
|
698
|
+
if (output && output !== "export" && output !== "standalone") console.warn(`[vinext] Unknown output mode "${output}", ignoring`);
|
|
699
|
+
const pageExtensions = normalizePageExtensions(config.pageExtensions);
|
|
700
|
+
const experimentalTurbo = readOptionalRecord(experimental?.turbo);
|
|
701
|
+
const turbopack = readOptionalRecord(config.turbopack);
|
|
702
|
+
const resolveExtensions = Array.isArray(turbopack?.resolveExtensions) ? readStringArray(turbopack.resolveExtensions) : Array.isArray(experimentalTurbo?.resolveExtensions) ? readStringArray(experimentalTurbo.resolveExtensions) : null;
|
|
703
|
+
let i18n = null;
|
|
704
|
+
if (config.i18n) i18n = {
|
|
705
|
+
locales: config.i18n.locales,
|
|
706
|
+
defaultLocale: config.i18n.defaultLocale,
|
|
707
|
+
localeDetection: config.i18n.localeDetection ?? true,
|
|
708
|
+
domains: config.i18n.domains
|
|
709
|
+
};
|
|
710
|
+
const buildId = await resolveBuildId(config.generateBuildId);
|
|
711
|
+
const deploymentId = resolveDeploymentId(config.deploymentId);
|
|
712
|
+
const cacheHandler = typeof config.cacheHandler === "string" ? resolveCacheHandlerPathToFilesystem(config.cacheHandler) : void 0;
|
|
713
|
+
const cacheMaxMemorySize = typeof config.cacheMaxMemorySize === "number" ? config.cacheMaxMemorySize : void 0;
|
|
714
|
+
if (i18n) {
|
|
715
|
+
const opts = { trailingSlash: config.trailingSlash ?? false };
|
|
716
|
+
redirects = applyLocaleToRoutes(redirects, i18n, "redirect", opts);
|
|
717
|
+
rewrites = {
|
|
718
|
+
beforeFiles: applyLocaleToRoutes(rewrites.beforeFiles, i18n, "rewrite", opts),
|
|
719
|
+
afterFiles: applyLocaleToRoutes(rewrites.afterFiles, i18n, "rewrite", opts),
|
|
720
|
+
fallback: applyLocaleToRoutes(rewrites.fallback, i18n, "rewrite", opts)
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
const resolved = {
|
|
724
|
+
env: config.env ?? {},
|
|
725
|
+
basePath: config.basePath ?? "",
|
|
726
|
+
assetPrefix: normalizeAssetPrefix(config.assetPrefix),
|
|
727
|
+
trailingSlash: config.trailingSlash ?? false,
|
|
728
|
+
output: output === "export" || output === "standalone" ? output : "",
|
|
729
|
+
pageExtensions,
|
|
730
|
+
resolveExtensions: resolveExtensions ?? webpackProbe.resolveExtensions,
|
|
731
|
+
serverResolveExtensions: resolveExtensions ?? webpackProbe.serverResolveExtensions,
|
|
732
|
+
instrumentationClientInject: Array.isArray(config.instrumentationClientInject) ? config.instrumentationClientInject.filter((x) => typeof x === "string") : [],
|
|
733
|
+
cacheComponents: config.cacheComponents ?? false,
|
|
734
|
+
appNavFailHandling: experimental?.appNavFailHandling === true,
|
|
735
|
+
gestureTransition: experimental?.gestureTransition === true,
|
|
736
|
+
prefetchInlining,
|
|
737
|
+
redirects,
|
|
738
|
+
rewrites,
|
|
739
|
+
headers,
|
|
740
|
+
images: resolveImagesConfig(config.images, root),
|
|
741
|
+
i18n,
|
|
742
|
+
mdx,
|
|
743
|
+
aliases,
|
|
744
|
+
allowedDevOrigins,
|
|
745
|
+
serverActionsAllowedOrigins,
|
|
746
|
+
optimizePackageImports,
|
|
747
|
+
inlineCss,
|
|
748
|
+
serverActionsBodySizeLimit,
|
|
749
|
+
serverActionsBodySizeLimitLabel,
|
|
750
|
+
expireTime: typeof config.expireTime === "number" ? config.expireTime : DEFAULT_EXPIRE_TIME,
|
|
751
|
+
reactMaxHeadersLength: typeof config.reactMaxHeadersLength === "number" ? config.reactMaxHeadersLength : DEFAULT_REACT_MAX_HEADERS_LENGTH,
|
|
752
|
+
htmlLimitedBots,
|
|
753
|
+
serverExternalPackages,
|
|
754
|
+
cacheHandler,
|
|
755
|
+
cacheMaxMemorySize,
|
|
756
|
+
enablePrerenderSourceMaps: config.enablePrerenderSourceMaps ?? true,
|
|
757
|
+
appShells,
|
|
758
|
+
hashSalt,
|
|
759
|
+
buildId,
|
|
760
|
+
deploymentId,
|
|
761
|
+
sassOptions: readOptionalRecord(config.sassOptions) ?? null,
|
|
762
|
+
removeConsole: config.compiler?.removeConsole === true ? true : isUnknownRecord(config.compiler?.removeConsole) ? { exclude: readStringArray(config.compiler.removeConsole.exclude) } : false,
|
|
763
|
+
disableOptimizedLoading: experimental?.disableOptimizedLoading === true,
|
|
764
|
+
scrollRestoration: experimental?.scrollRestoration === true,
|
|
765
|
+
compilerDefine: serializeCompilerDefine(config.compiler?.define),
|
|
766
|
+
compilerDefineServer: serializeCompilerDefine(config.compiler?.defineServer),
|
|
767
|
+
clientTraceMetadata: Array.isArray(experimental?.clientTraceMetadata) ? experimental.clientTraceMetadata.filter((value) => typeof value === "string") : void 0,
|
|
768
|
+
staleTimes: resolveStaleTimes(experimental),
|
|
769
|
+
useLightningcss,
|
|
770
|
+
lightningCssFeatures
|
|
771
|
+
};
|
|
772
|
+
detectNextIntlConfig(root, resolved);
|
|
773
|
+
if (resolved.basePath !== "" && resolved.basePath !== "/" && resolved.assetPrefix === "") resolved.assetPrefix = resolved.basePath;
|
|
774
|
+
return resolved;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Whether an alias target is a relative filesystem path (`./foo`, `../foo`,
|
|
778
|
+
* or a bare `.`/`..`) that should be resolved against the project root.
|
|
779
|
+
*
|
|
780
|
+
* Both Next.js Turbopack `resolveAlias` and webpack `resolve.alias` accept two
|
|
781
|
+
* kinds of values: relative/absolute file paths AND bare package specifiers
|
|
782
|
+
* (e.g. `react`, `preact/compat`, `@scope/pkg`). Bare specifiers must be left
|
|
783
|
+
* verbatim so Vite/Rolldown re-resolves them through node_modules — resolving
|
|
784
|
+
* them against `root` mangles them into bogus `<root>/react` paths and breaks
|
|
785
|
+
* the build with "No such file or directory". See cloudflare/vinext#1507.
|
|
786
|
+
*/
|
|
787
|
+
function isRelativeAliasTarget(value) {
|
|
788
|
+
return value === "." || value === ".." || value.startsWith("./") || value.startsWith("../");
|
|
789
|
+
}
|
|
790
|
+
function normalizeAliasEntries(aliases, root) {
|
|
791
|
+
if (!aliases) return {};
|
|
792
|
+
const normalized = {};
|
|
793
|
+
for (const [key, value] of Object.entries(aliases)) {
|
|
794
|
+
if (typeof value !== "string") continue;
|
|
795
|
+
if (path.isAbsolute(value)) normalized[key] = value;
|
|
796
|
+
else if (isRelativeAliasTarget(value)) normalized[key] = path.resolve(root, value);
|
|
797
|
+
else normalized[key] = value;
|
|
798
|
+
}
|
|
799
|
+
return normalized;
|
|
800
|
+
}
|
|
801
|
+
function extractTurboAliases(config, root) {
|
|
802
|
+
const experimentalTurbo = readOptionalRecord(readOptionalRecord(config.experimental)?.turbo);
|
|
803
|
+
const topLevelTurbopack = readOptionalRecord(config.turbopack);
|
|
804
|
+
return {
|
|
805
|
+
...normalizeAliasEntries(readOptionalRecord(experimentalTurbo?.resolveAlias), root),
|
|
806
|
+
...normalizeAliasEntries(readOptionalRecord(topLevelTurbopack?.resolveAlias), root)
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
async function probeWebpackConfig(config, root, dev) {
|
|
810
|
+
if (typeof config.webpack !== "function") return {
|
|
811
|
+
aliases: {},
|
|
812
|
+
mdx: null,
|
|
813
|
+
resolveExtensions: null,
|
|
814
|
+
serverResolveExtensions: null,
|
|
815
|
+
resolveExtensionsCustomized: false
|
|
816
|
+
};
|
|
817
|
+
try {
|
|
818
|
+
const clientProbe = await runWebpackConfigProbe(config, root, {
|
|
819
|
+
dev,
|
|
820
|
+
isServer: false
|
|
821
|
+
});
|
|
822
|
+
const serverProbe = await runWebpackConfigProbe(config, root, {
|
|
823
|
+
dev,
|
|
824
|
+
isServer: true,
|
|
825
|
+
nextRuntime: "nodejs"
|
|
826
|
+
});
|
|
827
|
+
invokeLoaderSideEffects(clientProbe.rules, root);
|
|
828
|
+
return {
|
|
829
|
+
aliases: normalizeAliasEntries(clientProbe.config.resolve?.alias, root),
|
|
830
|
+
mdx: extractMdxOptionsFromRules(clientProbe.rules),
|
|
831
|
+
resolveExtensions: clientProbe.resolveExtensions,
|
|
832
|
+
serverResolveExtensions: serverProbe.resolveExtensions,
|
|
833
|
+
resolveExtensionsCustomized: clientProbe.resolveExtensions !== null || serverProbe.resolveExtensions !== null
|
|
834
|
+
};
|
|
835
|
+
} catch {
|
|
836
|
+
return {
|
|
837
|
+
aliases: {},
|
|
838
|
+
mdx: null,
|
|
839
|
+
resolveExtensions: null,
|
|
840
|
+
serverResolveExtensions: null,
|
|
841
|
+
resolveExtensionsCustomized: false
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
const DEFAULT_WEBPACK_RESOLVE_EXTENSIONS = [
|
|
846
|
+
".js",
|
|
847
|
+
".mjs",
|
|
848
|
+
".tsx",
|
|
849
|
+
".ts",
|
|
850
|
+
".jsx",
|
|
851
|
+
".json",
|
|
852
|
+
".wasm"
|
|
853
|
+
];
|
|
854
|
+
async function runWebpackConfigProbe(config, root, options) {
|
|
855
|
+
const rules = [];
|
|
856
|
+
const mockConfig = {
|
|
857
|
+
context: root,
|
|
858
|
+
resolve: {
|
|
859
|
+
alias: {},
|
|
860
|
+
extensions: [...DEFAULT_WEBPACK_RESOLVE_EXTENSIONS]
|
|
861
|
+
},
|
|
862
|
+
module: { rules },
|
|
863
|
+
plugins: []
|
|
864
|
+
};
|
|
865
|
+
const finalConfig = await config.webpack(mockConfig, {
|
|
866
|
+
defaultLoaders: { babel: { loader: "next-babel-loader" } },
|
|
867
|
+
...options,
|
|
868
|
+
dir: root
|
|
869
|
+
}) ?? mockConfig;
|
|
870
|
+
const finalRules = finalConfig.module?.rules ?? rules;
|
|
871
|
+
const extensions = Array.isArray(finalConfig.resolve?.extensions) ? readStringArray(finalConfig.resolve.extensions) : null;
|
|
872
|
+
return {
|
|
873
|
+
config: finalConfig,
|
|
874
|
+
rules: finalRules,
|
|
875
|
+
resolveExtensions: extensions !== null && (extensions.length !== DEFAULT_WEBPACK_RESOLVE_EXTENSIONS.length || extensions.some((extension, index) => extension !== DEFAULT_WEBPACK_RESOLVE_EXTENSIONS[index])) ? extensions : null
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Walk webpack module rules and invoke each referenced loader once with a
|
|
880
|
+
* dummy source string. Loaders that mutate `process.env` at compile time (a
|
|
881
|
+
* pattern supported by Next.js' webpack pipeline — see issue #1500) get a
|
|
882
|
+
* chance to land their mutations before vinext computes its defines.
|
|
883
|
+
* Failures are swallowed: a loader throwing on dummy input must not break
|
|
884
|
+
* the build, since vinext doesn't actually use the loader's transform output.
|
|
885
|
+
*/
|
|
886
|
+
function invokeLoaderSideEffects(rules, root) {
|
|
887
|
+
const require = createRequire(path.join(root, "package.json"));
|
|
888
|
+
const seen = /* @__PURE__ */ new Set();
|
|
889
|
+
const invokeLoaderEntry = (entry, ruleOptions) => {
|
|
890
|
+
if (!entry) return;
|
|
891
|
+
let loaderPath;
|
|
892
|
+
let loaderFn;
|
|
893
|
+
let options = ruleOptions;
|
|
894
|
+
if (typeof entry === "string") loaderPath = entry;
|
|
895
|
+
else if (typeof entry === "function") loaderFn = entry;
|
|
896
|
+
else if (typeof entry === "object") {
|
|
897
|
+
const e = entry;
|
|
898
|
+
if (typeof e.loader === "string") loaderPath = e.loader;
|
|
899
|
+
else if (typeof e.loader === "function") loaderFn = e.loader;
|
|
900
|
+
if (e.options !== void 0) options = e.options;
|
|
901
|
+
}
|
|
902
|
+
if (loaderPath !== void 0) {
|
|
903
|
+
if (seen.has(loaderPath)) return;
|
|
904
|
+
seen.add(loaderPath);
|
|
905
|
+
if (loaderPath.includes("next-babel-loader") || loaderPath.includes("mdx") || loaderPath.startsWith("next/dist/build/webpack")) return;
|
|
906
|
+
try {
|
|
907
|
+
loaderFn = require(loaderPath);
|
|
908
|
+
if (loaderFn && typeof loaderFn === "object" && typeof loaderFn.default === "function") loaderFn = loaderFn.default;
|
|
909
|
+
} catch {
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
if (typeof loaderFn !== "function") return;
|
|
914
|
+
if (seen.has(loaderFn)) return;
|
|
915
|
+
seen.add(loaderFn);
|
|
916
|
+
try {
|
|
917
|
+
const loaderThis = {
|
|
918
|
+
async: () => () => {},
|
|
919
|
+
callback: () => {},
|
|
920
|
+
emitError: () => {},
|
|
921
|
+
emitWarning: () => {},
|
|
922
|
+
cacheable: () => {},
|
|
923
|
+
getOptions: () => options ?? {},
|
|
924
|
+
query: options ?? {},
|
|
925
|
+
resourcePath: "",
|
|
926
|
+
resource: "",
|
|
927
|
+
rootContext: root,
|
|
928
|
+
context: root,
|
|
929
|
+
mode: "production"
|
|
930
|
+
};
|
|
931
|
+
loaderFn.call(loaderThis, "");
|
|
932
|
+
} catch {}
|
|
933
|
+
};
|
|
934
|
+
const visit = (rule) => {
|
|
935
|
+
if (!rule || typeof rule !== "object") return;
|
|
936
|
+
if (Array.isArray(rule)) {
|
|
937
|
+
for (const child of rule) visit(child);
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
if (Array.isArray(rule.oneOf)) for (const child of rule.oneOf) visit(child);
|
|
941
|
+
if (Array.isArray(rule.rules)) for (const child of rule.rules) visit(child);
|
|
942
|
+
const uses = Array.isArray(rule.use) ? rule.use : rule.use ? [rule.use] : [];
|
|
943
|
+
for (const use of uses) invokeLoaderEntry(use);
|
|
944
|
+
if (rule.loader !== void 0) invokeLoaderEntry(rule.loader, rule.options);
|
|
945
|
+
};
|
|
946
|
+
for (const rule of rules) visit(rule);
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Extract MDX compilation options (remark/rehype/recma plugins) from
|
|
950
|
+
* a Next.js config that uses @next/mdx.
|
|
951
|
+
*
|
|
952
|
+
* @next/mdx wraps the config with a webpack function that injects an MDX
|
|
953
|
+
* loader rule. The remark/rehype plugins are captured in that closure.
|
|
954
|
+
* We probe the webpack function with a mock config to extract them.
|
|
955
|
+
*/
|
|
956
|
+
async function extractMdxOptions(config, root = process.cwd()) {
|
|
957
|
+
return (await probeWebpackConfig(config, root, false)).mdx;
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Probe file candidates relative to root. Returns the first one that exists,
|
|
961
|
+
* or null if none match.
|
|
962
|
+
*/
|
|
963
|
+
function probeFiles(root, candidates) {
|
|
964
|
+
for (const candidate of candidates) {
|
|
965
|
+
const abs = path.resolve(root, candidate);
|
|
966
|
+
if (fs.existsSync(abs)) return abs;
|
|
967
|
+
}
|
|
968
|
+
return null;
|
|
969
|
+
}
|
|
970
|
+
const I18N_REQUEST_CANDIDATES = [
|
|
971
|
+
"i18n/request.ts",
|
|
972
|
+
"i18n/request.tsx",
|
|
973
|
+
"i18n/request.js",
|
|
974
|
+
"i18n/request.jsx",
|
|
975
|
+
"src/i18n/request.ts",
|
|
976
|
+
"src/i18n/request.tsx",
|
|
977
|
+
"src/i18n/request.js",
|
|
978
|
+
"src/i18n/request.jsx"
|
|
979
|
+
];
|
|
980
|
+
/**
|
|
981
|
+
* Detect next-intl in the project and auto-register the `next-intl/config`
|
|
982
|
+
* alias if needed.
|
|
983
|
+
*
|
|
984
|
+
* next-intl's `createNextIntlPlugin()` crashes in vinext because it calls
|
|
985
|
+
* `require('next/package.json')` to check the Next.js version. Instead,
|
|
986
|
+
* vinext detects next-intl and registers the alias automatically.
|
|
987
|
+
*
|
|
988
|
+
* Note: `require.resolve('next-intl')` walks up to parent `node_modules`
|
|
989
|
+
* directories via standard Node module resolution. In a monorepo, next-intl
|
|
990
|
+
* installed at the workspace root will trigger detection even if not listed
|
|
991
|
+
* in the project's own package.json. This is acceptable since a workspace-root
|
|
992
|
+
* install implies the user wants it available.
|
|
993
|
+
*
|
|
994
|
+
* Mutates `resolved.aliases` and `resolved.env` in place.
|
|
995
|
+
*/
|
|
996
|
+
function detectNextIntlConfig(root, resolved) {
|
|
997
|
+
if (resolved.aliases["next-intl/config"]) return;
|
|
998
|
+
const require = createRequire(path.join(root, "package.json"));
|
|
999
|
+
try {
|
|
1000
|
+
require.resolve("next-intl");
|
|
1001
|
+
} catch {
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
const configPath = probeFiles(root, I18N_REQUEST_CANDIDATES);
|
|
1005
|
+
if (!configPath) return;
|
|
1006
|
+
resolved.aliases["next-intl/config"] = configPath;
|
|
1007
|
+
if (resolved.trailingSlash) resolved.env._next_intl_trailing_slash = "true";
|
|
1008
|
+
}
|
|
1009
|
+
function extractMdxOptionsFromRules(rules) {
|
|
1010
|
+
for (const rule of rules) {
|
|
1011
|
+
const loaders = extractMdxLoaders(rule);
|
|
1012
|
+
if (loaders) return loaders;
|
|
1013
|
+
}
|
|
1014
|
+
return null;
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Recursively search a webpack rule (which may have nested `oneOf` arrays)
|
|
1018
|
+
* for an MDX loader and extract its remark/rehype/recma plugin options.
|
|
1019
|
+
*/
|
|
1020
|
+
function extractMdxLoaders(rule) {
|
|
1021
|
+
if (!rule) return null;
|
|
1022
|
+
if (Array.isArray(rule.oneOf)) for (const child of rule.oneOf) {
|
|
1023
|
+
const result = extractMdxLoaders(child);
|
|
1024
|
+
if (result) return result;
|
|
1025
|
+
}
|
|
1026
|
+
const use = Array.isArray(rule.use) ? rule.use : rule.use ? [rule.use] : [];
|
|
1027
|
+
for (const loader of use) {
|
|
1028
|
+
const loaderPath = typeof loader === "string" ? loader : loader?.loader;
|
|
1029
|
+
if (typeof loaderPath === "string" && isMdxLoader(loaderPath)) return extractPluginsFromOptions(typeof loader === "object" ? loader.options : {});
|
|
1030
|
+
}
|
|
1031
|
+
if (typeof rule.loader === "string" && isMdxLoader(rule.loader)) return extractPluginsFromOptions(rule.options);
|
|
1032
|
+
return null;
|
|
1033
|
+
}
|
|
1034
|
+
function isMdxLoader(loaderPath) {
|
|
1035
|
+
return loaderPath.includes("mdx") && (loaderPath.includes("@next") || loaderPath.includes("@mdx-js") || loaderPath.includes("mdx-js-loader") || loaderPath.includes("next-mdx"));
|
|
1036
|
+
}
|
|
1037
|
+
function extractPluginsFromOptions(opts) {
|
|
1038
|
+
if (!opts || typeof opts !== "object") return null;
|
|
1039
|
+
const remarkPlugins = Array.isArray(opts.remarkPlugins) ? opts.remarkPlugins : void 0;
|
|
1040
|
+
const rehypePlugins = Array.isArray(opts.rehypePlugins) ? opts.rehypePlugins : void 0;
|
|
1041
|
+
const recmaPlugins = Array.isArray(opts.recmaPlugins) ? opts.recmaPlugins : void 0;
|
|
1042
|
+
if (remarkPlugins && remarkPlugins.length > 0 || rehypePlugins && rehypePlugins.length > 0 || recmaPlugins && recmaPlugins.length > 0) return {
|
|
1043
|
+
...remarkPlugins && remarkPlugins.length > 0 ? { remarkPlugins } : {},
|
|
1044
|
+
...rehypePlugins && rehypePlugins.length > 0 ? { rehypePlugins } : {},
|
|
1045
|
+
...recmaPlugins && recmaPlugins.length > 0 ? { recmaPlugins } : {}
|
|
1046
|
+
};
|
|
1047
|
+
return null;
|
|
1048
|
+
}
|
|
1049
|
+
//#endregion
|
|
1050
|
+
export { PHASE_PRODUCTION_BUILD, createRscCompatibilityId, detectNextIntlConfig, extractMdxOptions, findNextConfigPath, lightningCssFeatureNamesToMask, loadNextConfig, normalizeAssetPrefix, parseBodySizeLimit, reassignsModuleExports, referencesCjsGlobals, resolveNextConfig, resolveNextConfigInput };
|