I have a nodejs app with the following folder structure:
project
|-- src/
| |-- controllers/
| | |`-- authorize-controller.ts
| |`-- index.ts
|--dist/
| |--controllers/
| | |`-- authorize-controller.js
| | |`-- authorize-controller.js.map
| |`-- index.js
| |`-- index.js.map
`-- gulpfile.js
`-- tsconfig.json
The sourcemaps are generated. The index.js.map points to "../src/index.ts" (correct). The corresponding content of the map file is {"version":3,"sources":["../src/index.ts"],"names":[],"mappings"
But the dist\controllers\authorize-controller.js.map points to the wrong directory. It has {"version":3,"sources":["../src/controllers/authentication.controller.ts"],"names":[],
. There is one ../
missing.
My gulpfile.js is:
gulp.task('compile', () => {
var tsResult = tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject());
return tsResult.js
.pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: '/src' }))
.pipe(gulp.dest('dist'));
});
My tsconfig.json is:
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"sourceMap": true,
"outDir": "dist"
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
"dist",
".vscode"
]
}
What am I doing wrong? It seems the sourceRoot is ignored by gulp-sourcemaps.