Input source maps #26843
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Suggestion
Support input source maps, for the case where a TS file is generated programatically from some other source file, in order to permit end-to-end mapping.
Such source maps could either be specified in the
.ts
file using the//# SourceMappingURL=foo.ts.map
notation, searched for under the name*.ts.map
, or found in-line in the.ts
sources, etc., depending on various options.The effect would be that the
*.js.map
file generated (or inlined) would be the equivalent of what is known as "applying" the input source map to the tsc-generated sourcemap. In other words, the sourcemap would map lines in the*.js
file all the way back to the original file(s) from which the*.ts
file was generated.Use Cases
This issue has come up in the context of some literate programming hacking I am doing. The programmer works on "literate programming documents" (actually, a flavor of Markdown), and then "tangles" (to use Knuth's terminology) that into a TS file.
My tangler generates the
*.ts.map
file. Currently, what I am doing is to provide an extra utility which the programmer can use to "apply" the map I create to the one created bytsc
to get lines in the*.js
all the way back to the literate programming document. However, this is a bit clumsy, and requires some setup. It would be nicer iftsc
could take in source maps, apply them itself, and output*.js.map
files reflecting that mapping.Examples
Currently, the user does something like the following:
("modernlit" is the name I am currently using for my literate programming system.)
With the feature I am proposing, the call to
mlsourcemap
could be eliminated.tsc
would findfoo.ts.map
, and perform the mapping, generating afoo.js.map
which reflected it having been "applied" to the JS-to-TS sourcemap. This would avoid the user having to remember to callmlsourcemap
, and avoid me having to write it, maintain, and document it.For information on "applying" (remapping) sourcemaps, as implemented in the Mozilla source-maps library, see here.
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: