Skip to content

Commit 32d65d4

Browse files
authored
perf: fix race conditions with cache (#2579)
1 parent faab56f commit 32d65d4

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/node/build/build.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ export async function build(
5656
) as OutputChunk)
5757

5858
const cssChunk = (
59-
siteConfig.mpa ? serverResult : clientResult
59+
siteConfig.mpa ? serverResult : clientResult!
6060
).output.find(
6161
(chunk) => chunk.type === 'asset' && chunk.fileName.endsWith('.css')
6262
) as OutputAsset
6363

64-
const assets = (siteConfig.mpa ? serverResult : clientResult).output
64+
const assets = (siteConfig.mpa ? serverResult : clientResult!).output
6565
.filter(
6666
(chunk) => chunk.type === 'asset' && !chunk.fileName.endsWith('.css')
6767
)

src/node/build/bundle.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export async function bundle(
3131
config: SiteConfig,
3232
options: BuildOptions
3333
): Promise<{
34-
clientResult: RollupOutput
34+
clientResult: RollupOutput | null
3535
serverResult: RollupOutput
3636
pageToHashMap: Record<string, string>
3737
}> {
@@ -142,16 +142,16 @@ export async function bundle(
142142
}
143143
})
144144

145-
let clientResult: RollupOutput
145+
let clientResult: RollupOutput | null
146146
let serverResult: RollupOutput
147147

148148
const spinner = ora()
149149
spinner.start('building client + server bundles...')
150150
try {
151-
;[clientResult, serverResult] = await (Promise.all([
152-
config.mpa ? null : build(await resolveViteConfig(false)),
153-
build(await resolveViteConfig(true))
154-
]) as Promise<[RollupOutput, RollupOutput]>)
151+
clientResult = config.mpa
152+
? null
153+
: ((await build(await resolveViteConfig(false))) as RollupOutput)
154+
serverResult = (await build(await resolveViteConfig(true))) as RollupOutput
155155
} catch (e) {
156156
spinner.stopAndPersist({
157157
symbol: failMark

src/node/build/render.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export async function renderPage(
2424
config: SiteConfig,
2525
page: string, // foo.md
2626
result: RollupOutput | null,
27-
appChunk: OutputChunk | undefined,
28-
cssChunk: OutputAsset | undefined,
27+
appChunk: OutputChunk | null,
28+
cssChunk: OutputAsset | null,
2929
assets: string[],
3030
pageToHashMap: Record<string, string>,
3131
hashMapString: string,

0 commit comments

Comments
 (0)