Skip to content

Incorrect source mapping / points to wrong file. #159

@Sandbye

Description

@Sandbye

Reproduction link or steps

Minimal reproduction repo:
Example Repo with problem

This monorepo is based on the template from typescript-monorepo.

This is the tsconfig base: codecompose

Steps to reproduce:

  1. Clone the reproduction repo
  2. Run pnpm install and pnpm build
  3. Open this file packages/core/src/db-refs.ts
  4. Click "Go to Definition" on a property (e.g mutation_count) of variable counter. Line: 14
  5. Observe it navigates to wrong file/location

What is expected?

I expect that the generated maps are correct. And that when i use "Go To Declaration" it takes me to the correct file and line.

What is actually happening?

  1. The index.d.mts.map has sourcesContent as an empty array []
  2. When clicking "Go to Definition" on a type name, it navigates to the correct folder but a random file
  3. When clicking on a property of that type, it navigates to a completely unrelated file and highlights an unrelated property

Note: This worked correctly in tsdown 0.14.2, but that version had issues with the syntax:

export * as types from './types.ts'

The latest version does not have that issue that export syntax but has broken sourcemaps.

Output:

{
  "version": 3,
  "file": "index.d.mts",
  "names": [],
  "sources": [
    "../src/are-we-there-yet.ts",
    "../src/document-types.ts",
    "../src/utils/get-error-message.ts",
    "../src/utils/invariant.ts",
    "../src/utils/is-empty.ts",
    "../src/utils/is-present.ts",
    "../src/utils/unique.ts"
  ],
  "sourcesContent": [],
  "mappings": ";;;;iBACgB,aAAA,CAAA;;;;;;AAAhB;;KCIY,OAAA;;EAAA,UAAO,EAEL,WAAA;;;;;;;;;ADNd;iBEIgB,eAAA;;;iBCLA,SAAA;;;;;;AHChB;iBIGgB,OAAA;;;iBCJA,gBAAgB,4BAA4B;iBAI5C,gBAAgB,qBAAqB;iBAIrC,eAAe,gBAAgB;;;iBCN/B,4CAA4C,IAAC,0CAAA,CAAA,QAAA"
}

Any additional comments?

  • Empty sourcesContent: [] suggests source files aren't being embedded
  • The sources array has correct relative paths
  • The mappings field exists but appears to map to wrong locations

Is there a version between 0.14.2 and 0.18.4 that:

  • Supports export * as types from './types.ts' syntax
  • Generates correct sourcemaps with populated sourcesContent

Or is there a config option to fix the sourcemap generation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions