How to generate sourcemap that contains relative 'sources' and 'files', as tsc does?
See original GitHub issueI am building a typescript nodejs project using VSCode.
The gulp code is:
var tsProject = ts.createProject(tsConfigFile);
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
.js
.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''}))
.pipe(gulp.dest('.'));
For files in subdirectories, such as routes/users.ts
, the content of the generated users.js.map
is
{"version":3,"sources":["routes/users.ts"],"names":[], "mappings":"...","file":"routes/users.js","sourceRoot":""}
The breakpoint is not working in VSCode, so I tried to use tsc
to generate the sourcemap. The sourcemap generated by tsc
is
{"version":3,"file":"users.js","sourceRoot":"","sources":["users.ts"],"names":[], "mappings":"..."}
and it works fine in VSCode.
So how to config gulp-sourcemaps to generate the sourcemap as the tsc
does?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Emitting TypeScript Source Maps | Building SPAs - Carl Rippon
Generating source map files We can generate a basic source map using the sourceMap compilation option in tsconfig. json : { "compilerOptions": ......
Read more >Emitting source maps - Learn TypeScript
Generating source map files · Open the index.ts file in the src folder. · Go to the run view in Visual Studio Code...
Read more >How to set up source maps to help debug production JavaScript
These five tips help developers get source maps working in JavaScript so they can spend less time debugging and more time writing software....
Read more >Is there source map support for typescript in node / nodemon?
run npm install source-map-support --save at the root of your node project and add import 'source-map-support/register' to your main.ts or index.ts file.
Read more >TSConfig Reference - Docs on every TSConfig option
"tsc.ts". ] } This is useful when you only have a small number of files and ... Generates a source map for .d.ts...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is what I have and it works with VSCode although the output is not exactly like TSC’s output:
I have a similar issue, although the differences are a little more troubling - if I write out sourcemaps with the following invocation:
.pipe(sourcemaps.write('.')
The sourcemaps have the following at the end:
"sourceRoot":"/source"
How this gets there is baffling to me as no such directory is used anywhere in my compilation steps.