Skip to content

Commit

Permalink
Rename test suite and add worker_threads config
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Oct 28, 2019
1 parent 684c8ff commit 6d30574
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export default async function build(dir: string, conf = null): Promise<void> {

const staticCheckWorkers = new Worker(staticCheckWorker, {
numWorkers: config.experimental.cpus,
enableWorkerThreads: config.experimental.cpus > 1,
enableWorkerThreads: config.experimental.workerThreads,
})

const analysisBegin = process.hrtime()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class TaskRunner {
if (this.maxConcurrentWorkers > 1) {
this.workers = new Worker(worker, {
numWorkers: this.maxConcurrentWorkers,
enableWorkerThreads: this.maxConcurrentWorkers > 1,
enableWorkerThreads: true,
})
this.boundWorkers = options => this.workers.default(options)
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default async function(
{
maxRetries: 0,
numWorkers: threads,
enableWorkerThreads: threads > 1,
enableWorkerThreads: nextConfig.experimental.workerThreads,
exposedMethods: ['default'],
}
) as any
Expand Down
1 change: 1 addition & 0 deletions packages/next/next-server/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const defaultConfig: { [key: string]: any } = {
publicDirectory: false,
sprFlushToDisk: true,
deferScripts: false,
workerThreads: true,
},
future: {
excludeDefaultMomentLocales: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,25 @@ const appDir = path.join(__dirname, '..')
const nextConfig = path.join(appDir, 'next.config.js')

describe('Builds with firebase dependency only sequentially', () => {
it('Throws an error when building with firebase dependency in parallel', async () => {
await fs.writeFile(
nextConfig,
`module.exports = { experimental: { cpus: 2 } }`
)
it('Throws an error when building with firebase dependency with worker_threads', async () => {
await fs.remove(nextConfig)
const results = await nextBuild(appDir, [], { stdout: true, stderr: true })
expect(results.stdout + results.stderr).toMatch(/Build error occurred/)
expect(results.stdout + results.stderr).toMatch(
/grpc_node\.node\. Module did not self-register\./
)
await fs.remove(nextConfig)
})

it('Throws no error when building with firebase dependency in sequence', async () => {
it('Throws no error when building with firebase dependency without worker_threads', async () => {
await fs.writeFile(
nextConfig,
`module.exports = { experimental: { cpus: 1 } }`
`module.exports = { experimental: { workerThreads: false } }`
)
const results = await nextBuild(appDir, [], { stdout: true, stderr: true })
await fs.remove(nextConfig)
expect(results.stdout + results.stderr).not.toMatch(/Build error occurred/)
expect(results.stdout + results.stderr).not.toMatch(
/grpc_node\.node\. Module did not self-register\./
)
await fs.remove(nextConfig)
})
})

0 comments on commit 6d30574

Please sign in to comment.