packager: stronger option types

Reviewed By: davidaurelio

Differential Revision: D4868612

fbshipit-source-id: 50d72ce56d8e3ef0d917ee5bbe3dd42faf075584
This commit is contained in:
Jean Lauliac 2017-04-12 04:24:47 -07:00 committed by Facebook Github Bot
parent deebf15a56
commit 3c85a6b902
4 changed files with 69 additions and 72 deletions

View File

@ -89,27 +89,26 @@ const assetPropertyBlacklist = new Set([
'path',
]);
type Options = {
allowBundleUpdates: boolean,
assetExts: Array<string>,
assetServer: AssetServer,
blacklistRE?: RegExp,
cacheVersion: string,
extraNodeModules: {},
getTransformOptions?: GetTransformOptions,
globalTransformCache: ?GlobalTransformCache,
hasteImpl?: HasteImpl,
moduleFormat: string,
platforms: Array<string>,
polyfillModuleNames: Array<string>,
projectRoots: Array<string>,
providesModuleNodeModules?: Array<string>,
reporter: Reporter,
resetCache: boolean,
transformModulePath?: string,
transformTimeoutInterval: ?number,
watch: boolean,
};
type Options = {|
+allowBundleUpdates: boolean,
+assetExts: Array<string>,
+assetServer: AssetServer,
+blacklistRE?: RegExp,
+cacheVersion: string,
+extraNodeModules: {},
+getTransformOptions?: GetTransformOptions,
+globalTransformCache: ?GlobalTransformCache,
+hasteImpl?: HasteImpl,
+platforms: Array<string>,
+polyfillModuleNames: Array<string>,
+projectRoots: Array<string>,
+providesModuleNodeModules?: Array<string>,
+reporter: Reporter,
+resetCache: boolean,
+transformModulePath?: string,
+transformTimeoutInterval: ?number,
+watch: boolean,
|};
class Bundler {
@ -190,7 +189,6 @@ class Bundler {
hasteImpl: opts.hasteImpl,
maxWorkerCount,
minifyCode: this._transformer.minify,
moduleFormat: opts.moduleFormat,
platforms: new Set(opts.platforms),
polyfillModuleNames: opts.polyfillModuleNames,
projectRoots: opts.projectRoots,

View File

@ -29,25 +29,25 @@ import type {GlobalTransformCache} from '../lib/GlobalTransformCache';
type MinifyCode = (filePath: string, code: string, map: SourceMap) =>
Promise<{code: string, map: SourceMap}>;
type Options = {
assetExts: Array<string>,
blacklistRE?: RegExp,
cache: Cache,
extraNodeModules: ?{},
getTransformCacheKey: GetTransformCacheKey,
globalTransformCache: ?GlobalTransformCache,
hasteImpl?: HasteImpl,
maxWorkerCount: number,
minifyCode: MinifyCode,
platforms: Set<string>,
polyfillModuleNames?: Array<string>,
projectRoots: Array<string>,
providesModuleNodeModules: Array<string>,
reporter: Reporter,
resetCache: boolean,
transformCode: TransformCode,
watch: boolean,
};
type Options = {|
+assetExts: Array<string>,
+blacklistRE?: RegExp,
+cache: Cache,
+extraNodeModules: ?{},
+getTransformCacheKey: GetTransformCacheKey,
+globalTransformCache: ?GlobalTransformCache,
+hasteImpl?: HasteImpl,
+maxWorkerCount: number,
+minifyCode: MinifyCode,
+platforms: Set<string>,
+polyfillModuleNames?: Array<string>,
+projectRoots: Array<string>,
+providesModuleNodeModules: Array<string>,
+reporter: Reporter,
+resetCache: boolean,
+transformCode: TransformCode,
+watch: boolean,
|};
class Resolver {
@ -70,7 +70,6 @@ class Resolver {
return filepath.indexOf('__tests__') !== -1 ||
(opts.blacklistRE != null && opts.blacklistRE.test(filepath));
},
maxWorkers: null,
moduleOptions: {
cacheTransformResults: true,
hasteImpl: opts.hasteImpl,

View File

@ -21,8 +21,8 @@ class DependencyGraphHelpers {
_assetExts: Array<string>;
constructor({providesModuleNodeModules, assetExts}: {
providesModuleNodeModules: Array<string>,
assetExts: Array<string>,
+providesModuleNodeModules: Array<string>,
+assetExts: Array<string>,
}) {
this._providesModuleNodeModules = providesModuleNodeModules;
this._assetExts = assetExts;

View File

@ -49,28 +49,28 @@ import type {
} from './Module';
import type {HasteFS} from './types';
type Options = {
assetDependencies: Array<string>,
assetExts: Array<string>,
cache: Cache,
extensions: Array<string>,
extraNodeModules: ?{},
forceNodeFilesystemAPI: boolean,
getTransformCacheKey: GetTransformCacheKey,
globalTransformCache: ?GlobalTransformCache,
ignoreFilePath: (filePath: string) => boolean,
maxWorkerCount: number,
moduleOptions: ModuleOptions,
platforms: Set<string>,
preferNativePlatform: boolean,
providesModuleNodeModules: Array<string>,
reporter: Reporter,
resetCache: boolean,
roots: Array<string>,
transformCode: TransformCode,
useWatchman: boolean,
watch: boolean,
};
type Options = {|
+assetDependencies: Array<string>,
+assetExts: Array<string>,
+cache: Cache,
+extensions: Array<string>,
+extraNodeModules: ?{},
+forceNodeFilesystemAPI: boolean,
+getTransformCacheKey: GetTransformCacheKey,
+globalTransformCache: ?GlobalTransformCache,
+ignoreFilePath: (filePath: string) => boolean,
+maxWorkerCount: number,
+moduleOptions: ModuleOptions,
+platforms: Set<string>,
+preferNativePlatform: boolean,
+providesModuleNodeModules: Array<string>,
+reporter: Reporter,
+resetCache: boolean,
+roots: Array<string>,
+transformCode: TransformCode,
+useWatchman: boolean,
+watch: boolean,
|};
const JEST_HASTE_MAP_CACHE_BREAKER = 1;
@ -84,12 +84,12 @@ class DependencyGraph extends EventEmitter {
_hasteFS: HasteFS;
_moduleMap: ModuleMap;
constructor(config: {
opts: Options,
haste: JestHasteMap,
initialHasteFS: HasteFS,
initialModuleMap: ModuleMap,
}) {
constructor(config: {|
+opts: Options,
+haste: JestHasteMap,
+initialHasteFS: HasteFS,
+initialModuleMap: ModuleMap,
|}) {
super();
invariant(config.opts.maxWorkerCount >= 1, 'worker count must be greater or equal to 1');
this._opts = config.opts;