Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,28 +203,30 @@ module.exports = function (params) {

if (result.map.mappings && result.map.mappings.length > 0) {
var resultMap = new SourceMapConsumer(result.map);
resultMap.eachMapping(function (mapping) {
if (!mapping.source) return;

map.addMapping({
generated: {
line: mapping.generatedLine + currentLine - 1,
column: mapping.generatedColumn + (leadingWhitespace ? leadingWhitespace.length : 0)
},
original: {
line: mapping.originalLine,
column: mapping.originalColumn
},
source: mapping.source,
name: mapping.name
resultMap.then(consumer => {
consumer.eachMapping(function (mapping) {
if (!mapping.source) return;

map.addMapping({
generated: {
line: mapping.generatedLine + currentLine - 1,
column: mapping.generatedColumn + (leadingWhitespace ? leadingWhitespace.length : 0)
},
original: {
line: mapping.originalLine,
column: mapping.originalColumn
},
source: mapping.source,
name: mapping.name
});
});
});

if (result.map.sourcesContent) {
result.map.sourcesContent.forEach(function (sourceContent, i) {
map.setSourceContent(result.map.sources[i], sourceContent);
});
}
if (map.sourcesContent) {
map.sourcesContent.forEach(function (sourceContent, i) {
map.setSourceContent(map.sources[i], sourceContent);
});
}
});
}
} else { // result was a simple file, map whole file to new location
for (var q = 0; q < lines; q++) {
Expand Down Expand Up @@ -331,4 +333,4 @@ module.exports = function (params) {
}

return es.map(include)
};
};