Open Josmithr opened 4 months ago
@octogonz
Question: Why doesn't this:
export declare namespace A {
{
Foo, bar, Baz;
}
}
export {};
...look like this:
export declare namespace A {
export { // πππ
Foo, bar, Baz;
}
}
export {};
Discussed on 9/5/2024: I think this repro can be simplified to eliminate bundledPackages
. My guess is that this construct:
package-x/lib/index.d.ts
declare interface Foo {
x: string;
}
export declare namespace A {
export {
Foo
}
}
export { };
...would not get rolled up correctly. It would forget to include Foo
because the analyzer doesn't understand export { . . . }
inside a namespace
block.
A different way to say that, is that API Extractor cannot roll up a structure that API Extractor itself emits as output.
If that's true, then this issue is unrelated to bundledPackages
, and is really just another syntax we need to support.
This is the hard case to think about:
import * as A from './NamespaceModule.js';
export { A };
import * as B from './NamespaceModule.js';
export { B };
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
andpackage-b
.package-b
depends onpackage-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
It's type rollup, generated by API-Extractor looks like this:
package-a/dist/rollup.d.ts
package-b
also contains a single root export, which is simply a re-export of namespaceA
frompackage-a
. It is also configured withpackage-a
specified 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
bundledPackages
package-b/dist/rollup.d.ts WITHOUT
bundledPackages
Notice 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-extractor
version?node -v
)?