Skip to content

[api-extractor] Inconsistent rollups behaviour between moduleResolution #5106

@Lukinoh

Description

@Lukinoh

Summary

In my project, I have libraries that generate types using vite-plugin-dts which uses underneath api-extractor.
When I migrated the tsconfig.json from moduleResolution: node to moduleResolution: bundler I realised that the output .d.ts was not identical.

Repro steps

The following repository is configured to use the api-extractor on the same code, but with 3 different moduleResolution: node, node16 and bundler.`

  • git clone [email protected]:Lukinoh/repro-api-extractor-bug (Stackblitz)
  • cd repro-api-extractor-bug
  • npm install
  • npm run build
  • Look at the dist folders, it contains for each moduleResolution:
    • The result of the tsc build
    • The extracted .d.ts
    • The diagnostics

The extracted .d.ts of node16 and bundler are different from node.
I would have expected to have the content.

Expected result:

declare class ClassExample {
    field1: number;
    field2: string;
}

export declare const functions: ClassExample[];

export { }

Actual result:

import { ClassExample } from './hop/f1.ts';

export declare const functions: ClassExample[];

export { }

Standard questions

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

Question Answer
@microsoft/api-extractor version? 7.49.2
Operating system? Linux (WSL2)
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.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions