Skip to content

Commit

Permalink
[0.68] fix(cli): fix cache not being used when there are no dependenc…
Browse files Browse the repository at this point in the history
…ies (#9548)

This PR backports #9522 to 0.68.

- Bug fix (non-breaking change which fixes an issue)
This addresses a perf regression in autolinking when there are no dependencies to link.

Resolves #9518

Instead of checking whether the dependencies cache is empty, check whether it was instantiated.

| Before | After |
| -: | -: |
| 22488ms | 3561ms |

Co-authored-by: Tommy Nguyen <4123478+tido64@users.noreply.github.com>
  • Loading branch information
jonthysell and tido64 authored Feb 15, 2022
1 parent 69c33b2 commit 9ce3166
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "[0.68] Fix cache not being used when there are no dependencies",
"packageName": "@react-native-windows/cli",
"email": "4123478+tido64@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,13 @@ export class AutolinkWindows {
}

/** Cache of dependencies */
private readonly windowsDependencies: Record<
string,
WindowsDependencyConfig
> = {};
private windowsDependencies:
| Record<string, WindowsDependencyConfig>
| undefined;

private getWindowsDependencies() {
if (Object.keys(this.windowsDependencies).length === 0) {
if (!this.windowsDependencies) {
this.windowsDependencies = {};
for (const dependencyName of Object.keys(this.dependenciesConfig)) {
const windowsDependency: WindowsDependencyConfig | undefined =
this.dependenciesConfig[dependencyName].platforms.windows;
Expand Down

0 comments on commit 9ce3166

Please sign in to comment.