Vite plugin: 'use-sync-external-store/shim/index.js' is not aliased, dev server crashes with react-aria
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 90/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- react, typescript, vite
- 領域
- build-system
研究方向
從 packages/redact/src/vite/index.ts 開始,檢查 use-sync-external-store/shim 對應的 ALIASES 項目。在那裡新增建議的兩個檔案路徑別名,接著驗證這兩個指定字串在 Vite 開發伺服器中都會解析至 @tanstack/redact。當重現時不再因缺少 useSyncExternalStore 匯出而當機,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Summary
react-aria, react-aria-components and react-stately import the use-sync-external-store shim by its file path:
import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
The Vite plugin alias table does not contain this specifier. It contains use-sync-external-store/shim, but not use-sync-external-store/shim/index.js. The import therefore resolves to the real CJS shim.
In the dev server, the plugin also excludes use-sync-external-store* from optimizeDeps. The browser then loads the raw CJS file as ESM, and the root render crashes:
SyntaxError: The requested module '/node_modules/use-sync-external-store/shim/index.js?v=…'
does not provide an export named 'useSyncExternalStore'
The production build does not crash, because Rolldown converts the CJS file.
Reproduction
- Create a Vite + React SPA with
redact()inplugins. - Render any component from
react-aria-componentsthat usesuseSyncExternalStore. Examples:Sheet, a toast region (useToastState), or a collection component (CollectionBuilder). - Run
vite(the dev server) and open the page.
Result: blank page and the error above. Expected: the shim resolves to @tanstack/redact, the same as use-sync-external-store/shim.
Workaround
Add the specifier as an alias in the app's vite.config.ts:
resolve: {
alias: {
"use-sync-external-store/shim/index.js": "@tanstack/redact",
},
},
With this alias, our full e2e suite (66 Playwright tests) passes on Redact.
Suggested fix
Add these entries to ALIASES in packages/redact/src/vite/index.ts, before use-sync-external-store/shim:
'use-sync-external-store/shim/index.js': '@tanstack/redact',
'use-sync-external-store/index.js': '@tanstack/redact',
Versions
@tanstack/redact0.2.0. The alias table onmain(d56d87cb) has the same gap.vite8.3.4react-aria3.53.1,react-aria-components1.22.1,react-stately3.51.0
- 主要語言
- TypeScript
- 星號
- 408
- 分支
- 13
- 平均合併
- 1 小時 47 分鐘
- 30 天內合併 PR
- 22
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
TanStack/redact 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 82/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
相似的 Issue
-
Replace discontinued crypto-js in the theme可能已有人在做 @aelmanaa 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 85/100
PaloAltoNetworks/docusaurus-openapi-docs#1689 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
solana-foundation/solana-web3.js#4015 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
documentation
難度 1/5 1-3 小時 新手友好度 90/100
ivopogace/opencode-courier#422 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
chapel-lang/chapel-vscode#158 ·
維護者通常 1 天內回覆