Move DeltaBundler flow types to a single file

Reviewed By: mjesun

Differential Revision: D7895075

fbshipit-source-id: 0b9754b4b2a8210e6a8f3d74b0eae83bf6472b52
This commit is contained in:
Rafael Oleza 2018-05-11 15:05:32 -07:00 committed by Facebook Github Bot
parent bb9bfc261b
commit 06c8b6b7a6
19 changed files with 76 additions and 72 deletions

View File

@ -21,7 +21,7 @@ const toLocalPath = require('./node-haste/lib/toLocalPath');
const {Cache, stableHash} = require('metro-cache');
import type {TransformResult} from './DeltaBundler/traverseDependencies';
import type {TransformResult} from './DeltaBundler';
import type {
JsOutput,
WorkerOptions,

View File

@ -13,9 +13,15 @@
const DeltaCalculator = require('./DeltaBundler/DeltaCalculator');
import type Bundler from './Bundler';
import type {DeltaResult, Graph, Options} from './DeltaBundler/DeltaCalculator';
import type {DeltaResult, Graph, Options} from './DeltaBundler/types.flow';
export type {DeltaResult, Graph} from './DeltaBundler/DeltaCalculator';
export type {
DeltaResult,
Graph,
Module,
TransformFn,
TransformResult,
} from './DeltaBundler/types.flow';
/**
* `DeltaBundler` uses the `DeltaTransformer` to build bundle deltas. This

View File

@ -18,15 +18,7 @@ const {
const {EventEmitter} = require('events');
import type DependencyGraph from '../node-haste/DependencyGraph';
import type {Graph, Module, Options} from './traverseDependencies';
export type DeltaResult<T> = {|
+modified: Map<string, Module<T>>,
+deleted: Set<string>,
+reset: boolean,
|};
export type {Graph, Options} from './traverseDependencies';
import type {DeltaResult, Graph, Options} from './types.flow';
/**
* This class is in charge of calculating the delta of changed modules that

View File

@ -15,10 +15,8 @@ const getAppendScripts = require('../../lib/getAppendScripts');
const {wrapModule} = require('./helpers/js');
const {getJsOutput, isJsModule} = require('./helpers/js');
import type {DeltaResult} from '../../DeltaBundler/DeltaCalculator';
import type {Graph} from '../../DeltaBundler';
import type {JsOutput} from '../../JSTransformer/worker';
import type {Module} from '../traverseDependencies';
import type {DeltaResult, Graph, Module} from '../types.flow';
type Options = {|
+createModuleId: string => number | string,

View File

@ -14,8 +14,7 @@ const {getAssetFiles} = require('../../Assets');
const {getJsOutput, isJsModule} = require('./helpers/js');
import type {JsOutput} from '../../JSTransformer/worker';
import type {Graph} from '../DeltaCalculator';
import type {Module} from '../traverseDependencies';
import type {Graph, Module} from '../types.flow';
type Options = {|
platform: ?string,

View File

@ -17,7 +17,7 @@ const {getJsOutput, isJsModule} = require('./helpers/js');
import type {AssetData} from '../../Assets';
import type {JsOutput} from '../../JSTransformer/worker';
import type {Graph} from '../DeltaCalculator';
import type {Graph} from '../types.flow';
type Options = {|
assetPlugins: $ReadOnlyArray<string>,

View File

@ -22,8 +22,7 @@ const {isJsModule, wrapModule} = require('./helpers/js');
import type {GetTransformOptions} from '../../Bundler';
import type {JsOutput} from '../../JSTransformer/worker';
import type {ModuleTransportLike} from '../../shared/types.flow';
import type {Graph} from '../DeltaCalculator';
import type {Module} from '../traverseDependencies';
import type {Graph, Module} from '../types.flow';
type Options = {|
+createModuleId: string => number,

View File

@ -10,7 +10,7 @@
'use strict';
import type {Graph} from '../../DeltaCalculator';
import type {Graph} from '../../types.flow';
function getTransitiveDependencies<T>(
path: string,

View File

@ -15,7 +15,7 @@ const invariant = require('fbjs/lib/invariant');
const path = require('path');
import type {JsOutput} from '../../../JSTransformer/worker';
import type {Module} from '../../traverseDependencies';
import type {Module} from '../../types.flow';
export type Options = {
+createModuleId: string => number | string,

View File

@ -14,10 +14,8 @@ const addParamsToDefineCall = require('../../lib/addParamsToDefineCall');
const {isJsModule, wrapModule} = require('./helpers/js');
import type {DeltaResult} from '../../DeltaBundler/DeltaCalculator';
import type {Graph} from '../../DeltaBundler';
import type {JsOutput} from '../../JSTransformer/worker';
import type {Module} from '../traverseDependencies';
import type {DeltaResult, Graph, Module} from '../types.flow';
type Options = {
createModuleId: string => number,

View File

@ -15,8 +15,7 @@ const getAppendScripts = require('../../lib/getAppendScripts');
const {isJsModule, wrapModule} = require('./helpers/js');
import type {JsOutput} from '../../JSTransformer/worker';
import type {Graph} from '../DeltaCalculator';
import type {Module} from '../traverseDependencies';
import type {Graph, Module} from '../types.flow';
type Options = {|
+createModuleId: string => number | string,

View File

@ -14,8 +14,7 @@ const {isJsModule, getJsOutput} = require('./helpers/js');
const {fromRawMappings} = require('metro-source-map');
import type {JsOutput} from '../../JSTransformer/worker';
import type {Graph} from '../DeltaCalculator';
import type {Module} from '../traverseDependencies';
import type {Graph, Module} from '../types.flow';
import type {BabelSourceMap} from '@babel/core';
function fullSourceMapObject(

View File

@ -14,8 +14,7 @@ const {isJsModule, getJsOutput} = require('./helpers/js');
const {fromRawMappings} = require('metro-source-map');
import type {JsOutput} from '../../JSTransformer/worker';
import type {Graph} from '../DeltaCalculator';
import type {Module} from '../traverseDependencies';
import type {Graph, Module} from '../types.flow';
function fullSourceMap(
pre: $ReadOnlyArray<Module<JsOutput>>,

View File

@ -11,24 +11,7 @@
'use strict';
import type {TransformResultDependency} from '../ModuleGraph/types.flow';
export type Dependency = {|
absolutePath: string,
data: TransformResultDependency,
|};
export type Module<T> = {|
dependencies: Map<string, Dependency>,
inverseDependencies: Set<string>,
output: $ReadOnlyArray<T>,
path: string,
getSource: () => string,
|};
export type Graph<T> = {|
dependencies: Map<string, Module<T>>,
entryPoints: $ReadOnlyArray<string>,
|};
import type {Dependency, Graph, Module, Options} from './types.flow';
type Result<T> = {added: Map<string, Module<T>>, deleted: Set<string>};
@ -44,20 +27,6 @@ type Delta<T> = {
deleted: Set<string>,
};
export type TransformResult<T> = {|
dependencies: $ReadOnlyArray<TransformResultDependency>,
output: $ReadOnlyArray<T>,
+getSource: () => string,
|};
export type TransformFn<T> = string => Promise<TransformResult<T>>;
export type Options<T> = {|
resolve: (from: string, to: string) => string,
transform: TransformFn<T>,
onProgress: ?(numProcessed: number, total: number) => mixed,
|};
/**
* Dependency Traversal logic for the Delta Bundler. This method calculates
* the modules that should be included in the bundle by traversing the

View File

@ -0,0 +1,51 @@
/**
* Copyright (c) 2018-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'use strict';
import type {TransformResultDependency} from '../ModuleGraph/types.flow';
export type Dependency = {|
+absolutePath: string,
+data: TransformResultDependency,
|};
export type Module<T> = {|
dependencies: Map<string, Dependency>,
inverseDependencies: Set<string>,
output: $ReadOnlyArray<T>,
path: string,
getSource: () => string,
|};
export type Graph<T> = {|
dependencies: Map<string, Module<T>>,
entryPoints: $ReadOnlyArray<string>,
|};
export type TransformResult<T> = {|
dependencies: $ReadOnlyArray<TransformResultDependency>,
output: $ReadOnlyArray<T>,
+getSource: () => string,
|};
export type TransformFn<T> = string => Promise<TransformResult<T>>;
export type Options<T> = {|
resolve: (from: string, to: string) => string,
transform: TransformFn<T>,
onProgress: ?(numProcessed: number, total: number) => mixed,
|};
export type DeltaResult<T> = {|
+modified: Map<string, Module<T>>,
+deleted: Set<string>,
+reset: boolean,
|};

View File

@ -42,7 +42,7 @@ const {getAsset} = require('./Assets');
const resolveSync: ResolveSync = require('resolve').sync;
import type {CustomError} from './lib/formatBundlingError';
import type {Module} from './DeltaBundler/traverseDependencies';
import type {DeltaResult, Graph, Module} from './DeltaBundler';
import type {IncomingMessage, ServerResponse} from 'http';
import type {Reporter} from './lib/reporting';
import type {RamBundleInfo} from './DeltaBundler/Serializers/getRamBundleInfo';
@ -53,8 +53,6 @@ import type {
PostProcessBundleSourcemap,
} from './Bundler';
import type {CacheStore} from 'metro-cache';
import type {Graph} from './DeltaBundler';
import type {DeltaResult} from './DeltaBundler/DeltaCalculator';
import type {CustomResolver} from 'metro-resolver';
import type {MetroSourceMap} from 'metro-source-map';
import type {Symbolicate} from './Server/symbolicate/symbolicate';

View File

@ -10,8 +10,7 @@
'use strict';
import type {Graph} from '../DeltaBundler/DeltaCalculator';
import type {Module} from '../DeltaBundler/traverseDependencies';
import type {Graph, Module} from '../DeltaBundler';
import type {JsOutput} from '../JSTransformer/worker';
type Options<T: number | string> = {

View File

@ -15,8 +15,7 @@ const getPreludeCode = require('./getPreludeCode');
const transformHelpers = require('./transformHelpers');
import type Bundler from '../Bundler';
import type {Module} from '../DeltaBundler/traverseDependencies';
import type DeltaBundler from '../DeltaBundler';
import type DeltaBundler, {Module} from '../DeltaBundler';
import type {CustomTransformOptions, JsOutput} from '../JSTransformer/worker';
type Options = {

View File

@ -11,8 +11,7 @@
'use strict';
import type Bundler from '../Bundler';
import type {TransformFn} from '../DeltaBundler/traverseDependencies';
import type DeltaBundler from '../DeltaBundler';
import type DeltaBundler, {TransformFn} from '../DeltaBundler';
import type {JsOutput, WorkerOptions} from '../JSTransformer/worker';
import type {BuildGraphOptions} from '../Server';