-
Notifications
You must be signed in to change notification settings - Fork 26.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable worker_threads by default for firebase compatibility (#9199)
* Pass config.experimental.cpus to export during build Currently, there is no way of specifying the number of worker threads of `next export` when run as part of `next build`. I suggest a sane default should be to just use the same amount of workers that were used during the build process which currently seems to be configured through `config.experimental.cpus`. This setting is already respected in the two other places where jest-workers are in use: The TerserPlugin and the staticCheckWorkers in `next build`. * Only enable worker threads if there is more than 1 worker Multiple worker threads can cause problems when certain dependencies are being used, see e.g. #7894 This patch allows disabling of worker threads by setting `config.experimental.cpus = 1`. The benefit of spawning 1 worker thread, if there is any at all, should very limited anyways, so the workload can just as well be processed in the main thread. * Disable parallel build for firebase authentication example * Add integration test to cover #7894 * Rename test suite and add worker_threads config * Disable worker_threads by default * Update index.test.js * Use workerThreads config for TerserPlugin * Update to use workerThreads config in TerserPlugin for consistency * Disable node 12 specific test
- Loading branch information
Showing
9 changed files
with
50 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import 'firebase/firestore' | ||
export default () => <div>Firebase</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import 'firebase/firestore' | ||
export default () => <div>Firebase</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* eslint-env jest */ | ||
/* global jasmine */ | ||
import path from 'path' | ||
import fs from 'fs-extra' | ||
import { nextBuild } from 'next-test-utils' | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1 | ||
const appDir = path.join(__dirname, '..') | ||
const nextConfig = path.join(appDir, 'next.config.js') | ||
|
||
describe('Building Firebase', () => { | ||
// TODO: investigate re-enabling this test in node 12 environment | ||
xit('Throws an error when building with firebase dependency with worker_threads', async () => { | ||
await fs.writeFile( | ||
nextConfig, | ||
`module.exports = { experimental: { workerThreads: true } }` | ||
) | ||
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\./ | ||
) | ||
}) | ||
|
||
it('Throws no error when building with firebase dependency without worker_threads', async () => { | ||
await fs.remove(nextConfig) | ||
const results = await nextBuild(appDir, [], { stdout: true, stderr: true }) | ||
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\./ | ||
) | ||
}) | ||
}) |