title: gulp-typescript with gulp-sourcemap: output files to same directory
body: <p>I'm using <code>gulp-typescript</code> and <code>gulp-sourcemaps</code> to compile TypeScript with sourcemaps. I want to output both the <code>.js</code> and the source map files to the same directory as the original <code>.ts</code> file. </p>
  
  <p>I'm using a <code>tsconfig.json</code> file to configure TypeScript, and I'm using <code>typings</code> for managing TypeScript definition files. All of my own code is in the <code>js</code> directory. Here's my project structure:</p>
  
  <pre><code>project root
  |-- js/
  |   |-- subdir/
  |   |   |-- someScript.ts
  |   |-- app.ts
  |-- typings/
  |   |-- someDefinitionFile.d.ts
  |-- gulpfile.js
  |-- tsconfig.json
  </code></pre>
  
  <p>Now I would like <code>app.js</code> to appear in the <code>js</code> directory, and <code>someScript.js</code> to appear in <code>js/subdir</code>. Plus, when debugging in Chrome, I would like to keep the same folder structure in the 'Sources' tab.</p>
  
  <p>I've configured the following gulp task for this:</p>
  
  <pre><code>var gulp = require("gulp");
  var ts = require("gulp-typescript");
  var tsProject = ts.createProject("tsconfig.json");
  var sourcemaps = require('gulp-sourcemaps');
  
  gulp.task("ts", function () {
      var tsResult = tsProject
        .src()
        .pipe(sourcemaps.init())
        .pipe(ts(tsProject)).js
        .pipe(sourcemaps.write("."))
        .pipe(gulp.dest("js"));
  });
  </code></pre>
  
  <p>This effectively outputs the <code>.js</code> files in the correct directories. However, when running this in Chrome and opening Development tools, the <code>.ts</code> files are located in a 'source' directory under the root, meaning the source map files contain an incorrect root.</p>
  
  <p>What should be changed to show the <code>.ts</code> files and the <code>.js</code> files in the same location?</p>
  
  <p>Note: this question is similar to <a href="https://stackoverflow.com/questions/29505055/how-can-i-get-get-gulp-typescript-to-output-to-the-same-directory-as-the-source">this</a> one, except that I want to use <code>tsconfig.json</code>, and thus cannot use <code>gulp.src</code> or its <code>base</code> property.</p>