Skip to content

Commit c7be9cf

Browse files
authored
Speed up the build even more (#9074)
Caching `getDocsRootNode` improves local build times from 5:19 to 4:39, and also gets rid of a bunch of waiting (the CPU utilization during build according to `time` goes from 74% to 531%). See #9020.
1 parent d71f365 commit c7be9cf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/docTree.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {cache} from 'react';
2+
13
import {type FrontMatter, getDocsFrontMatter} from 'sentry-docs/mdx';
24

35
import {platformsData} from './platformsData';
@@ -21,9 +23,9 @@ function slugWithoutIndex(slug: string): string[] {
2123
return parts;
2224
}
2325

24-
export async function getDocsRootNode(): Promise<DocNode | undefined> {
26+
export const getDocsRootNode = cache(async (): Promise<DocNode | undefined> => {
2527
return frontmatterToTree(await getDocsFrontMatter());
26-
}
28+
});
2729

2830
function frontmatterToTree(frontmatter: FrontMatter[]): DocNode | undefined {
2931
if (frontmatter.length === 0) {

0 commit comments

Comments
 (0)