Skip to content

Tsdown doesn't bundle types for trpc server and some other popular libs #303

@Zombobot1

Description

@Zombobot1

Reproduction link or steps

I have an issue in my monorepo where i want to build types for a trpc router. In the resulting .d.ts file i end up with import * as _trpc_server_unstable_core_do_not_import1 from "@trpc/server/unstable-core-do-not-import";

I tried to reproduce the error in smaller example and i get import * as _trpc_server0 from "@trpc/server"; in the final bundle. I tried different options but i couldn't properly bundle the types. In my monorepo this issue persists with other popular packages (eg pg). it refuses to bundle them. I think this is a bug.

I created a repo which shows the issue with the bundled index.d.ts file.

https://github.com/Zombobot1/tsdown-trcp-repro

What is expected?

with

export default defineConfig({
  dts: { resolve: true, emitDtsOnly: true },
})

tsdown bundles types for external deps so the library doesn't require installation of additional deps.

What is actually happening?

it doesn't bundle types from "@trpc/server" and imports from them instead.

import * as _trpc_server_unstable_core_do_not_import0 from "@trpc/server/unstable-core-do-not-import";
import * as _trpc_server1 from "@trpc/server";

Any additional comments?

Some other deps are bundled correctly in my monorepo (eg hono and drizzle) but others don't

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