Skip to content

Commit

Permalink
perf: parallelize mpa chunks copy (#2389)
Browse files Browse the repository at this point in the history
  • Loading branch information
zonemeen committed May 27, 2023
1 parent 0e96217 commit 6d7d195
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/node/build/bundle.ts
Expand Up @@ -165,13 +165,15 @@ export async function bundle(
if (config.mpa) {
// in MPA mode, we need to copy over the non-js asset files from the
// server build since there is no client-side build.
for (const chunk of serverResult.output) {
if (!chunk.fileName.endsWith('.js')) {
const tempPath = path.resolve(config.tempDir, chunk.fileName)
const outPath = path.resolve(config.outDir, chunk.fileName)
await fs.copy(tempPath, outPath)
}
}
await Promise.all(
serverResult.output.map(async (chunk) => {
if (!chunk.fileName.endsWith('.js')) {
const tempPath = path.resolve(config.tempDir, chunk.fileName)
const outPath = path.resolve(config.outDir, chunk.fileName)
await fs.copy(tempPath, outPath)
}
})
)
// also copy over public dir
const publicDir = path.resolve(config.srcDir, 'public')
if (fs.existsSync(publicDir)) {
Expand Down

0 comments on commit 6d7d195

Please sign in to comment.