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 小时 44 分钟
- 30 天内合并 PR
- 21
环境准备
这个项目没有提供开发容器、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
-
难度 1/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
area:plugins area:security area:skills bug has repro
难度 2/5 1-3 小时 新手友好度 76/100
anthropics/claude-code#105911 ·
维护者通常 1 天内回复
-
documentation good first issue help wanted
难度 2/5 1-3 小时 新手友好度 74/100
dev-five-git/devup-ui#879 ·
维护者通常 11 天内回复
-
openspec-apply-change skill: when blocked, may select a ready artifact unrelated to missingArtifacts未关闭
难度 2/5 1-3 小时 新手友好度 72/100
Fission-AI/OpenSpec#2165 ·
维护者通常 1 天内回复
-
🐞 bug 🧐 unconfirmed
难度 2/5 1-3 小时 新手友好度 66/100
Tencent/tdesign-vue-next#7032 · 1 条评论 ·
维护者通常 1 天内回复