Skip to content

Commit

Permalink
~fix doubled files in source map
Browse files Browse the repository at this point in the history
  • Loading branch information
timofei-iatsenko committed Aug 29, 2016
1 parent 57f2ad6 commit 4fd77f7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ function mergeSourceMaps(inputSourceMap, annotateMap) {
// See also vinyl-sourcemaps-apply (used by gulp-ng-annotate) - https://github.com/floridoo/vinyl-sourcemaps-apply/blob/master/index.js
if (sourceMapEnabled && inputSourceMap) {
if (annotateMap) {
// it is important that sources in inputSourceMap be the same as sources in annotateMap,
// in case when using loaders (babel, tsloader, eslint) filenames in sources will be prefixed with loader executable filename.
// we should remove prefix and leave only filename
for(var i = 0; i < inputSourceMap.sources.length; i++) {
var chunks = inputSourceMap.sources[i].split('!');
inputSourceMap.sources[i] = chunks[chunks.length - 1];
}

var generator = SourceMapGenerator.fromSourceMap(new SourceMapConsumer(annotateMap));
generator.applySourceMap(new SourceMapConsumer(inputSourceMap), filename);

Expand Down

0 comments on commit 4fd77f7

Please sign in to comment.