Skip to content

Commit

Permalink
Clean up source map sources with webpack uri, #144
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbarke committed Sep 12, 2017
1 parent ab3299b commit 6082e9e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dist/bundler/source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,15 @@ var SourceMap = (function () {
});
map.addProperty("sourcesContent", sourcesContent_1);
}
this.cleanupSources(map);
bundleItem.source = combineSourceMap.removeComments(bundleItem.source) + map.toComment();
}
};
SourceMap.prototype.cleanupSources = function (map) {
map.sourcemap.sources.forEach(function (source, index) {
map.sourcemap.sources[index] = source.replace("webpack:///", "");
});
};
SourceMap.prototype.getNumberOfNewlines = function (source) {
var newlines = source.match(/\n/g);
return newlines ? newlines.length : 0;
Expand Down
10 changes: 9 additions & 1 deletion src/bundler/source-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class SourceMap {

if (commentMatch && commentMatch[1]) {

let map;
let map: convertSourceMap.SourceMapConverter;
let dirname = path.dirname(bundleItem.filename);

if (!commentMatch[1].startsWith("data:")) {
Expand All @@ -90,10 +90,18 @@ export class SourceMap {
map.addProperty("sourcesContent", sourcesContent);
}

this.cleanupSources(map);

bundleItem.source = combineSourceMap.removeComments(bundleItem.source) + map.toComment();
}
}

private cleanupSources(map: convertSourceMap.SourceMapConverter) {
map.sourcemap.sources.forEach((source: string, index: number) => {
map.sourcemap.sources[index] = source.replace("webpack:///", "");
});
}

private getNumberOfNewlines(source: any) {
let newlines = source.match(/\n/g);
return newlines ? newlines.length : 0;
Expand Down

0 comments on commit 6082e9e

Please sign in to comment.