mirror of
https://github.com/status-im/metro.git
synced 2025-01-12 20:14:24 +00:00
Move DeltaBundler flow types to a single file
Reviewed By: mjesun Differential Revision: D7895075 fbshipit-source-id: 0b9754b4b2a8210e6a8f3d74b0eae83bf6472b52
This commit is contained in:
parent
bb9bfc261b
commit
06c8b6b7a6
@ -21,7 +21,7 @@ const toLocalPath = require('./node-haste/lib/toLocalPath');
|
|||||||
|
|
||||||
const {Cache, stableHash} = require('metro-cache');
|
const {Cache, stableHash} = require('metro-cache');
|
||||||
|
|
||||||
import type {TransformResult} from './DeltaBundler/traverseDependencies';
|
import type {TransformResult} from './DeltaBundler';
|
||||||
import type {
|
import type {
|
||||||
JsOutput,
|
JsOutput,
|
||||||
WorkerOptions,
|
WorkerOptions,
|
||||||
|
@ -13,9 +13,15 @@
|
|||||||
const DeltaCalculator = require('./DeltaBundler/DeltaCalculator');
|
const DeltaCalculator = require('./DeltaBundler/DeltaCalculator');
|
||||||
|
|
||||||
import type Bundler from './Bundler';
|
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
|
* `DeltaBundler` uses the `DeltaTransformer` to build bundle deltas. This
|
||||||
|
@ -18,15 +18,7 @@ const {
|
|||||||
const {EventEmitter} = require('events');
|
const {EventEmitter} = require('events');
|
||||||
|
|
||||||
import type DependencyGraph from '../node-haste/DependencyGraph';
|
import type DependencyGraph from '../node-haste/DependencyGraph';
|
||||||
import type {Graph, Module, Options} from './traverseDependencies';
|
import type {DeltaResult, Graph, Options} from './types.flow';
|
||||||
|
|
||||||
export type DeltaResult<T> = {|
|
|
||||||
+modified: Map<string, Module<T>>,
|
|
||||||
+deleted: Set<string>,
|
|
||||||
+reset: boolean,
|
|
||||||
|};
|
|
||||||
|
|
||||||
export type {Graph, Options} from './traverseDependencies';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is in charge of calculating the delta of changed modules that
|
* This class is in charge of calculating the delta of changed modules that
|
||||||
|
@ -15,10 +15,8 @@ const getAppendScripts = require('../../lib/getAppendScripts');
|
|||||||
const {wrapModule} = require('./helpers/js');
|
const {wrapModule} = require('./helpers/js');
|
||||||
const {getJsOutput, isJsModule} = 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 {JsOutput} from '../../JSTransformer/worker';
|
||||||
import type {Module} from '../traverseDependencies';
|
import type {DeltaResult, Graph, Module} from '../types.flow';
|
||||||
|
|
||||||
type Options = {|
|
type Options = {|
|
||||||
+createModuleId: string => number | string,
|
+createModuleId: string => number | string,
|
||||||
|
@ -14,8 +14,7 @@ const {getAssetFiles} = require('../../Assets');
|
|||||||
const {getJsOutput, isJsModule} = require('./helpers/js');
|
const {getJsOutput, isJsModule} = require('./helpers/js');
|
||||||
|
|
||||||
import type {JsOutput} from '../../JSTransformer/worker';
|
import type {JsOutput} from '../../JSTransformer/worker';
|
||||||
import type {Graph} from '../DeltaCalculator';
|
import type {Graph, Module} from '../types.flow';
|
||||||
import type {Module} from '../traverseDependencies';
|
|
||||||
|
|
||||||
type Options = {|
|
type Options = {|
|
||||||
platform: ?string,
|
platform: ?string,
|
||||||
|
@ -17,7 +17,7 @@ const {getJsOutput, isJsModule} = require('./helpers/js');
|
|||||||
|
|
||||||
import type {AssetData} from '../../Assets';
|
import type {AssetData} from '../../Assets';
|
||||||
import type {JsOutput} from '../../JSTransformer/worker';
|
import type {JsOutput} from '../../JSTransformer/worker';
|
||||||
import type {Graph} from '../DeltaCalculator';
|
import type {Graph} from '../types.flow';
|
||||||
|
|
||||||
type Options = {|
|
type Options = {|
|
||||||
assetPlugins: $ReadOnlyArray<string>,
|
assetPlugins: $ReadOnlyArray<string>,
|
||||||
|
@ -22,8 +22,7 @@ const {isJsModule, wrapModule} = require('./helpers/js');
|
|||||||
import type {GetTransformOptions} from '../../Bundler';
|
import type {GetTransformOptions} from '../../Bundler';
|
||||||
import type {JsOutput} from '../../JSTransformer/worker';
|
import type {JsOutput} from '../../JSTransformer/worker';
|
||||||
import type {ModuleTransportLike} from '../../shared/types.flow';
|
import type {ModuleTransportLike} from '../../shared/types.flow';
|
||||||
import type {Graph} from '../DeltaCalculator';
|
import type {Graph, Module} from '../types.flow';
|
||||||
import type {Module} from '../traverseDependencies';
|
|
||||||
|
|
||||||
type Options = {|
|
type Options = {|
|
||||||
+createModuleId: string => number,
|
+createModuleId: string => number,
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import type {Graph} from '../../DeltaCalculator';
|
import type {Graph} from '../../types.flow';
|
||||||
|
|
||||||
function getTransitiveDependencies<T>(
|
function getTransitiveDependencies<T>(
|
||||||
path: string,
|
path: string,
|
||||||
|
@ -15,7 +15,7 @@ const invariant = require('fbjs/lib/invariant');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
import type {JsOutput} from '../../../JSTransformer/worker';
|
import type {JsOutput} from '../../../JSTransformer/worker';
|
||||||
import type {Module} from '../../traverseDependencies';
|
import type {Module} from '../../types.flow';
|
||||||
|
|
||||||
export type Options = {
|
export type Options = {
|
||||||
+createModuleId: string => number | string,
|
+createModuleId: string => number | string,
|
||||||
|
@ -14,10 +14,8 @@ const addParamsToDefineCall = require('../../lib/addParamsToDefineCall');
|
|||||||
|
|
||||||
const {isJsModule, wrapModule} = require('./helpers/js');
|
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 {JsOutput} from '../../JSTransformer/worker';
|
||||||
import type {Module} from '../traverseDependencies';
|
import type {DeltaResult, Graph, Module} from '../types.flow';
|
||||||
|
|
||||||
type Options = {
|
type Options = {
|
||||||
createModuleId: string => number,
|
createModuleId: string => number,
|
||||||
|
@ -15,8 +15,7 @@ const getAppendScripts = require('../../lib/getAppendScripts');
|
|||||||
const {isJsModule, wrapModule} = require('./helpers/js');
|
const {isJsModule, wrapModule} = require('./helpers/js');
|
||||||
|
|
||||||
import type {JsOutput} from '../../JSTransformer/worker';
|
import type {JsOutput} from '../../JSTransformer/worker';
|
||||||
import type {Graph} from '../DeltaCalculator';
|
import type {Graph, Module} from '../types.flow';
|
||||||
import type {Module} from '../traverseDependencies';
|
|
||||||
|
|
||||||
type Options = {|
|
type Options = {|
|
||||||
+createModuleId: string => number | string,
|
+createModuleId: string => number | string,
|
||||||
|
@ -14,8 +14,7 @@ const {isJsModule, getJsOutput} = require('./helpers/js');
|
|||||||
const {fromRawMappings} = require('metro-source-map');
|
const {fromRawMappings} = require('metro-source-map');
|
||||||
|
|
||||||
import type {JsOutput} from '../../JSTransformer/worker';
|
import type {JsOutput} from '../../JSTransformer/worker';
|
||||||
import type {Graph} from '../DeltaCalculator';
|
import type {Graph, Module} from '../types.flow';
|
||||||
import type {Module} from '../traverseDependencies';
|
|
||||||
import type {BabelSourceMap} from '@babel/core';
|
import type {BabelSourceMap} from '@babel/core';
|
||||||
|
|
||||||
function fullSourceMapObject(
|
function fullSourceMapObject(
|
||||||
|
@ -14,8 +14,7 @@ const {isJsModule, getJsOutput} = require('./helpers/js');
|
|||||||
const {fromRawMappings} = require('metro-source-map');
|
const {fromRawMappings} = require('metro-source-map');
|
||||||
|
|
||||||
import type {JsOutput} from '../../JSTransformer/worker';
|
import type {JsOutput} from '../../JSTransformer/worker';
|
||||||
import type {Graph} from '../DeltaCalculator';
|
import type {Graph, Module} from '../types.flow';
|
||||||
import type {Module} from '../traverseDependencies';
|
|
||||||
|
|
||||||
function fullSourceMap(
|
function fullSourceMap(
|
||||||
pre: $ReadOnlyArray<Module<JsOutput>>,
|
pre: $ReadOnlyArray<Module<JsOutput>>,
|
||||||
|
@ -11,24 +11,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import type {TransformResultDependency} from '../ModuleGraph/types.flow';
|
import type {TransformResultDependency} from '../ModuleGraph/types.flow';
|
||||||
|
import type {Dependency, Graph, Module, Options} from './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>,
|
|
||||||
|};
|
|
||||||
|
|
||||||
type Result<T> = {added: Map<string, Module<T>>, deleted: Set<string>};
|
type Result<T> = {added: Map<string, Module<T>>, deleted: Set<string>};
|
||||||
|
|
||||||
@ -44,20 +27,6 @@ type Delta<T> = {
|
|||||||
deleted: Set<string>,
|
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
|
* Dependency Traversal logic for the Delta Bundler. This method calculates
|
||||||
* the modules that should be included in the bundle by traversing the
|
* the modules that should be included in the bundle by traversing the
|
||||||
|
51
packages/metro/src/DeltaBundler/types.flow.js
Normal file
51
packages/metro/src/DeltaBundler/types.flow.js
Normal 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,
|
||||||
|
|};
|
@ -42,7 +42,7 @@ const {getAsset} = require('./Assets');
|
|||||||
const resolveSync: ResolveSync = require('resolve').sync;
|
const resolveSync: ResolveSync = require('resolve').sync;
|
||||||
|
|
||||||
import type {CustomError} from './lib/formatBundlingError';
|
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 {IncomingMessage, ServerResponse} from 'http';
|
||||||
import type {Reporter} from './lib/reporting';
|
import type {Reporter} from './lib/reporting';
|
||||||
import type {RamBundleInfo} from './DeltaBundler/Serializers/getRamBundleInfo';
|
import type {RamBundleInfo} from './DeltaBundler/Serializers/getRamBundleInfo';
|
||||||
@ -53,8 +53,6 @@ import type {
|
|||||||
PostProcessBundleSourcemap,
|
PostProcessBundleSourcemap,
|
||||||
} from './Bundler';
|
} from './Bundler';
|
||||||
import type {CacheStore} from 'metro-cache';
|
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 {CustomResolver} from 'metro-resolver';
|
||||||
import type {MetroSourceMap} from 'metro-source-map';
|
import type {MetroSourceMap} from 'metro-source-map';
|
||||||
import type {Symbolicate} from './Server/symbolicate/symbolicate';
|
import type {Symbolicate} from './Server/symbolicate/symbolicate';
|
||||||
|
@ -10,8 +10,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import type {Graph} from '../DeltaBundler/DeltaCalculator';
|
import type {Graph, Module} from '../DeltaBundler';
|
||||||
import type {Module} from '../DeltaBundler/traverseDependencies';
|
|
||||||
import type {JsOutput} from '../JSTransformer/worker';
|
import type {JsOutput} from '../JSTransformer/worker';
|
||||||
|
|
||||||
type Options<T: number | string> = {
|
type Options<T: number | string> = {
|
||||||
|
@ -15,8 +15,7 @@ const getPreludeCode = require('./getPreludeCode');
|
|||||||
const transformHelpers = require('./transformHelpers');
|
const transformHelpers = require('./transformHelpers');
|
||||||
|
|
||||||
import type Bundler from '../Bundler';
|
import type Bundler from '../Bundler';
|
||||||
import type {Module} from '../DeltaBundler/traverseDependencies';
|
import type DeltaBundler, {Module} from '../DeltaBundler';
|
||||||
import type DeltaBundler from '../DeltaBundler';
|
|
||||||
import type {CustomTransformOptions, JsOutput} from '../JSTransformer/worker';
|
import type {CustomTransformOptions, JsOutput} from '../JSTransformer/worker';
|
||||||
|
|
||||||
type Options = {
|
type Options = {
|
||||||
|
@ -11,8 +11,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import type Bundler from '../Bundler';
|
import type Bundler from '../Bundler';
|
||||||
import type {TransformFn} from '../DeltaBundler/traverseDependencies';
|
import type DeltaBundler, {TransformFn} from '../DeltaBundler';
|
||||||
import type DeltaBundler from '../DeltaBundler';
|
|
||||||
import type {JsOutput, WorkerOptions} from '../JSTransformer/worker';
|
import type {JsOutput, WorkerOptions} from '../JSTransformer/worker';
|
||||||
import type {BuildGraphOptions} from '../Server';
|
import type {BuildGraphOptions} from '../Server';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user