Remove .meta files generation from metro

Reviewed By: davidaurelio

Differential Revision: D7347623

fbshipit-source-id: 29c8b79771566178ea8f720a93bd73df678c7807
This commit is contained in:
Rafael Oleza 2018-04-10 09:23:41 -07:00 committed by Facebook Github Bot
parent b05f9692e7
commit c35f1a2c01
1 changed files with 15 additions and 19 deletions

View File

@ -12,7 +12,6 @@
const Server = require('../../Server');
const meta = require('./meta');
const relativizeSourceMapInline = require('../../lib/relativizeSourceMap');
const writeFile = require('./writeFile');
@ -39,7 +38,7 @@ function relativateSerializedMap(
return JSON.stringify(sourceMap);
}
function saveBundleAndMap(
async function saveBundleAndMap(
bundle: {code: string, map: string},
options: OutputOptions,
log: (...args: Array<string>) => void,
@ -51,18 +50,13 @@ function saveBundleAndMap(
sourcemapSourcesRoot,
} = options;
log('Writing bundle output to:', bundleOutput);
const writeFns = [];
const {code} = bundle;
const writeBundle = writeFile(bundleOutput, code, encoding);
const writeMetadata = writeFile(
bundleOutput + '.meta',
meta(code, encoding),
'binary',
);
Promise.all([writeBundle, writeMetadata]).then(() =>
log('Done writing bundle output'),
);
writeFns.push(async () => {
log('Writing bundle output to:', bundleOutput);
await writeFile(bundleOutput, bundle.code, encoding);
log('Done writing bundle output');
});
if (sourcemapOutput) {
let {map} = bundle;
@ -72,13 +66,15 @@ function saveBundleAndMap(
log('finished relativating');
}
writeFns.push(async () => {
log('Writing sourcemap output to:', sourcemapOutput);
const writeMap = writeFile(sourcemapOutput, map, null);
writeMap.then(() => log('Done writing sourcemap output'));
return Promise.all([writeBundle, writeMetadata, writeMap]);
} else {
return writeBundle;
await writeFile(sourcemapOutput, map, null);
log('Done writing sourcemap output');
});
}
// Wait until everything is written to disk.
await Promise.all(writeFns.map(cb => cb()));
}
exports.build = buildBundle;