--subpaths: a shadowed subpath export is dropped. Bind it under a subpath-qualified name (blend V1 deprecated paths)
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 64/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript
- Lĩnh vực
- tooling
Hướng nghiên cứu
Start in src/extract.mjs at the seen.has(name) branch that currently records subpath-name-shadowed, then inspect the existing --subpaths binding and golden-fixture tests. Implement the deterministic qualified-name rule from the issue while preserving same-symbol deduplication and collision fallback. Done means shadowed exports are emitted with their original @module and export name, the relevant golden fixtures cover component/function cases, and the simulated blend output compiles with both V2 root bindings and qualified V1 bindings.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
With --subpaths, when a subpath exports a different symbol under a name the main entry already binds, bindgen keeps the main binding and drops the subpath one: it is pushed to skipped as subpath-name-shadowed (src/extract.mjs, the seen.has(name) branch added in #147). The export is reported, but it is unreachable from ReScript: there is no binding for it at all.
That was fine for the #147 case it was written for (clsx's ./lite clsx), but it is now a blocker for a real migration pattern.
Real-world trigger: blend-design-system "V2 by default" (juspay/blend-design-system#1664)
That PR (planned for blend's next stable release) re-points the root names at the V2 components and keeps V1 reachable only through per-component deprecated subpaths:
// main.ts
export { ButtonV2 as Button } from './components/ButtonV2'
// deprecated/button/index.ts → exports map "./deprecated/button"
export * from '../../components/Button' // V1 Button, ButtonType, ButtonSize, …
TS consumers stay on V1 with import { Button } from '@juspay/blend-design-system/deprecated/button' and migrate one component at a time.
I simulated the PR (its main.ts + the 36 deprecated/* subpaths over the 0.0.39-beta.4 dist) and ran bindgen 1.4.0-beta.9 with --subpaths:
- Non-colliding V1 exports are bound to the deprecated subpath, as intended:
DrawerBody…DrawerTrigger,TabsList/Trigger/Content,RadioGroup,SwitchGroup,AccordionItem,addSnackbar,get*Tokens, … - The 36 colliding components (
Button,Modal,TextInput,Tabs,Drawer,Snackbar,Tooltip, …) are allsubpath-name-shadowed:Button.resbinds the root (V2) and no V1Buttonbinding exists.
So ReScript consumers (blend-rescript and everything downstream) get no "stay on V1" route: the next sync forces a big-bang V2 migration across every V1 call site, while TS users get an incremental path.
Proposal
When a subpath export is genuinely shadowed (different symbol, same name), emit it under a subpath-qualified name instead of dropping it. Keep the JS export name and the subpath @module:
// DeprecatedButton.res
@module("@juspay/blend-design-system/deprecated/button")
external make: React.component<props> = "Button"
Naming rule (deterministic, derived only from the subpath + export name)
- Take the subpath suffix's segments (
/deprecated/button→deprecated,button). - Drop any segment that is the export name itself (case and
-/_insensitive):button≡Button,button-group≡ButtonGroup. That avoidsDeprecatedButtonButton. - PascalCase what is left and prefix it:
Deprecated+Button→DeprecatedButton. A lowercase (function/value) export keeps its case:./lite+clsx→liteClsx. - If every segment was dropped (
./buttonexporting a differentButton), use all segments (ButtonButton) rather than give up. - If the qualified name is also taken, fall back to today's behaviour (
subpath-name-shadowedskip, reported), so it never silently overwrites anything.
Types need no special handling: they are deduped by type.id and homed by declaring file, so the V1 prop/enum types (ButtonTypes.*) come back automatically once the V1 component is reachable.
Compatibility
- Purely additive, and only under
--subpaths(off by default). Without--subpathsthe output is byte-identical. With it, everything previously emitted keeps its name. The only change is that formerly dropped exports now appear under new names. - Main-entry bindings always win the bare name, so no existing public module path changes (#190).
- Renames are logged as a note (not a skip), so they stay visible in the run output.
Acceptance
- A shadowed subpath component/function/value is emitted under the qualified name with
@module("pkg/sub")and= "<original export name>". - A same-symbol re-export across subpaths still binds once (no qualified duplicate).
- Qualified-name collision falls back to the existing reported skip.
- Golden fixture covering component and function shadowing, plus the segment-drop rule.
- Verified on the simulated blend PR:
DeprecatedButton,DeprecatedModal, … exist and bind V1, rootButtonbinds V2, and the output compiles.
- Ngôn ngữ chính
- ReScript
- Star
- 11
- Fork
- 0
- Merge trung bình
- 7 giờ 27 phút
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của juspay/rescript-bindgen
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 22/100
juspay/rescript-bindgen#241 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
juspay/rescript-bindgen#164 · 2 bình luận ·
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
juspay/rescript-bindgen#162 ·
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
juspay/rescript-bindgen#160 ·
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
juspay/rescript-bindgen#159 ·
Tất cả issue của juspay/rescript-bindgen
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
c1overzz/dsh-bili-scroll#213 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
conda/governance#490 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
jonathanong/no-mistakes#5441 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 2 ngày