mirror of https://github.com/status-im/metro.git
packager: GlobalTransformCache: reduce asynchronicity for non-cached bundles
Reviewed By: davidaurelio Differential Revision: D4745595 fbshipit-source-id: 3126fdcc11dd1c8085316457ead0cabae633d0db
This commit is contained in:
parent
112a177399
commit
7357a916c3
|
@ -247,14 +247,15 @@ class GlobalTransformCache {
|
|||
});
|
||||
}
|
||||
|
||||
shouldFetch(props: FetchProps): boolean {
|
||||
return this._profileSet.has(props.transformOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* This may return `null` if either the cache doesn't have a value for that
|
||||
* key yet, or an error happened, processed separately.
|
||||
*/
|
||||
async fetch(props: FetchProps): Promise<?CachedResult> {
|
||||
if (!this._profileSet.has(props.transformOptions)) {
|
||||
return null;
|
||||
}
|
||||
const uri = await this._fetcher.fetch(GlobalTransformCache.keyOf(props));
|
||||
if (uri == null) {
|
||||
return null;
|
||||
|
|
|
@ -303,7 +303,7 @@ class Module {
|
|||
callback: (error: ?Error, result: ?TransformedCode) => void,
|
||||
) {
|
||||
const {_globalCache} = this;
|
||||
if (_globalCache == null) {
|
||||
if (_globalCache == null || !_globalCache.shouldFetch(cacheProps)) {
|
||||
this._transformCodeForCallback(cacheProps, callback);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue