Skip to content

Commit

Permalink
Pass the maxWorkers config param correctly to Metro
Browse files Browse the repository at this point in the history
Summary:
@public

The React Native CLI is not passing the default `maxWorkers` param to Metro, making it run in a single thread and making the development process really slow.

This fixes facebook/metro#253

Reviewed By: mjesun

Differential Revision: D9915500

fbshipit-source-id: d15030af582e99fe20535c07e751cfe12e444f2f
  • Loading branch information
rafeca authored and facebook-github-bot committed Sep 18, 2018
1 parent 68c7999 commit 7a69f1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
17 changes: 5 additions & 12 deletions local-cli/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ module.exports = {
options: [
{
command: '--port [number]',
default: process.env.RCT_METRO_PORT || 8081,
parse: (val: string) => Number(val),
default: (config: ConfigT) => config.server.port,
},
{
command: '--host [string]',
Expand All @@ -42,18 +42,14 @@ module.exports = {
{
command: '--projectRoot [string]',
description: 'Specify the main project root',
default: (config: ConfigT) => {
return config.projectRoot;
},
default: (config: ConfigT) => config.projectRoot,
},
{
command: '--watchFolders [list]',
description:
'Specify any additional folders to be added to the watch list',
parse: (val: string) => val.split(','),
default: (config: ConfigT) => {
return config.watchFolders;
},
default: (config: ConfigT) => config.watchFolders,
},
{
command: '--assetExts [list]',
Expand Down Expand Up @@ -81,18 +77,15 @@ module.exports = {
description:
'Specify any npm packages that import dependencies with providesModule',
parse: (val: string) => val.split(','),
default: (config: RNConfig) => {
return config.resolver
? config.resolver.providesModuleNodeModules
: undefined;
},
default: (config: ConfigT) => config.resolver.providesModuleNodeModules,
},
{
command: '--max-workers [number]',
description:
'Specifies the maximum number of workers the worker-pool ' +
'will spawn for transforming files. This defaults to the number of the ' +
'cores available on your machine.',
default: (config: ConfigT) => config.maxWorkers,
parse: (workers: string) => Number(workers),
},
{
Expand Down
3 changes: 3 additions & 0 deletions local-cli/util/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ const Config = {
],
getPolyfills,
},
server: {
port: process.env.RCT_METRO_PORT || 8081,
},
transformer: {
babelTransformerPath: require.resolve('metro/src/reactNativeTransformer'),
},
Expand Down

0 comments on commit 7a69f1a

Please sign in to comment.