Skip to content

Commit

Permalink
fix: apply sourceRoot to typescript sourcemaps
Browse files Browse the repository at this point in the history
  • Loading branch information
justindujardin committed Dec 8, 2015
1 parent 2dc0657 commit 2d3e971
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion compilers/esm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var traceur = require('traceur');
var path = require('path');

var ParseTreeTransformer = traceur.get('codegeneration/ParseTreeTransformer.js').ParseTreeTransformer;
var ModuleSpecifier = traceur.get('syntax/trees/ParseTrees.js').ModuleSpecifier;
Expand Down Expand Up @@ -165,7 +166,15 @@ exports.compile = function(load, opts, loader) {
};

var transpiled = transpiler.transpileModule(source, transpileOptions);


// Typescript compiler source map has no "sourceRoot" on entries when
// transpiled in this way. Apply the sourceRoot to sourcemap manually.
if (transpiled.sourceMapText) {
var sourceMapObject = JSON.parse(transpiled.sourceMapText);
sourceMapObject.sourceRoot = path.dirname(load.path);
transpiled.sourceMapText = JSON.stringify(sourceMapObject);
}

return Promise.resolve({
source: transpiled.outputText,
sourceMap: transpiled.sourceMapText
Expand Down

0 comments on commit 2d3e971

Please sign in to comment.