mirror of
https://github.com/status-im/metro.git
synced 2025-01-31 21:34:53 +00:00
Do not calculate inverseDependencies when processing a standard delta bundle
Reviewed By: mjesun Differential Revision: D6373006 fbshipit-source-id: 86863595b1e5f0417e898f19f21ed83147b46db3
This commit is contained in:
parent
b77f177f92
commit
e58b7f1d73
@ -49,10 +49,6 @@ export type DeltaTransformResponse = {|
|
|||||||
+pre: DeltaEntries,
|
+pre: DeltaEntries,
|
||||||
+post: DeltaEntries,
|
+post: DeltaEntries,
|
||||||
+delta: DeltaEntries,
|
+delta: DeltaEntries,
|
||||||
+inverseDependencies: {
|
|
||||||
[key: string]: $ReadOnlyArray<string>,
|
|
||||||
__proto__: null,
|
|
||||||
},
|
|
||||||
+reset: boolean,
|
+reset: boolean,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
@ -161,6 +157,32 @@ class DeltaTransformer extends EventEmitter {
|
|||||||
return this._getDependencies;
|
return this._getDependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a function that can be used to calculate synchronously the
|
||||||
|
* transitive dependencies of any given file within the dependency graph.
|
||||||
|
**/
|
||||||
|
async getInverseDependencies(): Promise<{
|
||||||
|
[key: string]: $ReadOnlyArray<string>,
|
||||||
|
__proto__: null,
|
||||||
|
}> {
|
||||||
|
if (!this._deltaCalculator.getDependencyEdges().size) {
|
||||||
|
// If by any means the dependency graph has not been initialized, call
|
||||||
|
// getDelta() to initialize it.
|
||||||
|
await this._getDelta();
|
||||||
|
}
|
||||||
|
|
||||||
|
const dependencyEdges = this._deltaCalculator.getDependencyEdges();
|
||||||
|
const output = Object.create(null);
|
||||||
|
|
||||||
|
for (const [path, {inverseDependencies}] of dependencyEdges.entries()) {
|
||||||
|
output[this._getModuleId({path})] = Array.from(
|
||||||
|
inverseDependencies,
|
||||||
|
).map(dep => this._getModuleId({path: dep}));
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
async getRamOptions(
|
async getRamOptions(
|
||||||
entryFile: string,
|
entryFile: string,
|
||||||
options: {dev: boolean, platform: ?string},
|
options: {dev: boolean, platform: ?string},
|
||||||
@ -238,14 +260,10 @@ class DeltaTransformer extends EventEmitter {
|
|||||||
? await this._getAppend(dependencyEdges)
|
? await this._getAppend(dependencyEdges)
|
||||||
: new Map();
|
: new Map();
|
||||||
|
|
||||||
// Inverse dependencies are needed for HMR.
|
|
||||||
const inverseDependencies = this._getInverseDependencies(dependencyEdges);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pre: prependSources,
|
pre: prependSources,
|
||||||
post: appendSources,
|
post: appendSources,
|
||||||
delta: modifiedDelta,
|
delta: modifiedDelta,
|
||||||
inverseDependencies,
|
|
||||||
reset,
|
reset,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -379,23 +397,6 @@ class DeltaTransformer extends EventEmitter {
|
|||||||
return append;
|
return append;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the paths in the inverse dependendencies to module ids.
|
|
||||||
*/
|
|
||||||
_getInverseDependencies(
|
|
||||||
dependencyEdges: DependencyEdges,
|
|
||||||
): {[key: string]: $ReadOnlyArray<string>, __proto__: null} {
|
|
||||||
const output = Object.create(null);
|
|
||||||
|
|
||||||
for (const [path, {inverseDependencies}] of dependencyEdges.entries()) {
|
|
||||||
output[this._getModuleId({path})] = Array.from(
|
|
||||||
inverseDependencies,
|
|
||||||
).map(dep => this._getModuleId({path: dep}));
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
async _transformModules(
|
async _transformModules(
|
||||||
modules: Array<Module>,
|
modules: Array<Module>,
|
||||||
transformOptions: JSTransformerOptions,
|
transformOptions: JSTransformerOptions,
|
||||||
|
@ -140,7 +140,7 @@ class HmrServer<TClient: Client> {
|
|||||||
type: 'update',
|
type: 'update',
|
||||||
body: {
|
body: {
|
||||||
modules,
|
modules,
|
||||||
inverseDependencies: result.inverseDependencies,
|
inverseDependencies: await client.deltaTransformer.getInverseDependencies(),
|
||||||
sourceURLs: {},
|
sourceURLs: {},
|
||||||
sourceMappingURLs: {}, // TODO: handle Source Maps
|
sourceMappingURLs: {}, // TODO: handle Source Maps
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user