ivogabe / gulp-typescript

A TypeScript compiler for gulp with incremental compilation support.
MIT License
831 stars 129 forks source link

Sourcemaps: Nothing written to outDir #599

Closed lukewis closed 5 years ago

lukewis commented 5 years ago

This likely isn't a bug. Probably just incorrect configuration on my part, but I've been stuck for days and my config looks like the examples I've found. Hoping someone is kind enough to point me in the right direction. The problem occurs when I uncomment the sourcemap lines. If I leave these lines commented, the js files are generated correctly (but obviously no map files).

Expected behavior: Javascript and sourcemaps are written to outDir

Actual behavior: Nothing is written to outDir (no *.js files, no .map files, nothing)

Your gulpfile:

var tsProject = ts.createProject("./tsconfig.json");

let build = () => {
  return tsProject.src()
    //.pipe(sourcemaps.init().on('error', gutil.log))
    .pipe(tsProject()).js
    //.pipe(sourcemaps.write(".").on('error', gutil.log))
    .pipe(gulp.dest(tsProject.config.compilerOptions.outDir));
}
gulp.task('build', () => build());

tsconfig.json

Include your tsconfig, if related to this issue.

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "lib": [
      "es2015",
      "dom"
    ],
    "jsx": "react",
    "sourceMap": true,
    "outDir": "./build",
    "rootDir": "./",
    "strict": true,
    "esModuleInterop": true
  },
  "include": [
    "./src"
  ]
}
samjudge commented 5 years ago

Weird, I copied your configuration and ran your gulp build task and it worked totally fine for me

[09:41:35] Using gulpfile ~/my-project-dir/gulpfile.js [09:41:35] Starting 'build'... [09:41:38] Finished 'build' after 3.61 s

I can also confirm that this also generates the sourcemap files for me

Could you please share your package.json? I was able to build with the following devDependancies

"gulp": "^3.9.1", "gulp-sourcemaps": "^2.6.4", "gulp-typescript": "^5.0.0-alpha.3", "gutil": "^1.6.4", "typescript": "^3.1.6"

lukewis commented 5 years ago

@samjudge Thanks so much for taking a look! I went back trying to find the repository where I had this issue but found that I had since switched to using tsify instead of gulp-typescript (I should have created a sample repo specifically for this issue). If I circle back to gulp-typescript in the future (I'm having a different set of sourcemap issues with tsify) and can reproduce this again I'll create a sample repo and then re-open an issue. Thanks again for helping and so sorry for wasting your time!