[api-extractor] bundledPackages does not work if the package to be bundled has no version field
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- typescript
- Área
- tooling
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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 |
- Lenguaje dominante
- TypeScript
- Estrellas
- 6.5k
- Forks
- 708
- Merge medio
- 2 d 1 h
- PR fusionados (30 d)
- 46
Preparar el entorno
Aún no hemos revisado los archivos de configuración de este proyecto. Empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/rushstack
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
microsoft/rushstack#5971 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
microsoft/rushstack#5902 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microsoft/rushstack#5839 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
microsoft/rushstack#5683 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/rushstack
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
📕documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
db-ux-design-system/core-web#8343 ·
Los mantenedores suelen responder en 1 día
-
enhancement triage/needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
heygen-com/hyperframes#4944 ·
Los mantenedores suelen responder en 1 día
-
Pressing Escape to close the time dropdown in the event form asks to discard the whole eventAbiertoai-driven-qa bug claude
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
linagora/twake-calendar-frontend#1493 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
material-extensions/vscode-material-icon-theme#3610 ·
Los mantenedores suelen responder en 2 días