Skip to content

Commit

Permalink
packager: GlobalTransformCache: reduce asynchronicity for non-cached …
Browse files Browse the repository at this point in the history
…bundles

Reviewed By: davidaurelio

Differential Revision: D4745595

fbshipit-source-id: 3126fdcc11dd1c8085316457ead0cabae633d0db
  • Loading branch information
Jean Lauliac authored and facebook-github-bot committed Mar 21, 2017
1 parent 4cbb645 commit 439cb76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions packager/src/lib/GlobalTransformCache.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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 * This may return `null` if either the cache doesn't have a value for that
* key yet, or an error happened, processed separately. * key yet, or an error happened, processed separately.
*/ */
async fetch(props: FetchProps): Promise<?CachedResult> { async fetch(props: FetchProps): Promise<?CachedResult> {
if (!this._profileSet.has(props.transformOptions)) {
return null;
}
const uri = await this._fetcher.fetch(GlobalTransformCache.keyOf(props)); const uri = await this._fetcher.fetch(GlobalTransformCache.keyOf(props));
if (uri == null) { if (uri == null) {
return null; return null;
Expand Down
2 changes: 1 addition & 1 deletion packager/src/node-haste/Module.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class Module {
callback: (error: ?Error, result: ?TransformedCode) => void, callback: (error: ?Error, result: ?TransformedCode) => void,
) { ) {
const {_globalCache} = this; const {_globalCache} = this;
if (_globalCache == null) { if (_globalCache == null || !_globalCache.shouldFetch(cacheProps)) {
this._transformCodeForCallback(cacheProps, callback); this._transformCodeForCallback(cacheProps, callback);
return; return;
} }
Expand Down

0 comments on commit 439cb76

Please sign in to comment.