Skip to content

enabling declaration maps force-enables source maps #360

Description

@altano

Reproduction link or steps

https://stackblitz.com/edit/github-axjtgnyh

What is expected?

I would expect that if I enabled declaration maps (either from the tsdown config or the tsconfig), I would get declaration maps. I would expect that source maps would stay disabled. E.g.:

tsdown.config

{
  sourcemap: false,
  dts: {
    sourcemap: true,
  },
}

What is actually happening?

  1. Enabling declaration maps also implicitly enables source maps.
  2. Explicitly DISABLING source maps still doesn't disable them.

Any additional comments?

Declaration maps and source maps serve different purposes. TS lets you enable one and not the other (or both) for that reason, so I would expect tsdown to do the same. The toggle should be independent.

If tsdown can't support that for whatever reason, that's fine, that isn't the end of the world, but this problem should be more discoverable. It took me a really long time to binary chop the problem and discover that I was getting source maps because my shared tsconfig had "declarationMap": true.

Thank you in advance for taking a look at this bug!

Activity

  1. added theissue type on Jul 1, 2025
  2. sxzzbot commented on Nov 2, 2026

    @sxzzbot
    Collaborator

    Thanks for the report, and sorry it took so long to track down. This is a real limitation, but it can't be fixed properly in tsdown or rolldown-plugin-dts right now.

    output.sourcemap applies to the whole output in Rolldown, and Rolldown has no per-chunk source map control. To generate declaration maps, rolldown-plugin-dts has to turn it on for the entire output, so JS source maps are generated as well.

    We looked at removing the JS maps afterwards in generateBundle (sxzz/rolldown-plugin-dts#334), but decided against it. It can delete .map files emitted by other plugins, drop JS maps that were explicitly requested in multi-output builds, and strip maps enabled by later plugins. That's a worse failure than an extra .js.map.

    We're treating this as a feature request: independent declaration maps need per-chunk source map support in Rolldown.

    For now, there are two workarounds:

    • If you don't need declaration maps, set dts: { sourcemap: false } or disable declarationMap in your tsconfig.
    • If you need declaration maps but don't want to publish JS maps, exclude them from the package, for example with "!dist/**/*.{js,mjs}.map" in files. The sourceMappingURL comment will stay in the JS files.
  3. changed the issue type fromtoon Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Fields

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions