[api-extractor] bundledPackages does not work if the package to be bundled has no version field
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- typescript
- Ambito
- tooling
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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 |
- Lingua principale
- TypeScript
- Stelle
- 6.5k
- Fork
- 708
- Merge medio
- 4g 7h
- PR unite (30g)
- 61
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/rushstack
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
microsoft/rushstack#5971 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
microsoft/rushstack#5902 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
microsoft/rushstack#5839 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
microsoft/rushstack#5683 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoft/rushstack
Issue simili
-
resources
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
railmapgen/rmg-palette#2445 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
danielmiessler/LifeOS#2242 ·
I maintainer di solito rispondono entro 5 giorni
-
good first issue hacktoberfest help wanted translation
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
callstackincubator/appduct#129 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100