mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
d38661f809
* fix: dedup RSC client references to prevent module duplication in dev When the RSC plugin creates client-in-server-package-proxy modules for "use client" submodules within packages, it re-exports from absolute file paths. These bypass Vite's pre-bundling in the client environment, causing the browser to load two separate module instances — one from the raw ESM path and one from .vite/deps/. This breaks React context providers/consumers since createContext() runs twice. Add vinext:client-reference-dedup plugin that intercepts absolute node_modules path imports originating from proxy virtual modules in the client environment and redirects them through bare specifier imports, which Vite's import analysis routes through pre-bundling automatically. Closes #409 * fix: make dedup test layout a server component to exercise RSC proxy path Remove "use client" from layout.tsx so ThemeProvider import goes through RSC → client-in-server-package-proxy (absolute path), while the page's useTheme goes through client pre-bundling (bare specifier). This ensures the integration test actually validates the dedup plugin works. * docs: address PR review feedback for client-reference-dedup plugin - Document lossy submodule-to-package mapping assumption in resolveId - Extract load filter regex to named DEDUP_FILTER constant - Note default export edge case in generated re-export code