From 2c1057062e81f8b43d3f942a35371fb3db841bed Mon Sep 17 00:00:00 2001 From: Rafael Oleza Date: Wed, 26 Sep 2018 16:45:44 -0700 Subject: [PATCH] Make config object read-only 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 --- local-cli/core/index.js | 4 ++++ local-cli/server/runServer.js | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/local-cli/core/index.js b/local-cli/core/index.js index dfe66b372d96a8..6bfdd8cd550e9e 100644 --- a/local-cli/core/index.js +++ b/local-cli/core/index.js @@ -131,12 +131,16 @@ async function getCliConfig(): Promise { 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( diff --git a/local-cli/server/runServer.js b/local-cli/server/runServer.js index b3859eb0a4b128..e393a8a61241b0 100644 --- a/local-cli/server/runServer.js +++ b/local-cli/server/runServer.js @@ -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);