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
|
@@ -20,12 +20,29 @@ type NextRedirect = {
|
|
|
20
20
|
permanent: boolean;
|
|
21
21
|
has?: HasCondition[];
|
|
22
22
|
missing?: HasCondition[];
|
|
23
|
+
/**
|
|
24
|
+
* When true (the default with i18n configured), Next.js prepends an internal
|
|
25
|
+
* locale alternation to the source so the rule matches locale-prefixed paths.
|
|
26
|
+
* When `false`, the source is left untouched and matches the raw path,
|
|
27
|
+
* letting user-supplied `:locale` segments capture the prefix themselves.
|
|
28
|
+
* See https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects#locale
|
|
29
|
+
*/
|
|
30
|
+
locale?: false;
|
|
31
|
+
/**
|
|
32
|
+
* When `false`, the rule is NOT prefixed with `basePath`. Source and
|
|
33
|
+
* destination are matched/applied verbatim. Mirrors Next.js's
|
|
34
|
+
* `Redirect.basePath: false` opt-out — see
|
|
35
|
+
* `.nextjs-ref/packages/next/src/lib/load-custom-routes.ts:26`.
|
|
36
|
+
*/
|
|
37
|
+
basePath?: false;
|
|
23
38
|
};
|
|
24
39
|
type NextRewrite = {
|
|
25
40
|
source: string;
|
|
26
41
|
destination: string;
|
|
27
42
|
has?: HasCondition[];
|
|
28
|
-
missing?: HasCondition[];
|
|
43
|
+
missing?: HasCondition[]; /** See {@link NextRedirect.locale}. */
|
|
44
|
+
locale?: false; /** See {@link NextRedirect.basePath}. */
|
|
45
|
+
basePath?: false;
|
|
29
46
|
};
|
|
30
47
|
type NextHeader = {
|
|
31
48
|
source: string;
|
|
@@ -34,7 +51,8 @@ type NextHeader = {
|
|
|
34
51
|
headers: Array<{
|
|
35
52
|
key: string;
|
|
36
53
|
value: string;
|
|
37
|
-
}>;
|
|
54
|
+
}>; /** See {@link NextRedirect.basePath}. */
|
|
55
|
+
basePath?: false;
|
|
38
56
|
};
|
|
39
57
|
type NextI18nConfig = {
|
|
40
58
|
/** List of supported locales */locales: string[]; /** The default locale (used when no locale prefix is in the URL) */
|
|
@@ -66,7 +84,15 @@ type MdxOptions = {
|
|
|
66
84
|
};
|
|
67
85
|
type NextConfig = {
|
|
68
86
|
/** Additional env variables */env?: Record<string, string>; /** Base URL path prefix */
|
|
69
|
-
basePath?: string;
|
|
87
|
+
basePath?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Prefix applied to every emitted JS/CSS/image/static asset URL.
|
|
90
|
+
* Accepts a path prefix (e.g. `/custom-asset-prefix`) or an absolute
|
|
91
|
+
* URL (e.g. `https://cdn.example.com`). Distinct from `basePath`:
|
|
92
|
+
* `basePath` affects route URLs; `assetPrefix` only affects asset URLs.
|
|
93
|
+
* @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix
|
|
94
|
+
*/
|
|
95
|
+
assetPrefix?: string; /** Whether to add trailing slashes */
|
|
70
96
|
trailingSlash?: boolean; /** Internationalization routing config */
|
|
71
97
|
i18n?: NextI18nConfig; /** URL redirect rules */
|
|
72
98
|
redirects?: () => Promise<NextRedirect[]> | NextRedirect[]; /** URL rewrite rules */
|
|
@@ -151,6 +177,20 @@ type NextConfigInput = NextConfig | NextConfigFactory;
|
|
|
151
177
|
type ResolvedNextConfig = {
|
|
152
178
|
env: Record<string, string>;
|
|
153
179
|
basePath: string;
|
|
180
|
+
/**
|
|
181
|
+
* Resolved `assetPrefix` from next.config.
|
|
182
|
+
*
|
|
183
|
+
* Empty string when unset. Trailing slashes are trimmed. May be either:
|
|
184
|
+
* - a path prefix beginning with `/` (e.g. `"/custom-asset-prefix"`), or
|
|
185
|
+
* - an absolute URL with `http(s)://` origin (e.g. `"https://cdn.example.com"`
|
|
186
|
+
* or `"https://cdn.example.com/sub"`).
|
|
187
|
+
*
|
|
188
|
+
* Mirrors Next.js semantics — `assetPrefix` controls emitted asset URLs
|
|
189
|
+
* only; route URLs continue to live under `basePath`.
|
|
190
|
+
*
|
|
191
|
+
* @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix
|
|
192
|
+
*/
|
|
193
|
+
assetPrefix: string;
|
|
154
194
|
trailingSlash: boolean;
|
|
155
195
|
output: "" | "export" | "standalone";
|
|
156
196
|
pageExtensions: string[];
|
|
@@ -197,7 +237,52 @@ type ResolvedNextConfig = {
|
|
|
197
237
|
* change without modifying source — useful for cache-busting after CDN poisoning.
|
|
198
238
|
*/
|
|
199
239
|
hashSalt: string;
|
|
240
|
+
/**
|
|
241
|
+
* Raw `sassOptions` object from next.config (or `null` when unset). vinext
|
|
242
|
+
* passes the relevant keys through to Vite's `css.preprocessorOptions.scss`
|
|
243
|
+
* so SCSS variables defined via `additionalData` / `prependData`, partials
|
|
244
|
+
* resolved via `includePaths` / `loadPaths`, and a custom `implementation`
|
|
245
|
+
* all behave the same as in Next.js.
|
|
246
|
+
*
|
|
247
|
+
* Kept loose (`Record<string, unknown> | null`) to match Next.js's typing —
|
|
248
|
+
* the object is forwarded to Sass and may contain any modern Sass option.
|
|
249
|
+
*/
|
|
250
|
+
sassOptions: Record<string, unknown> | null;
|
|
200
251
|
};
|
|
252
|
+
/**
|
|
253
|
+
* Whole-word substring check for any of the CJS-style globals that the
|
|
254
|
+
* injector plugin would shim. Used to skip the transform entirely for the
|
|
255
|
+
* common case where the config is pure ESM (no `__filename`, `__dirname`,
|
|
256
|
+
* `require`, `module`, or `exports` references).
|
|
257
|
+
*
|
|
258
|
+
* False positives are harmless: a comment, string literal, or unrelated
|
|
259
|
+
* identifier like `node:module` will trigger the transform unnecessarily,
|
|
260
|
+
* but the resulting injection is idempotent and the loaded config is
|
|
261
|
+
* unaffected. False negatives would be a correctness bug, so we err on the
|
|
262
|
+
* side of matching too eagerly.
|
|
263
|
+
*
|
|
264
|
+
* Note: `\bexports\b` does not match `export default` (different word
|
|
265
|
+
* boundaries), and `\brequire\b` does not match `requireSomething`.
|
|
266
|
+
*/
|
|
267
|
+
declare function referencesCjsGlobals(source: string): boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Static heuristic: returns true when the source appears to assign to
|
|
270
|
+
* `module.exports` — either via `module.exports = …`, `module.exports.foo = …`,
|
|
271
|
+
* or `module.exports[…] = …`. Used to decide whether the injector plugin
|
|
272
|
+
* needs to wire up the wrapper `module` object so {@link unwrapConfig} can
|
|
273
|
+
* read back the user's CJS-style export.
|
|
274
|
+
*
|
|
275
|
+
* Pure-ESM configs skip the wrapper entirely, which means a faster transform
|
|
276
|
+
* (no extra `export const` line) and a simpler unwrap path (no need to
|
|
277
|
+
* disambiguate "initial empty object" from "user reassigned to {}").
|
|
278
|
+
*
|
|
279
|
+
* Like {@link referencesCjsGlobals}, false positives are harmless: at worst
|
|
280
|
+
* we emit an unused `__vinext_cjs_exports` named export, and `unwrapConfig`
|
|
281
|
+
* still prefers it (it points at an empty object, which then gets treated
|
|
282
|
+
* as the config — equivalent to today's sentinel logic for pure-ESM files
|
|
283
|
+
* that happen to mention `module.exports` only in a string).
|
|
284
|
+
*/
|
|
285
|
+
declare function reassignsModuleExports(source: string): boolean;
|
|
201
286
|
declare function findNextConfigPath(root: string): string | null;
|
|
202
287
|
declare function resolveNextConfigInput(config: NextConfigInput, phase?: string): Promise<NextConfig>;
|
|
203
288
|
/**
|
|
@@ -207,9 +292,26 @@ declare function resolveNextConfigInput(config: NextConfigInput, phase?: string)
|
|
|
207
292
|
* Attempts Vite's module runner first so TS configs and extensionless local
|
|
208
293
|
* imports (e.g. `import "./env"`) resolve consistently. If loading fails due
|
|
209
294
|
* to CJS constructs (`require`, `module.exports`), falls back to `createRequire`
|
|
210
|
-
* so common CJS plugin wrappers (nextra, @next/mdx, etc.) still work
|
|
295
|
+
* so common CJS plugin wrappers (nextra, @next/mdx, etc.) still work, including
|
|
296
|
+
* `next.config.js` files written in CJS syntax inside a `"type": "module"`
|
|
297
|
+
* package (the common shape after `vinext init`).
|
|
211
298
|
*/
|
|
212
299
|
declare function loadNextConfig(root: string, phase?: string): Promise<NextConfig | null>;
|
|
300
|
+
/**
|
|
301
|
+
* Normalize the `assetPrefix` option from next.config.
|
|
302
|
+
*
|
|
303
|
+
* Accepts both absolute URLs (`https://cdn.example.com[/subpath]`) and
|
|
304
|
+
* path prefixes (`/custom-asset-prefix`). Trailing slashes are trimmed.
|
|
305
|
+
* Empty/whitespace-only strings are treated as unset and return `""`.
|
|
306
|
+
*
|
|
307
|
+
* Path prefixes that omit the leading slash get one added so they always
|
|
308
|
+
* begin with `/` — this matches how Next.js routes match against them.
|
|
309
|
+
*
|
|
310
|
+
* Non-string values are rejected to surface config mistakes early.
|
|
311
|
+
*
|
|
312
|
+
* @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix
|
|
313
|
+
*/
|
|
314
|
+
declare function normalizeAssetPrefix(value: unknown): string;
|
|
213
315
|
/**
|
|
214
316
|
* Resolve a NextConfig into a fully-resolved ResolvedNextConfig.
|
|
215
317
|
* Awaits async functions for redirects/rewrites/headers.
|
|
@@ -242,5 +344,5 @@ declare function extractMdxOptions(config: NextConfig, root?: string): Promise<M
|
|
|
242
344
|
*/
|
|
243
345
|
declare function detectNextIntlConfig(root: string, resolved: ResolvedNextConfig): void;
|
|
244
346
|
//#endregion
|
|
245
|
-
export { HasCondition, MdxOptions, NextConfig, NextConfigFactory, NextConfigInput, NextHeader, NextI18nConfig, NextRedirect, NextRewrite, PHASE_PRODUCTION_BUILD, ResolvedNextConfig, detectNextIntlConfig, extractMdxOptions, findNextConfigPath, loadNextConfig, parseBodySizeLimit, resolveNextConfig, resolveNextConfigInput };
|
|
347
|
+
export { HasCondition, MdxOptions, NextConfig, NextConfigFactory, NextConfigInput, NextHeader, NextI18nConfig, NextRedirect, NextRewrite, PHASE_PRODUCTION_BUILD, ResolvedNextConfig, detectNextIntlConfig, extractMdxOptions, findNextConfigPath, loadNextConfig, normalizeAssetPrefix, parseBodySizeLimit, reassignsModuleExports, referencesCjsGlobals, resolveNextConfig, resolveNextConfigInput };
|
|
246
348
|
//# sourceMappingURL=next-config.d.ts.map
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { normalizePageExtensions } from "../routing/file-matcher.js";
|
|
2
|
-
import { isExternalUrl } from "./config-matchers.js";
|
|
2
|
+
import { applyLocaleToRoutes, isExternalUrl } from "./config-matchers.js";
|
|
3
3
|
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "../shims/constants.js";
|
|
4
|
+
import { loadTsconfigPathAliasesForRoot } from "./tsconfig-paths.js";
|
|
4
5
|
import { createRequire } from "node:module";
|
|
5
6
|
import fs from "node:fs";
|
|
6
7
|
import path from "node:path";
|
|
7
8
|
import { fileURLToPath } from "node:url";
|
|
8
9
|
import { randomUUID } from "node:crypto";
|
|
10
|
+
import commonjs from "vite-plugin-commonjs";
|
|
9
11
|
//#region src/config/next-config.ts
|
|
10
12
|
/**
|
|
11
13
|
* next.config.js / next.config.mjs / next.config.ts parser
|
|
@@ -60,6 +62,7 @@ function parseBodySizeLimit(value) {
|
|
|
60
62
|
}
|
|
61
63
|
const CONFIG_FILES = [
|
|
62
64
|
"next.config.ts",
|
|
65
|
+
"next.config.mts",
|
|
63
66
|
"next.config.mjs",
|
|
64
67
|
"next.config.js",
|
|
65
68
|
"next.config.cjs"
|
|
@@ -97,11 +100,138 @@ async function resolveConfigValue(config, phase = DEFAULT_PHASE) {
|
|
|
97
100
|
return config;
|
|
98
101
|
}
|
|
99
102
|
/**
|
|
103
|
+
* Named export attached by `cjsGlobalsInjectorPlugin` when the source
|
|
104
|
+
* statically looks like it assigns to `module.exports`. Holds the wrapper
|
|
105
|
+
* `module` object so {@link unwrapConfig} can read back the user's CJS-style
|
|
106
|
+
* export. Pure-ESM configs skip the wrapper entirely and rely on the ESM
|
|
107
|
+
* `default` export instead.
|
|
108
|
+
*/
|
|
109
|
+
const VINEXT_CJS_EXPORTS_KEY = "__vinext_cjs_exports";
|
|
110
|
+
/**
|
|
111
|
+
* Companion named export pointing at the initial empty `{}` that the wrapper
|
|
112
|
+
* is constructed with. Lets {@link unwrapConfig} distinguish "user reassigned
|
|
113
|
+
* or mutated module.exports" from "module.exports is still the untouched
|
|
114
|
+
* empty wrapper" — the latter happens when {@link reassignsModuleExports}
|
|
115
|
+
* matches inside a string or comment (a harmless false positive that should
|
|
116
|
+
* still fall through to the ESM `default` export).
|
|
117
|
+
*/
|
|
118
|
+
const VINEXT_CJS_INITIAL_KEY = "__vinext_cjs_initial_exports";
|
|
119
|
+
/**
|
|
100
120
|
* Unwrap the config value from a loaded module namespace.
|
|
121
|
+
*
|
|
122
|
+
* Prefers `module.exports` (CJS style) when the config file reassigned it,
|
|
123
|
+
* otherwise falls back to `default`/the namespace itself. Mirrors Next.js's
|
|
124
|
+
* behaviour, where the config is loaded through `Module._compile` and CJS
|
|
125
|
+
* assignments override any ESM-style exports.
|
|
126
|
+
*
|
|
127
|
+
* The presence of the `__vinext_cjs_exports` named export is the static
|
|
128
|
+
* signal (set by `cjsGlobalsInjectorPlugin` when `reassignsModuleExports`
|
|
129
|
+
* matched) that this file might use CJS-style exports. We then disambiguate
|
|
130
|
+
* "user actually touched module.exports" from "static heuristic was a false
|
|
131
|
+
* positive" by comparing identity against the initial empty wrapper: if
|
|
132
|
+
* `module.exports` is still the original `{}`, fall back to ESM `default`.
|
|
101
133
|
*/
|
|
102
134
|
async function unwrapConfig(mod, phase = PHASE_DEVELOPMENT_SERVER) {
|
|
135
|
+
const cjsExports = (mod?.[VINEXT_CJS_EXPORTS_KEY])?.exports;
|
|
136
|
+
const cjsInitial = mod?.[VINEXT_CJS_INITIAL_KEY];
|
|
137
|
+
if (cjsExports !== void 0 && cjsExports !== null && (cjsExports !== cjsInitial || typeof cjsExports === "object" && Object.keys(cjsExports).length > 0)) return await resolveConfigValue(cjsExports, phase);
|
|
103
138
|
return await resolveConfigValue(mod.default ?? mod, phase);
|
|
104
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Resolve a path through filesystem symlinks, falling back to the original
|
|
142
|
+
* path when the file does not exist (e.g. virtual ids, query-suffixed ids).
|
|
143
|
+
*/
|
|
144
|
+
function safeRealpath(p) {
|
|
145
|
+
try {
|
|
146
|
+
return fs.realpathSync(p);
|
|
147
|
+
} catch {
|
|
148
|
+
return p;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Whole-word substring check for any of the CJS-style globals that the
|
|
153
|
+
* injector plugin would shim. Used to skip the transform entirely for the
|
|
154
|
+
* common case where the config is pure ESM (no `__filename`, `__dirname`,
|
|
155
|
+
* `require`, `module`, or `exports` references).
|
|
156
|
+
*
|
|
157
|
+
* False positives are harmless: a comment, string literal, or unrelated
|
|
158
|
+
* identifier like `node:module` will trigger the transform unnecessarily,
|
|
159
|
+
* but the resulting injection is idempotent and the loaded config is
|
|
160
|
+
* unaffected. False negatives would be a correctness bug, so we err on the
|
|
161
|
+
* side of matching too eagerly.
|
|
162
|
+
*
|
|
163
|
+
* Note: `\bexports\b` does not match `export default` (different word
|
|
164
|
+
* boundaries), and `\brequire\b` does not match `requireSomething`.
|
|
165
|
+
*/
|
|
166
|
+
function referencesCjsGlobals(source) {
|
|
167
|
+
return /\b(?:__filename|__dirname|require|module|exports)\b/.test(source);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Static heuristic: returns true when the source appears to assign to
|
|
171
|
+
* `module.exports` — either via `module.exports = …`, `module.exports.foo = …`,
|
|
172
|
+
* or `module.exports[…] = …`. Used to decide whether the injector plugin
|
|
173
|
+
* needs to wire up the wrapper `module` object so {@link unwrapConfig} can
|
|
174
|
+
* read back the user's CJS-style export.
|
|
175
|
+
*
|
|
176
|
+
* Pure-ESM configs skip the wrapper entirely, which means a faster transform
|
|
177
|
+
* (no extra `export const` line) and a simpler unwrap path (no need to
|
|
178
|
+
* disambiguate "initial empty object" from "user reassigned to {}").
|
|
179
|
+
*
|
|
180
|
+
* Like {@link referencesCjsGlobals}, false positives are harmless: at worst
|
|
181
|
+
* we emit an unused `__vinext_cjs_exports` named export, and `unwrapConfig`
|
|
182
|
+
* still prefers it (it points at an empty object, which then gets treated
|
|
183
|
+
* as the config — equivalent to today's sentinel logic for pure-ESM files
|
|
184
|
+
* that happen to mention `module.exports` only in a string).
|
|
185
|
+
*/
|
|
186
|
+
function reassignsModuleExports(source) {
|
|
187
|
+
return /\bmodule\s*\.\s*exports\b\s*(?:=(?!=)|\.\s*[A-Za-z_$][\w$]*\s*=(?!=)|\[)/.test(source);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Vite plugin that prepends CJS-style globals (`__filename`, `__dirname`,
|
|
191
|
+
* `module`, `exports`, `require`) to the next.config.* source before
|
|
192
|
+
* Vite's module runner evaluates it.
|
|
193
|
+
*
|
|
194
|
+
* Next.js's `next.config.ts` loader (packages/next/src/build/next-config-ts/
|
|
195
|
+
* transpile-config.ts → require-hook.ts) feeds the file through Node's
|
|
196
|
+
* `Module._compile`, which provides these CJS globals even when the source
|
|
197
|
+
* uses ESM syntax. Upstream test fixtures in `test/e2e/app-dir/next-config-ts*`
|
|
198
|
+
* rely on that, e.g. `node-api-cjs/next.config.ts` reads
|
|
199
|
+
* `fs.readFileSync(path.join(__dirname, 'foo.txt'), 'utf8')`. vinext loads
|
|
200
|
+
* configs through Vite's ESM-only module runner, so we inject the same
|
|
201
|
+
* globals as plain `const` declarations.
|
|
202
|
+
*
|
|
203
|
+
* For configs that don't reference any CJS global (the common case — every
|
|
204
|
+
* upstream `next-config-ts` fixture except `node-api-cjs` is pure ESM) we
|
|
205
|
+
* skip the transform entirely; see {@link referencesCjsGlobals}.
|
|
206
|
+
*
|
|
207
|
+
* `module.exports` reassignment is preserved by exposing the injected
|
|
208
|
+
* `module` object as a named export (see {@link VINEXT_CJS_EXPORTS_KEY}) and
|
|
209
|
+
* reading it back in {@link unwrapConfig}.
|
|
210
|
+
*/
|
|
211
|
+
function cjsGlobalsInjectorPlugin(configPath) {
|
|
212
|
+
const normalizedTarget = safeRealpath(path.resolve(configPath));
|
|
213
|
+
return {
|
|
214
|
+
name: "vinext:next-config-cjs-globals",
|
|
215
|
+
enforce: "pre",
|
|
216
|
+
transform(code, id) {
|
|
217
|
+
const idPath = id.startsWith("file://") ? fileURLToPath(id) : id.split("?")[0];
|
|
218
|
+
if (safeRealpath(path.resolve(idPath)) !== normalizedTarget) return null;
|
|
219
|
+
if (!referencesCjsGlobals(code)) return null;
|
|
220
|
+
const dirname = path.dirname(normalizedTarget);
|
|
221
|
+
const filenameLiteral = JSON.stringify(normalizedTarget);
|
|
222
|
+
const dirnameLiteral = JSON.stringify(dirname);
|
|
223
|
+
const requireBaseLiteral = JSON.stringify(path.join(dirname, "package.json"));
|
|
224
|
+
const moduleLines = reassignsModuleExports(code) ? `const __vinextInitialExports = {};
|
|
225
|
+
const module = { exports: __vinextInitialExports };
|
|
226
|
+
const exports = module.exports;
|
|
227
|
+
export const ${VINEXT_CJS_EXPORTS_KEY} = module;\nexport const ${VINEXT_CJS_INITIAL_KEY} = __vinextInitialExports;\n` : "";
|
|
228
|
+
return {
|
|
229
|
+
code: `import { createRequire as __vinextCreateRequire } from "node:module";\nconst __filename = ${filenameLiteral};\nconst __dirname = ${dirnameLiteral};\nconst require = __vinextCreateRequire(${requireBaseLiteral});\n` + moduleLines + code,
|
|
230
|
+
map: null
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
105
235
|
function findNextConfigPath(root) {
|
|
106
236
|
for (const filename of CONFIG_FILES) {
|
|
107
237
|
const configPath = path.join(root, filename);
|
|
@@ -113,29 +243,84 @@ async function resolveNextConfigInput(config, phase = PHASE_DEVELOPMENT_SERVER)
|
|
|
113
243
|
return await resolveConfigValue(config, phase);
|
|
114
244
|
}
|
|
115
245
|
/**
|
|
246
|
+
* Load a CJS-flavoured next.config.{js,cjs} via createRequire.
|
|
247
|
+
*
|
|
248
|
+
* For `.cjs` (or `.js` in a non-type-module package) Node's loader picks the
|
|
249
|
+
* right format automatically and `require()` just works. For `.js` in a
|
|
250
|
+
* `"type": "module"` package, Node infers ESM from package.json and the file
|
|
251
|
+
* fails with `require is not defined`. In that case we copy the source to a
|
|
252
|
+
* sibling temp `.cjs` (where the explicit extension forces CJS regardless of
|
|
253
|
+
* the parent type field) and require *that*. Relative imports inside the
|
|
254
|
+
* config still resolve against the original directory.
|
|
255
|
+
*/
|
|
256
|
+
async function loadConfigViaRequire(configPath, root, phase) {
|
|
257
|
+
const require = createRequire(path.join(root, "package.json"));
|
|
258
|
+
try {
|
|
259
|
+
return await unwrapConfig(require(configPath), phase);
|
|
260
|
+
} catch (e) {
|
|
261
|
+
if (!isCjsError(e) || !configPath.endsWith(".js")) throw e;
|
|
262
|
+
return await loadConfigViaCjsTempCopy(configPath, root, phase);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
async function loadConfigViaCjsTempCopy(configPath, root, phase) {
|
|
266
|
+
const dir = path.dirname(configPath);
|
|
267
|
+
const tmpPath = path.join(dir, `.vinext-next-config.${process.pid}.${Date.now()}.cjs`);
|
|
268
|
+
fs.copyFileSync(configPath, tmpPath);
|
|
269
|
+
try {
|
|
270
|
+
return await unwrapConfig(createRequire(path.join(root, "package.json"))(tmpPath), phase);
|
|
271
|
+
} finally {
|
|
272
|
+
try {
|
|
273
|
+
fs.unlinkSync(tmpPath);
|
|
274
|
+
} catch {}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
116
278
|
* Find and load the next.config file from the project root.
|
|
117
279
|
* Returns null if no config file is found.
|
|
118
280
|
*
|
|
119
281
|
* Attempts Vite's module runner first so TS configs and extensionless local
|
|
120
282
|
* imports (e.g. `import "./env"`) resolve consistently. If loading fails due
|
|
121
283
|
* to CJS constructs (`require`, `module.exports`), falls back to `createRequire`
|
|
122
|
-
* so common CJS plugin wrappers (nextra, @next/mdx, etc.) still work
|
|
284
|
+
* so common CJS plugin wrappers (nextra, @next/mdx, etc.) still work, including
|
|
285
|
+
* `next.config.js` files written in CJS syntax inside a `"type": "module"`
|
|
286
|
+
* package (the common shape after `vinext init`).
|
|
123
287
|
*/
|
|
124
288
|
async function loadNextConfig(root, phase = DEFAULT_PHASE) {
|
|
125
289
|
const configPath = findNextConfigPath(root);
|
|
126
290
|
if (!configPath) return null;
|
|
127
291
|
const filename = path.basename(configPath);
|
|
292
|
+
const tsconfigAliases = loadTsconfigPathAliasesForRoot(root);
|
|
293
|
+
const normalizedConfigPath = safeRealpath(path.resolve(configPath));
|
|
128
294
|
try {
|
|
129
295
|
const { runnerImport } = await import("vite");
|
|
130
296
|
const { module: mod } = await runnerImport(configPath, {
|
|
131
297
|
root,
|
|
132
298
|
logLevel: "error",
|
|
133
|
-
clearScreen: false
|
|
299
|
+
clearScreen: false,
|
|
300
|
+
resolve: {
|
|
301
|
+
alias: tsconfigAliases,
|
|
302
|
+
extensions: [
|
|
303
|
+
".mjs",
|
|
304
|
+
".js",
|
|
305
|
+
".cjs",
|
|
306
|
+
".mts",
|
|
307
|
+
".ts",
|
|
308
|
+
".cts",
|
|
309
|
+
".jsx",
|
|
310
|
+
".tsx",
|
|
311
|
+
".json"
|
|
312
|
+
]
|
|
313
|
+
},
|
|
314
|
+
plugins: [.../\.[cm]?ts$/.test(configPath) ? [cjsGlobalsInjectorPlugin(configPath)] : [], commonjs({ filter: (id) => {
|
|
315
|
+
const idPath = id.startsWith("file://") ? fileURLToPath(id) : id.split("?")[0];
|
|
316
|
+
if (safeRealpath(path.resolve(idPath)) === normalizedConfigPath) return false;
|
|
317
|
+
return id.includes("node_modules") ? true : void 0;
|
|
318
|
+
} })]
|
|
134
319
|
});
|
|
135
320
|
return await unwrapConfig(mod, phase);
|
|
136
321
|
} catch (e) {
|
|
137
322
|
if (isCjsError(e) && (filename.endsWith(".js") || filename.endsWith(".cjs"))) try {
|
|
138
|
-
return await
|
|
323
|
+
return await loadConfigViaRequire(configPath, root, phase);
|
|
139
324
|
} catch (e2) {
|
|
140
325
|
warnConfigLoadFailure(filename, e2);
|
|
141
326
|
throw e2;
|
|
@@ -169,6 +354,32 @@ async function resolveBuildId(generate) {
|
|
|
169
354
|
if (trimmed.length === 0) throw new Error("generateBuildId returned an empty string. https://nextjs.org/docs/messages/generatebuildid-not-a-string");
|
|
170
355
|
return trimmed;
|
|
171
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* Normalize the `assetPrefix` option from next.config.
|
|
359
|
+
*
|
|
360
|
+
* Accepts both absolute URLs (`https://cdn.example.com[/subpath]`) and
|
|
361
|
+
* path prefixes (`/custom-asset-prefix`). Trailing slashes are trimmed.
|
|
362
|
+
* Empty/whitespace-only strings are treated as unset and return `""`.
|
|
363
|
+
*
|
|
364
|
+
* Path prefixes that omit the leading slash get one added so they always
|
|
365
|
+
* begin with `/` — this matches how Next.js routes match against them.
|
|
366
|
+
*
|
|
367
|
+
* Non-string values are rejected to surface config mistakes early.
|
|
368
|
+
*
|
|
369
|
+
* @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix
|
|
370
|
+
*/
|
|
371
|
+
function normalizeAssetPrefix(value) {
|
|
372
|
+
if (value === void 0 || value === null || value === "") return "";
|
|
373
|
+
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").`);
|
|
374
|
+
let trimmed = value.trim();
|
|
375
|
+
while (trimmed.endsWith("/")) trimmed = trimmed.slice(0, -1);
|
|
376
|
+
if (trimmed === "") return "";
|
|
377
|
+
if (/^https?:\/\//i.test(trimmed)) {
|
|
378
|
+
if (!URL.canParse(trimmed)) throw new Error(`Invalid \`assetPrefix\` configuration: "${value}" is not a parseable URL.`);
|
|
379
|
+
return trimmed;
|
|
380
|
+
}
|
|
381
|
+
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
382
|
+
}
|
|
172
383
|
function resolveDeploymentId(configDeploymentId) {
|
|
173
384
|
const deploymentId = configDeploymentId !== void 0 ? configDeploymentId : process.env.NEXT_DEPLOYMENT_ID;
|
|
174
385
|
if (deploymentId === void 0 || deploymentId === "") return void 0;
|
|
@@ -198,6 +409,7 @@ async function resolveNextConfig(config, root = process.cwd()) {
|
|
|
198
409
|
const resolved = {
|
|
199
410
|
env: {},
|
|
200
411
|
basePath: "",
|
|
412
|
+
assetPrefix: "",
|
|
201
413
|
trailingSlash: false,
|
|
202
414
|
output: "",
|
|
203
415
|
pageExtensions: normalizePageExtensions(),
|
|
@@ -224,7 +436,8 @@ async function resolveNextConfig(config, root = process.cwd()) {
|
|
|
224
436
|
enablePrerenderSourceMaps: true,
|
|
225
437
|
hashSalt: process.env.NEXT_HASH_SALT ?? "",
|
|
226
438
|
buildId,
|
|
227
|
-
deploymentId
|
|
439
|
+
deploymentId,
|
|
440
|
+
sassOptions: null
|
|
228
441
|
};
|
|
229
442
|
detectNextIntlConfig(root, resolved);
|
|
230
443
|
return resolved;
|
|
@@ -279,6 +492,7 @@ async function resolveNextConfig(config, root = process.cwd()) {
|
|
|
279
492
|
const legacyServerComponentsExternal = experimental?.serverComponentsExternalPackages;
|
|
280
493
|
const serverExternalPackages = Array.isArray(config.serverExternalPackages) ? config.serverExternalPackages : Array.isArray(legacyServerComponentsExternal) ? legacyServerComponentsExternal : [];
|
|
281
494
|
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.");
|
|
495
|
+
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).");
|
|
282
496
|
if (config.webpack !== void 0) if (mdx || Object.keys(webpackProbe.aliases).length > 0) console.warn("[vinext] next.config option \"webpack\" is only partially supported. vinext preserves resolve.alias entries and MDX loader settings, but other webpack customization is ignored");
|
|
283
497
|
else console.warn("[vinext] next.config option \"webpack\" is not yet supported and will be ignored");
|
|
284
498
|
const output = config.output ?? "";
|
|
@@ -295,9 +509,19 @@ async function resolveNextConfig(config, root = process.cwd()) {
|
|
|
295
509
|
const deploymentId = resolveDeploymentId(config.deploymentId);
|
|
296
510
|
const cacheHandler = typeof config.cacheHandler === "string" ? resolveCacheHandlerPathToFilesystem(config.cacheHandler) : void 0;
|
|
297
511
|
const cacheMaxMemorySize = typeof config.cacheMaxMemorySize === "number" ? config.cacheMaxMemorySize : void 0;
|
|
512
|
+
if (i18n) {
|
|
513
|
+
const opts = { trailingSlash: config.trailingSlash ?? false };
|
|
514
|
+
redirects = applyLocaleToRoutes(redirects, i18n, "redirect", opts);
|
|
515
|
+
rewrites = {
|
|
516
|
+
beforeFiles: applyLocaleToRoutes(rewrites.beforeFiles, i18n, "rewrite", opts),
|
|
517
|
+
afterFiles: applyLocaleToRoutes(rewrites.afterFiles, i18n, "rewrite", opts),
|
|
518
|
+
fallback: applyLocaleToRoutes(rewrites.fallback, i18n, "rewrite", opts)
|
|
519
|
+
};
|
|
520
|
+
}
|
|
298
521
|
const resolved = {
|
|
299
522
|
env: config.env ?? {},
|
|
300
523
|
basePath: config.basePath ?? "",
|
|
524
|
+
assetPrefix: normalizeAssetPrefix(config.assetPrefix),
|
|
301
525
|
trailingSlash: config.trailingSlash ?? false,
|
|
302
526
|
output: output === "export" || output === "standalone" ? output : "",
|
|
303
527
|
pageExtensions,
|
|
@@ -320,9 +544,11 @@ async function resolveNextConfig(config, root = process.cwd()) {
|
|
|
320
544
|
enablePrerenderSourceMaps: config.enablePrerenderSourceMaps ?? true,
|
|
321
545
|
hashSalt,
|
|
322
546
|
buildId,
|
|
323
|
-
deploymentId
|
|
547
|
+
deploymentId,
|
|
548
|
+
sassOptions: config.sassOptions && typeof config.sassOptions === "object" ? config.sassOptions : null
|
|
324
549
|
};
|
|
325
550
|
detectNextIntlConfig(root, resolved);
|
|
551
|
+
if (resolved.basePath !== "" && resolved.basePath !== "/" && resolved.assetPrefix === "") resolved.assetPrefix = resolved.basePath;
|
|
326
552
|
return resolved;
|
|
327
553
|
}
|
|
328
554
|
function normalizeAliasEntries(aliases, root) {
|
|
@@ -476,6 +702,6 @@ function extractPluginsFromOptions(opts) {
|
|
|
476
702
|
return null;
|
|
477
703
|
}
|
|
478
704
|
//#endregion
|
|
479
|
-
export { PHASE_PRODUCTION_BUILD, detectNextIntlConfig, extractMdxOptions, findNextConfigPath, loadNextConfig, parseBodySizeLimit, resolveNextConfig, resolveNextConfigInput };
|
|
705
|
+
export { PHASE_PRODUCTION_BUILD, detectNextIntlConfig, extractMdxOptions, findNextConfigPath, loadNextConfig, normalizeAssetPrefix, parseBodySizeLimit, reassignsModuleExports, referencesCjsGlobals, resolveNextConfig, resolveNextConfigInput };
|
|
480
706
|
|
|
481
707
|
//# sourceMappingURL=next-config.js.map
|