Skip to content

Commit 2c1f4f3

Browse files
committed
Simplify logic
1 parent c2f2fc7 commit 2c1f4f3

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

node_package/src/loadReactClientManifest.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ export default async function loadReactClientManifest(reactClientManifestFileNam
1010
// Thus, the __dirname of this code is where we can find the manifest file.
1111
const manifestPath = path.resolve(__dirname, reactClientManifestFileName);
1212
const loadedReactClientManifest = loadedReactClientManifests.get(manifestPath);
13-
if (!loadedReactClientManifest) {
14-
// TODO: convert to async
15-
try {
16-
const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8')) as ClientManifest;
17-
loadedReactClientManifests.set(manifestPath, manifest);
18-
return manifest;
19-
} catch (error) {
20-
throw new Error(`Failed to load React client manifest from ${manifestPath}: ${error}`);
21-
}
13+
if (loadedReactClientManifest) {
14+
return loadedReactClientManifest;
2215
}
2316

24-
return loadedReactClientManifest;
17+
try {
18+
const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8')) as ClientManifest;
19+
loadedReactClientManifests.set(manifestPath, manifest);
20+
return manifest;
21+
} catch (error) {
22+
throw new Error(`Failed to load React client manifest from ${manifestPath}: ${error}`);
23+
}
2524
}

0 commit comments

Comments
 (0)