rushstack
rushstack copied to clipboard
[api-extractor] dts can not rollup when `mainEntryPointFilePath` in `node_modules` folder
Summary
When using dtsRollup feature, I found that it is unable to bundle types from mainEntryPointFilePath in node_modules folder.
Repro steps
https://github.com/Timeless0911/api-extractor-issue-node-modules-entry
Run pnpm gen-types to repro this issue.
Expected result:
If I configure mainEntryPointFilePath to "<projectFolder>/dist/index.d.ts",, the dts bundle in untrimmedFilePath is:
// dist-types/index.d.ts
export declare const num1 = 1;
export declare const num2 = 2;
export declare const num3 = 3;
export declare const numSum: number;
export declare const str1 = "str1";
export declare const str2 = "str2";
export declare const str3 = "str3";
export declare const strSum: string;
export { }
Actual result:
In repro demo, I copy the
distfolder generated bytsctonode_modules/.temp
When mainEntryPointFilePath set to "mainEntryPointFilePath": "<projectFolder>/node_modules/.temp/index.d.ts",, the dts bundle in untrimmedFilePath is:
// dist-types/index.d.ts
export * from "./sum";
export * from "./utils/numbers";
export * from "./utils/strings";
export { }
Details
I want to use the dtsRollup feature to bundle the dts files emitted by tsc, so I need to put them in a temporary folder of node_modules to avoid publishing them to npm.
I do not want to put them directly in temp folder in projectFolder since most build tools like swc and webpack all generate temp files in node_modules folder.
Standard questions
Please answer these questions to help us investigate your issue more quickly:
| Question | Answer |
|---|---|
@microsoft/api-extractor version? |
7.48.1 |
| Operating system? | Mac |
| API Extractor scenario? | rollups (.d.ts) |
| Would you consider contributing a PR? | No |
| TypeScript compiler version? | 5.7.2 |
Node.js version (node -v)? |
22.10.0 |