diff --git a/packages/metro/src/commands/build.js b/packages/metro/src/commands/build.js index 6de007a6..bd0c6e0f 100644 --- a/packages/metro/src/commands/build.js +++ b/packages/metro/src/commands/build.js @@ -15,8 +15,6 @@ const MetroApi = require('..'); const TerminalReporter = require('../lib/TerminalReporter'); -const os = require('os'); - const {makeAsyncCommand} = require('../cli-utils'); const {Terminal} = require('metro-core'); @@ -35,11 +33,7 @@ exports.builder = (yargs: Yargs) => { yargs.option('platform', {alias: 'p', type: 'string'}); yargs.option('output-type', {alias: 't', type: 'string'}); - yargs.option('max-workers', { - alias: 'j', - type: 'number', - default: Math.max(1, Math.floor(os.cpus().length)), - }); + yargs.option('max-workers', {alias: 'j', type: 'number'}); yargs.option('optimize', {alias: 'z', type: 'boolean'}); yargs.option('dev', {alias: 'g', type: 'boolean'}); diff --git a/packages/metro/src/commands/serve.js b/packages/metro/src/commands/serve.js index 7f9e6cb4..92a61569 100644 --- a/packages/metro/src/commands/serve.js +++ b/packages/metro/src/commands/serve.js @@ -14,8 +14,6 @@ const MetroApi = require('..'); -const os = require('os'); - const {watchFile, makeAsyncCommand} = require('../cli-utils'); const {promisify} = require('util'); @@ -33,11 +31,7 @@ exports.builder = (yargs: Yargs) => { yargs.option('host', {alias: 'h', type: 'string', default: 'localhost'}); yargs.option('port', {alias: 'p', type: 'number', default: 8080}); - yargs.option('max-workers', { - alias: 'j', - type: 'number', - default: Math.max(1, Math.floor(os.cpus().length)), - }); + yargs.option('max-workers', {alias: 'j', type: 'number'}); yargs.option('secure', {type: 'boolean'}); yargs.option('secure-key', {type: 'string'}); diff --git a/packages/metro/src/index.js b/packages/metro/src/index.js index 89d5e698..d6499b7e 100644 --- a/packages/metro/src/index.js +++ b/packages/metro/src/index.js @@ -22,6 +22,7 @@ const TransformCaching = require('./lib/TransformCaching'); const attachWebsocketServer = require('./lib/attachWebsocketServer'); const defaults = require('./defaults'); const fs = require('fs'); +const getMaxWorkers = require('./lib/getMaxWorkers'); const http = require('http'); const https = require('https'); const path = require('path'); @@ -78,7 +79,7 @@ async function asyncRealpath(path): Promise { async function runMetro({ config, resetCache = false, - maxWorkers = 1, + maxWorkers = getMaxWorkers(), // $FlowFixMe TODO t0 https://github.com/facebook/flow/issues/183 port = null, reporter = new TerminalReporter(new Terminal(process.stdout)),