Skip to content

Commit

Permalink
Make config object read-only
Browse files Browse the repository at this point in the history
Summary: This makes the Metro config type readonly, only a couple of things inside Metro needed to be tweaked :)

Reviewed By: mjesun

Differential Revision: D10028083

fbshipit-source-id: 15f5d957a8ee7384d6156c973639d86240fd251f
  • Loading branch information
rafeca authored and facebook-github-bot committed Sep 26, 2018
1 parent 4052816 commit 2c10570
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions local-cli/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,16 @@ async function getCliConfig(): Promise<RNConfig> {
cliArgs.config != null ? path.resolve(__dirname, cliArgs.config) : null,
);

// $FlowFixMe Metro configuration is immutable.
config.transformer.assetRegistryPath = ASSET_REGISTRY_PATH;
// $FlowFixMe Metro configuration is immutable.
config.resolver.hasteImplModulePath =
config.resolver.hasteImplModulePath || defaultConfig.hasteImplModulePath;
// $FlowFixMe Metro configuration is immutable.
config.resolver.platforms = config.resolver.platforms
? config.resolver.platforms.concat(defaultConfig.getPlatforms())
: defaultConfig.getPlatforms();
// $FlowFixMe Metro configuration is immutable.
config.resolver.providesModuleNodeModules = config.resolver
.providesModuleNodeModules
? config.resolver.providesModuleNodeModules.concat(
Expand Down
7 changes: 7 additions & 0 deletions local-cli/server/runServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,19 @@ async function runServer(args: Args, config: ConfigT) {

args.watchFolders.forEach(middlewareManager.serveStatic);

// $FlowFixMe Metro configuration is immutable.
config.maxWorkers = args.maxWorkers;
// $FlowFixMe Metro configuration is immutable.
config.server.port = args.port;
// $FlowFixMe Metro configuration is immutable.
config.reporter = reporter;
// $FlowFixMe Metro configuration is immutable.
config.resetCache = args.resetCache;
// $FlowFixMe Metro configuration is immutable.
config.projectRoot = args.projectRoot;
// $FlowFixMe Metro configuration is immutable.
config.watchFolders = args.watchFolders.slice(0);
// $FlowFixMe Metro configuration is immutable.
config.server.enhanceMiddleware = middleware =>
middlewareManager.getConnectInstance().use(middleware);

Expand Down

0 comments on commit 2c10570

Please sign in to comment.