Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Vite plugin: 'use-sync-external-store/shim/index.js' is not aliased, dev server crashes with react-aria

未关闭 适合新手
#67 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 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
  1. Create a Vite + React SPA with redact() in plugins.
  2. Render any component from react-aria-components that uses useSyncExternalStore. Examples: Sheet, a toast region (useToastState), or a collection component (CollectionBuilder).
  3. 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/redact 0.2.0. The alias table on main (d56d87cb) has the same gap.
  • vite 8.3.4
  • react-aria 3.53.1, react-aria-components 1.22.1, react-stately 3.51.0
主要语言
TypeScript
星标
408
派生
13
平均合并
1 小时 44 分钟
30 天内合并 PR
21

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/redact 的其他 Issue

查看 TanStack/redact 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。