From 218cab5e88b37a53a89863266a52ffd3bed5cbc1 Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Wed, 17 May 2017 04:55:59 -0700 Subject: [PATCH] packager: runServer: @flow Summary: This makes it easier to verify correctness when adding new config/args. Reviewed By: davidaurelio Differential Revision: D5069537 fbshipit-source-id: 4d8058851900b23163d0f2744e91dd14dfcdd461 --- packages/metro-bundler/react-packager.js | 2 +- packages/metro-bundler/src/Bundler/index.js | 6 +++--- packages/metro-bundler/src/Resolver/index.js | 2 +- packages/metro-bundler/src/Server/index.js | 6 +++--- packages/metro-bundler/src/node-haste/DependencyGraph.js | 2 +- packages/metro-bundler/src/node-haste/ModuleCache.js | 4 ++-- packages/metro-bundler/src/node-haste/lib/toLocalPath.js | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/metro-bundler/react-packager.js b/packages/metro-bundler/react-packager.js index 457a877f..7d7ab760 100644 --- a/packages/metro-bundler/react-packager.js +++ b/packages/metro-bundler/react-packager.js @@ -31,7 +31,7 @@ type Options = { nonPersistent?: boolean, postProcessModules?: PostProcessModules, postMinifyProcess?: PostMinifyProcess, - projectRoots: Array, + projectRoots: $ReadOnlyArray, reporter?: Reporter, +sourceExts: ?Array, +transformModulePath: string, diff --git a/packages/metro-bundler/src/Bundler/index.js b/packages/metro-bundler/src/Bundler/index.js index da622d9c..d5da5d7c 100644 --- a/packages/metro-bundler/src/Bundler/index.js +++ b/packages/metro-bundler/src/Bundler/index.js @@ -128,7 +128,7 @@ type Options = {| +polyfillModuleNames: Array, +postProcessModules?: PostProcessModules, +postMinifyProcess: PostMinifyProcess, - +projectRoots: Array, + +projectRoots: $ReadOnlyArray, +providesModuleNodeModules?: Array, +reporter: Reporter, +resetCache: boolean, @@ -146,7 +146,7 @@ class Bundler { _getModuleId: (opts: Module) => number; _transformer: Transformer; _resolverPromise: Promise; - _projectRoots: Array; + _projectRoots: $ReadOnlyArray; _assetServer: AssetServer; _getTransformOptions: void | GetTransformOptions; @@ -785,7 +785,7 @@ class Bundler { hot: boolean, minify: boolean, platform: ?string, - projectRoots: Array, + projectRoots: $ReadOnlyArray, |}, ): Promise { const getDependencies = (entryFile: string) => diff --git a/packages/metro-bundler/src/Resolver/index.js b/packages/metro-bundler/src/Resolver/index.js index c3dbe177..1713a42e 100644 --- a/packages/metro-bundler/src/Resolver/index.js +++ b/packages/metro-bundler/src/Resolver/index.js @@ -42,7 +42,7 @@ type Options = {| +postMinifyProcess: PostMinifyProcess, +platforms: Set, +polyfillModuleNames?: Array, - +projectRoots: Array, + +projectRoots: $ReadOnlyArray, +providesModuleNodeModules: Array, +reporter: Reporter, +resetCache: boolean, diff --git a/packages/metro-bundler/src/Server/index.js b/packages/metro-bundler/src/Server/index.js index e2d13126..f9dcf6e6 100644 --- a/packages/metro-bundler/src/Server/index.js +++ b/packages/metro-bundler/src/Server/index.js @@ -69,7 +69,7 @@ type Options = { polyfillModuleNames?: Array, postProcessModules?: PostProcessModules, postMinifyProcess: PostMinifyProcess, - projectRoots: Array, + projectRoots: $ReadOnlyArray, providesModuleNodeModules?: Array, reporter: Reporter, resetCache?: boolean, @@ -125,7 +125,7 @@ class Server { polyfillModuleNames: Array, postProcessModules?: PostProcessModules, postMinifyProcess: PostMinifyProcess, - projectRoots: Array, + projectRoots: $ReadOnlyArray, providesModuleNodeModules?: Array, reporter: Reporter, resetCache: boolean, @@ -135,7 +135,7 @@ class Server { transformTimeoutInterval: ?number, watch: boolean, }; - _projectRoots: Array; + _projectRoots: $ReadOnlyArray; _bundles: {}; _changeWatchers: Array<{ req: IncomingMessage, diff --git a/packages/metro-bundler/src/node-haste/DependencyGraph.js b/packages/metro-bundler/src/node-haste/DependencyGraph.js index 9eecbd8c..7516bc8f 100644 --- a/packages/metro-bundler/src/node-haste/DependencyGraph.js +++ b/packages/metro-bundler/src/node-haste/DependencyGraph.js @@ -60,7 +60,7 @@ type Options = {| +providesModuleNodeModules: Array, +reporter: Reporter, +resetCache: boolean, - +roots: Array, + +roots: $ReadOnlyArray, +sourceExts: Array, +transformCode: TransformCode, +useWatchman: boolean, diff --git a/packages/metro-bundler/src/node-haste/ModuleCache.js b/packages/metro-bundler/src/node-haste/ModuleCache.js index c1f0a2d3..bdc7c1b3 100644 --- a/packages/metro-bundler/src/node-haste/ModuleCache.js +++ b/packages/metro-bundler/src/node-haste/ModuleCache.js @@ -41,7 +41,7 @@ class ModuleCache { _platforms: Set; _transformCode: TransformCode; _reporter: Reporter; - _roots: Array; + _roots: $ReadOnlyArray; constructor( { @@ -62,7 +62,7 @@ class ModuleCache { getTransformCacheKey: GetTransformCacheKey, globalTransformCache: ?GlobalTransformCache, moduleOptions: ModuleOptions, - roots: Array, + roots: $ReadOnlyArray, reporter: Reporter, transformCode: TransformCode, |}, diff --git a/packages/metro-bundler/src/node-haste/lib/toLocalPath.js b/packages/metro-bundler/src/node-haste/lib/toLocalPath.js index dbdb2037..2b8ed331 100644 --- a/packages/metro-bundler/src/node-haste/lib/toLocalPath.js +++ b/packages/metro-bundler/src/node-haste/lib/toLocalPath.js @@ -18,7 +18,7 @@ export type LocalPath = OpaqueLocalPath & string; // FIXME: This function has the shortcoming of potentially returning identical // paths for two files in different roots. -function toLocalPath(roots: Array, absolutePath: string): LocalPath { +function toLocalPath(roots: $ReadOnlyArray, absolutePath: string): LocalPath { for (let i = 0; i < roots.length; i++) { const localPath = relative(roots[i], absolutePath); if (localPath[0] !== '.') {