gulp-typescript icon indicating copy to clipboard operation
gulp-typescript copied to clipboard

Sourcemaps are not generated correctly when using gulp-header plugin.

Open frenchu opened this issue 7 years ago • 0 comments

Expected behavior:

Sourcemaps are generated properly even if intermediate plugins are used.

Actual behavior:

When I use gulp-header plugin in the gulp pipe, sourcemaps are generated but it is not possible to put breakpoints in the right place in the source code while debugging in Chrome Dev Tools. When I disable gulp-header plugin sourcemaps are generated correctly. As stated in gulp-header plugin documentation it supports sourcemaps, I've also made tests and it looks like it works fine. Moreover, I've tried to use other similar plugins to gulp-header, which support sourcemaps and the issue persists.

gulpfile:

var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var header = require('gulp-header');
var ts = require('gulp-typescript');
var tsProject = ts.createProject('tsconfig.json');

gulp.task('default', function () {
    return tsProject.src()
        .pipe(sourcemaps.init())
        .pipe(header('//Hello <%= name %>\n\n', { name: 'frenchu' }))
        .pipe(tsProject())
        .pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: '..' }))
        .pipe(gulp.dest('dist'));
});

tsconfig.json:

{
  "files": [
    "src/app.ts",
    "src/path/to/module/greet.ts"
  ],
  "compilerOptions": {
    "module": "amd",
    "outFile": "module.js",
    "noImplicitAny": true,
    "target": "es5"
  }
}

Code:

Sample project where you can replicate the issue is here: github.com/frenchu/sourcemaps-issue

Remarks:

The reason of this issue may be similar to #576.

frenchu avatar Oct 24 '18 13:10 frenchu