Dont build sourcemap if it will not be used

Summary: Don't bother to work on the source map if it won't be used anyways

Reviewed By: mjesun

Differential Revision: D6884247

fbshipit-source-id: 811409313e7ac1a7255ddd0eed665ed92020241e
This commit is contained in:
Peter van der Zee 2018-02-05 00:59:29 -08:00 committed by Facebook Github Bot
parent b1372a37bd
commit 63e8aebf79
1 changed files with 20 additions and 14 deletions

View File

@ -61,21 +61,27 @@ function saveAsIndexedFile(
buildTableAndContents(startupCode, lazyModules, moduleGroups, encoding),
).then(() => log('Done writing unbundle output'));
const sourceMap = relativizeSourceMap(
buildSourceMapWithMetaData({
startupModules: startupModules.concat(),
lazyModules: lazyModules.concat(),
moduleGroups,
fixWrapperOffset: true,
}),
sourcemapSourcesRoot,
);
if (sourcemapOutput) {
const sourceMap = relativizeSourceMap(
buildSourceMapWithMetaData({
startupModules: startupModules.concat(),
lazyModules: lazyModules.concat(),
moduleGroups,
fixWrapperOffset: true,
}),
sourcemapSourcesRoot,
);
return Promise.all([
writeUnbundle,
sourcemapOutput &&
writeSourceMap(sourcemapOutput, JSON.stringify(sourceMap), log),
]);
const wroteSourceMap = writeSourceMap(
sourcemapOutput,
JSON.stringify(sourceMap),
log,
);
return Promise.all([writeUnbundle, wroteSourceMap]);
} else {
return writeUnbundle;
}
}
/* global Buffer: true */