Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[api-extractor] bundledPackages does not work if the package to be bundled has no version field

オープン
#5,730 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
typescript
領域
tooling

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

Summary

When using the bundledPackages option, if the target package has no version field, it is silently not bundled.

Repro steps

  1. Take any existing api-extractor setup in a monorepo.
  2. Remove the version field in the package.json of a local package (say, it’s called "foo"). Example foo/package.json: { "name": "foo" }.
  3. Add bundledPackages: ["foo"] to the api-extractor configuration.
  4. 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).

https://github.com/microsoft/rushstack/blob/4e87cfd81cb47b77b8ab214897e80ad0cfb5a50f/apps/api-extractor/src/analyzer/ExportAnalyzer.ts#L298-L301

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
主要言語
TypeScript
スター
6.5k
フォーク
708
平均マージ
5日 19時間
マージ済み PR(30日)
48

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/rushstack のほかの issue

microsoft/rushstack の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。