svelte-store: extensionless re-exports in src/index.svelte.ts break Node ESM and nodenext types
维护者通常 1 天内回复
@Mittalnew 已经在做这个了。
开始于 2026年11月16日。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 86/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
调研方向
从 packages/svelte-store/src/index.svelte.ts 开始,将其相对再导出与生成的 dist/index.svelte.js 和 dist/index.svelte.d.ts 进行比较。为 issue 中指出的三个没有扩展名的再导出添加 .js 扩展名。完成标准是 Node ESM 导入成功,且 TypeScript 使用 node16 或 nodenext 时能解析这些导出;issue 报告称 svelte-check 仍然通过。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
packages/svelte-store/src/index.svelte.ts mixes .js and extensionless relative re-exports:
export * from '@tanstack/store'
export * from './useSelector.svelte.js'
export * from './useAtom'
export * from './useStore' // @deprecated in favor of useSelector
export * from './_useStore'
Unlike the other packages in this repo (which bundle with tsdown), @tanstack/svelte-store builds with svelte-package, which copies relative specifiers unchanged into dist/index.svelte.js and dist/index.svelte.d.ts. Because @tanstack/svelte-store declares "type": "module", Node's ESM loader throws ERR_MODULE_NOT_FOUND on ./useAtom whenever @tanstack/svelte-store is loaded outside Vite's bundler (such as Node scripts, tests, or SSR with externalized dependencies), and TypeScript under moduleResolution: "node16" or "nodenext" fails to resolve useAtom, useStore, and _useStore.
Steps to Reproduce the Bug or Issue
mkdir repro && cd repro
npm init -y && npm pkg set type=module
npm i @tanstack/[email protected] svelte [email protected]
node --input-type=module -e "import('@tanstack/svelte-store').catch(e => console.log(e.code, e.message))"
Node output:
ERR_MODULE_NOT_FOUND Cannot find module '.../repro/node_modules/@tanstack/svelte-store/dist/useAtom' imported from .../repro/node_modules/@tanstack/svelte-store/dist/index.svelte.js
TypeScript (repro.mts):
import { createAtom, useAtom, useSelector, useStore, _useStore } from '@tanstack/svelte-store'
console.log(createAtom, useAtom, useSelector, useStore, _useStore)
Running npx tsc --noEmit --strict --module nodenext --moduleResolution nodenext repro.mts:
node_modules/@tanstack/svelte-store/dist/index.svelte.d.ts(3,15): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './useAtom.js'?
node_modules/@tanstack/svelte-store/dist/index.svelte.d.ts(4,15): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './useStore.js'?
node_modules/@tanstack/svelte-store/dist/index.svelte.d.ts(5,15): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './_useStore.js'?
repro.mts(1,22): error TS2305: Module '"@tanstack/svelte-store"' has no exported member 'useAtom'.
repro.mts(1,44): error TS2305: Module '"@tanstack/svelte-store"' has no exported member 'useStore'.
repro.mts(1,54): error TS2305: Module '"@tanstack/svelte-store"' has no exported member '_useStore'.
With --skipLibCheck, the three TS2305 errors on repro.mts still fail compilation. (--moduleResolution bundler passes.)
Expected behavior
import('@tanstack/svelte-store') loads cleanly in Node ESM, and useAtom, useStore, and _useStore resolve under node16 and nodenext just as useSelector already does.
Screenshots or Videos
N/A
Platform
- OS: Linux x86_64
- Runtime / Compiler: Node.js v26.13.0, TypeScript 6.0.3 and 7.0.2
- Version:
@tanstack/[email protected](latest release; also reproduces when built frommainat0e95a97)
Additional context
Adding .js to the three re-exports in packages/svelte-store/src/index.svelte.ts ('./useAtom.js', './useStore.js', './_useStore.js') fixes both dist/index.svelte.js and dist/index.svelte.d.ts while keeping svelte-check green.
Credit: https://ucsbplse.github.io/
- 主要语言
- TypeScript
- 星标
- 913
- 派生
- 121
- 平均合并
- 19 小时 51 分钟
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/store 的其他 Issue
-
`useSelector` triggers `state_proxy_equality_mismatch` on every store update in svelte-store可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
TanStack/store#322 · 3 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
Missing atom docs可能已有人在做 @looooown2006 于 196 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
compareDeep reports unequal Sets as equal可能已有人在做 @Gourav224 于 28 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 30/100
维护者通常 1 天内回复
-
Reading a computed atom without subscribing can prevent garbage collection可能已有人在做 @Sheraff 于 52 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 58/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 45/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
fb55/htmlparser2#2579 ·
维护者通常 1 天内回复
-
bug good first issue needs-review
难度 1/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
documentation public
难度 1/5 1-3 小时 新手友好度 68/100
midnightntwrk/umbradb#65 ·
维护者通常 2 天内回复
-
area/channels kind/bug priority/medium
难度 2/5 1-3 小时 新手友好度 78/100
nanocoai/nanoclaw#4501 · 1 条评论 ·
维护者通常 1 天内回复
-
needs verification
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 13 天内回复