Skip to content
Snippets Groups Projects
Commit 279c0905 authored by Rafael Oleza's avatar Rafael Oleza Committed by Mike Grabowski
Browse files

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
parent 4aec7c95
No related merge requests found
......@@ -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(
......
......@@ -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);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment