A type imported from a JS module (declared `export type` in its .d.rx, or a package's TS-only type) compiles to a value import; the bundle fails with MISSING_EXPORT
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 56/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- compilers
调研方向
Start with compiler/src/emit.rs at the module import emission around lines 361 and 676–696, then compare the existing type filtering around line 606. Check how .d.rx declarations represent JsDecl::Type and how imports used only in type positions are tracked. Done means type-only names emit neither an ES value import nor a runtime binding; verify with the provided repro and confirm the Vite build no longer reports MISSING_EXPORT.
由索引模型根据 Issue 内容生成。
描述
A type imported from a JS module compiles to a runtime value import, so the bundler fails on an export that only exists in TypeScript.
Versions: @reactivescript/compiler, @reactivescript/runtime, @reactivescript/language-server 0.3.1; solid-js 2.0.0-rc.21; @solidjs/vite-plugin 3.0.0-next.57.
Repro
lib.d.rx:
export type Outcome = { kind: "idle" } | { kind: "sent" }
export fn post(body: object)
lib.ts:
export type Outcome = { kind: 'idle' } | { kind: 'sent' }
export function post(_b: object) {}
main.rx:
import { StyleXStyles } from "@stylexjs/stylex"
import { Outcome } from "./lib"
export component App({ s }: { s?: StyleXStyles }) {
source o: Outcome := { kind: "idle" }
<p>{o.kind}</p>
}
app("main.rx", "dom") from the compiler's Node-API reports no diagnostic and emits:
import { StyleXStyles as w$StyleXStyles } from "@stylexjs/stylex";
import { Outcome as w$Outcome } from "./lib";
...
const v$StyleXStyles = w$StyleXStyles;
__rt.reg("StyleXStyles", { value: v$StyleXStyles });
const v$Outcome = w$Outcome;
__rt.reg("Outcome", { value: v$Outcome });
A Vite (Rolldown) build then fails with MISSING_EXPORT for both names: neither lib.ts nor @stylexjs/stylex exports them as values.
Expected
guide/reference.md says there is no import type and types are imported the same way, and MO-6c says an imported type "binds no value". So:
Outcomeis declaredexport typein the.d.rxbeside the module (MO-8a). The compiler knows it is a type and should emit neither the ES import nor the binding.StyleXStyleshas no.d.rx, so only its use tells the compiler it is a type. A name an import binds that is only read in type positions should be erased too. Otherwise a type from a package cannot be imported at all; the only workaround is an inlineimport("@stylexjs/stylex").StyleXStylestype.
Cause
.rx imports already skip types: compiler/src/emit.rs:606 checks Decl::TypeDecl / ExportSig::Type and continues ("a type binds nothing"). JS imports (resolved: None) have no such check, even when the .d.rx declares the name as JsDecl::Type:
compiler/src/emit.rs:361builds the module-levelimport { … }from every name;compiler/src/emit.rs:676-696binds every name tow$<alias>and emits__rt.reg.
Both should drop a name the declaration file declares as a type, and ideally a name that is used only in type positions.
- 主要语言
- TypeScript
- 星标
- 127
- 派生
- 7
- 平均合并
- 15 小时 42 分钟
- 30 天内合并 PR
- 63
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/reactivescript 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
solidjs/reactivescript#96 ·
维护者通常 1 天内回复
-
Vite front end keeps serving a failed build after the missing/broken imported module is fixed可能已有人在做 @cgaaf 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 77/100
solidjs/reactivescript#84 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
solidjs/reactivescript#77 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
solidjs/reactivescript#74 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 62/100
solidjs/reactivescript#97 ·
维护者通常 1 天内回复
查看 solidjs/reactivescript 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
GetStream/stream-chat-react#3467 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
vercel-labs/ui#1139 ·
维护者通常 1 天内回复
-
generate_image reference URL guard lets through IPv4-mapped IPv6 hosts and 100.64.0.0/10可能已有人在做 @goranai 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
bot:ai-assisted component:platform-js status:untriaged
难度 2/5 1-3 小时 新手友好度 82/100
midnightntwrk/platform-js#93 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100