Design review: per-project export-condition selection (PR #4351) — single-package motivation, Node-divergence semantics, alternatives
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/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ệ
- node.js, typescript
- Lĩnh vực
- build-system
Hướng nghiên cứu
Read PR #4351 and issue #3566 first, then compare scriptc’s package export and imports resolution with Node’s condition ordering. Survey packages beyond rxjs and write down the proposed divergence rule, interactions with existing scriptc conditions, and failure behavior for missing targets. Done means the design questions in the issue have explicit decisions and a measurable win condition.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
PR #4351 proposes a new project-level setting, scriptc.packages.<name>.conditions, letting a project name the export condition scriptc compiles for a package. Architectural concerns before considering the implementation:
1. Single motivating package. The evidence base is one package: rxjs 7, whose root export map is { types, node: dist/cjs, require: dist/cjs, es2015: dist/esm, default: dist/esm5 }. Every motivation in the PR is rxjs-specific. There is no survey of how many published packages have the shape (ESM-preferred condition shadowed by an earlier node/require key) that actually break scriptc resolution today, and no explanation of why the existing scriptc condition (added in #3566) cannot be contributed upstream or shimmed via package overrides.
2. New config surface for a resolution-policy change. Today scriptc mirrors Node's resolution semantics: it selects the same file Node selects. The PR changes that default: when the setting is present, scriptc compiles a condition Node would not pick (es2015 over node). That is a semantic divergence between "what scriptc builds" and "what runs under Node" — precisely the divergence the compiler otherwise refuses (Node.js decides behavior; a compiled program must do what Node does). It needs a written position on when divergence is acceptable, how declaration types vs. compiled runtime stay consistent, and what happens when the chosen condition's build differs behaviorally from the CJS build Node loads (esm5 vs esm vs cjs are materially different artifacts).
3. Alternatives not evaluated.
- Extend the existing
scriptccondition mechanism (#3566): a package can already publishscriptcin its export map; why is per-package condition aliasing in project config preferable to documenting/automating thescriptckey (e.g. a patch/override step)? - Reuse Node's own
--conditions: rejected in the PR becausenodeprecedeses2015in key order, but a pnpm/patch-package override of the map, or upstream fix to the package, achieves the same without new config. imports-map indirection or an explicit per-package override file (like TypeScript'spaths) rather than a new condition-aliasing rule.
4. Spec-level questions. Interaction with imports conditions is mentioned but the semantics of aliasing inside imports (where node ordering matters differently) are not specified. Also unspecified: precedence when a package both publishes scriptc and the project names conditions, error behavior for unknown conditions at the far end (e.g. a package whose es2015 target directory does not exist), and Windows/path cases.
Proposal
Before merging #4351, decide the design:
- Either scope this to "packages that publish no compatible ESM condition" with documented criteria, or generalize it into a full package-override mechanism with one semantic story.
- Write the rule for when scriptc may resolve differently from Node, and what guarantees the compiled program still matches Node's runtime behavior (or document explicitly that it does not, and what the dual-run reporter should then do).
- Add a survey of real packages (beyond rxjs) whose resolution scriptc gets wrong today, with and without the feature, so the feature has a measurable win condition.
- Specify
importsinteraction, precedence with an existingscriptckey, and failure modes for missing targets.
- Ngôn ngữ chính
- TypeScript
- Star
- 6.7k
- Fork
- 229
- Merge trung bình
- 14 giờ 29 phút
- Pull request đã merge (30 ngày)
- 787
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
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 vercel-labs/scriptc
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
vercel-labs/scriptc#4865 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
vercel-labs/scriptc#4864 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows ARM64 as a cross-compile targetCó thể đã có người làm @hum-n đã nhận 1 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
vercel-labs/scriptc#4858 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
post-merge-bisect-unresolved
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 43/100
vercel-labs/scriptc#4791 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
post-merge-bisect-unconfirmed
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
vercel-labs/scriptc#4755 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của vercel-labs/scriptc
Issue tương tự
-
bug data-types
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
ClickHouse/clickhouse-js#1293 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: middleware enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
agent/quality testing
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/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 92/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
juspay/agent-distro#203 ·
Maintainer thường phản hồi trong vòng 1 ngày