vinext 0.0.50 → 0.0.52
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/dist/build/google-fonts/fallback-metrics-data.js +14031 -0
- package/dist/build/google-fonts/fallback-metrics-data.js.map +1 -0
- package/dist/build/google-fonts/fallback-metrics.d.ts +13 -0
- package/dist/build/google-fonts/fallback-metrics.js +46 -0
- package/dist/build/google-fonts/fallback-metrics.js.map +1 -0
- package/dist/build/precompress.d.ts +13 -2
- package/dist/build/precompress.js +23 -13
- package/dist/build/precompress.js.map +1 -1
- package/dist/build/prerender.d.ts +4 -15
- package/dist/build/prerender.js +83 -53
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/report.d.ts +5 -4
- package/dist/build/report.js +196 -348
- package/dist/build/report.js.map +1 -1
- package/dist/check.js +5 -0
- package/dist/check.js.map +1 -1
- package/dist/cli-args.d.ts +1 -0
- package/dist/cli-args.js +5 -0
- package/dist/cli-args.js.map +1 -1
- package/dist/cli.js +99 -3
- package/dist/cli.js.map +1 -1
- package/dist/client/navigation-runtime.d.ts +47 -0
- package/dist/client/navigation-runtime.js +156 -0
- package/dist/client/navigation-runtime.js.map +1 -0
- package/dist/client/pages-router-link-navigation.d.ts +26 -0
- package/dist/client/pages-router-link-navigation.js +14 -0
- package/dist/client/pages-router-link-navigation.js.map +1 -0
- package/dist/client/vinext-next-data.d.ts +12 -2
- package/dist/client/vinext-next-data.js +50 -1
- package/dist/client/vinext-next-data.js.map +1 -0
- package/dist/client/window-next.d.ts +3 -1
- package/dist/client/window-next.js.map +1 -1
- package/dist/cloudflare/kv-cache-handler.js +2 -1
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/config/config-matchers.d.ts +63 -16
- package/dist/config/config-matchers.js +143 -8
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/dotenv.d.ts +11 -1
- package/dist/config/dotenv.js.map +1 -1
- package/dist/config/next-config.d.ts +107 -5
- package/dist/config/next-config.js +233 -7
- package/dist/config/next-config.js.map +1 -1
- package/dist/config/tsconfig-paths.d.ts +13 -0
- package/dist/config/tsconfig-paths.js +117 -0
- package/dist/config/tsconfig-paths.js.map +1 -0
- package/dist/deploy.js +104 -41
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +2 -2
- package/dist/entries/app-browser-entry.js +34 -3
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +19 -1
- package/dist/entries/app-rsc-entry.js +89 -23
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +10 -0
- package/dist/entries/app-rsc-manifest.js +57 -7
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/app-ssr-entry.d.ts +3 -3
- package/dist/entries/app-ssr-entry.js +4 -4
- package/dist/entries/app-ssr-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.js +21 -7
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +77 -9
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.d.ts +2 -1
- package/dist/entries/runtime-entry-module.js +9 -3
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +260 -75
- package/dist/index.js.map +1 -1
- package/dist/plugins/client-reference-dedup.d.ts +15 -2
- package/dist/plugins/client-reference-dedup.js +138 -16
- package/dist/plugins/client-reference-dedup.js.map +1 -1
- package/dist/plugins/css-data-url.d.ts +7 -0
- package/dist/plugins/css-data-url.js +81 -0
- package/dist/plugins/css-data-url.js.map +1 -0
- package/dist/plugins/fonts.d.ts +2 -2
- package/dist/plugins/fonts.js +20 -9
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/middleware-server-only.d.ts +54 -0
- package/dist/plugins/middleware-server-only.js +91 -0
- package/dist/plugins/middleware-server-only.js.map +1 -0
- package/dist/plugins/optimize-imports.js +4 -4
- package/dist/plugins/optimize-imports.js.map +1 -1
- package/dist/plugins/sass.d.ts +34 -0
- package/dist/plugins/sass.js +22 -0
- package/dist/plugins/sass.js.map +1 -0
- package/dist/plugins/strip-server-exports.js +5 -8
- package/dist/plugins/strip-server-exports.js.map +1 -1
- package/dist/routing/app-route-graph.d.ts +50 -2
- package/dist/routing/app-route-graph.js +140 -16
- package/dist/routing/app-route-graph.js.map +1 -1
- package/dist/routing/app-router.d.ts +2 -2
- package/dist/routing/app-router.js +2 -2
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/route-pattern.d.ts +56 -1
- package/dist/routing/route-pattern.js +60 -1
- package/dist/routing/route-pattern.js.map +1 -1
- package/dist/routing/utils.d.ts +2 -1
- package/dist/routing/utils.js +4 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.js +139 -37
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-browser-action-result.d.ts +27 -2
- package/dist/server/app-browser-action-result.js +63 -2
- package/dist/server/app-browser-action-result.js.map +1 -1
- package/dist/server/app-browser-entry.js +493 -195
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-hydration.d.ts +13 -1
- package/dist/server/app-browser-hydration.js +9 -1
- package/dist/server/app-browser-hydration.js.map +1 -1
- package/dist/server/app-browser-interception-context.d.ts +24 -0
- package/dist/server/app-browser-interception-context.js +32 -0
- package/dist/server/app-browser-interception-context.js.map +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +17 -2
- package/dist/server/app-browser-navigation-controller.js +33 -10
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-popstate.d.ts +16 -0
- package/dist/server/app-browser-popstate.js +17 -0
- package/dist/server/app-browser-popstate.js.map +1 -0
- package/dist/server/app-browser-rsc-redirect.d.ts +29 -0
- package/dist/server/app-browser-rsc-redirect.js +37 -0
- package/dist/server/app-browser-rsc-redirect.js.map +1 -0
- package/dist/server/app-browser-state.d.ts +28 -7
- package/dist/server/app-browser-state.js +63 -27
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-browser-stream.d.ts +9 -17
- package/dist/server/app-browser-stream.js +18 -13
- package/dist/server/app-browser-stream.js.map +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +7 -1
- package/dist/server/app-browser-visible-commit.js +39 -5
- package/dist/server/app-browser-visible-commit.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +43 -6
- package/dist/server/app-elements-wire.js +189 -7
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +3 -2
- package/dist/server/app-elements.js +3 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.d.ts +10 -1
- package/dist/server/app-fallback-renderer.js +41 -3
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-history-state.d.ts +26 -0
- package/dist/server/app-history-state.js +53 -0
- package/dist/server/app-history-state.js.map +1 -0
- package/dist/server/app-middleware.d.ts +13 -0
- package/dist/server/app-middleware.js +3 -1
- package/dist/server/app-middleware.js.map +1 -1
- package/dist/server/app-optimistic-routing.d.ts +54 -0
- package/dist/server/app-optimistic-routing.js +200 -0
- package/dist/server/app-optimistic-routing.js.map +1 -0
- package/dist/server/app-page-boundary-render.d.ts +10 -1
- package/dist/server/app-page-boundary-render.js +13 -6
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.js +3 -2
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +26 -1
- package/dist/server/app-page-cache.js +86 -14
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +7 -0
- package/dist/server/app-page-dispatch.js +96 -12
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.d.ts +7 -0
- package/dist/server/app-page-element-builder.js +34 -5
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.d.ts +28 -1
- package/dist/server/app-page-execution.js +91 -7
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.d.ts +7 -0
- package/dist/server/app-page-head.js +23 -3
- package/dist/server/app-page-head.js.map +1 -1
- package/dist/server/app-page-probe.d.ts +23 -1
- package/dist/server/app-page-probe.js +29 -1
- package/dist/server/app-page-probe.js.map +1 -1
- package/dist/server/app-page-render-observation.d.ts +35 -0
- package/dist/server/app-page-render-observation.js +68 -0
- package/dist/server/app-page-render-observation.js.map +1 -0
- package/dist/server/app-page-render.d.ts +7 -1
- package/dist/server/app-page-render.js +81 -4
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.d.ts +1 -0
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.js +7 -5
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +3 -1
- package/dist/server/app-page-route-wiring.js +59 -24
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +5 -0
- package/dist/server/app-page-stream.js +2 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-prerender-static-params.d.ts +2 -1
- package/dist/server/app-prerender-static-params.js +44 -8
- package/dist/server/app-prerender-static-params.js.map +1 -1
- package/dist/server/app-route-handler-cache.d.ts +2 -2
- package/dist/server/app-route-handler-cache.js +3 -2
- package/dist/server/app-route-handler-cache.js.map +1 -1
- package/dist/server/app-route-handler-dispatch.d.ts +6 -1
- package/dist/server/app-route-handler-dispatch.js +1 -1
- package/dist/server/app-route-handler-dispatch.js.map +1 -1
- package/dist/server/app-route-handler-execution.d.ts +17 -2
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-response.js +5 -4
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-router-entry.js +7 -15
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +19 -1
- package/dist/server/app-rsc-cache-busting.js +36 -1
- package/dist/server/app-rsc-cache-busting.js.map +1 -1
- package/dist/server/app-rsc-embedded-chunks.d.ts +9 -0
- package/dist/server/app-rsc-embedded-chunks.js +34 -0
- package/dist/server/app-rsc-embedded-chunks.js.map +1 -0
- package/dist/server/app-rsc-errors.d.ts +4 -1
- package/dist/server/app-rsc-errors.js +1 -1
- package/dist/server/app-rsc-errors.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +21 -5
- package/dist/server/app-rsc-handler.js +38 -15
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-render-mode.d.ts +4 -3
- package/dist/server/app-rsc-render-mode.js +7 -1
- package/dist/server/app-rsc-render-mode.js.map +1 -1
- package/dist/server/app-rsc-request-normalization.d.ts +4 -1
- package/dist/server/app-rsc-request-normalization.js +4 -1
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-rsc-response-finalizer.d.ts +8 -1
- package/dist/server/app-rsc-response-finalizer.js +10 -3
- package/dist/server/app-rsc-response-finalizer.js.map +1 -1
- package/dist/server/app-rsc-route-matching.d.ts +23 -0
- package/dist/server/app-rsc-route-matching.js +47 -25
- package/dist/server/app-rsc-route-matching.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +35 -3
- package/dist/server/app-server-action-execution.js +87 -33
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +3 -0
- package/dist/server/app-ssr-entry.js +83 -58
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-error-meta.d.ts +14 -0
- package/dist/server/app-ssr-error-meta.js +50 -0
- package/dist/server/app-ssr-error-meta.js.map +1 -0
- package/dist/server/app-ssr-stream.d.ts +7 -2
- package/dist/server/app-ssr-stream.js +26 -15
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/artifact-compatibility.d.ts +13 -3
- package/dist/server/artifact-compatibility.js +12 -8
- package/dist/server/artifact-compatibility.js.map +1 -1
- package/dist/server/cache-headers.d.ts +7 -0
- package/dist/server/cache-headers.js +19 -0
- package/dist/server/cache-headers.js.map +1 -0
- package/dist/server/cache-proof.d.ts +170 -5
- package/dist/server/cache-proof.js +472 -18
- package/dist/server/cache-proof.js.map +1 -1
- package/dist/server/client-reuse-manifest.d.ts +99 -0
- package/dist/server/client-reuse-manifest.js +212 -0
- package/dist/server/client-reuse-manifest.js.map +1 -0
- package/dist/server/default-global-error-module.d.ts +20 -0
- package/dist/server/default-global-error-module.js +20 -0
- package/dist/server/default-global-error-module.js.map +1 -0
- package/dist/server/dev-lockfile.d.ts +110 -0
- package/dist/server/dev-lockfile.js +180 -0
- package/dist/server/dev-lockfile.js.map +1 -0
- package/dist/server/dev-server.d.ts +9 -1
- package/dist/server/dev-server.js +76 -19
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/edge-api-runtime.d.ts +5 -0
- package/dist/server/edge-api-runtime.js +8 -0
- package/dist/server/edge-api-runtime.js.map +1 -0
- package/dist/server/file-based-metadata.d.ts +13 -0
- package/dist/server/file-based-metadata.js +49 -2
- package/dist/server/file-based-metadata.js.map +1 -1
- package/dist/server/headers.d.ts +20 -1
- package/dist/server/headers.js +22 -2
- package/dist/server/headers.js.map +1 -1
- package/dist/server/html.js +1 -1
- package/dist/server/html.js.map +1 -1
- package/dist/server/http-error-responses.d.ts +26 -1
- package/dist/server/http-error-responses.js +32 -2
- package/dist/server/http-error-responses.js.map +1 -1
- package/dist/server/isr-cache.d.ts +8 -3
- package/dist/server/isr-cache.js +24 -6
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-route-response.js +22 -5
- package/dist/server/metadata-route-response.js.map +1 -1
- package/dist/server/metadata-routes.js +27 -8
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-runtime.d.ts +15 -0
- package/dist/server/middleware-runtime.js +60 -7
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/middleware.d.ts +13 -1
- package/dist/server/middleware.js +16 -2
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/navigation-planner.d.ts +26 -6
- package/dist/server/navigation-planner.js +358 -24
- package/dist/server/navigation-planner.js.map +1 -1
- package/dist/server/navigation-trace.d.ts +9 -1
- package/dist/server/navigation-trace.js +8 -0
- package/dist/server/navigation-trace.js.map +1 -1
- package/dist/server/normalize-path.d.ts +2 -1
- package/dist/server/normalize-path.js +4 -1
- package/dist/server/normalize-path.js.map +1 -1
- package/dist/server/pages-api-route.d.ts +27 -1
- package/dist/server/pages-api-route.js +25 -3
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-data-route.d.ts +77 -0
- package/dist/server/pages-data-route.js +97 -0
- package/dist/server/pages-data-route.js.map +1 -0
- package/dist/server/pages-i18n.d.ts +51 -1
- package/dist/server/pages-i18n.js +61 -1
- package/dist/server/pages-i18n.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +32 -4
- package/dist/server/pages-page-data.js +52 -19
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.d.ts +11 -1
- package/dist/server/pages-page-response.js +6 -4
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prod-server.d.ts +26 -1
- package/dist/server/prod-server.js +150 -44
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +11 -2
- package/dist/server/request-pipeline.js +28 -11
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/seed-cache.d.ts +12 -31
- package/dist/server/seed-cache.js +22 -35
- package/dist/server/seed-cache.js.map +1 -1
- package/dist/server/server-action-not-found.d.ts +16 -3
- package/dist/server/server-action-not-found.js +27 -4
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/server-globals.d.ts +5 -0
- package/dist/server/server-globals.js +37 -0
- package/dist/server/server-globals.js.map +1 -0
- package/dist/server/skip-cache-proof.d.ts +41 -0
- package/dist/server/skip-cache-proof.js +101 -0
- package/dist/server/skip-cache-proof.js.map +1 -0
- package/dist/server/static-file-cache.d.ts +1 -1
- package/dist/server/static-file-cache.js +7 -6
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/shims/cache-runtime.d.ts +19 -2
- package/dist/shims/cache-runtime.js +67 -11
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +5 -18
- package/dist/shims/cache.js +2 -0
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/client-locale.d.ts +15 -0
- package/dist/shims/client-locale.js +13 -0
- package/dist/shims/client-locale.js.map +1 -0
- package/dist/shims/default-global-error.d.ts +32 -0
- package/dist/shims/default-global-error.js +181 -0
- package/dist/shims/default-global-error.js.map +1 -0
- package/dist/shims/document.d.ts +59 -3
- package/dist/shims/document.js +36 -5
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +2 -2
- package/dist/shims/error-boundary.js +6 -8
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.d.ts +18 -1
- package/dist/shims/error.js +56 -1
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts +4 -1
- package/dist/shims/fetch-cache.js +40 -5
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.d.ts +22 -8
- package/dist/shims/font-google-base.js +41 -71
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/font-local.d.ts +3 -20
- package/dist/shims/font-local.js +23 -75
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/font-utils.d.ts +51 -0
- package/dist/shims/font-utils.js +97 -0
- package/dist/shims/font-utils.js.map +1 -0
- package/dist/shims/form.js +13 -6
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/hash-scroll.d.ts +7 -0
- package/dist/shims/hash-scroll.js +30 -0
- package/dist/shims/hash-scroll.js.map +1 -0
- package/dist/shims/headers.d.ts +8 -11
- package/dist/shims/headers.js +22 -2
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/image.d.ts +1 -0
- package/dist/shims/image.js +144 -78
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/app-router-context.d.ts +6 -6
- package/dist/shims/internal/app-router-context.js +17 -6
- package/dist/shims/internal/app-router-context.js.map +1 -1
- package/dist/shims/link-prefetch.d.ts +9 -1
- package/dist/shims/link-prefetch.js +11 -6
- package/dist/shims/link-prefetch.js.map +1 -1
- package/dist/shims/link.d.ts +33 -5
- package/dist/shims/link.js +205 -50
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +16 -30
- package/dist/shims/metadata.js +91 -32
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +164 -17
- package/dist/shims/navigation.js +355 -84
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/navigation.react-server.d.ts +3 -2
- package/dist/shims/navigation.react-server.js +5 -2
- package/dist/shims/navigation.react-server.js.map +1 -1
- package/dist/shims/og.d.ts +18 -2
- package/dist/shims/og.js +49 -1
- package/dist/shims/og.js.map +1 -0
- package/dist/shims/pages-router-runtime.d.ts +7 -0
- package/dist/shims/pages-router-runtime.js +16 -0
- package/dist/shims/pages-router-runtime.js.map +1 -0
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/root-params.d.ts +3 -1
- package/dist/shims/root-params.js +11 -3
- package/dist/shims/root-params.js.map +1 -1
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +40 -7
- package/dist/shims/router.js +355 -250
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.js +110 -32
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.d.ts +21 -4
- package/dist/shims/server.js +31 -10
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/slot.d.ts +1 -0
- package/dist/shims/slot.js +45 -1
- package/dist/shims/slot.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/shims/unrecognized-action-error.d.ts +35 -0
- package/dist/shims/unrecognized-action-error.js +41 -0
- package/dist/shims/unrecognized-action-error.js.map +1 -0
- package/dist/shims/url-safety.d.ts +23 -1
- package/dist/shims/url-safety.js +29 -2
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/shims/url-utils.d.ts +21 -1
- package/dist/shims/url-utils.js +67 -3
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/typegen.d.ts +10 -0
- package/dist/typegen.js +242 -0
- package/dist/typegen.js.map +1 -0
- package/dist/utils/asset-prefix.d.ts +97 -0
- package/dist/utils/asset-prefix.js +124 -0
- package/dist/utils/asset-prefix.js.map +1 -0
- package/dist/utils/base-path.d.ts +7 -1
- package/dist/utils/base-path.js +10 -1
- package/dist/utils/base-path.js.map +1 -1
- package/dist/utils/cache-control-metadata.d.ts +2 -1
- package/dist/utils/cache-control-metadata.js +1 -3
- package/dist/utils/cache-control-metadata.js.map +1 -1
- package/dist/utils/domain-locale.d.ts +2 -1
- package/dist/utils/domain-locale.js +9 -1
- package/dist/utils/domain-locale.js.map +1 -1
- package/dist/utils/lazy-chunks.d.ts +1 -1
- package/dist/utils/lazy-chunks.js +1 -1
- package/dist/utils/lazy-chunks.js.map +1 -1
- package/dist/utils/navigation-signal.d.ts +1 -2
- package/dist/utils/navigation-signal.js +1 -1
- package/dist/utils/navigation-signal.js.map +1 -1
- package/dist/utils/prerender-output-paths.d.ts +15 -0
- package/dist/utils/prerender-output-paths.js +24 -0
- package/dist/utils/prerender-output-paths.js.map +1 -0
- package/dist/utils/query.d.ts +17 -1
- package/dist/utils/query.js +36 -1
- package/dist/utils/query.js.map +1 -1
- package/dist/utils/record.d.ts +5 -0
- package/dist/utils/record.js +8 -0
- package/dist/utils/record.js.map +1 -0
- package/dist/utils/sorted-array.d.ts +9 -0
- package/dist/utils/sorted-array.js +22 -0
- package/dist/utils/sorted-array.js.map +1 -0
- package/package.json +13 -5
package/dist/index.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { detectPackageManager } from "./utils/project.js";
|
|
2
2
|
import { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
|
|
3
3
|
import { createValidFileMatcher } from "./routing/file-matcher.js";
|
|
4
|
-
import { hasBasePath
|
|
4
|
+
import { hasBasePath } from "./utils/base-path.js";
|
|
5
5
|
import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./routing/pages-router.js";
|
|
6
6
|
import { INTERNAL_HEADERS, VINEXT_MW_CTX_HEADER, VINEXT_TIMING_HEADER } from "./server/headers.js";
|
|
7
7
|
import { buildRequestHeadersFromMiddlewareResponse } from "./server/middleware-request-headers.js";
|
|
8
8
|
import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
|
|
9
9
|
import { isExternalUrl, matchHeaders, matchRedirect, matchRewrite, proxyExternalRequest, requestContextFromRequest, sanitizeDestination } from "./config/config-matchers.js";
|
|
10
|
-
import { filterInternalHeaders, isOpenRedirectShaped } from "./server/request-pipeline.js";
|
|
10
|
+
import { filterInternalHeaders, isOpenRedirectShaped, normalizeTrailingSlash } from "./server/request-pipeline.js";
|
|
11
|
+
import { mergeRewriteQuery } from "./utils/query.js";
|
|
11
12
|
import { findMiddlewareFile, runMiddleware } from "./server/middleware.js";
|
|
12
13
|
import { generateServerEntry } from "./entries/pages-server-entry.js";
|
|
13
14
|
import { generateClientEntry } from "./entries/pages-client-entry.js";
|
|
14
|
-
import { appRouter, invalidateAppRouteCache } from "./routing/app-router.js";
|
|
15
|
+
import { appRouteGraph, appRouter, invalidateAppRouteCache } from "./routing/app-router.js";
|
|
15
16
|
import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
|
|
16
17
|
import { logRequest, now } from "./server/request-log.js";
|
|
18
|
+
import { normalizeDefaultLocalePathname, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
|
|
17
19
|
import { createSSRHandler } from "./server/dev-server.js";
|
|
18
20
|
import { handleApiRoute } from "./server/api-handler.js";
|
|
19
21
|
import { installSocketErrorBackstop } from "./server/socket-error-backstop.js";
|
|
@@ -27,21 +29,27 @@ import { generateBrowserEntry } from "./entries/app-browser-entry.js";
|
|
|
27
29
|
import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
|
|
28
30
|
import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
|
|
29
31
|
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
|
|
32
|
+
import { ASSET_PREFIX_URL_DIR, resolveAssetUrlPrefix, resolveAssetsDir } from "./utils/asset-prefix.js";
|
|
33
|
+
import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
|
|
30
34
|
import { findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
|
|
35
|
+
import { isNextDataPathname, parseNextDataPathname } from "./server/pages-data-route.js";
|
|
31
36
|
import { precompressAssets } from "./build/precompress.js";
|
|
32
37
|
import { manifestFileWithBase, manifestFilesWithBase } from "./utils/manifest-paths.js";
|
|
33
38
|
import { asyncHooksStubPlugin } from "./plugins/async-hooks-stub.js";
|
|
34
39
|
import { clientReferenceDedupPlugin } from "./plugins/client-reference-dedup.js";
|
|
40
|
+
import { dataUrlCssPlugin } from "./plugins/css-data-url.js";
|
|
35
41
|
import { createRscClientReferenceLoadersPlugin } from "./plugins/rsc-client-reference-loaders.js";
|
|
36
42
|
import { createInstrumentationClientTransformPlugin } from "./plugins/instrumentation-client.js";
|
|
43
|
+
import { createMiddlewareServerOnlyPlugin } from "./plugins/middleware-server-only.js";
|
|
37
44
|
import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
|
|
38
45
|
import { createOgInlineFetchAssetsPlugin, ogAssetsPlugin } from "./plugins/og-assets.js";
|
|
46
|
+
import { generateRouteTypes } from "./typegen.js";
|
|
39
47
|
import { SSR_EXTERNAL_REACT_ENTRIES, VINEXT_OPTIMIZE_DEPS_EXCLUDE, mergeOptimizeDepsExclude } from "./plugins/rsc-client-shim-excludes.js";
|
|
40
48
|
import { createServerExternalsManifestPlugin } from "./plugins/server-externals-manifest.js";
|
|
41
|
-
import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
|
|
42
49
|
import { computeLazyChunks } from "./utils/lazy-chunks.js";
|
|
43
50
|
import { formatMissingCloudflarePluginError, hasWranglerConfig } from "./deploy.js";
|
|
44
51
|
import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
|
|
52
|
+
import { buildSassPreprocessorOptions } from "./plugins/sass.js";
|
|
45
53
|
import { createClientCodeSplittingConfig, createClientManualChunks, createClientOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfigForVite, withBuildBundlerOptions } from "./build/client-build-config.js";
|
|
46
54
|
import { augmentSsrManifestFromBundle, relativeWithinRoot, tryRealpathSync } from "./build/ssr-manifest.js";
|
|
47
55
|
import { stripServerExports } from "./plugins/strip-server-exports.js";
|
|
@@ -53,12 +61,16 @@ import fs from "node:fs";
|
|
|
53
61
|
import path from "node:path";
|
|
54
62
|
import { loadEnv, parseAst, transformWithOxc } from "vite";
|
|
55
63
|
import { pathToFileURL } from "node:url";
|
|
56
|
-
import { randomBytes } from "node:crypto";
|
|
64
|
+
import { randomBytes, randomUUID } from "node:crypto";
|
|
65
|
+
import commonjs from "vite-plugin-commonjs";
|
|
57
66
|
import MagicString from "magic-string";
|
|
58
67
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
59
|
-
import commonjs from "vite-plugin-commonjs";
|
|
60
68
|
//#region src/index.ts
|
|
61
69
|
installSocketErrorBackstop();
|
|
70
|
+
function createRscCompatibilityId(nextConfig) {
|
|
71
|
+
if (nextConfig.deploymentId) return nextConfig.deploymentId;
|
|
72
|
+
return randomUUID();
|
|
73
|
+
}
|
|
62
74
|
const __dirname = import.meta.dirname;
|
|
63
75
|
function resolveOptionalDependency(projectRoot, specifier) {
|
|
64
76
|
try {
|
|
@@ -70,12 +82,24 @@ function resolveOptionalDependency(projectRoot, specifier) {
|
|
|
70
82
|
return null;
|
|
71
83
|
}
|
|
72
84
|
function resolveShimModulePath(shimsDir, moduleName) {
|
|
73
|
-
for (const ext of [
|
|
85
|
+
for (const ext of [
|
|
86
|
+
".ts",
|
|
87
|
+
".tsx",
|
|
88
|
+
".js"
|
|
89
|
+
]) {
|
|
74
90
|
const candidate = path.join(shimsDir, `${moduleName}${ext}`);
|
|
75
91
|
if (fs.existsSync(candidate)) return candidate;
|
|
76
92
|
}
|
|
77
93
|
return path.join(shimsDir, `${moduleName}.js`);
|
|
78
94
|
}
|
|
95
|
+
function isVercelOgImport(id) {
|
|
96
|
+
return id === "@vercel/og" || id === "@vercel/og.js";
|
|
97
|
+
}
|
|
98
|
+
function isVinextOgShimImporter(importer) {
|
|
99
|
+
if (!importer) return false;
|
|
100
|
+
const normalizedImporter = (importer.startsWith("\0") ? importer.slice(1) : importer).split("?")[0].replace(/\\/g, "/");
|
|
101
|
+
return normalizedImporter.endsWith("/shims/og.tsx") || normalizedImporter.endsWith("/shims/og.js") || normalizedImporter.endsWith("/dist/shims/og.js");
|
|
102
|
+
}
|
|
79
103
|
function toRelativeFileEntry(root, absPath) {
|
|
80
104
|
return path.relative(root, absPath).split(path.sep).join("/");
|
|
81
105
|
}
|
|
@@ -240,6 +264,51 @@ const _fontGoogleShimPath = resolveShimModulePath(_shimsDir, "font-google");
|
|
|
240
264
|
function isValidExportIdentifier(name) {
|
|
241
265
|
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
242
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Returns true when `code` starts with a React `"use client"` or `"use server"`
|
|
269
|
+
* directive (after stripping leading comments, hashbang, and whitespace).
|
|
270
|
+
*
|
|
271
|
+
* Used by `vinext:jsx-in-js` to opt `.js` files inside `node_modules` into the
|
|
272
|
+
* JSX transform. We mirror `@vitejs/plugin-rsc`'s detection by looking at the
|
|
273
|
+
* directive prologue rather than scanning the whole file — `code.includes`
|
|
274
|
+
* alone would match incidental occurrences in template literals or comments.
|
|
275
|
+
*/
|
|
276
|
+
function hasReactDirective(code) {
|
|
277
|
+
let i = 0;
|
|
278
|
+
const len = code.length;
|
|
279
|
+
if (code.charCodeAt(0) === 65279) i = 1;
|
|
280
|
+
if (code[i] === "#" && code[i + 1] === "!") {
|
|
281
|
+
const nl = code.indexOf("\n", i);
|
|
282
|
+
if (nl === -1) return false;
|
|
283
|
+
i = nl + 1;
|
|
284
|
+
}
|
|
285
|
+
while (i < len) {
|
|
286
|
+
while (i < len && /\s/.test(code[i] ?? "")) i++;
|
|
287
|
+
if (i >= len) return false;
|
|
288
|
+
if (code[i] === "/" && code[i + 1] === "/") {
|
|
289
|
+
const nl = code.indexOf("\n", i + 2);
|
|
290
|
+
if (nl === -1) return false;
|
|
291
|
+
i = nl + 1;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (code[i] === "/" && code[i + 1] === "*") {
|
|
295
|
+
const end = code.indexOf("*/", i + 2);
|
|
296
|
+
if (end === -1) return false;
|
|
297
|
+
i = end + 2;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const quote = code[i];
|
|
301
|
+
if (quote !== "\"" && quote !== "'") return false;
|
|
302
|
+
const closing = code.indexOf(quote, i + 1);
|
|
303
|
+
if (closing === -1) return false;
|
|
304
|
+
const directive = code.slice(i + 1, closing);
|
|
305
|
+
if (directive === "use client" || directive === "use server") return true;
|
|
306
|
+
i = closing + 1;
|
|
307
|
+
while (i < len && (code[i] === ";" || code[i] === " " || code[i] === " ")) i++;
|
|
308
|
+
if (code[i] === "\n") i++;
|
|
309
|
+
}
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
243
312
|
function generateRootParamsModule(rootParamNames) {
|
|
244
313
|
const names = Array.from(new Set(rootParamNames)).filter(isValidExportIdentifier).sort();
|
|
245
314
|
if (names.length === 0) return "export {};\n";
|
|
@@ -287,6 +356,7 @@ function vinext(options = {}) {
|
|
|
287
356
|
let hasCloudflarePlugin = false;
|
|
288
357
|
let warnedInlineNextConfigOverride = false;
|
|
289
358
|
let hasNitroPlugin = false;
|
|
359
|
+
let rscCompatibilityId;
|
|
290
360
|
let rscClassificationManifest = null;
|
|
291
361
|
const shimsDir = path.resolve(__dirname, "shims");
|
|
292
362
|
const canonicalize = (p) => tryRealpathSync(p) ?? p;
|
|
@@ -314,6 +384,14 @@ function vinext(options = {}) {
|
|
|
314
384
|
async function generateClientEntry$1() {
|
|
315
385
|
return generateClientEntry(pagesDir, nextConfig, fileMatcher);
|
|
316
386
|
}
|
|
387
|
+
async function writeRouteTypes() {
|
|
388
|
+
if (!hasAppDir) return;
|
|
389
|
+
await generateRouteTypes({
|
|
390
|
+
root,
|
|
391
|
+
appDir,
|
|
392
|
+
pageExtensions: nextConfig.pageExtensions
|
|
393
|
+
});
|
|
394
|
+
}
|
|
317
395
|
const autoRsc = options.rsc !== false;
|
|
318
396
|
const earlyBaseDir = options.appDir ?? process.cwd();
|
|
319
397
|
const earlyAppDirExists = !options.disableAppRouter && (fs.existsSync(path.join(earlyBaseDir, "app")) || fs.existsSync(path.join(earlyBaseDir, "src", "app")));
|
|
@@ -388,7 +466,10 @@ function vinext(options = {}) {
|
|
|
388
466
|
async transform(code, id) {
|
|
389
467
|
const cleanId = id.split("?")[0];
|
|
390
468
|
if (!/\.(m?js)$/.test(cleanId)) return;
|
|
391
|
-
if (cleanId.includes("/node_modules/"))
|
|
469
|
+
if (cleanId.includes("/node_modules/")) {
|
|
470
|
+
if (!code.includes("use client") && !code.includes("use server")) return;
|
|
471
|
+
if (!hasReactDirective(code)) return;
|
|
472
|
+
}
|
|
392
473
|
const result = await transformWithOxc(code, id, {
|
|
393
474
|
lang: "jsx",
|
|
394
475
|
jsx: { runtime: "automatic" },
|
|
@@ -400,6 +481,12 @@ function vinext(options = {}) {
|
|
|
400
481
|
};
|
|
401
482
|
}
|
|
402
483
|
}] : [],
|
|
484
|
+
createMiddlewareServerOnlyPlugin({
|
|
485
|
+
getMiddlewarePath: () => middlewarePath,
|
|
486
|
+
getCanonicalMiddlewarePath: () => middlewarePath ? tryRealpathSync(middlewarePath) ?? middlewarePath : null,
|
|
487
|
+
serverOnlyShimPath: resolveShimModulePath(shimsDir, "server-only")
|
|
488
|
+
}),
|
|
489
|
+
dataUrlCssPlugin(),
|
|
403
490
|
{
|
|
404
491
|
name: "vinext:config",
|
|
405
492
|
enforce: "pre",
|
|
@@ -444,10 +531,12 @@ function vinext(options = {}) {
|
|
|
444
531
|
} else rawConfig = await loadNextConfig(root, phase);
|
|
445
532
|
nextConfig = await resolveNextConfig(rawConfig, root);
|
|
446
533
|
}
|
|
534
|
+
rscCompatibilityId ??= createRscCompatibilityId(nextConfig);
|
|
447
535
|
fileMatcher = createValidFileMatcher(nextConfig.pageExtensions);
|
|
448
536
|
instrumentationPath = findInstrumentationFile(root, fileMatcher);
|
|
449
537
|
instrumentationClientPath = findInstrumentationClientFile(root, fileMatcher);
|
|
450
538
|
middlewarePath = findMiddlewareFile(root, fileMatcher);
|
|
539
|
+
if (env?.command === "build") await writeRouteTypes();
|
|
451
540
|
const defines = getNextPublicEnvDefines();
|
|
452
541
|
if (!config.define || typeof config.define !== "object" || !("process.env.NODE_ENV" in config.define)) defines["process.env.NODE_ENV"] = JSON.stringify(resolvedNodeEnv);
|
|
453
542
|
for (const [key, value] of Object.entries(nextConfig.env)) {
|
|
@@ -455,6 +544,7 @@ function vinext(options = {}) {
|
|
|
455
544
|
defines[`process.env.${key}`] = JSON.stringify(value);
|
|
456
545
|
}
|
|
457
546
|
defines["process.env.__NEXT_ROUTER_BASEPATH"] = JSON.stringify(nextConfig.basePath);
|
|
547
|
+
defines["process.env.__VINEXT_TRAILING_SLASH"] = JSON.stringify(nextConfig.trailingSlash ? "true" : "false");
|
|
458
548
|
defines["process.env.__VINEXT_IMAGE_REMOTE_PATTERNS"] = JSON.stringify(JSON.stringify(nextConfig.images?.remotePatterns ?? []));
|
|
459
549
|
defines["process.env.__VINEXT_IMAGE_DOMAINS"] = JSON.stringify(JSON.stringify(nextConfig.images?.domains ?? []));
|
|
460
550
|
{
|
|
@@ -485,8 +575,10 @@ function vinext(options = {}) {
|
|
|
485
575
|
defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_LOCAL_IP"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowLocalIP ?? false));
|
|
486
576
|
defines["process.env.__VINEXT_DRAFT_SECRET"] = JSON.stringify(crypto.randomUUID());
|
|
487
577
|
defines["process.env.__VINEXT_BUILD_ID"] = JSON.stringify(nextConfig.buildId);
|
|
578
|
+
defines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify(rscCompatibilityId);
|
|
488
579
|
defines["process.env.__VINEXT_DEPLOYMENT_ID"] = JSON.stringify(nextConfig.deploymentId ?? "");
|
|
489
580
|
defines["process.env.__NEXT_VERSION"] = JSON.stringify(getVinextVersion());
|
|
581
|
+
defines["process.env.__NEXT_APP_SHELLS"] = JSON.stringify(false);
|
|
490
582
|
nextShimMap = Object.fromEntries(Object.entries({
|
|
491
583
|
"next/link": path.join(shimsDir, "link"),
|
|
492
584
|
"next/head": path.join(shimsDir, "head"),
|
|
@@ -533,6 +625,7 @@ function vinext(options = {}) {
|
|
|
533
625
|
"vinext/cache-runtime": path.join(shimsDir, "cache-runtime"),
|
|
534
626
|
"vinext/navigation-state": path.join(shimsDir, "navigation-state"),
|
|
535
627
|
"vinext/unified-request-context": path.join(shimsDir, "unified-request-context"),
|
|
628
|
+
"vinext/pages-router-runtime": path.join(shimsDir, "pages-router-runtime"),
|
|
536
629
|
"vinext/router-state": path.join(shimsDir, "router-state"),
|
|
537
630
|
"vinext/head-state": path.join(shimsDir, "head-state"),
|
|
538
631
|
"vinext/i18n-state": path.join(shimsDir, "i18n-state"),
|
|
@@ -553,26 +646,37 @@ function vinext(options = {}) {
|
|
|
553
646
|
hasNitroPlugin = pluginsFlat.some((p) => p && typeof p === "object" && "name" in p && typeof p.name === "string" && (p.name === "nitro" || p.name.startsWith("nitro:")));
|
|
554
647
|
let postcssOverride;
|
|
555
648
|
if (!config.css?.postcss || typeof config.css.postcss === "string") postcssOverride = await resolvePostcssStringPlugins(root);
|
|
649
|
+
const sassPreprocessorOptions = buildSassPreprocessorOptions(nextConfig.sassOptions);
|
|
556
650
|
hasUserMdxPlugin = pluginsFlat.some((p) => p && typeof p === "object" && "name" in p && typeof p.name === "string" && (p.name === "@mdx-js/rollup" || p.name === "mdx"));
|
|
557
651
|
if (!hasUserMdxPlugin && hasMdxFiles(root, hasAppDir ? appDir : null, hasPagesDir ? pagesDir : null)) await ensureMdxDelegate("detected");
|
|
558
652
|
const isSSR = !!config.build?.ssr;
|
|
559
653
|
const isMultiEnv = hasAppDir || hasCloudflarePlugin || hasNitroPlugin;
|
|
560
654
|
const viteConfig = {
|
|
561
655
|
appType: "custom",
|
|
562
|
-
build: {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
656
|
+
build: {
|
|
657
|
+
ssrEmitAssets: true,
|
|
658
|
+
cssTarget: [
|
|
659
|
+
"chrome111",
|
|
660
|
+
"edge111",
|
|
661
|
+
"firefox114",
|
|
662
|
+
"safari15"
|
|
663
|
+
],
|
|
664
|
+
assetsDir: resolveAssetsDir(nextConfig.assetPrefix ?? ""),
|
|
665
|
+
...withBuildBundlerOptions(viteMajorVersion, {
|
|
666
|
+
onwarn: (() => {
|
|
667
|
+
const userOnwarn = getBuildBundlerOptions(config.build)?.onwarn;
|
|
668
|
+
return (warning, defaultHandler) => {
|
|
669
|
+
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && (warning.message?.includes("\"use client\"") || warning.message?.includes("\"use server\""))) return;
|
|
670
|
+
if (warning.code === "IMPORT_IS_UNDEFINED" && warning.message?.includes("generateStaticParams")) return;
|
|
671
|
+
if (warning.code === "IMPORT_IS_UNDEFINED" && /Import `(?:default|proxy|middleware)` will always be undefined/.test(warning.message ?? "") && /\b(?:proxy|middleware)\.\w+\b/.test(warning.message ?? "") && (warning.message?.includes("virtual:vinext-rsc-entry") || warning.message?.includes("virtual:vinext-server-entry"))) return;
|
|
672
|
+
if (userOnwarn) userOnwarn(warning, defaultHandler);
|
|
673
|
+
else defaultHandler(warning);
|
|
674
|
+
};
|
|
675
|
+
})(),
|
|
676
|
+
...!isSSR && !isMultiEnv ? { treeshake: getClientTreeshakeConfigForVite(viteMajorVersion) } : {},
|
|
677
|
+
...!isSSR && !isMultiEnv ? { output: getClientOutputConfigForVite(viteMajorVersion) } : {}
|
|
678
|
+
})
|
|
679
|
+
},
|
|
576
680
|
server: { cors: {
|
|
577
681
|
preflightContinue: true,
|
|
578
682
|
origin: /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/
|
|
@@ -603,7 +707,18 @@ function vinext(options = {}) {
|
|
|
603
707
|
...viteMajorVersion >= 8 ? { oxc: { jsx: { runtime: "automatic" } } } : { esbuild: { jsx: "automatic" } },
|
|
604
708
|
define: defines,
|
|
605
709
|
...nextConfig.basePath ? { base: nextConfig.basePath + "/" } : {},
|
|
606
|
-
...
|
|
710
|
+
...nextConfig.assetPrefix ? { experimental: { renderBuiltUrl: (filename) => {
|
|
711
|
+
const urlPrefix = resolveAssetUrlPrefix(nextConfig.assetPrefix);
|
|
712
|
+
const dirPrefix = resolveAssetsDir(nextConfig.assetPrefix) + "/";
|
|
713
|
+
return urlPrefix + (filename.startsWith(dirPrefix) ? filename.slice(dirPrefix.length) : filename.startsWith(`_next/static/`) ? filename.slice(ASSET_PREFIX_URL_DIR.length + 1) : filename);
|
|
714
|
+
} } } : {},
|
|
715
|
+
...postcssOverride || sassPreprocessorOptions ? { css: {
|
|
716
|
+
...postcssOverride ? { postcss: postcssOverride } : {},
|
|
717
|
+
...sassPreprocessorOptions ? { preprocessorOptions: {
|
|
718
|
+
scss: sassPreprocessorOptions,
|
|
719
|
+
sass: sassPreprocessorOptions
|
|
720
|
+
} } : {}
|
|
721
|
+
} } : {}
|
|
607
722
|
};
|
|
608
723
|
const nextServerExternal = nextConfig?.serverExternalPackages ?? [];
|
|
609
724
|
const userSsrExternal = Array.isArray(config.ssr?.external) ? [...config.ssr.external, ...nextServerExternal] : config.ssr?.external === true ? true : nextServerExternal;
|
|
@@ -652,7 +767,7 @@ function vinext(options = {}) {
|
|
|
652
767
|
...userSsrExternal === true ? {} : { noExternal: true }
|
|
653
768
|
} },
|
|
654
769
|
optimizeDeps: {
|
|
655
|
-
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, userSsrExternal === true ? SSR_EXTERNAL_REACT_ENTRIES : []),
|
|
770
|
+
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, ["ipaddr.js"], userSsrExternal === true ? SSR_EXTERNAL_REACT_ENTRIES : []),
|
|
656
771
|
entries: optimizeEntries
|
|
657
772
|
},
|
|
658
773
|
build: {
|
|
@@ -722,6 +837,7 @@ function vinext(options = {}) {
|
|
|
722
837
|
],
|
|
723
838
|
noExternal: true
|
|
724
839
|
},
|
|
840
|
+
optimizeDeps: { exclude: ["ipaddr.js"] },
|
|
725
841
|
build: {
|
|
726
842
|
outDir: "dist/server",
|
|
727
843
|
...withBuildBundlerOptions(viteMajorVersion, {
|
|
@@ -759,9 +875,10 @@ function vinext(options = {}) {
|
|
|
759
875
|
}));
|
|
760
876
|
},
|
|
761
877
|
resolveId: {
|
|
762
|
-
filter: { id: /(?:next\/|virtual:vinext
|
|
763
|
-
handler(id) {
|
|
878
|
+
filter: { id: /(?:next\/|virtual:vinext-|^@vercel\/og(?:\.js)?$)/ },
|
|
879
|
+
handler(id, importer) {
|
|
764
880
|
const cleanId = id.startsWith("\0") ? id.slice(1) : id;
|
|
881
|
+
if (isVercelOgImport(cleanId) && !isVinextOgShimImporter(importer)) return resolveShimModulePath(_shimsDir, "og");
|
|
765
882
|
if (cleanId === VIRTUAL_SERVER_ENTRY) return RESOLVED_SERVER_ENTRY;
|
|
766
883
|
if (cleanId === VIRTUAL_CLIENT_ENTRY) return RESOLVED_CLIENT_ENTRY;
|
|
767
884
|
if (cleanId.endsWith("/" + VIRTUAL_SERVER_ENTRY) || cleanId.endsWith("\\" + VIRTUAL_SERVER_ENTRY)) return RESOLVED_SERVER_ENTRY;
|
|
@@ -789,6 +906,7 @@ function vinext(options = {}) {
|
|
|
789
906
|
const routes = await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher);
|
|
790
907
|
const metaRoutes = scanMetadataFiles(appDir);
|
|
791
908
|
const globalErrorPath = findFileWithExts(appDir, "global-error", fileMatcher);
|
|
909
|
+
const globalNotFoundPath = findFileWithExts(appDir, "global-not-found", fileMatcher);
|
|
792
910
|
rscClassificationManifest = collectRouteClassificationManifest(routes);
|
|
793
911
|
return generateRscEntry(appDir, routes, middlewarePath, metaRoutes, globalErrorPath, nextConfig?.basePath, nextConfig?.trailingSlash, {
|
|
794
912
|
redirects: nextConfig?.redirects,
|
|
@@ -797,15 +915,20 @@ function vinext(options = {}) {
|
|
|
797
915
|
allowedOrigins: nextConfig?.serverActionsAllowedOrigins,
|
|
798
916
|
allowedDevOrigins: nextConfig?.allowedDevOrigins,
|
|
799
917
|
bodySizeLimit: nextConfig?.serverActionsBodySizeLimit,
|
|
918
|
+
assetPrefix: nextConfig?.assetPrefix,
|
|
800
919
|
expireTime: nextConfig?.expireTime,
|
|
801
920
|
i18n: nextConfig?.i18n,
|
|
802
921
|
hasPagesDir,
|
|
803
|
-
publicFiles: scanPublicFileRoutes(root)
|
|
922
|
+
publicFiles: scanPublicFileRoutes(root),
|
|
923
|
+
globalNotFoundPath
|
|
804
924
|
}, instrumentationPath);
|
|
805
925
|
}
|
|
806
926
|
if (id === RESOLVED_ROOT_PARAMS) return generateRootParamsModule((hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : []).flatMap((route) => route.rootParamNames ?? []));
|
|
807
927
|
if (id === RESOLVED_APP_SSR_ENTRY && hasAppDir) return generateSsrEntry(hasPagesDir);
|
|
808
|
-
if (id === RESOLVED_APP_BROWSER_ENTRY && hasAppDir)
|
|
928
|
+
if (id === RESOLVED_APP_BROWSER_ENTRY && hasAppDir) {
|
|
929
|
+
const graph = await appRouteGraph(appDir, nextConfig?.pageExtensions, fileMatcher);
|
|
930
|
+
return generateBrowserEntry(graph.routes, graph.routeManifest);
|
|
931
|
+
}
|
|
809
932
|
if (id.startsWith("\0virtual:vinext-google-fonts?")) return generateGoogleFontsVirtualModule(id, _fontGoogleShimPath);
|
|
810
933
|
},
|
|
811
934
|
// @vitejs/plugin-rsc runs the RSC environment build in two phases:
|
|
@@ -942,16 +1065,46 @@ function vinext(options = {}) {
|
|
|
942
1065
|
invalidateRscEntryModule();
|
|
943
1066
|
invalidateRootParamsModule();
|
|
944
1067
|
}
|
|
1068
|
+
let appRouteTypeGeneration = null;
|
|
1069
|
+
let appRouteTypeGenerationPending = false;
|
|
1070
|
+
function warnRouteTypeGenerationFailure(error) {
|
|
1071
|
+
server.config.logger.warn(`[vinext] Failed to regenerate route types: ${error instanceof Error ? error.message : String(error)}`);
|
|
1072
|
+
}
|
|
1073
|
+
async function drainAppRouteTypeGeneration() {
|
|
1074
|
+
while (appRouteTypeGenerationPending) {
|
|
1075
|
+
appRouteTypeGenerationPending = false;
|
|
1076
|
+
try {
|
|
1077
|
+
await writeRouteTypes();
|
|
1078
|
+
} catch (error) {
|
|
1079
|
+
warnRouteTypeGenerationFailure(error);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
function regenerateAppRouteTypes() {
|
|
1084
|
+
appRouteTypeGenerationPending = true;
|
|
1085
|
+
if (appRouteTypeGeneration) return;
|
|
1086
|
+
appRouteTypeGeneration = drainAppRouteTypeGeneration().finally(() => {
|
|
1087
|
+
appRouteTypeGeneration = null;
|
|
1088
|
+
if (appRouteTypeGenerationPending) regenerateAppRouteTypes();
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
regenerateAppRouteTypes();
|
|
945
1092
|
server.httpServer?.on("connection", (socket) => {
|
|
946
1093
|
socket.on("error", () => {});
|
|
947
1094
|
});
|
|
948
1095
|
server.watcher.on("add", (filePath) => {
|
|
949
1096
|
if (hasPagesDir && filePath.startsWith(pagesDir) && pageExtensions.test(filePath)) invalidateRouteCache(pagesDir);
|
|
950
|
-
if (hasAppDir && shouldInvalidateAppRouteFile(appDir, filePath, fileMatcher))
|
|
1097
|
+
if (hasAppDir && shouldInvalidateAppRouteFile(appDir, filePath, fileMatcher)) {
|
|
1098
|
+
invalidateAppRoutingModules();
|
|
1099
|
+
regenerateAppRouteTypes();
|
|
1100
|
+
}
|
|
951
1101
|
});
|
|
952
1102
|
server.watcher.on("unlink", (filePath) => {
|
|
953
1103
|
if (hasPagesDir && filePath.startsWith(pagesDir) && pageExtensions.test(filePath)) invalidateRouteCache(pagesDir);
|
|
954
|
-
if (hasAppDir && shouldInvalidateAppRouteFile(appDir, filePath, fileMatcher))
|
|
1104
|
+
if (hasAppDir && shouldInvalidateAppRouteFile(appDir, filePath, fileMatcher)) {
|
|
1105
|
+
invalidateAppRoutingModules();
|
|
1106
|
+
regenerateAppRouteTypes();
|
|
1107
|
+
}
|
|
955
1108
|
});
|
|
956
1109
|
server.middlewares.use((req, res, next) => {
|
|
957
1110
|
const blockReason = validateDevRequest({
|
|
@@ -1065,10 +1218,9 @@ function vinext(options = {}) {
|
|
|
1065
1218
|
if (rawPathname.endsWith("/index.html")) url = url.replace("/index.html", "/");
|
|
1066
1219
|
else if (rawPathname.endsWith(".html")) url = url.replace(/\.html(?=\?|$)/, "");
|
|
1067
1220
|
let pathname = url.split("?")[0];
|
|
1068
|
-
if (pathname.includes(".") && !pathname.endsWith(".html")) return next();
|
|
1069
1221
|
if (isOpenRedirectShaped(pathname)) {
|
|
1070
1222
|
res.writeHead(404);
|
|
1071
|
-
res.end("
|
|
1223
|
+
res.end("This page could not be found");
|
|
1072
1224
|
return;
|
|
1073
1225
|
}
|
|
1074
1226
|
pathname = pathname.replaceAll("\\", "/");
|
|
@@ -1085,30 +1237,45 @@ function vinext(options = {}) {
|
|
|
1085
1237
|
url = stripped + (url.includes("?") ? url.slice(url.indexOf("?")) : "");
|
|
1086
1238
|
pathname = stripped;
|
|
1087
1239
|
}
|
|
1088
|
-
if (nextConfig
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
const
|
|
1093
|
-
res.writeHead(
|
|
1240
|
+
if (nextConfig) {
|
|
1241
|
+
const qs = url.includes("?") ? url.slice(url.indexOf("?")) : "";
|
|
1242
|
+
const trailingSlashRedirect = normalizeTrailingSlash(pathname, bp, nextConfig.trailingSlash, qs);
|
|
1243
|
+
if (trailingSlashRedirect) {
|
|
1244
|
+
const location = trailingSlashRedirect.headers.get("Location");
|
|
1245
|
+
res.writeHead(trailingSlashRedirect.status, location ? { Location: location } : void 0);
|
|
1094
1246
|
res.end();
|
|
1095
1247
|
return;
|
|
1096
|
-
}
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
let isDataReq = false;
|
|
1251
|
+
if (isNextDataPathname(pathname)) {
|
|
1252
|
+
const devBuildId = nextConfig?.buildId ?? process.env.__VINEXT_BUILD_ID ?? "development";
|
|
1253
|
+
const dataMatch = parseNextDataPathname(pathname, devBuildId);
|
|
1254
|
+
if (dataMatch) {
|
|
1255
|
+
isDataReq = true;
|
|
1097
1256
|
const qs = url.includes("?") ? url.slice(url.indexOf("?")) : "";
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1257
|
+
url = dataMatch.pagePathname + qs;
|
|
1258
|
+
pathname = dataMatch.pagePathname;
|
|
1259
|
+
req.url = url;
|
|
1260
|
+
} else {
|
|
1261
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
1262
|
+
res.end("{}");
|
|
1101
1263
|
return;
|
|
1102
1264
|
}
|
|
1103
1265
|
}
|
|
1266
|
+
if (pathname.includes(".") && !pathname.endsWith(".html")) return next();
|
|
1104
1267
|
if (hasCloudflarePlugin) return next();
|
|
1105
|
-
const
|
|
1268
|
+
const rawHeaders = new Headers(Object.fromEntries(Object.entries(req.headers).filter(([, v]) => v !== void 0).map(([k, v]) => [k, Array.isArray(v) ? v.join(", ") : String(v)])));
|
|
1269
|
+
const isDataRequest = rawHeaders.get("x-nextjs-data") === "1";
|
|
1270
|
+
const nodeRequestHeaders = filterInternalHeaders(rawHeaders);
|
|
1106
1271
|
for (const header of INTERNAL_HEADERS) delete req.headers[header];
|
|
1107
1272
|
const requestOrigin = `http://${req.headers.host || "localhost"}`;
|
|
1108
1273
|
const preMiddlewareReqUrl = new URL(url, requestOrigin);
|
|
1109
1274
|
const preMiddlewareReqCtx = requestContextFromRequest(new Request(preMiddlewareReqUrl, { headers: nodeRequestHeaders }));
|
|
1275
|
+
const matchPathname = nextConfig?.i18n ? normalizeDefaultLocalePathname(pathname, nextConfig.i18n, { hostname: preMiddlewareReqUrl.hostname }) : pathname;
|
|
1276
|
+
const matchResolvedPathname = (p) => nextConfig?.i18n ? normalizeDefaultLocalePathname(p, nextConfig.i18n, { hostname: preMiddlewareReqUrl.hostname }) : p;
|
|
1110
1277
|
if (nextConfig?.redirects.length) {
|
|
1111
|
-
if (applyRedirects(
|
|
1278
|
+
if (applyRedirects(matchPathname, res, nextConfig.redirects, preMiddlewareReqCtx, nextConfig.basePath ?? "")) return;
|
|
1112
1279
|
}
|
|
1113
1280
|
const applyRequestHeadersToNodeRequest = (nextRequestHeaders) => {
|
|
1114
1281
|
for (const key of Object.keys(req.headers)) delete req.headers[key];
|
|
@@ -1130,7 +1297,7 @@ function vinext(options = {}) {
|
|
|
1130
1297
|
method: req.method,
|
|
1131
1298
|
headers: nodeRequestHeaders
|
|
1132
1299
|
});
|
|
1133
|
-
const result = await runMiddleware(getPagesRunner(), middlewarePath, middlewareRequest, nextConfig?.i18n, nextConfig?.basePath);
|
|
1300
|
+
const result = await runMiddleware(getPagesRunner(), middlewarePath, middlewareRequest, nextConfig?.i18n, nextConfig?.basePath, nextConfig?.trailingSlash, isDataRequest);
|
|
1134
1301
|
if (result.waitUntilPromises?.length) Promise.allSettled(result.waitUntilPromises);
|
|
1135
1302
|
if (!result.continue) {
|
|
1136
1303
|
if (result.redirectUrl) {
|
|
@@ -1184,23 +1351,27 @@ function vinext(options = {}) {
|
|
|
1184
1351
|
}
|
|
1185
1352
|
const reqUrl = new URL(url, requestOrigin);
|
|
1186
1353
|
const reqCtx = requestContextFromRequest(new Request(reqUrl, { headers: middlewareRequestHeaders ?? nodeRequestHeaders }));
|
|
1187
|
-
if (nextConfig?.headers.length) applyHeaders(
|
|
1354
|
+
if (nextConfig?.headers.length) applyHeaders(matchPathname, res, nextConfig.headers, preMiddlewareReqCtx, bp);
|
|
1188
1355
|
let resolvedUrl = url;
|
|
1189
|
-
if (nextConfig?.rewrites.beforeFiles.length)
|
|
1356
|
+
if (nextConfig?.rewrites.beforeFiles.length) {
|
|
1357
|
+
const rewritten = applyRewrites(matchPathname, nextConfig.rewrites.beforeFiles, reqCtx, bp);
|
|
1358
|
+
if (rewritten) resolvedUrl = mergeRewriteQuery(url, rewritten);
|
|
1359
|
+
}
|
|
1190
1360
|
if (isExternalUrl(resolvedUrl)) {
|
|
1191
1361
|
applyDeferredMwHeaders();
|
|
1192
1362
|
applyMwRequestHeadersForExternalProxy();
|
|
1193
1363
|
await proxyExternalRewriteNode(req, res, resolvedUrl);
|
|
1194
1364
|
return;
|
|
1195
1365
|
}
|
|
1196
|
-
const
|
|
1366
|
+
const apiLookupUrl = stripI18nLocaleForApiRoute(resolvedUrl, nextConfig?.i18n);
|
|
1367
|
+
const resolvedPathname = apiLookupUrl.split("?")[0];
|
|
1197
1368
|
if (resolvedPathname.startsWith("/api/") || resolvedPathname === "/api") {
|
|
1198
1369
|
const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
1199
|
-
if (matchRoute(
|
|
1370
|
+
if (matchRoute(apiLookupUrl, apiRoutes)) {
|
|
1200
1371
|
applyDeferredMwHeaders();
|
|
1201
1372
|
if (middlewareRequestHeaders) applyRequestHeadersToNodeRequest(middlewareRequestHeaders);
|
|
1202
1373
|
}
|
|
1203
|
-
if (await handleApiRoute(getPagesRunner(), req, res,
|
|
1374
|
+
if (await handleApiRoute(getPagesRunner(), req, res, apiLookupUrl, apiRoutes)) return;
|
|
1204
1375
|
if (hasAppDir) return next();
|
|
1205
1376
|
res.statusCode = 404;
|
|
1206
1377
|
res.end("404 - API route not found");
|
|
@@ -1209,9 +1380,9 @@ function vinext(options = {}) {
|
|
|
1209
1380
|
const routes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
1210
1381
|
let match = matchRoute(resolvedUrl.split("?")[0], routes);
|
|
1211
1382
|
if ((!match || match.route.isDynamic) && nextConfig?.rewrites.afterFiles.length) {
|
|
1212
|
-
const afterRewrite = applyRewrites(resolvedUrl.split("?")[0], nextConfig.rewrites.afterFiles, reqCtx);
|
|
1383
|
+
const afterRewrite = applyRewrites(matchResolvedPathname(resolvedUrl.split("?")[0]), nextConfig.rewrites.afterFiles, reqCtx, bp);
|
|
1213
1384
|
if (afterRewrite) {
|
|
1214
|
-
resolvedUrl = afterRewrite;
|
|
1385
|
+
resolvedUrl = mergeRewriteQuery(resolvedUrl, afterRewrite);
|
|
1215
1386
|
match = matchRoute(resolvedUrl.split("?")[0], routes);
|
|
1216
1387
|
}
|
|
1217
1388
|
}
|
|
@@ -1226,11 +1397,11 @@ function vinext(options = {}) {
|
|
|
1226
1397
|
if (match) {
|
|
1227
1398
|
applyDeferredMwHeaders();
|
|
1228
1399
|
if (middlewareRequestHeaders) applyRequestHeadersToNodeRequest(middlewareRequestHeaders);
|
|
1229
|
-
await handler(req, res, resolvedUrl, mwStatus);
|
|
1400
|
+
await handler(req, res, resolvedUrl, mwStatus, isDataReq);
|
|
1230
1401
|
return;
|
|
1231
1402
|
}
|
|
1232
1403
|
if (nextConfig?.rewrites.fallback.length) {
|
|
1233
|
-
const fallbackRewrite = applyRewrites(resolvedUrl.split("?")[0], nextConfig.rewrites.fallback, reqCtx);
|
|
1404
|
+
const fallbackRewrite = applyRewrites(matchResolvedPathname(resolvedUrl.split("?")[0]), nextConfig.rewrites.fallback, reqCtx, bp);
|
|
1234
1405
|
if (fallbackRewrite) {
|
|
1235
1406
|
if (isExternalUrl(fallbackRewrite)) {
|
|
1236
1407
|
applyDeferredMwHeaders();
|
|
@@ -1241,12 +1412,12 @@ function vinext(options = {}) {
|
|
|
1241
1412
|
if (!matchRoute(fallbackRewrite.split("?")[0], routes) && hasAppDir) return next();
|
|
1242
1413
|
applyDeferredMwHeaders();
|
|
1243
1414
|
if (middlewareRequestHeaders) applyRequestHeadersToNodeRequest(middlewareRequestHeaders);
|
|
1244
|
-
await handler(req, res, fallbackRewrite, mwStatus);
|
|
1415
|
+
await handler(req, res, fallbackRewrite, mwStatus, isDataReq);
|
|
1245
1416
|
return;
|
|
1246
1417
|
}
|
|
1247
1418
|
}
|
|
1248
1419
|
if (hasAppDir) return next();
|
|
1249
|
-
await handler(req, res, resolvedUrl, mwStatus);
|
|
1420
|
+
await handler(req, res, resolvedUrl, mwStatus, isDataReq);
|
|
1250
1421
|
} catch (e) {
|
|
1251
1422
|
next(e);
|
|
1252
1423
|
}
|
|
@@ -1574,22 +1745,26 @@ function vinext(options = {}) {
|
|
|
1574
1745
|
if (!options.precompress && process.env.VINEXT_PRECOMPRESS !== "1") return;
|
|
1575
1746
|
const outDir = outputOptions.dir;
|
|
1576
1747
|
if (!outDir) return;
|
|
1577
|
-
const
|
|
1748
|
+
const assetsSubdir = resolveAssetsDir(nextConfig.assetPrefix);
|
|
1749
|
+
const assetsDir = path.join(outDir, assetsSubdir);
|
|
1578
1750
|
if (!fs.existsSync(assetsDir)) return;
|
|
1579
1751
|
const isTTY = process.stderr.isTTY;
|
|
1580
1752
|
let lastLineLen = 0;
|
|
1581
1753
|
pendingPrecompressError = null;
|
|
1582
1754
|
pendingPrecompress = (async () => {
|
|
1583
|
-
const result = await precompressAssets(outDir,
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1755
|
+
const result = await precompressAssets(outDir, {
|
|
1756
|
+
assetsDir: assetsSubdir,
|
|
1757
|
+
onProgress: (completed, total, file) => {
|
|
1758
|
+
if (!isTTY) return;
|
|
1759
|
+
const pct = total > 0 ? Math.floor(completed / total * 100) : 0;
|
|
1760
|
+
const bar = `[${"█".repeat(Math.floor(pct / 5))}${" ".repeat(20 - Math.floor(pct / 5))}]`;
|
|
1761
|
+
const maxFile = 30;
|
|
1762
|
+
const fileLabel = file.length > maxFile ? "…" + file.slice(-(maxFile - 1)) : file;
|
|
1763
|
+
const line = `Compressing assets... ${bar} ${String(completed).padStart(String(total).length)}/${total} ${fileLabel}`;
|
|
1764
|
+
const padded = line.padEnd(lastLineLen);
|
|
1765
|
+
lastLineLen = line.length;
|
|
1766
|
+
process.stderr.write(`\r${padded}`);
|
|
1767
|
+
}
|
|
1593
1768
|
});
|
|
1594
1769
|
if (isTTY) process.stderr.write(`\r${" ".repeat(lastLineLen)}\r`);
|
|
1595
1770
|
if (result.filesCompressed > 0) {
|
|
@@ -1679,10 +1854,11 @@ function vinext(options = {}) {
|
|
|
1679
1854
|
const workerEntry = path.join(workerOutDir, "index.js");
|
|
1680
1855
|
if (!fs.existsSync(workerEntry)) return;
|
|
1681
1856
|
if (!clientEntryFile) {
|
|
1682
|
-
const
|
|
1857
|
+
const assetsSubdir = resolveAssetsDir(nextConfig?.assetPrefix);
|
|
1858
|
+
const assetsDir = path.join(clientDir, assetsSubdir);
|
|
1683
1859
|
if (fs.existsSync(assetsDir)) {
|
|
1684
1860
|
const entry = fs.readdirSync(assetsDir).find((f) => (f.includes("vinext-client-entry") || f.includes("vinext-app-browser-entry")) && f.endsWith(".js"));
|
|
1685
|
-
if (entry) clientEntryFile = manifestFileWithBase(
|
|
1861
|
+
if (entry) clientEntryFile = manifestFileWithBase(`${assetsSubdir}/${entry}`, clientBase);
|
|
1686
1862
|
}
|
|
1687
1863
|
}
|
|
1688
1864
|
if (clientEntryFile || ssrManifestData || lazyChunksData) {
|
|
@@ -1699,7 +1875,7 @@ function vinext(options = {}) {
|
|
|
1699
1875
|
if (!fs.existsSync(headersPath)) {
|
|
1700
1876
|
const headersContent = [
|
|
1701
1877
|
"# Cache content-hashed assets immutably (generated by vinext)",
|
|
1702
|
-
`/${envConfig.build?.assetsDir ?? "
|
|
1878
|
+
`/${envConfig.build?.assetsDir ?? "_next/static"}/*`,
|
|
1703
1879
|
" Cache-Control: public, max-age=31536000, immutable",
|
|
1704
1880
|
""
|
|
1705
1881
|
].join("\n");
|
|
@@ -1779,7 +1955,10 @@ function getNextPublicEnvDefines() {
|
|
|
1779
1955
|
* Returns true if a redirect was applied.
|
|
1780
1956
|
*/
|
|
1781
1957
|
function applyRedirects(pathname, res, redirects, ctx, basePath = "") {
|
|
1782
|
-
const result = matchRedirect(pathname, redirects, ctx
|
|
1958
|
+
const result = matchRedirect(pathname, redirects, ctx, {
|
|
1959
|
+
basePath,
|
|
1960
|
+
hadBasePath: true
|
|
1961
|
+
});
|
|
1783
1962
|
if (result) {
|
|
1784
1963
|
const dest = sanitizeDestination(basePath && !isExternalUrl(result.destination) && !hasBasePath(result.destination, basePath) ? basePath + result.destination : result.destination);
|
|
1785
1964
|
res.writeHead(result.permanent ? 308 : 307, { Location: dest });
|
|
@@ -1826,8 +2005,11 @@ async function proxyExternalRewriteNode(req, res, externalUrl) {
|
|
|
1826
2005
|
* Apply rewrite rules from next.config.js.
|
|
1827
2006
|
* Returns the rewritten URL or null if no rewrite matched.
|
|
1828
2007
|
*/
|
|
1829
|
-
function applyRewrites(pathname, rewrites, ctx) {
|
|
1830
|
-
const dest = matchRewrite(pathname, rewrites, ctx
|
|
2008
|
+
function applyRewrites(pathname, rewrites, ctx, basePath = "") {
|
|
2009
|
+
const dest = matchRewrite(pathname, rewrites, ctx, {
|
|
2010
|
+
basePath,
|
|
2011
|
+
hadBasePath: true
|
|
2012
|
+
});
|
|
1831
2013
|
if (dest) return sanitizeDestination(dest);
|
|
1832
2014
|
return null;
|
|
1833
2015
|
}
|
|
@@ -1836,8 +2018,11 @@ function applyRewrites(pathname, rewrites, ctx) {
|
|
|
1836
2018
|
* Middleware headers take precedence: if a header key was already set on the
|
|
1837
2019
|
* response (by middleware), the config value is skipped for that key.
|
|
1838
2020
|
*/
|
|
1839
|
-
function applyHeaders(pathname, res, headers, ctx) {
|
|
1840
|
-
const matched = matchHeaders(pathname, headers, ctx
|
|
2021
|
+
function applyHeaders(pathname, res, headers, ctx, basePath = "") {
|
|
2022
|
+
const matched = matchHeaders(pathname, headers, ctx, {
|
|
2023
|
+
basePath,
|
|
2024
|
+
hadBasePath: true
|
|
2025
|
+
});
|
|
1841
2026
|
for (const header of matched) {
|
|
1842
2027
|
const lk = header.key.toLowerCase();
|
|
1843
2028
|
if (lk === "set-cookie") {
|