build/bundle: use task return value passthrough

pull/3385/head
Yuxuan Zhang 2 years ago
parent 9195369746
commit 007fa592da
No known key found for this signature in database
GPG Key ID: 6910B04F3351EF7D

@ -143,19 +143,18 @@ export async function bundle(
configFile: config.vite?.configFile configFile: config.vite?.configFile
}) })
let clientResult!: Rollup.RollupOutput | null const serverResult = await task(
let serverResult!: Rollup.RollupOutput 'building server bundle',
() => resolveViteConfig(true).then(build) as Promise<Rollup.RollupOutput>
await task('building client + server bundles', async () => { )
clientResult = config.mpa
? null
: ((await build(await resolveViteConfig(false))) as Rollup.RollupOutput)
serverResult = (await build(
await resolveViteConfig(true)
)) as Rollup.RollupOutput
})
if (config.mpa) { const clientResult = !config.mpa
? await task(
'building client bundle',
() =>
resolveViteConfig(false).then(build) as Promise<Rollup.RollupOutput>
)
: await task('building client bundle (MPA)', async () => {
// in MPA mode, we need to copy over the non-js asset files from the // in MPA mode, we need to copy over the non-js asset files from the
// server build since there is no client-side build. // server build since there is no client-side build.
await Promise.all( await Promise.all(
@ -174,9 +173,11 @@ export async function bundle(
} }
// build <script client> bundle // build <script client> bundle
if (Object.keys(clientJSMap).length) { if (Object.keys(clientJSMap).length) {
clientResult = await buildMPAClient(clientJSMap, config) return buildMPAClient(clientJSMap, config)
} } else {
return null
} }
})
return { clientResult, serverResult, pageToHashMap } return { clientResult, serverResult, pageToHashMap }
} }

Loading…
Cancel
Save