rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[api-extractor] Fails to parse `bundledPackages` declarations from dir import

Open adventure-yunfei opened this issue 3 months ago • 1 comments

Summary

When using bundledPackages options, import declaration from dir generates incorrect dts result.

e.g. configure "bundledPackages": ["foo"], with following foo package files:

  • index.d.ts
    export { Bar } from './bar-dir';
    
  • bar-dir/index.d.ts
    export interface Bar {}
    

and following entry dts file:

export * from "foo";

generates dts result:

import { Bar } from './bar-dir';
export { Bar }

Repro steps

Expected result:

Previous example should generate:

export declare interface Bar {}

or reproduce by: https://github.com/adventure-yunfei/api-extractor-issue--bundledPackages

Details

Debugged and found the reason, introduced by #3321. For import declaration from dir (e.g., import { A } from "./a", while resolved file is a/index.d.ts), TypeScriptInternals.getResolvedModule (in ExportAnalyzer.ts) returns the result without packageId data, thus bundledPackages check is skipped (cause bug here).

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/api-extractor version? 7.53.1
Operating system? Mac
API Extractor scenario? rollups (.d.ts)
Would you consider contributing a PR? No
TypeScript compiler version? 5.8.2
Node.js version (node -v)? v16.20.0

adventure-yunfei avatar Oct 10 '25 07:10 adventure-yunfei

Running into this issue as well

zachmerrill avatar Nov 19 '25 14:11 zachmerrill