Skip to content

[Bug]: @rolldown/browser missing binding type declarations #8929

@nyan-left

Description

@nyan-left

Reproduction link or steps

https://github.com/nyan-left/rolldown-browser-repro

CI failure: https://github.com/nyan-left/rolldown-browser-repro/actions/runs/23632405151/job/68834536336

Install @rolldown/browser in a TypeScript project with moduleResolution: "bundler" and run tsc --noEmit. The repro has the minimal setup and a CI workflow that shows the failure.

What is expected?

@rolldown/browser type declarations work with moduleResolution: "bundler" - same as the main rolldown package.

What is actually happening?

9 TS2307 errors. The .d.mts files in @rolldown/browser reference binding.cjs as an external module, but no corresponding type declaration file exists in the published package.

Cannot find module '../binding.cjs' or its corresponding type declarations.
Cannot find module '../../binding.cjs' or its corresponding type declarations.
Cannot find module './binding.cjs' or its corresponding type declarations.

The main rolldown package doesn't have this issue because its DTS output bundles the binding types inline into dist/shared/binding-[hash].d.mts. The browser package doesn't because resolveWasiBinding() in build.ts marks binding.cjs as external: 'relative' for all importers - including the .d.ts files generated by rolldown-plugin-dts. The dts resolver sees external: true and passes it through without bundling the types.

System Info

TypeScript: 5.9.3
@rolldown/browser: 1.0.0-rc.12
@types/node: 24.10.3
Node: 22
pnpm: 9

Any additional comments?

Here is a proposed solution: #8930

Metadata

Metadata

Assignees

No one assigned

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions