Skip to content

tsdown fail to bundle d.ts #238

@ryanelian

Description

@ryanelian

Reproduction link or steps

https://stackblitz.com/edit/github-9x4fstux?file=dist%2Findex.d.ts

This reproduction contains a minimal library that exports several functions.

The functions are created using another library cva and tailwind-merge that is listed as devDependencies

The intent of this is library so that the consumer of the library do not need to worry about cva or tailwind-merge dependencies versioning that they have in their own projects, as the resulting library is standalone.

When pnpm build is run, the JS output is correct ✅ because the libraries in devDependencies is bundled.

Image

This is aligned with the behavior of the tsdown as documented:

Image

However, the .d.ts output fails to bundle the types for the internal dependencies, despite configured like the documentation:

Image Image Image

As the library is intended to be shipped without the cva dependencies, that means the resulting .d.ts is incorrect.

What is expected?

Run dtsroll that is installed in the reproduction.

❯ pnpm dtsroll
dtsroll

📥 Entry points in package.json
 → dist/index.d.ts from types

💠 Bundled output
 ● dist/index.d.ts 2.8 kB
    ├─ dist/index.d.ts
    └─ cva (node_modules/.pnpm/cva@1.0.0-beta.3_typescri

The resulting .d.ts is now bundled with type definitions from cva or other internal libraries, enabling consumers of the library to use the library without installing the internal dependencies.

Image

What is actually happening?

The dts:resolve settings do not seem to be respected by tsdown

Image

Any additional comments?

Thank you for making this wonderful project!

I wish tsdown can leverage or collaborate with dtsroll to enable the production of even better TypeScript libraries with zero config.

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