[api-extractor] bundledPackages does not work if the package to be bundled has no version field
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- typescript
- Lĩnh vực
- tooling
Hướng nghiên cứu
Start at apps/api-extractor/src/analyzer/ExportAnalyzer.ts around lines 298-301 and reproduce the bundledPackages scenario with a local package whose package.json lacks version. Trace how the optional packageId is handled, then add coverage for the missing-version case; done means the behavior is explicit rather than silently leaving the package unbundled.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
When using the bundledPackages option, if the target package has no version field, it is silently not bundled.
Repro steps
- Take any existing api-extractor setup in a monorepo.
- Remove the version field in the package.json of a local package (say, it’s called "foo"). Example foo/package.json:
{ "name": "foo" }. - Add
bundledPackages: ["foo"]to the api-extractor configuration. - Run the api-extractor.
Expected result: there are no instances of from "foo" in the output.
Actual result: there are instances of from "foo" in the output.
Details
The root of the issue is we depend on the TypeScript’s packageId field to get the name of a resolved module to match that name against the bundlePackages option configuration. But TypeScript does not generate a packageId field if a package is missing a name or version field (TypeScript issue).
It’s not obvious how to get the module name without TypeScript’s help, so the root fix is probably upstream. That said, api-extractor does silently produce a highly unexpected result, primarily due to the casual use of the optional chaining operator.
Perhaps a strict crash is something we should have instead:
if (!resolvedModule.packageId) throw new InternalError("Compiler did not generate the packageId");
Given that we know the scenario, we could even suggest a remedy:
if (!resolvedModule.packageId) throw Error('Compiler did not generate the packageId. This is most likely a package you have has no version field. Try to add `version: ""` field for all your packages. https://github.com/microsoft/TypeScript/issues/63307');
Standard questions
| Question | Answer |
|---|---|
@microsoft/api-extractor version? |
7.57.7 |
| Operating system? | Mac |
| API Extractor scenario? | rollups (.d.ts) |
| Would you consider contributing a PR? | Yes |
| TypeScript compiler version? | 5.9.3 |
Node.js version (node -v)? |
22.22.0 |
- Ngôn ngữ chính
- TypeScript
- Star
- 6.5k
- Fork
- 708
- Merge trung bình
- 5 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 48
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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 microsoft/rushstack
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Tất cả issue của microsoft/rushstack
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
mksglu/context-mode#1200 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
anthropics/claude-code#96687 ·
-
good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
AOSSIE-Org/DebateAI#582 · 2 bình luận ·