Skip to content

Commit b27f30d

Browse files
committed
fix: changes from review
1 parent 7184379 commit b27f30d

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/lib/helpers/copyDynamicImportChunks.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,30 @@ const copyDynamicImportChunks = async (functionPath) => {
1212
const filesWP4 = readdirSync(chunksPathWebpack4)
1313
const chunkRegexWP4 = new RegExp(/^(\.?[-$~\w]+)+\.js$/g)
1414
const excludeFiles = new Set(['init-server.js.js', 'on-error-server.js.js'])
15+
const copyPathWP4 = join(functionPath, 'nextPage')
16+
if (filesWP4.length !== 0) {
17+
logTitle('💼 Copying WP4 dynamic import chunks to', copyPathWP4)
18+
}
1519
filesWP4.forEach((file) => {
1620
if (!excludeFiles.has(file) && chunkRegexWP4.test(file)) {
17-
// WP4 files are looked for one level up (../) in runtime
18-
// This is a hack to make the file one level up i.e. with
19-
// nextPage/nextPage/index.js, the chunk is moved to the inner nextPage
20-
const copyPath = join(functionPath, 'nextPage')
21-
// logTitle('💼 Copying WP4 dynamic import chunks to', copyPath)
22-
copySync(join(chunksPathWebpack4, file), join(copyPath, file), {
21+
copySync(join(chunksPathWebpack4, file), join(copyPathWP4, file), {
2322
overwrite: false,
2423
errorOnExist: true,
2524
})
2625
}
2726
})
27+
28+
// Chunks are copied into the nextPage directory, as a sibling to "pages" or "api".
29+
// This matches the Next output, so that imports work correctly
2830
const chunksPathWebpack5 = join(nextDistDir, 'serverless', 'chunks')
2931
const filesWP5 = existsSync(chunksPathWebpack5) ? readdirSync(chunksPathWebpack5) : []
32+
const copyPathWP5 = join(functionPath, 'nextPage', 'chunks')
33+
if (filesWP5.length !== 0) {
34+
logTitle('💼 Copying WB5 dynamic import chunks to', copyPathWP5)
35+
}
36+
3037
filesWP5.forEach((file) => {
31-
// Chunks are copied into the nextPage directory, as a sibling to pages or api.
32-
// This matches the Next output, so that imports work correctly
33-
const copyPath = join(functionPath, 'nextPage', 'chunks')
34-
// logTitle('💼 Copying WB5 dynamic import chunks to', copyPath)
35-
copySync(join(chunksPathWebpack5, file), join(copyPath, file), {
38+
copySync(join(chunksPathWebpack5, file), join(copyPathWP5, file), {
3639
overwrite: false,
3740
errorOnExist: true,
3841
})

src/lib/helpers/runJobsQueue.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ const fastq = require('fastq')
44

55
const { processPage } = require('../pages/worker')
66

7+
// TODO: benchmark a large site to find a good value for this
8+
const PAGE_CONCURRENCY = 4
9+
710
const runJobsQueue = (jobs) => {
811
console.log(`Building ${jobs.length} pages`)
912

10-
const queue = fastq.promise(processPage, 4)
13+
const queue = fastq.promise(processPage, PAGE_CONCURRENCY)
1114

1215
return Promise.all(jobs.map((job) => queue.push(job)))
1316
}

0 commit comments

Comments
 (0)