vinext 1.0.0-beta.3 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -3
- package/dist/build/client-build-config.d.ts +0 -1
- package/dist/build/css-url-assets.d.ts +0 -1
- package/dist/build/google-fonts/build-url.d.ts +5 -2
- package/dist/build/google-fonts/font-metadata.d.ts +7 -3
- package/dist/build/google-fonts/get-axes.d.ts +0 -1
- package/dist/build/layout-classification.d.ts +7 -4
- package/dist/build/next-client-runtime-manifests.d.ts +0 -1
- package/dist/build/next-client-runtime-manifests.js +2 -19
- package/dist/build/nitro-route-rules.d.ts +0 -1
- package/dist/build/pages-client-assets-module.d.ts +0 -1
- package/dist/build/precompress.d.ts +7 -2
- package/dist/build/precompress.js +42 -8
- package/dist/build/prerender-paths.d.ts +2 -2
- package/dist/build/prerender-server-entry.d.ts +1 -1
- package/dist/build/prerender-server-pool.d.ts +4 -2
- package/dist/build/prerender.d.ts +36 -32
- package/dist/build/prerender.js +18 -3
- package/dist/build/public-dir-conflict.d.ts +14 -0
- package/dist/build/public-dir-conflict.js +25 -0
- package/dist/build/report.d.ts +2 -2
- package/dist/build/route-classification-injector.d.ts +0 -1
- package/dist/build/route-classification-manifest.d.ts +5 -3
- package/dist/build/run-prerender.d.ts +3 -2
- package/dist/build/static-export.d.ts +23 -12
- package/dist/cache/cache-adapters-virtual.d.ts +5 -2
- package/dist/check.js +4 -4
- package/dist/cli-args.d.ts +2 -1
- package/dist/cli-args.js +10 -0
- package/dist/cli-dev-config.d.ts +0 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +14 -8
- package/dist/client/client-rewrite-matcher.d.ts +12 -0
- package/dist/client/client-rewrite-matcher.js +20 -0
- package/dist/client/client-rewrites.d.ts +31 -0
- package/dist/client/client-rewrites.js +41 -0
- package/dist/client/dev-error-overlay.d.ts +0 -1
- package/dist/client/empty-module.d.ts +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +2 -0
- package/dist/client/instrumentation-client-state.d.ts +0 -1
- package/dist/client/navigation-runtime.d.ts +12 -1
- package/dist/client/navigation-runtime.js +6 -2
- package/dist/client/pages-router-link-navigation.d.ts +3 -21
- package/dist/client/react-instance-bootstrap.d.ts +1 -0
- package/dist/client/react-instance-bootstrap.js +7 -0
- package/dist/client/react-instance.d.ts +13 -0
- package/dist/client/react-instance.js +20 -0
- package/dist/client/vinext-next-data.d.ts +11 -6
- package/dist/client/window-next.d.ts +5 -2
- package/dist/config/config-matchers.d.ts +3 -5
- package/dist/config/config-matchers.js +7 -6
- package/dist/config/dotenv.d.ts +4 -9
- package/dist/config/dotenv.js +30 -22
- package/dist/config/next-config.d.ts +113 -52
- package/dist/config/next-config.js +6 -0
- package/dist/config/prerender.d.ts +0 -1
- package/dist/entries/app-browser-entry.d.ts +0 -1
- package/dist/entries/app-browser-entry.js +7 -3
- package/dist/entries/app-rsc-entry.d.ts +30 -16
- package/dist/entries/app-rsc-entry.js +40 -12
- package/dist/entries/app-rsc-manifest.d.ts +0 -1
- package/dist/entries/app-rsc-manifest.js +1 -0
- package/dist/entries/pages-client-entry.d.ts +0 -1
- package/dist/entries/pages-client-entry.js +7 -2
- package/dist/entries/pages-server-entry.d.ts +1 -2
- package/dist/entries/pages-server-entry.js +25 -6
- package/dist/image/image-adapters-virtual.d.ts +4 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +257 -75
- package/dist/init-cloudflare.d.ts +0 -1
- package/dist/init-platform.d.ts +0 -1
- package/dist/init.d.ts +40 -20
- package/dist/plugins/ast-scope.d.ts +0 -1
- package/dist/plugins/async-hooks-stub.d.ts +0 -1
- package/dist/plugins/client-reference-dedup.d.ts +0 -1
- package/dist/plugins/client-reference-dedup.js +7 -5
- package/dist/plugins/css-data-url.d.ts +0 -1
- package/dist/plugins/css-module-imports.d.ts +0 -1
- package/dist/plugins/dynamic-preload-metadata.d.ts +0 -1
- package/dist/plugins/extensionless-dynamic-import.d.ts +0 -1
- package/dist/plugins/extensionless-dynamic-import.js +352 -13
- package/dist/plugins/fonts.d.ts +0 -1
- package/dist/plugins/ignore-dynamic-requests.d.ts +0 -1
- package/dist/plugins/ignore-dynamic-requests.js +28 -4
- package/dist/plugins/import-meta-url.d.ts +0 -1
- package/dist/plugins/instrumentation-client.d.ts +0 -1
- package/dist/plugins/middleware-server-only.d.ts +0 -1
- package/dist/plugins/og-asset-ownership.d.ts +0 -1
- package/dist/plugins/og-assets.d.ts +0 -1
- package/dist/plugins/optimize-imports.d.ts +0 -1
- package/dist/plugins/remove-console.d.ts +0 -1
- package/dist/plugins/require-context.d.ts +0 -1
- package/dist/plugins/require-context.js +143 -26
- package/dist/plugins/rsc-client-reference-loaders.d.ts +0 -1
- package/dist/plugins/rsc-reference-validation-normalizer.d.ts +0 -1
- package/dist/plugins/sass.d.ts +30 -2
- package/dist/plugins/sass.js +67 -5
- package/dist/plugins/server-externals-manifest.d.ts +0 -1
- package/dist/plugins/strip-server-exports.d.ts +0 -1
- package/dist/plugins/styled-jsx.d.ts +0 -1
- package/dist/plugins/wasm-module-import.d.ts +0 -1
- package/dist/routing/app-route-graph.d.ts +115 -56
- package/dist/routing/app-route-graph.js +2 -1
- package/dist/routing/app-router.d.ts +0 -1
- package/dist/routing/pages-router.d.ts +9 -5
- package/dist/routing/route-matching.d.ts +0 -1
- package/dist/routing/utils.d.ts +1 -23
- package/dist/routing/utils.js +1 -30
- package/dist/server/accept-encoding.d.ts +0 -1
- package/dist/server/api-handler.d.ts +0 -1
- package/dist/server/api-handler.js +4 -3
- package/dist/server/app-bfcache-identity.d.ts +9 -10
- package/dist/server/app-bfcache-identity.js +27 -102
- package/dist/server/app-browser-action-result.d.ts +0 -1
- package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -1
- package/dist/server/app-browser-entry.d.ts +1 -1
- package/dist/server/app-browser-entry.js +106 -66
- package/dist/server/app-browser-history-controller.d.ts +8 -5
- package/dist/server/app-browser-hydration.d.ts +0 -1
- package/dist/server/app-browser-interception-context.d.ts +0 -1
- package/dist/server/app-browser-mpa-navigation.d.ts +0 -1
- package/dist/server/app-browser-navigation-controller.d.ts +3 -6
- package/dist/server/app-browser-navigation-controller.js +29 -4
- package/dist/server/app-browser-popstate.d.ts +0 -1
- package/dist/server/app-browser-prefetch-response.d.ts +25 -0
- package/dist/server/app-browser-prefetch-response.js +54 -0
- package/dist/server/app-browser-server-action-client.d.ts +1 -1
- package/dist/server/app-browser-server-action-client.js +3 -2
- package/dist/server/app-browser-server-action-navigation.d.ts +0 -1
- package/dist/server/app-browser-state.d.ts +11 -5
- package/dist/server/app-browser-state.js +10 -6
- package/dist/server/app-browser-stream.d.ts +0 -1
- package/dist/server/app-browser-visible-commit.d.ts +1 -1
- package/dist/server/app-browser-visible-commit.js +6 -2
- package/dist/server/app-elements-wire.d.ts +16 -13
- package/dist/server/app-elements-wire.js +37 -10
- package/dist/server/app-elements.d.ts +2 -3
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-fallback-renderer.d.ts +8 -4
- package/dist/server/app-fallback-renderer.js +2 -1
- package/dist/server/app-history-state.d.ts +2 -2
- package/dist/server/app-history-state.js +1 -1
- package/dist/server/app-hook-warning-suppression.d.ts +0 -1
- package/dist/server/app-layout-param-observation.d.ts +0 -1
- package/dist/server/app-layout-param-observation.js +1 -1
- package/dist/server/app-middleware.d.ts +5 -1
- package/dist/server/app-middleware.js +96 -31
- package/dist/server/app-optimistic-routing.d.ts +1 -0
- package/dist/server/app-page-boundary-render.d.ts +8 -4
- package/dist/server/app-page-cache-finalizer.d.ts +2 -3
- package/dist/server/app-page-cache-finalizer.js +47 -17
- package/dist/server/app-page-cache-render.d.ts +2 -2
- package/dist/server/app-page-cache-render.js +2 -1
- package/dist/server/app-page-cache.d.ts +1 -3
- package/dist/server/app-page-cache.js +22 -11
- package/dist/server/app-page-dispatch.d.ts +12 -6
- package/dist/server/app-page-dispatch.js +14 -6
- package/dist/server/app-page-element-builder.d.ts +63 -20
- package/dist/server/app-page-element-builder.js +114 -43
- package/dist/server/app-page-execution.d.ts +12 -5
- package/dist/server/app-page-execution.js +1 -1
- package/dist/server/app-page-head.d.ts +2 -2
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +2 -2
- package/dist/server/app-page-params.d.ts +0 -1
- package/dist/server/app-page-ppr-runtime.d.ts +0 -1
- package/dist/server/app-page-probe.d.ts +4 -3
- package/dist/server/app-page-probe.js +1 -1
- package/dist/server/app-page-render-identity.d.ts +1 -0
- package/dist/server/app-page-render-observation.d.ts +0 -1
- package/dist/server/app-page-render.d.ts +7 -5
- package/dist/server/app-page-render.js +59 -24
- package/dist/server/app-page-request.d.ts +3 -2
- package/dist/server/app-page-request.js +6 -46
- package/dist/server/app-page-response.d.ts +15 -3
- package/dist/server/app-page-response.js +21 -3
- package/dist/server/app-page-route-wiring.d.ts +30 -7
- package/dist/server/app-page-route-wiring.js +163 -63
- package/dist/server/app-page-search-params-observation.d.ts +0 -1
- package/dist/server/app-page-segment-plan.d.ts +56 -0
- package/dist/server/app-page-segment-plan.js +177 -0
- package/dist/server/app-page-segment-state.d.ts +18 -2
- package/dist/server/app-page-segment-state.js +23 -4
- package/dist/server/app-page-stream.d.ts +19 -10
- package/dist/server/app-pages-bridge.d.ts +2 -2
- package/dist/server/app-pages-bridge.js +14 -2
- package/dist/server/app-post-middleware-context.d.ts +0 -1
- package/dist/server/app-ppr-fallback-shell-render.d.ts +0 -1
- package/dist/server/app-prerender-endpoints.d.ts +0 -1
- package/dist/server/app-prerender-static-params.d.ts +0 -1
- package/dist/server/app-render-dependency.d.ts +11 -4
- package/dist/server/app-render-dependency.js +59 -9
- package/dist/server/app-request-context.d.ts +1 -0
- package/dist/server/app-route-handler-cache.d.ts +2 -2
- package/dist/server/app-route-handler-cache.js +5 -1
- package/dist/server/app-route-handler-dispatch.d.ts +0 -1
- package/dist/server/app-route-handler-execution.d.ts +2 -2
- package/dist/server/app-route-handler-execution.js +5 -1
- package/dist/server/app-route-handler-policy.d.ts +0 -1
- package/dist/server/app-route-handler-response.d.ts +0 -1
- package/dist/server/app-route-handler-runtime.d.ts +0 -1
- package/dist/server/app-route-handler-runtime.js +1 -2
- package/dist/server/app-route-module-loader.d.ts +32 -6
- package/dist/server/app-route-module-loader.js +73 -3
- package/dist/server/app-router-entry.d.ts +0 -1
- package/dist/server/app-router-entry.js +2 -2
- package/dist/server/app-rsc-cache-busting.d.ts +7 -1
- package/dist/server/app-rsc-cache-busting.js +6 -0
- package/dist/server/app-rsc-handler.d.ts +9 -2
- package/dist/server/app-rsc-handler.js +173 -41
- package/dist/server/app-rsc-redirect-flight.d.ts +0 -1
- package/dist/server/app-rsc-render-mode.d.ts +3 -2
- package/dist/server/app-rsc-render-mode.js +4 -1
- package/dist/server/app-rsc-request-normalization.d.ts +19 -10
- package/dist/server/app-rsc-request-normalization.js +65 -4
- package/dist/server/app-rsc-response-finalizer.d.ts +5 -2
- package/dist/server/app-rsc-response-finalizer.js +31 -18
- package/dist/server/app-rsc-route-matching.d.ts +6 -1
- package/dist/server/app-rsc-route-matching.js +47 -2
- package/dist/server/app-segment-config.d.ts +0 -1
- package/dist/server/app-server-action-execution.d.ts +42 -9
- package/dist/server/app-server-action-execution.js +189 -111
- package/dist/server/app-ssr-entry.d.ts +5 -3
- package/dist/server/app-ssr-entry.js +4 -5
- package/dist/server/app-ssr-router-instance.d.ts +0 -1
- package/dist/server/app-ssr-stream.d.ts +7 -1
- package/dist/server/app-ssr-stream.js +2 -1
- package/dist/server/app-static-generation.d.ts +0 -1
- package/dist/server/app-visited-response-cache.d.ts +7 -2
- package/dist/server/app-visited-response-cache.js +49 -1
- package/dist/server/before-interactive-head.d.ts +0 -1
- package/dist/server/before-interactive-head.js +2 -0
- package/dist/server/bfcache-identity.d.ts +45 -0
- package/dist/server/bfcache-identity.js +52 -0
- package/dist/server/cache-control.d.ts +3 -3
- package/dist/server/cache-control.js +3 -2
- package/dist/server/cache-proof.d.ts +0 -1
- package/dist/server/client-reuse-manifest.d.ts +0 -1
- package/dist/server/config-headers.d.ts +2 -2
- package/dist/server/csp.d.ts +0 -1
- package/dist/server/default-global-error-module.d.ts +0 -1
- package/dist/server/default-global-not-found-module.d.ts +0 -1
- package/dist/server/default-not-found-module.d.ts +0 -1
- package/dist/server/dev-lockfile.d.ts +21 -9
- package/dist/server/dev-module-runner.d.ts +0 -1
- package/dist/server/dev-route-files.d.ts +0 -1
- package/dist/server/dev-server.d.ts +4 -8
- package/dist/server/dev-server.js +86 -131
- package/dist/server/dev-stack-sourcemap.d.ts +0 -1
- package/dist/server/document-initial-head.d.ts +12 -2
- package/dist/server/document-initial-head.js +17 -2
- package/dist/server/edge-api-runtime.d.ts +10 -1
- package/dist/server/edge-api-runtime.js +29 -1
- package/dist/server/file-based-metadata.d.ts +0 -1
- package/dist/server/headers.d.ts +17 -2
- package/dist/server/headers.js +17 -1
- package/dist/server/http-conditional.d.ts +22 -0
- package/dist/server/http-conditional.js +117 -0
- package/dist/server/http-date.d.ts +5 -0
- package/dist/server/http-date.js +73 -0
- package/dist/server/http-error-responses.d.ts +2 -1
- package/dist/server/http-error-responses.js +14 -2
- package/dist/server/http-range.d.ts +25 -0
- package/dist/server/http-range.js +67 -0
- package/dist/server/image-optimization.d.ts +14 -6
- package/dist/server/image-optimization.js +0 -1
- package/dist/server/instrumentation.d.ts +7 -4
- package/dist/server/isr-cache.d.ts +28 -6
- package/dist/server/isr-cache.js +19 -13
- package/dist/server/isr-decision.d.ts +6 -4
- package/dist/server/metadata-route-build-data.d.ts +0 -1
- package/dist/server/metadata-route-response.d.ts +0 -1
- package/dist/server/metadata-route-response.js +7 -6
- package/dist/server/metadata-routes.d.ts +34 -16
- package/dist/server/middleware-matcher-pattern.d.ts +0 -1
- package/dist/server/middleware-matcher.d.ts +8 -3
- package/dist/server/middleware-matcher.js +23 -18
- package/dist/server/middleware-runtime.d.ts +6 -1
- package/dist/server/middleware-runtime.js +91 -28
- package/dist/server/middleware.d.ts +0 -1
- package/dist/server/navigation-planner.d.ts +1 -1
- package/dist/server/next-error-digest.d.ts +0 -1
- package/dist/server/pages-api-route.d.ts +2 -1
- package/dist/server/pages-api-route.js +32 -7
- package/dist/server/pages-asset-tags.d.ts +3 -1
- package/dist/server/pages-asset-tags.js +6 -4
- package/dist/server/pages-data-route.d.ts +14 -6
- package/dist/server/pages-data-route.js +19 -10
- package/dist/server/pages-dev-hydration.js +3 -0
- package/dist/server/pages-dev-stylesheets.d.ts +10 -0
- package/dist/server/pages-dev-stylesheets.js +150 -0
- package/dist/server/pages-document-asset-props.d.ts +26 -0
- package/dist/server/pages-document-asset-props.js +69 -0
- package/dist/server/pages-document-initial-props.d.ts +10 -6
- package/dist/server/pages-get-initial-props.d.ts +2 -2
- package/dist/server/pages-i18n.d.ts +1 -7
- package/dist/server/pages-node-compat.d.ts +11 -2
- package/dist/server/pages-node-compat.js +52 -5
- package/dist/server/pages-page-data.d.ts +21 -9
- package/dist/server/pages-page-data.js +109 -30
- package/dist/server/pages-page-handler.d.ts +70 -32
- package/dist/server/pages-page-handler.js +25 -6
- package/dist/server/pages-page-response.d.ts +9 -13
- package/dist/server/pages-page-response.js +25 -26
- package/dist/server/pages-readiness.d.ts +0 -1
- package/dist/server/pages-request-pipeline.d.ts +20 -6
- package/dist/server/pages-request-pipeline.js +40 -20
- package/dist/server/pages-revalidate.d.ts +0 -1
- package/dist/server/pages-revalidate.js +1 -1
- package/dist/server/pages-router-entry.js +14 -10
- package/dist/server/prerender-manifest.d.ts +7 -0
- package/dist/server/prod-server.d.ts +13 -7
- package/dist/server/prod-server.js +276 -83
- package/dist/server/proxy-trust.d.ts +0 -1
- package/dist/server/request-log.d.ts +7 -11
- package/dist/server/request-pipeline.d.ts +13 -4
- package/dist/server/request-pipeline.js +28 -20
- package/dist/server/revalidation-host.d.ts +0 -1
- package/dist/server/revalidation-host.js +1 -1
- package/dist/server/rsc-completion-metadata.d.ts +15 -0
- package/dist/server/rsc-completion-metadata.js +183 -0
- package/dist/server/seed-cache.d.ts +2 -1
- package/dist/server/seed-cache.js +8 -5
- package/dist/server/skip-cache-proof.d.ts +0 -1
- package/dist/server/static-file-cache.d.ts +23 -9
- package/dist/server/static-file-cache.js +47 -23
- package/dist/server/static-layout-client-reuse-proof.d.ts +0 -1
- package/dist/server/worker-revalidation-context.d.ts +0 -1
- package/dist/server/worker-revalidation-context.js +1 -0
- package/dist/server/worker-utils.d.ts +3 -1
- package/dist/server/worker-utils.js +11 -2
- package/dist/shims/app-router-scroll-state.d.ts +2 -1
- package/dist/shims/app-router-scroll-state.js +7 -2
- package/dist/shims/app-router-scroll.d.ts +2 -8
- package/dist/shims/app.d.ts +1 -5
- package/dist/shims/before-interactive-context.d.ts +5 -3
- package/dist/shims/cache-handler.d.ts +6 -1
- package/dist/shims/cache-handler.js +4 -2
- package/dist/shims/cache-request-state.d.ts +12 -1
- package/dist/shims/cache-request-state.js +22 -1
- package/dist/shims/cache-runtime.d.ts +9 -5
- package/dist/shims/cache-runtime.js +16 -6
- package/dist/shims/cache.d.ts +2 -3
- package/dist/shims/cache.js +2 -2
- package/dist/shims/cdn-cache.d.ts +0 -1
- package/dist/shims/client-locale.d.ts +1 -6
- package/dist/shims/client-only.d.ts +1 -1
- package/dist/shims/compat-router.d.ts +0 -1
- package/dist/shims/constants.d.ts +1 -1
- package/dist/shims/default-global-error.d.ts +1 -4
- package/dist/shims/default-not-found.d.ts +0 -1
- package/dist/shims/document.d.ts +0 -1
- package/dist/shims/document.js +17 -3
- package/dist/shims/dynamic-preload-chunks.d.ts +0 -1
- package/dist/shims/dynamic.d.ts +0 -1
- package/dist/shims/error-boundary-navigation.d.ts +0 -1
- package/dist/shims/error-boundary.d.ts +7 -32
- package/dist/shims/error.d.ts +1 -6
- package/dist/shims/fetch-cache.js +112 -63
- package/dist/shims/font-google-base.d.ts +0 -1
- package/dist/shims/font-local.d.ts +0 -1
- package/dist/shims/form.d.ts +5 -3
- package/dist/shims/hash-scroll.d.ts +1 -1
- package/dist/shims/hash-scroll.js +2 -1
- package/dist/shims/head-state.d.ts +0 -1
- package/dist/shims/head.d.ts +1 -4
- package/dist/shims/headers.d.ts +2 -2
- package/dist/shims/headers.js +1 -1
- package/dist/shims/i18n-context.d.ts +0 -1
- package/dist/shims/i18n-state.d.ts +0 -1
- package/dist/shims/image.d.ts +0 -1
- package/dist/shims/image.js +1 -2
- package/dist/shims/internal/als-registry.d.ts +31 -2
- package/dist/shims/internal/als-registry.js +50 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +17 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.js +69 -7
- package/dist/shims/internal/app-route-detection.d.ts +0 -1
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +31 -0
- package/dist/shims/internal/app-route-prefetch-policy.js +57 -0
- package/dist/shims/internal/app-router-context.d.ts +0 -1
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +1 -5
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +0 -1
- package/dist/shims/internal/hybrid-client-route-owner.js +6 -8
- package/dist/shims/internal/interpolate-as.d.ts +3 -2
- package/dist/shims/internal/pages-data-target.d.ts +21 -10
- package/dist/shims/internal/pages-data-target.js +1 -1
- package/dist/shims/internal/pages-data-url.d.ts +3 -1
- package/dist/shims/internal/router-context.d.ts +0 -1
- package/dist/shims/internal/work-unit-async-storage.d.ts +4 -3
- package/dist/shims/internal/work-unit-async-storage.js +2 -0
- package/dist/shims/layout-segment-context.d.ts +2 -6
- package/dist/shims/legacy-image.d.ts +0 -1
- package/dist/shims/link.d.ts +29 -21
- package/dist/shims/link.js +52 -97
- package/dist/shims/metadata.d.ts +11 -25
- package/dist/shims/metadata.js +24 -32
- package/dist/shims/navigation-context-state.d.ts +0 -1
- package/dist/shims/navigation-state.d.ts +1 -0
- package/dist/shims/navigation.d.ts +54 -6
- package/dist/shims/navigation.js +325 -73
- package/dist/shims/navigation.react-server.d.ts +1 -0
- package/dist/shims/og.d.ts +0 -1
- package/dist/shims/request-context.d.ts +8 -3
- package/dist/shims/request-state-types.d.ts +1 -0
- package/dist/shims/router.d.ts +44 -23
- package/dist/shims/router.js +8 -7
- package/dist/shims/script-nonce-context.d.ts +0 -1
- package/dist/shims/script.d.ts +25 -13
- package/dist/shims/server-only.d.ts +1 -1
- package/dist/shims/server.d.ts +1 -3
- package/dist/shims/server.js +5 -6
- package/dist/shims/slot.d.ts +23 -11
- package/dist/shims/slot.js +103 -19
- package/dist/shims/streamed-icons.d.ts +7 -0
- package/dist/shims/streamed-icons.js +33 -0
- package/dist/shims/unified-request-context.d.ts +44 -4
- package/dist/shims/unified-request-context.js +56 -2
- package/dist/shims/use-merged-ref.d.ts +0 -1
- package/dist/shims/web-vitals.d.ts +0 -1
- package/dist/typegen.d.ts +1 -2
- package/dist/typegen.js +1 -1
- package/dist/utils/cache-control-metadata.d.ts +13 -1
- package/dist/utils/cache-control-metadata.js +17 -1
- package/dist/utils/client-build-manifest.d.ts +0 -1
- package/dist/utils/domain-locale.d.ts +1 -5
- package/dist/utils/html-limited-bots.js +1 -1
- package/dist/utils/middleware-request-headers.d.ts +17 -5
- package/dist/utils/middleware-request-headers.js +32 -23
- package/dist/utils/precompressed-variant.d.ts +9 -0
- package/dist/utils/precompressed-variant.js +15 -0
- package/dist/utils/project.d.ts +12 -7
- package/dist/utils/public-file-path.d.ts +5 -0
- package/dist/utils/public-file-path.js +12 -0
- package/dist/utils/public-routes.d.ts +1 -1
- package/dist/utils/public-routes.js +6 -5
- package/package.json +7 -3
|
@@ -43,6 +43,21 @@ function stringValue(node) {
|
|
|
43
43
|
if ((node.type === "Literal" || node.type === "StringLiteral") && typeof node.value === "string") return node.value;
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
|
+
function stringFromCharCodeValue(value, scope) {
|
|
47
|
+
const node = unwrapExpression(value);
|
|
48
|
+
if (node?.type !== "CallExpression") return null;
|
|
49
|
+
const callee = unwrapExpression(node.callee);
|
|
50
|
+
const object = callee?.type === "MemberExpression" ? unwrapExpression(callee.object) : null;
|
|
51
|
+
const property = callee?.type === "MemberExpression" ? unwrapExpression(callee.property) : null;
|
|
52
|
+
if (callee?.type !== "MemberExpression" || callee.computed === true || !isIdentifierNamed(object, "String") || hasAstBinding(scope, "String") || !isIdentifierNamed(property, "fromCharCode")) return null;
|
|
53
|
+
let resolved = "";
|
|
54
|
+
for (const argument of nodeArray(node.arguments)) {
|
|
55
|
+
const argumentNode = unwrapExpression(argument);
|
|
56
|
+
if (argumentNode?.type !== "Literal" || typeof argumentNode.value !== "number" || !Number.isInteger(argumentNode.value) || argumentNode.value < 0 || argumentNode.value > 65535) return null;
|
|
57
|
+
resolved += String.fromCharCode(argumentNode.value);
|
|
58
|
+
}
|
|
59
|
+
return resolved;
|
|
60
|
+
}
|
|
46
61
|
function isUnboundNumericGlobal(node, scope) {
|
|
47
62
|
return node.type === "Identifier" && typeof node.name === "string" && !hasAstBinding(scope, node.name) && (isIdentifierNamed(node, "NaN") || isIdentifierNamed(node, "Infinity"));
|
|
48
63
|
}
|
|
@@ -482,10 +497,19 @@ function transformVeryDynamicRequests(code, id) {
|
|
|
482
497
|
if (node.type === "CallExpression" && hasRange(node)) {
|
|
483
498
|
const callee = unwrapExpression(node.callee);
|
|
484
499
|
const argumentsList = nodeArray(node.arguments);
|
|
485
|
-
if (isIdentifierNamed(callee, "require") && !hasAstBinding(scope, "require") && argumentsList.length === 1 && astNode(argumentsList[0])?.type !== "SpreadElement" && !hasDynamicRequestIgnoreDirective(code, node, argumentsList[0])
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
500
|
+
if (isIdentifierNamed(callee, "require") && !hasAstBinding(scope, "require") && argumentsList.length === 1 && astNode(argumentsList[0])?.type !== "SpreadElement" && !hasDynamicRequestIgnoreDirective(code, node, argumentsList[0])) {
|
|
501
|
+
const resolvedRequest = stringFromCharCodeValue(argumentsList[0], scope);
|
|
502
|
+
const argument = astNode(argumentsList[0]);
|
|
503
|
+
if (resolvedRequest !== null && resolvedRequest.replaceAll("\\", "/") !== "/" && argument && hasRange(argument)) {
|
|
504
|
+
output.overwrite(argument.start, argument.end, JSON.stringify(resolvedRequest));
|
|
505
|
+
changed = true;
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
if (!requestHasStaticPart(argumentsList[0], scope)) {
|
|
509
|
+
output.overwrite(node.start, node.end, dynamicRequireReplacement());
|
|
510
|
+
changed = true;
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
489
513
|
}
|
|
490
514
|
}
|
|
491
515
|
if (node.type === "ImportExpression" && hasRange(node) && !hasDynamicRequestIgnoreDirective(code, node, node.source) && !requestHasStaticPart(node.source, scope)) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { forEachAstChild, hasRange, isAstRecord, nodeArray } from "./ast-utils.js";
|
|
2
|
-
import { createTransformCache } from "./transform-cache.js";
|
|
3
3
|
import { parseAst } from "vite";
|
|
4
|
+
import { readdir, realpath, stat } from "node:fs/promises";
|
|
4
5
|
import MagicString from "magic-string";
|
|
5
6
|
//#region src/plugins/require-context.ts
|
|
6
7
|
const TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
@@ -14,7 +15,7 @@ const TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
14
15
|
".cts"
|
|
15
16
|
]);
|
|
16
17
|
function createRequireContextPlugin() {
|
|
17
|
-
const
|
|
18
|
+
const watchedContexts = /* @__PURE__ */ new WeakMap();
|
|
18
19
|
return {
|
|
19
20
|
name: "vinext:require-context",
|
|
20
21
|
enforce: "pre",
|
|
@@ -23,13 +24,42 @@ function createRequireContextPlugin() {
|
|
|
23
24
|
id: /\.(?:[cm]?[jt]s|[jt]sx)(?:\?.*)?$/i,
|
|
24
25
|
code: /\brequire\b[\s\S]*\.context/
|
|
25
26
|
},
|
|
26
|
-
handler(code, id) {
|
|
27
|
-
|
|
27
|
+
async handler(code, id) {
|
|
28
|
+
const transformed = await transformRequireContext(code, id);
|
|
29
|
+
const contextsForEnvironment = watchedContexts.get(this.environment) ?? /* @__PURE__ */ new Map();
|
|
30
|
+
watchedContexts.set(this.environment, contextsForEnvironment);
|
|
31
|
+
if (!transformed) {
|
|
32
|
+
contextsForEnvironment.delete(id);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
contextsForEnvironment.set(id, transformed.contexts);
|
|
36
|
+
for (const context of transformed.contexts) this.addWatchFile(context.directory);
|
|
37
|
+
return {
|
|
38
|
+
code: transformed.code,
|
|
39
|
+
map: transformed.map
|
|
40
|
+
};
|
|
28
41
|
}
|
|
42
|
+
},
|
|
43
|
+
hotUpdate({ type, file, modules }) {
|
|
44
|
+
const contextsForEnvironment = watchedContexts.get(this.environment);
|
|
45
|
+
if (!contextsForEnvironment) return;
|
|
46
|
+
for (const module of modules) if (module.id != null) contextsForEnvironment.delete(module.id);
|
|
47
|
+
if (type === "update") return;
|
|
48
|
+
const normalizedFile = toSlash(file);
|
|
49
|
+
const affectedModules = new Set(modules);
|
|
50
|
+
let addedImporter = false;
|
|
51
|
+
for (const [id, contexts] of contextsForEnvironment) {
|
|
52
|
+
if (!contexts.some((context) => matchesWatchedContext(normalizedFile, context))) continue;
|
|
53
|
+
const module = this.environment.moduleGraph.getModuleById(id);
|
|
54
|
+
if (!module || affectedModules.has(module)) continue;
|
|
55
|
+
affectedModules.add(module);
|
|
56
|
+
addedImporter = true;
|
|
57
|
+
}
|
|
58
|
+
return addedImporter ? [...affectedModules] : void 0;
|
|
29
59
|
}
|
|
30
60
|
};
|
|
31
61
|
}
|
|
32
|
-
function transformRequireContext(code, id) {
|
|
62
|
+
async function transformRequireContext(code, id) {
|
|
33
63
|
const lang = langForId(id);
|
|
34
64
|
let ast;
|
|
35
65
|
try {
|
|
@@ -40,10 +70,25 @@ function transformRequireContext(code, id) {
|
|
|
40
70
|
const calls = collectRequireContextCalls(ast);
|
|
41
71
|
if (calls.length === 0) return null;
|
|
42
72
|
const output = new MagicString(code);
|
|
43
|
-
|
|
73
|
+
const importOffset = findImportInsertionOffset(ast);
|
|
74
|
+
const imports = [];
|
|
75
|
+
const contexts = [];
|
|
76
|
+
let bindingPrefix = "__vinext_require_context";
|
|
77
|
+
while (code.includes(bindingPrefix)) bindingPrefix += "_";
|
|
78
|
+
for (const [callIndex, call] of calls.entries()) {
|
|
79
|
+
const resolved = await resolveContextModules(id, call, bindingPrefix, callIndex);
|
|
80
|
+
contexts.push(resolved.context);
|
|
81
|
+
for (const module of resolved.modules) imports.push(`import * as ${module.binding} from ${JSON.stringify(module.specifier)};`);
|
|
82
|
+
output.overwrite(call.range.start, call.range.end, buildReplacement(call, resolved.modules));
|
|
83
|
+
}
|
|
84
|
+
if (imports.length > 0) {
|
|
85
|
+
const importBlock = `${importOffset > 0 ? "\n" : ""}${imports.join("\n")}\n`;
|
|
86
|
+
output.appendLeft(importOffset, importBlock);
|
|
87
|
+
}
|
|
44
88
|
return {
|
|
45
89
|
code: output.toString(),
|
|
46
|
-
map: output.generateMap({ hires: "boundary" })
|
|
90
|
+
map: output.generateMap({ hires: "boundary" }),
|
|
91
|
+
contexts
|
|
47
92
|
};
|
|
48
93
|
}
|
|
49
94
|
function langForId(id) {
|
|
@@ -75,6 +120,16 @@ function collectRequireContextCalls(ast) {
|
|
|
75
120
|
visit(ast);
|
|
76
121
|
return calls;
|
|
77
122
|
}
|
|
123
|
+
function findImportInsertionOffset(ast) {
|
|
124
|
+
if (!isAstRecord(ast) || ast.type !== "Program") return 0;
|
|
125
|
+
let offset = 0;
|
|
126
|
+
if (isAstRecord(ast.hashbang) && hasRange(ast.hashbang)) offset = ast.hashbang.end;
|
|
127
|
+
for (const statement of nodeArray(ast.body)) {
|
|
128
|
+
if (!isAstRecord(statement) || statement.type !== "ExpressionStatement" || typeof statement.directive !== "string" || !hasRange(statement)) break;
|
|
129
|
+
offset = statement.end;
|
|
130
|
+
}
|
|
131
|
+
return offset;
|
|
132
|
+
}
|
|
78
133
|
function parseRequireContextCall(node) {
|
|
79
134
|
if (node.type !== "CallExpression" || !hasRange(node)) return null;
|
|
80
135
|
const callee = node.callee;
|
|
@@ -146,26 +201,14 @@ function regexLiteralValue(value) {
|
|
|
146
201
|
};
|
|
147
202
|
return null;
|
|
148
203
|
}
|
|
149
|
-
function buildReplacement(call) {
|
|
150
|
-
const globPattern = globPatternFor(call.dir, call.recursive);
|
|
151
|
-
const glob = `import.meta.glob(${JSON.stringify(globPattern)}, { eager: true })`;
|
|
204
|
+
function buildReplacement(call, modules) {
|
|
152
205
|
const base = JSON.stringify(stripTrailingSlash(call.dir));
|
|
153
|
-
const
|
|
154
|
-
const regexArgs = `${JSON.stringify(call.pattern)}, ${JSON.stringify(filterFlags)}`;
|
|
206
|
+
const entries = modules.map((module) => `${JSON.stringify(module.key)}: ${module.binding}`);
|
|
155
207
|
return [
|
|
156
208
|
"(() => {",
|
|
157
|
-
` const __modules = ${glob};`,
|
|
158
209
|
` const __base = ${base};`,
|
|
159
|
-
` const
|
|
160
|
-
|
|
161
|
-
" const __map = Object.create(null);",
|
|
162
|
-
" for (const __abs in __modules) {",
|
|
163
|
-
" if (!__abs.startsWith(__prefix)) continue;",
|
|
164
|
-
" const __key = './' + __abs.slice(__prefix.length);",
|
|
165
|
-
" if (__re && !__re.test(__key)) continue;",
|
|
166
|
-
" __map[__key] = __modules[__abs];",
|
|
167
|
-
" }",
|
|
168
|
-
" const __keys = Object.keys(__map).sort();",
|
|
210
|
+
` const __map = Object.assign(Object.create(null), {${entries.join(",")}});`,
|
|
211
|
+
` const __keys = ${JSON.stringify(modules.map((module) => module.key))};`,
|
|
169
212
|
" const __ctx = (__key) => {",
|
|
170
213
|
" if (__key in __map) return __map[__key];",
|
|
171
214
|
" const __err = new Error('Cannot find module \\'' + __key + '\\'');",
|
|
@@ -179,9 +222,83 @@ function buildReplacement(call) {
|
|
|
179
222
|
"})()"
|
|
180
223
|
].join("\n");
|
|
181
224
|
}
|
|
182
|
-
function
|
|
183
|
-
const
|
|
184
|
-
|
|
225
|
+
async function resolveContextModules(id, call, bindingPrefix, callIndex) {
|
|
226
|
+
const importer = toSlash(id.split("?", 1)[0]);
|
|
227
|
+
const directory = path.resolve(path.dirname(importer), call.dir);
|
|
228
|
+
const context = {
|
|
229
|
+
directory,
|
|
230
|
+
recursive: call.recursive,
|
|
231
|
+
pattern: call.pattern,
|
|
232
|
+
flags: filterFlags(call.flags)
|
|
233
|
+
};
|
|
234
|
+
const regexp = call.pattern ? new RegExp(call.pattern, context.flags) : null;
|
|
235
|
+
const accepted = [];
|
|
236
|
+
for (const candidate of await listContextFiles(directory, call.recursive)) {
|
|
237
|
+
const key = `./${candidate}`;
|
|
238
|
+
if (regexp && !regexp.test(key)) continue;
|
|
239
|
+
accepted.push({
|
|
240
|
+
key,
|
|
241
|
+
specifier: `${stripTrailingSlash(call.dir)}/${candidate}`
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
accepted.sort((left, right) => left.key < right.key ? -1 : left.key > right.key ? 1 : 0);
|
|
245
|
+
return {
|
|
246
|
+
context,
|
|
247
|
+
modules: accepted.map((entry, index) => ({
|
|
248
|
+
...entry,
|
|
249
|
+
binding: `${bindingPrefix}_${callIndex}_${index}`
|
|
250
|
+
}))
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
async function listContextFiles(directory, recursive) {
|
|
254
|
+
const files = [];
|
|
255
|
+
const ancestorRealPaths = /* @__PURE__ */ new Set();
|
|
256
|
+
async function walk(currentDirectory, prefix) {
|
|
257
|
+
let realDirectory;
|
|
258
|
+
let entries;
|
|
259
|
+
try {
|
|
260
|
+
realDirectory = await realpath(currentDirectory);
|
|
261
|
+
entries = await readdir(currentDirectory, { withFileTypes: true });
|
|
262
|
+
} catch (error) {
|
|
263
|
+
const code = error.code;
|
|
264
|
+
if (code === "ENOENT" || code === "ENOTDIR") return;
|
|
265
|
+
throw error;
|
|
266
|
+
}
|
|
267
|
+
if (ancestorRealPaths.has(realDirectory)) return;
|
|
268
|
+
ancestorRealPaths.add(realDirectory);
|
|
269
|
+
try {
|
|
270
|
+
for (const entry of entries) {
|
|
271
|
+
if (entry.name.startsWith(".")) continue;
|
|
272
|
+
const entryPath = path.join(currentDirectory, entry.name);
|
|
273
|
+
let isFile = entry.isFile();
|
|
274
|
+
let isDirectory = entry.isDirectory();
|
|
275
|
+
if (!isFile && !isDirectory) try {
|
|
276
|
+
const stats = await stat(entryPath);
|
|
277
|
+
isFile = stats.isFile();
|
|
278
|
+
isDirectory = stats.isDirectory();
|
|
279
|
+
} catch (error) {
|
|
280
|
+
const code = error.code;
|
|
281
|
+
if (code === "ENOENT" || code === "ELOOP") continue;
|
|
282
|
+
throw error;
|
|
283
|
+
}
|
|
284
|
+
if (isFile) files.push(`${prefix}${entry.name}`);
|
|
285
|
+
else if (isDirectory && recursive) await walk(entryPath, `${prefix}${entry.name}/`);
|
|
286
|
+
}
|
|
287
|
+
} finally {
|
|
288
|
+
ancestorRealPaths.delete(realDirectory);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
await walk(directory, "");
|
|
292
|
+
return files;
|
|
293
|
+
}
|
|
294
|
+
function matchesWatchedContext(file, context) {
|
|
295
|
+
const candidate = path.relative(context.directory, file);
|
|
296
|
+
if (candidate.length === 0 || candidate === ".." || candidate.startsWith("../") || candidate.split("/").some((segment) => segment.startsWith(".")) || !context.recursive && candidate.includes("/")) return false;
|
|
297
|
+
if (context.recursive) return true;
|
|
298
|
+
return context.pattern === "" || new RegExp(context.pattern, context.flags).test(`./${candidate}`);
|
|
299
|
+
}
|
|
300
|
+
function filterFlags(flags) {
|
|
301
|
+
return flags.replace(/[gy]/g, "");
|
|
185
302
|
}
|
|
186
303
|
function stripTrailingSlash(value) {
|
|
187
304
|
return value.endsWith("/") ? value.slice(0, -1) : value;
|
package/dist/plugins/sass.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ResolvedConfig } from "vite";
|
|
2
|
-
|
|
3
2
|
//#region src/plugins/sass.d.ts
|
|
4
3
|
type AdditionalData = string | ((source: string, filename: string) => string | Promise<string>);
|
|
5
4
|
type VitePreprocessorOptions = {
|
|
@@ -7,6 +6,35 @@ type VitePreprocessorOptions = {
|
|
|
7
6
|
loadPaths?: string[];
|
|
8
7
|
[key: string]: any;
|
|
9
8
|
};
|
|
9
|
+
type SassTsconfigPathAlias = {
|
|
10
|
+
find: string;
|
|
11
|
+
replacements: readonly string[];
|
|
12
|
+
};
|
|
13
|
+
type SassFileImporterContext = {
|
|
14
|
+
containingUrl?: URL | null;
|
|
15
|
+
};
|
|
16
|
+
type SassFileImporter = {
|
|
17
|
+
findFileUrl(url: string, context?: SassFileImporterContext): URL | null;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Create Sass `FileImporter`s for paths materialized from tsconfig.
|
|
21
|
+
*
|
|
22
|
+
* Vite does not apply tsconfig path aliases while resolving Sass loads. Vinext
|
|
23
|
+
* deliberately extends that behavior for migration compatibility: application
|
|
24
|
+
* stylesheets may use the same exact and single-wildcard mappings as source
|
|
25
|
+
* modules. This is a vinext capability, not Next.js parity; current Next.js
|
|
26
|
+
* webpack builds do not resolve tsconfig `paths` from Sass.
|
|
27
|
+
*
|
|
28
|
+
* One importer is emitted per ordered replacement slot. When Sass cannot find
|
|
29
|
+
* a file for the first target it advances to the next importer, preserving the
|
|
30
|
+
* fallback order from `paths`. All importers select the same best pattern, so a
|
|
31
|
+
* failed specific mapping never falls through to a less-specific mapping.
|
|
32
|
+
*
|
|
33
|
+
* Aliases stay scoped to application stylesheets. Loads originating in
|
|
34
|
+
* `node_modules`, plus absolute, relative, protocol-relative, and scheme URLs,
|
|
35
|
+
* are left to user and Vite importers.
|
|
36
|
+
*/
|
|
37
|
+
declare function createSassTsconfigPathImporters(aliases: readonly SassTsconfigPathAlias[]): SassFileImporter[];
|
|
10
38
|
/**
|
|
11
39
|
* Create a Sass `FileImporter` that resolves webpack-style tilde (`~`) imports.
|
|
12
40
|
*
|
|
@@ -75,4 +103,4 @@ declare function createSassAwareFileSystemLoader(): {
|
|
|
75
103
|
setResolvedConfig: (config: ResolvedConfig) => void;
|
|
76
104
|
};
|
|
77
105
|
//#endregion
|
|
78
|
-
export { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter };
|
|
106
|
+
export { SassTsconfigPathAlias, buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter, createSassTsconfigPathImporters };
|
package/dist/plugins/sass.js
CHANGED
|
@@ -3,7 +3,7 @@ import { markCssUrlAssetReferences, rebaseCssUrlAssetReferences } from "../build
|
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import { preprocessCSS } from "vite";
|
|
6
|
-
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
7
|
//#region src/plugins/sass.ts
|
|
8
8
|
/**
|
|
9
9
|
* Map a Next.js `sassOptions` object onto Vite's
|
|
@@ -28,6 +28,69 @@ import { pathToFileURL } from "node:url";
|
|
|
28
28
|
*
|
|
29
29
|
* @see https://vite.dev/config/shared-options.html#css-preprocessoroptions
|
|
30
30
|
*/
|
|
31
|
+
const URL_SCHEME_RE = /^[A-Za-z][A-Za-z\d+.-]*:/;
|
|
32
|
+
const NODE_MODULES_PATH_RE = /(?:^|\/)node_modules(?:\/|$)/;
|
|
33
|
+
function matchSassTsconfigPathAlias(aliases, url) {
|
|
34
|
+
for (const alias of aliases) if (!alias.find.includes("*") && alias.find === url) return {
|
|
35
|
+
alias,
|
|
36
|
+
matchedStar: null
|
|
37
|
+
};
|
|
38
|
+
let bestMatch = null;
|
|
39
|
+
let bestPrefixLength = -1;
|
|
40
|
+
for (const alias of aliases) {
|
|
41
|
+
const starIndex = alias.find.indexOf("*");
|
|
42
|
+
if (starIndex < 0) continue;
|
|
43
|
+
const prefix = alias.find.slice(0, starIndex);
|
|
44
|
+
const suffix = alias.find.slice(starIndex + 1);
|
|
45
|
+
if (url.length < prefix.length + suffix.length || !url.startsWith(prefix) || !url.endsWith(suffix) || prefix.length <= bestPrefixLength) continue;
|
|
46
|
+
bestPrefixLength = prefix.length;
|
|
47
|
+
bestMatch = {
|
|
48
|
+
alias,
|
|
49
|
+
matchedStar: url.slice(prefix.length, url.length - suffix.length)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return bestMatch;
|
|
53
|
+
}
|
|
54
|
+
function isSassAliasEligibleUrl(url, context) {
|
|
55
|
+
if (URL_SCHEME_RE.test(url) || url.startsWith("//") || url.startsWith("/") || url.startsWith("./") || url.startsWith("../") || url.startsWith("~")) return false;
|
|
56
|
+
const containingUrl = context?.containingUrl;
|
|
57
|
+
if (containingUrl?.protocol === "file:") {
|
|
58
|
+
const containingPath = toSlash(fileURLToPath(containingUrl));
|
|
59
|
+
if (NODE_MODULES_PATH_RE.test(containingPath)) return false;
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create Sass `FileImporter`s for paths materialized from tsconfig.
|
|
65
|
+
*
|
|
66
|
+
* Vite does not apply tsconfig path aliases while resolving Sass loads. Vinext
|
|
67
|
+
* deliberately extends that behavior for migration compatibility: application
|
|
68
|
+
* stylesheets may use the same exact and single-wildcard mappings as source
|
|
69
|
+
* modules. This is a vinext capability, not Next.js parity; current Next.js
|
|
70
|
+
* webpack builds do not resolve tsconfig `paths` from Sass.
|
|
71
|
+
*
|
|
72
|
+
* One importer is emitted per ordered replacement slot. When Sass cannot find
|
|
73
|
+
* a file for the first target it advances to the next importer, preserving the
|
|
74
|
+
* fallback order from `paths`. All importers select the same best pattern, so a
|
|
75
|
+
* failed specific mapping never falls through to a less-specific mapping.
|
|
76
|
+
*
|
|
77
|
+
* Aliases stay scoped to application stylesheets. Loads originating in
|
|
78
|
+
* `node_modules`, plus absolute, relative, protocol-relative, and scheme URLs,
|
|
79
|
+
* are left to user and Vite importers.
|
|
80
|
+
*/
|
|
81
|
+
function createSassTsconfigPathImporters(aliases) {
|
|
82
|
+
const entries = aliases.filter(({ find, replacements }) => find.length > 0 && replacements.length > 0);
|
|
83
|
+
const replacementSlots = Math.max(0, ...entries.map((alias) => alias.replacements.length));
|
|
84
|
+
return Array.from({ length: replacementSlots }, (_, replacementIndex) => ({ findFileUrl(url, context) {
|
|
85
|
+
if (!isSassAliasEligibleUrl(url, context)) return null;
|
|
86
|
+
const match = matchSassTsconfigPathAlias(entries, url);
|
|
87
|
+
if (!match) return null;
|
|
88
|
+
const replacement = match.alias.replacements[replacementIndex];
|
|
89
|
+
if (!replacement) return null;
|
|
90
|
+
const matchedStar = match.matchedStar;
|
|
91
|
+
return pathToFileURL(matchedStar === null ? replacement : replacement.replaceAll("*", () => matchedStar));
|
|
92
|
+
} }));
|
|
93
|
+
}
|
|
31
94
|
/**
|
|
32
95
|
* Create a Sass `FileImporter` that resolves webpack-style tilde (`~`) imports.
|
|
33
96
|
*
|
|
@@ -130,8 +193,7 @@ function createSassCssUrlAssetImporter() {
|
|
|
130
193
|
if (!fs.statSync(candidate, { throwIfNoEntry: false })?.isFile()) continue;
|
|
131
194
|
const prepared = prepareStylesheet(candidate, entryDirectory);
|
|
132
195
|
if (prepared === null) return match;
|
|
133
|
-
|
|
134
|
-
markedStylesheets.set(canonicalUrl.href, prepared);
|
|
196
|
+
markedStylesheets.set(candidate, prepared);
|
|
135
197
|
const namespace = rule === "use" && !/\bas\s+(?:\*|[-\w]+)/.test(suffix) ? ` as ${deriveSassNamespace(importUrl)}` : "";
|
|
136
198
|
return `${prefix}${quote}${importUrlPrefix}${encodeURIComponent(candidate)}${quote}${namespace}${suffix}`;
|
|
137
199
|
}
|
|
@@ -143,7 +205,7 @@ function createSassCssUrlAssetImporter() {
|
|
|
143
205
|
return pathToFileURL(decodeURIComponent(url.slice(21)));
|
|
144
206
|
},
|
|
145
207
|
load(canonicalUrl) {
|
|
146
|
-
return markedStylesheets.get(canonicalUrl
|
|
208
|
+
return markedStylesheets.get(toSlash(fileURLToPath(canonicalUrl))) ?? null;
|
|
147
209
|
},
|
|
148
210
|
rewriteImports
|
|
149
211
|
};
|
|
@@ -338,4 +400,4 @@ function createSassAwareFileSystemLoader() {
|
|
|
338
400
|
};
|
|
339
401
|
}
|
|
340
402
|
//#endregion
|
|
341
|
-
export { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter };
|
|
403
|
+
export { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter, createSassTsconfigPathImporters };
|