RFC: Replace `lib/bs` and `lib/ocaml` with a single flat `lib/rescript` directory (v13)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 重構
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- javascript, node.js, ocaml
- 領域
- build-system, tooling
研究方向
Start with the checklist and trace output paths through rewatch-ocaml, analysis (find_files, packages, cmt), reanalyze, and gentype (module_resolver); then review the shared rewatch suite, rewatch-ocaml tests, and analysis fixtures. The proposal is a v13 layout migration across compiler, runtime packaging, editor integrations, tests, and docs. Done means the listed consumers and tests use lib/rescript, migration support and cleanup are covered, and the migration note documents new paths.
由索引模型根據 Issue 內容生成。
描述
Every package's build output lives in two directories with historical names: lib/bs (from BuckleScript) and lib/ocaml (the old bsb install directory). Most files exist in both. This RFC proposes replacing them with a single flat lib/rescript directory in v13.
Today: almost everything exists twice
The build writes each artifact to lib/bs/<srcdir>/ (nested like the sources), then copies it byte for byte into lib/ocaml/ (flat). Most consumers read only one of the two copies:
| Artifact | lib/bs/<srcdir>/ copy read by |
lib/ocaml/ copy read by |
|---|---|---|
.res / .resi (copy of the source) |
nobody | nobody (only the stdlib's copies in @rescript/runtime are read, by analysis) |
.ast / .iast |
bsc (compile input), the dependency scan |
both build systems (persistent state: freshness, previous dependencies, removed modules) |
.cmi |
the editor (createInterface, file watcher) | bsc, through -I ../ocaml and each dependency's lib/ocaml; both build systems (timestamp: "interface last changed") |
.cmj |
nobody after the build (copy source) | bsc (cross-module inlining; derives the package as pkg/lib/ocaml/X.cmj) |
.cmt / .cmti |
analysis, reanalyze, gentype, the editor | both build systems (only the .cmt timestamp: "last compiled"); the stdlib's copies are read by analysis |
.mlmap (namespaces) |
bsc |
nobody (only compared by the build) |
| compiled JS | the build's cleanup (proves it owns an output) | (none) |
.compiler.log, compiler-info.json, .sourcedirs.json, ___incremental/ |
the editor, analysis, reanalyze, the build systems | (none) |
So each source file exists three times on disk, and the build output takes about twice the space it needs. For tests/tests (661 modules) that's 32 MB in lib/bs and 29 MB in lib/ocaml. The editor sees lib/ocaml only through the -I paths from rescript compiler-args. lib/ocaml exists because bsc needs one flat include directory per package, and lib/bs is nested by source directory. It is also the only directory @rescript/runtime ships.
Proposal
lib/rescript/
X.ast X.iast parse output and build state
X.cmi X.cmj bsc input: -I lib/rescript for the package and each dependency
X.cmt X.cmti editor, analysis, reanalyze, gentype
Ns.cmi Ns.cmj Ns.mlmap namespace map
.compiler.log
compiler-info.json
.sourcedirs.json
build.lock replaces lib/rescript.lock and lib/rewatch.lock
incremental/ editor scratch space, replaces lib/bs/___incremental
- Flat: one directory per package, keyed by the compiler's file name for the module (
XorX-Ns), aslib/ocamlis today. Module names are already unique within a package. - One copy of everything: no source copies and no JS mirror. Output ownership for cleanup comes from the build state instead.
- Freshness stays timestamp-based: the
.cmtmarks "last compiled" and the.cmimarks "interface last changed". A.cmiis written to a temporary name and renamed into place only on success, and only when it changed. That keeps early cutoff, and dependents never see a half-written interface. bscbarely changes:-I ../ocamlbecomes-I lib/rescript. The.cmjpackage-path derivation keeps working, becausepkg/lib/rescript/X.cmjhas the same depth aspkg/lib/ocaml/X.cmj.@rescript/runtimeshipslib/rescript, and analysis reads the stdlib from there.rescript cleanremoveslib/bsandlib/ocamlleft over from earlier versions.
Checklist
- rewatch-ocaml: output paths, publishing, freshness/state, the watcher's ignore list,
compiler-args, clean - Remove the Rust rewatch first, so only one build system changes
- analysis (
find_files,packages,cmt): look up a module's files directly inlib/rescriptinstead of going through source directories - reanalyze (the
.sourcedirs.jsonscan plan) and gentype (module_resolver): read<pkg>/lib/rescript -
@rescript/runtimepackaging (artifacts.json,.npmignore) - Tests: the shared rewatch suite, rewatch-ocaml's tests, and analysis fixtures that hard-code
lib/bs/lib/ocaml - Docs, templates, and the migration note in the CHANGELOG
- rescript-vscode and
@rescript/language-server: choose the layout by compiler version (compiler-info.json,.compiler.log, watchers,incremental/, createInterface, incremental type-checking)
Migration
- This is a breaking change for v13.
- The editor extension supports both layouts, choosing by compiler version, so the build writes nothing to
lib/bsfor older editors. - Third-party tools that read
lib/bs/.compiler.logorlib/ocamldirectly, such as bundler plugins, need updating; the CHANGELOG lists the new paths.
- 主要語言
- OCaml
- 星號
- 7.5k
- 分支
- 484
- 平均合併
- 20 小時 43 分鐘
- 30 天內合併 PR
- 263
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
rescript-lang/rescript 的其他 Issue
-
難度 1/5 1 小時以內 新手友好度 85/100
rescript-lang/rescript#9139 ·
維護者通常 1 天內回覆
-
Printed @as names of fields and constructors turn non-ASCII letters into other characters可能已有人在做 @cknitt 於 1 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 25/100
rescript-lang/rescript#9142 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
rescript-lang/rescript#9130 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 4/5 1-2 天 新手友好度 55/100
rescript-lang/rescript#9122 ·
維護者通常 1 天內回覆
-
Dev dependencies interacting可能已有人在做 @CarlOlson 於 4 天前認領。 未關閉
難度 4/5 1-2 天 新手友好度 25/100
rescript-lang/rescript#9089 · 1 則留言 ·
維護者通常 1 天內回覆
查看 rescript-lang/rescript 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
dsh-market/dsh-market#1072 ·
維護者通常 1 天內回覆
-
stage-fail
難度 2/5 1-3 小時 新手友好度 72/100
siyuan-note/bazaar#2447 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
mihaip/infinite-mac#475 ·
-
Status: Opened Type: Bug
難度 1/5 1 小時以內 新手友好度 85/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 85/100
msys2/MSYS2-packages#6919 ·
維護者通常 1 天內回覆