You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[@rollup/plugin-typescript]: Source-map source paths break if "sourceRoot" is specified #1948
Each path reference inside the source map leads to a source file inside the source root.
Actual Behavior
The paths are invalid if a source root is specified and repeat the path to the source file after the path to the directory containing the source file (see dist/index.js.map inside the stackblitz)
Additional Information
If the sourceRoot option is removed from the compilerOptions, it works as expected.
@CharlieHelps using the reproduction link and the issue description, please do a best-effort triage of this issue and recommend a reasonable fix. If you have questions, please ask them first and provide 1-4 suggested answers in a b c d format. this has come up in issues in this repo in the past and there are commits around this subject, be sure to research and consider those.
Thanks for the ping — I did a best-effort triage and looked at prior related work.
I can reproduce this on master with a local fixture mirroring the report (sourceRoot: "./src"): final map.sources entries get duplicated path segments (examples: .../src/foo/src/foo/foo.ts, .../src/src/index.ts). Removing sourceRoot produces correct paths.
Likely root cause:
packages/typescript/src/outputFile.ts (findTypescriptOutput) currently passes the emitted TS .map through unchanged.
packages/typescript/src/index.ts returns that map directly from load().
With relative sourceRoot, map paths are not rebased for Rollup’s collapse base (dirname(id)), so path segments effectively get re-applied and produce invalid/duplicated sources paths.
Activity
shellscape commentedon Mar 8, 2026
@CharlieHelps using the reproduction link and the issue description, please do a best-effort triage of this issue and recommend a reasonable fix. If you have questions, please ask them first and provide 1-4 suggested answers in
a b c dformat. this has come up in issues in this repo in the past and there are commits around this subject, be sure to research and consider those.charliecreates commentedon Mar 8, 2026
Thanks for the ping — I did a best-effort triage and looked at prior related work.
I can reproduce this on
masterwith a local fixture mirroring the report (sourceRoot: "./src"): finalmap.sourcesentries get duplicated path segments (examples:.../src/foo/src/foo/foo.ts,.../src/src/index.ts). RemovingsourceRootproduces correct paths.Likely root cause:
packages/typescript/src/outputFile.ts(findTypescriptOutput) currently passes the emitted TS.mapthrough unchanged.packages/typescript/src/index.tsreturns that map directly fromload().sourceRoot, map paths are not rebased for Rollup’s collapse base (dirname(id)), so path segments effectively get re-applied and produce invalid/duplicatedsourcespaths.Related history I considered:
src/src-style sourcemap paths)outputFile/indexflow)sourceRootduplication case.Recommended fix:
packages/typescript/src/outputFile.ts, parse and rewrite emitted sourcemaps before returning them:sourceRootinto eachsourcesentry,dirname(id),/) with existing normalization utilities,sourceRootafter folding to avoid downstream double-application,sourceRoot/sourcesentries.sourceRoot: "./src"with nested imports) asserting no duplicated segments in finalmap.sources.If helpful, I can follow up with a PR implementing this approach.