Avoid generating source maps for packages with no files.

Chrome has difficulty parsing these (arguably useless) source maps,
anyway. I don't want to speak too soon, but this also seems to help with
This commit is contained in:
Ben Newman
2016-02-27 13:31:53 -05:00
parent 97819a74bb
commit a00e1f51b5

View File

@@ -159,14 +159,14 @@ _.extend(Module.prototype, {
// An array of strings and SourceNode objects.
let chunks = [];
let fileCount = 0;
// Emit each file
if (self.meteorInstallOptions) {
const tree = self._buildModuleTree();
const moduleCount =
self._chunkifyModuleTree(tree, chunks, sourceWidth);
fileCount = self._chunkifyModuleTree(tree, chunks, sourceWidth);
result.exportsName =
self._chunkifyEagerRequires(chunks, moduleCount, sourceWidth);
self._chunkifyEagerRequires(chunks, fileCount, sourceWidth);
} else {
_.each(self.files, function (file) {
@@ -183,6 +183,8 @@ _.extend(Module.prototype, {
sourceWidth: sourceWidth,
noLineNumbers: self.noLineNumbers
}));
++fileCount;
});
}
@@ -191,12 +193,18 @@ _.extend(Module.prototype, {
Profile.time(
'getPrelinkedFiles toStringWithSourceMap',
function () {
const { code, map } = node.toStringWithSourceMap({
file: self.combinedServePath
});
result.source = code;
result.sourceMap = map.toJSON();
if (fileCount > 0) {
var swsm = node.toStringWithSourceMap({
file: self.combinedServePath
});
result.source = swsm.code;
result.sourceMap = swsm.map.toJSON();
} else {
// If there were no files in this bundle, we do not need to
// generate a source map.
result.source = node.toString();
result.sourceMap = null;
}
}
);