make module IDs deterministic when bundling

Summary:
This makes sure that `getModuleId` is called on modules in the order returned by `node-haste`, rather than waiting for a couple of promises to resolve before calling the function.

Related: #7758

Reviewed By: frantic

Differential Revision: D3450853

fbshipit-source-id: 7f26590b39b94ade32c73a8db9fd31d283d57549
This commit is contained in:
David Aurelio 2016-06-17 12:55:43 -07:00 committed by Facebook Github Bot 6
parent 50d5275fc0
commit 930ef51646
1 changed files with 9 additions and 7 deletions

View File

@ -530,12 +530,14 @@ class Bundler {
_toModuleTransport({module, bundle, entryFilePath, transformOptions, getModuleId}) { _toModuleTransport({module, bundle, entryFilePath, transformOptions, getModuleId}) {
let moduleTransport; let moduleTransport;
const moduleId = getModuleId(module);
if (module.isAsset_DEPRECATED()) { if (module.isAsset_DEPRECATED()) {
moduleTransport = moduleTransport =
this._generateAssetModule_DEPRECATED(bundle, module, getModuleId); this._generateAssetModule_DEPRECATED(bundle, module, moduleId);
} else if (module.isAsset()) { } else if (module.isAsset()) {
moduleTransport = this._generateAssetModule( moduleTransport = this._generateAssetModule(
bundle, module, getModuleId, transformOptions.platform); bundle, module, moduleId, transformOptions.platform);
} }
if (moduleTransport) { if (moduleTransport) {
@ -556,7 +558,7 @@ class Bundler {
return new ModuleTransport({ return new ModuleTransport({
name, name,
id: getModuleId(module), id: moduleId,
code, code,
map, map,
meta: {dependencies, dependencyOffsets, preloaded}, meta: {dependencies, dependencyOffsets, preloaded},
@ -566,7 +568,7 @@ class Bundler {
}); });
} }
_generateAssetModule_DEPRECATED(bundle, module, getModuleId) { _generateAssetModule_DEPRECATED(bundle, module, moduleId) {
return Promise.all([ return Promise.all([
sizeOf(module.path), sizeOf(module.path),
module.getName(), module.getName(),
@ -586,7 +588,7 @@ class Bundler {
return new ModuleTransport({ return new ModuleTransport({
name: id, name: id,
id: getModuleId(module), id: moduleId,
code: code, code: code,
sourceCode: code, sourceCode: code,
sourcePath: module.path, sourcePath: module.path,
@ -645,7 +647,7 @@ class Bundler {
} }
_generateAssetModule(bundle, module, getModuleId, platform = null) { _generateAssetModule(bundle, module, moduleId, platform = null) {
return Promise.all([ return Promise.all([
module.getName(), module.getName(),
this._generateAssetObjAndCode(module, platform), this._generateAssetObjAndCode(module, platform),
@ -653,7 +655,7 @@ class Bundler {
bundle.addAsset(asset); bundle.addAsset(asset);
return new ModuleTransport({ return new ModuleTransport({
name, name,
id: getModuleId(module), id: moduleId,
code, code,
meta: meta, meta: meta,
sourceCode: code, sourceCode: code,