Skip to content

Commit

Permalink
Always include sourcesContent, #144
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbarke committed Aug 25, 2017
1 parent 5c2af03 commit fde750c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
14 changes: 10 additions & 4 deletions dist/bundler/source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,17 @@ var SourceMap = (function () {
};
SourceMap.prototype.loadFileFromComment = function (bundleItem) {
var commentMatch = convertSourceMap.mapFileCommentRegex.exec(bundleItem.source);
if (commentMatch && !commentMatch[1].startsWith("data:")) {
if (commentMatch && commentMatch[1]) {
var map = void 0;
var dirname_1 = path.dirname(bundleItem.filename);
var mapFilename = path.join(dirname_1, commentMatch[1]);
var mapJson = fs.readFileSync(mapFilename, "utf-8");
var map = convertSourceMap.fromJSON(mapJson);
if (!commentMatch[1].startsWith("data:")) {
var mapFilename = path.join(dirname_1, commentMatch[1]);
var mapJson = fs.readFileSync(mapFilename, "utf-8");
map = convertSourceMap.fromJSON(mapJson);
}
else {
map = convertSourceMap.fromComment(commentMatch[0]);
}
if (!map.getProperty("sourcesContent")) {
var sourcesContent_1 = [];
map.getProperty("sources").forEach(function (source) {
Expand Down
17 changes: 13 additions & 4 deletions src/bundler/source-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,20 @@ export class SourceMap {

let commentMatch = convertSourceMap.mapFileCommentRegex.exec(bundleItem.source);

if (commentMatch && !commentMatch[1].startsWith("data:")) {
if (commentMatch && commentMatch[1]) {

let map;
let dirname = path.dirname(bundleItem.filename);
let mapFilename = path.join(dirname, commentMatch[1]);
let mapJson = fs.readFileSync(mapFilename, "utf-8");
let map = convertSourceMap.fromJSON(mapJson);

if (!commentMatch[1].startsWith("data:")) {

let mapFilename = path.join(dirname, commentMatch[1]);
let mapJson = fs.readFileSync(mapFilename, "utf-8");
map = convertSourceMap.fromJSON(mapJson);
}
else {
map = convertSourceMap.fromComment(commentMatch[0]);
}

if (!map.getProperty("sourcesContent")) {

Expand Down

0 comments on commit fde750c

Please sign in to comment.