Dont build sourcemap stuff if it wont be used

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

Reviewed By: rafeca

Differential Revision: D6884244

fbshipit-source-id: ac014bf982e33c669a1e79f16dd06149e758a797
This commit is contained in:
Peter van der Zee 2018-02-05 00:59:33 -08:00 committed by Facebook Github Bot
parent 5e505980ec
commit eb08ed4adc
1 changed files with 19 additions and 14 deletions

View File

@ -66,21 +66,26 @@ function saveAsAssets(
);
writeUnbundle.then(() => log('Done writing unbundle output'));
const sourceMap = buildSourceMapWithMetaData({
fixWrapperOffset: true,
lazyModules: lazyModules.concat(),
moduleGroups: null,
startupModules: startupModules.concat(),
});
if (sourcemapSourcesRoot !== undefined) {
relativizeSourceMapInline(sourceMap, sourcemapSourcesRoot);
}
if (sourcemapOutput) {
const sourceMap = buildSourceMapWithMetaData({
fixWrapperOffset: true,
lazyModules: lazyModules.concat(),
moduleGroups: null,
startupModules: startupModules.concat(),
});
if (sourcemapSourcesRoot !== undefined) {
relativizeSourceMapInline(sourceMap, sourcemapSourcesRoot);
}
const wroteSourceMap = writeSourceMap(
sourcemapOutput,
JSON.stringify(sourceMap),
log,
);
return Promise.all([
writeUnbundle,
sourcemapOutput &&
writeSourceMap(sourcemapOutput, JSON.stringify(sourceMap), log),
]);
return Promise.all([writeUnbundle, wroteSourceMap]);
} else {
return writeUnbundle;
}
}
function createDir(dirName) {