mirror of https://github.com/status-im/metro.git
Keep the dependencyMaps consistent between runs
Reviewed By: mjesun Differential Revision: D6413998 fbshipit-source-id: fd0ff9a82dcca23603977456b51213216c370f8d
This commit is contained in:
parent
167bda72b0
commit
d46e4ecb6a
|
@ -16,6 +16,7 @@ const DeltaCalculator = require('./DeltaCalculator');
|
||||||
|
|
||||||
const addParamsToDefineCall = require('../lib/addParamsToDefineCall');
|
const addParamsToDefineCall = require('../lib/addParamsToDefineCall');
|
||||||
const createModuleIdFactory = require('../lib/createModuleIdFactory');
|
const createModuleIdFactory = require('../lib/createModuleIdFactory');
|
||||||
|
const nullthrows = require('fbjs/lib/nullthrows');
|
||||||
const removeInlineRequiresBlacklistFromOptions = require('../lib/removeInlineRequiresBlacklistFromOptions');
|
const removeInlineRequiresBlacklistFromOptions = require('../lib/removeInlineRequiresBlacklistFromOptions');
|
||||||
|
|
||||||
const {EventEmitter} = require('events');
|
const {EventEmitter} = require('events');
|
||||||
|
@ -433,6 +434,13 @@ class DeltaTransformer extends EventEmitter {
|
||||||
|
|
||||||
let wrappedCode;
|
let wrappedCode;
|
||||||
|
|
||||||
|
// Get the absolute path of each of the module dependencies from the
|
||||||
|
// dependency edges. The module dependencies ensure correct order, while
|
||||||
|
// the dependency edges do not ensure the same order between rebuilds.
|
||||||
|
const dependencies = metadata.dependencies.map(dependency =>
|
||||||
|
nullthrows(dependencyPairs.get(dependency)),
|
||||||
|
);
|
||||||
|
|
||||||
if (module.isAsset()) {
|
if (module.isAsset()) {
|
||||||
wrappedCode = await this._wrapAsset({
|
wrappedCode = await this._wrapAsset({
|
||||||
code: metadata.code,
|
code: metadata.code,
|
||||||
|
@ -443,7 +451,7 @@ class DeltaTransformer extends EventEmitter {
|
||||||
} else if (!module.isPolyfill()) {
|
} else if (!module.isPolyfill()) {
|
||||||
wrappedCode = this._addDependencyMap({
|
wrappedCode = this._addDependencyMap({
|
||||||
code: metadata.code,
|
code: metadata.code,
|
||||||
dependencyPairs,
|
dependencies,
|
||||||
name,
|
name,
|
||||||
path: module.path,
|
path: module.path,
|
||||||
});
|
});
|
||||||
|
@ -483,20 +491,17 @@ class DeltaTransformer extends EventEmitter {
|
||||||
*/
|
*/
|
||||||
_addDependencyMap({
|
_addDependencyMap({
|
||||||
code,
|
code,
|
||||||
dependencyPairs,
|
dependencies,
|
||||||
name,
|
name,
|
||||||
path,
|
path,
|
||||||
}: {
|
}: {
|
||||||
code: string,
|
code: string,
|
||||||
dependencyPairs: Map<string, string>,
|
dependencies: $ReadOnlyArray<string>,
|
||||||
name: string,
|
name: string,
|
||||||
path: string,
|
path: string,
|
||||||
}): string {
|
}): string {
|
||||||
const moduleId = this._getModuleId(path);
|
const moduleId = this._getModuleId(path);
|
||||||
const params = [
|
const params = [moduleId, dependencies.map(this._getModuleId)];
|
||||||
moduleId,
|
|
||||||
Array.from(dependencyPairs.values()).map(this._getModuleId),
|
|
||||||
];
|
|
||||||
|
|
||||||
// Add the module name as the last parameter (to make it easier to do
|
// Add the module name as the last parameter (to make it easier to do
|
||||||
// requires by name when debugging).
|
// requires by name when debugging).
|
||||||
|
|
Loading…
Reference in New Issue