Rebuild source dependencies when package output settings change
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- ocaml
调研方向
首先跟踪初始化期间针对根 source-map 参数的现有依赖项失效处理,并检查 compiler-info.json 以及生成的 .cmj 构件。然后检查两个共享源依赖项的项目的集成测试设置。当更改包输出设置会使 Rewatch 重新构建该依赖项,并且两种模块顺序场景都能成功编译时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Problem
Rewatch can reuse stale dependency build artifacts when projects with different package-specs build the same source dependency.
We encountered this while working on moving Belt into the separate @rescript/belt package in the ReScript compiler repository:
- The regular analysis tests build
@rescript/beltthrough a CommonJS test project. - The reanalyze tests subsequently use the same package through an ES module test project.
- Both projects reference the same source dependency and therefore share its build artifacts.
- Rewatch considers the existing Belt artifacts current and does not rebuild them for the second project.
- The reanalyze tests fail with a misleading
Missing dependency Belt_*error.
This is not a particularly common project setup, but the compiler repository exposes the underlying invalidation problem because multiple test projects with different output formats build the same source dependency in sequence.
Dependencies are compiled using the consuming root project's package output settings. However, these settings are not recorded in lib/bs/compiler-info.json. Belt's .cmj files therefore still contain only the CommonJS package-output metadata when the ES module project is built.
The dependency files and compiler search path are present; it is the package-output metadata inside the .cmj files that is stale.
Proposed solution
Include the effective root package output settings in each package's compiler-info.json.
The stored value should contain a normalized representation of every effective package spec, including:
- Module format
in-source- Resolved suffix, including the root-level suffix fallback
During initialization, compare the current package output settings with those stored in compiler-info.json. If they differ, clean and rebuild the affected dependency.
This follows the existing mechanism that invalidates dependency builds when root source-map arguments change.
Testing
Add an integration test with two projects sharing a source dependency:
- Build the dependency through a CommonJS project.
- Build it through an ES module project without explicitly cleaning the dependency.
- Verify that Rewatch rebuilds the dependency and that the second project compiles successfully.
Ideally, test the reverse order as well.
- 主要语言
- OCaml
- 星标
- 7.5k
- 派生
- 485
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 55
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rescript-lang/rescript 的其他 Issue
-
难度 5/5 一周以上 新手友好度 35/100
rescript-lang/rescript#8659 · 2 条评论 · 2 个 reaction ·
-
难度 5/5 一周以上 新手友好度 35/100
rescript-lang/rescript#8647 ·
-
rescript-lang/rescript#8632 · 已指派 1 人 ·
-
难度 5/5 一周以上 新手友好度 28/100
rescript-lang/rescript#8624 ·
-
难度 5/5 一周以上 新手友好度 30/100
rescript-lang/rescript#8596 · 2 条评论 ·
查看 rescript-lang/rescript 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
typelevel/sbt-typelevel#929 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
openSUSE/python-rpm-macros#219 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 1/5 1 小时以内 新手友好度 90/100
Qiskit/mcp-servers#221 ·