Skip to content

Commit 7a69f1a

Browse files
rafecafacebook-github-bot
authored andcommittedSep 18, 2018
Pass the maxWorkers config param correctly to Metro
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
1 parent 68c7999 commit 7a69f1a

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed
 

‎local-cli/server/server.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ module.exports = {
3232
options: [
3333
{
3434
command: '--port [number]',
35-
default: process.env.RCT_METRO_PORT || 8081,
3635
parse: (val: string) => Number(val),
36+
default: (config: ConfigT) => config.server.port,
3737
},
3838
{
3939
command: '--host [string]',
@@ -42,18 +42,14 @@ module.exports = {
4242
{
4343
command: '--projectRoot [string]',
4444
description: 'Specify the main project root',
45-
default: (config: ConfigT) => {
46-
return config.projectRoot;
47-
},
45+
default: (config: ConfigT) => config.projectRoot,
4846
},
4947
{
5048
command: '--watchFolders [list]',
5149
description:
5250
'Specify any additional folders to be added to the watch list',
5351
parse: (val: string) => val.split(','),
54-
default: (config: ConfigT) => {
55-
return config.watchFolders;
56-
},
52+
default: (config: ConfigT) => config.watchFolders,
5753
},
5854
{
5955
command: '--assetExts [list]',
@@ -81,18 +77,15 @@ module.exports = {
8177
description:
8278
'Specify any npm packages that import dependencies with providesModule',
8379
parse: (val: string) => val.split(','),
84-
default: (config: RNConfig) => {
85-
return config.resolver
86-
? config.resolver.providesModuleNodeModules
87-
: undefined;
88-
},
80+
default: (config: ConfigT) => config.resolver.providesModuleNodeModules,
8981
},
9082
{
9183
command: '--max-workers [number]',
9284
description:
9385
'Specifies the maximum number of workers the worker-pool ' +
9486
'will spawn for transforming files. This defaults to the number of the ' +
9587
'cores available on your machine.',
88+
default: (config: ConfigT) => config.maxWorkers,
9689
parse: (workers: string) => Number(workers),
9790
},
9891
{

‎local-cli/util/Config.js

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ const Config = {
7676
],
7777
getPolyfills,
7878
},
79+
server: {
80+
port: process.env.RCT_METRO_PORT || 8081,
81+
},
7982
transformer: {
8083
babelTransformerPath: require.resolve('metro/src/reactNativeTransformer'),
8184
},

0 commit comments

Comments
 (0)