Summary
See this repo for a repro of the issue: https://github.com/Josmithr/api-extractor-playground/tree/re-export-module-namespace
The repo contains 2 packages, package-a and package-b.
package-b depends on package-a, and both are configured with API-Extractor.
In this scenario, package-a contains a single root export, which is a "namespace" generated via:
package-a/src/index.ts
import * as A from './NamespaceModule.js';
export { A };
It's type rollup, generated by API-Extractor looks like this:
package-a/dist/rollup.d.ts
declare namespace A {
export { Foo, bar, Baz };
}
export { A };
/** @public */
declare const bar = 5;
/** @public */
declare interface Baz {
value: string;
}
/** @public */
declare class Foo {}
export {};
package-b also contains a single root export, which is simply a re-export of namespace A from package-a.
It is also configured with package-a specified in its bundledPackages.
Its export looks like this:
package-b/src/index.ts
export { A } from 'package-a';
I would expect package-b's type roll-up to look identical to that of package-a, but instead, a malformed rollup is generated:
package-b/dist/rollup.d.ts with bundledPackages
export declare namespace A {
{
Foo, bar, Baz;
}
}
export {};
package-b/dist/rollup.d.ts WITHOUT bundledPackages
import { A } from "package-a";
export { A }
Notice that the necessary imports are missing for Foo, bar, and Baz.
Standard questions
Please answer these questions to help us investigate your issue more quickly:
| Question |
Answer |
@microsoft/api-extractor version? |
7.47.0 |
| Operating system? |
Linux (GitHub Codespace) |
| API Extractor scenario? |
reporting (.api.md) / rollups (.d.ts) / docs (.api.json) |
| Would you consider contributing a PR? |
Yes |
| TypeScript compiler version? |
5.5.2 |
Node.js version (node -v)? |
20.12.1 |
Summary
See this repo for a repro of the issue: https://github.com/Josmithr/api-extractor-playground/tree/re-export-module-namespace
The repo contains 2 packages,
package-aandpackage-b.package-bdepends onpackage-a, and both are configured with API-Extractor.In this scenario,
package-acontains a single root export, which is a "namespace" generated via:package-a/src/index.ts
It's type rollup, generated by API-Extractor looks like this:
package-a/dist/rollup.d.ts
package-balso contains a single root export, which is simply a re-export of namespaceAfrompackage-a.It is also configured with
package-aspecified in itsbundledPackages.Its export looks like this:
package-b/src/index.ts
I would expect
package-b's type roll-up to look identical to that ofpackage-a, but instead, a malformed rollup is generated:package-b/dist/rollup.d.ts with
bundledPackagespackage-b/dist/rollup.d.ts WITHOUT
bundledPackagesNotice that the necessary imports are missing for
Foo,bar, andBaz.Standard questions
Please answer these questions to help us investigate your issue more quickly:
@microsoft/api-extractorversion?node -v)?