From e9d2575b2681201aa7e2fa7816fc289ab0c51a16 Mon Sep 17 00:00:00 2001 From: Rafael Oleza Date: Wed, 18 Oct 2017 11:56:25 -0700 Subject: [PATCH] Make the module ids deterministic between runs Reviewed By: Hypuk Differential Revision: D6082114 fbshipit-source-id: fd43b64818a1da192c9252a9d2aed918a130517c --- .../metro-bundler/src/DeltaBundler/DeltaTransformer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/metro-bundler/src/DeltaBundler/DeltaTransformer.js b/packages/metro-bundler/src/DeltaBundler/DeltaTransformer.js index 784dfa58..929efb9f 100644 --- a/packages/metro-bundler/src/DeltaBundler/DeltaTransformer.js +++ b/packages/metro-bundler/src/DeltaBundler/DeltaTransformer.js @@ -182,9 +182,14 @@ class DeltaTransformer extends EventEmitter { const transformerOptions = await this._deltaCalculator.getTransformerOptions(); const dependencyEdges = this._deltaCalculator.getDependencyEdges(); + // Precalculate all module ids sequentially. We do this to be sure that the + // mapping between module -> moduleId is deterministic between runs. + const modules = Array.from(modified.values()); + modules.forEach(module => this._getModuleId(module)); + // Get the transformed source code of each modified/added module. const modifiedDelta = await this._transformModules( - Array.from(modified.values()), + modules, transformerOptions, dependencyEdges, );