From 930ef516467c7bb88bfa29205a71ec812fb2c7f5 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Fri, 17 Jun 2016 12:55:43 -0700 Subject: [PATCH] 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 --- react-packager/src/Bundler/index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/react-packager/src/Bundler/index.js b/react-packager/src/Bundler/index.js index d2053fa1..8ee861d2 100644 --- a/react-packager/src/Bundler/index.js +++ b/react-packager/src/Bundler/index.js @@ -530,12 +530,14 @@ class Bundler { _toModuleTransport({module, bundle, entryFilePath, transformOptions, getModuleId}) { let moduleTransport; + const moduleId = getModuleId(module); + if (module.isAsset_DEPRECATED()) { moduleTransport = - this._generateAssetModule_DEPRECATED(bundle, module, getModuleId); + this._generateAssetModule_DEPRECATED(bundle, module, moduleId); } else if (module.isAsset()) { moduleTransport = this._generateAssetModule( - bundle, module, getModuleId, transformOptions.platform); + bundle, module, moduleId, transformOptions.platform); } if (moduleTransport) { @@ -556,7 +558,7 @@ class Bundler { return new ModuleTransport({ name, - id: getModuleId(module), + id: moduleId, code, map, meta: {dependencies, dependencyOffsets, preloaded}, @@ -566,7 +568,7 @@ class Bundler { }); } - _generateAssetModule_DEPRECATED(bundle, module, getModuleId) { + _generateAssetModule_DEPRECATED(bundle, module, moduleId) { return Promise.all([ sizeOf(module.path), module.getName(), @@ -586,7 +588,7 @@ class Bundler { return new ModuleTransport({ name: id, - id: getModuleId(module), + id: moduleId, code: code, sourceCode: code, sourcePath: module.path, @@ -645,7 +647,7 @@ class Bundler { } - _generateAssetModule(bundle, module, getModuleId, platform = null) { + _generateAssetModule(bundle, module, moduleId, platform = null) { return Promise.all([ module.getName(), this._generateAssetObjAndCode(module, platform), @@ -653,7 +655,7 @@ class Bundler { bundle.addAsset(asset); return new ModuleTransport({ name, - id: getModuleId(module), + id: moduleId, code, meta: meta, sourceCode: code,