Skip to content

unbundle output files lack the type declaration #533

@fengmk2

Description

@fengmk2

Reproduction link or steps

https://stackblitz.com/github/fengmk2/tsdown-vs-tsc?file=README.md

Reproduce Build Output

npm run build

What is expected?

The tsdown + unbundle build output should import './types.js'

// dist-unbundle/index.d.ts

import './types.js';

//#region src/index.d.ts
declare function main(): void;
//#endregion
export { main };

What is actually happening?

Missing the import './types.js'

// dist-unbundle/index.d.ts

//#region src/index.d.ts
declare function main(): void;
//#endregion
export { main };

Any additional comments?

When building a project using tsdown + unbundle, the output files lack the type declaration file import './types.ts', whereas building with tsc will generate the type declaration files.

tsdown + bundle build output:

  • Input: src/index.ts and dependencies
  • Output: dist-bundle/index.js and dist-bundle/index.d.ts

tsdown + unbundle build output:

  • Input: src/index.ts and dependencies
  • Output: dist-unbundle/index.js and dist-unbundle/index.d.ts

tsc build output:

  • Input: src/index.ts and dependencies
  • Output: dist-tsc/index.js and dist-tsc/index.d.ts

The tsdown + unbundle build output is missing the types import './types.ts'.

// dist-unbundle/index.d.ts

//#region src/index.d.ts
declare function main(): void;
//#endregion
export { main };
// dist-tsc/index.d.ts

import './types.ts';
export declare function main(): void;
// dist-bundle/index.d.ts

import "./types-_8Ni1WEK.js";

//#region src/index.d.ts
declare function main(): void;
//#endregion
export { main };

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions