mirror of https://github.com/status-im/metro.git
packager: DependencyGraphHelpers: @flow
Reviewed By: cpojer Differential Revision: D4190148 fbshipit-source-id: 320496bb683288a19605bd667de1472c7fc9c6b4
This commit is contained in:
parent
d96e125d39
commit
06de9b9a93
|
@ -9,6 +9,10 @@
|
|||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import DependencyGraphHelpers from '../../node-haste/DependencyGraph/DependencyGraphHelpers';
|
||||
|
||||
type ModuleID = string;
|
||||
export type Path = string;
|
||||
type Platform = string;
|
||||
|
@ -45,21 +49,10 @@ export type FastFS = {
|
|||
matches(directory: Path, pattern: RegExp): Array<Path>,
|
||||
};
|
||||
|
||||
type HelpersOptions = {|
|
||||
assetExts: Extensions,
|
||||
providesModuleNodeModules: Array<string>,
|
||||
|};
|
||||
|
||||
declare class Helpers {
|
||||
// node-haste/DependencyGraph/DependencyGraphHelpers.js
|
||||
constructor(options: HelpersOptions): void,
|
||||
}
|
||||
export type HelpersT = Helpers;
|
||||
|
||||
type DeprecatedAssetMapOptions = {|
|
||||
assetExts: Extensions,
|
||||
files: Array<Path>,
|
||||
helpers: Helpers,
|
||||
helpers: DependencyGraphHelpers,
|
||||
platforms: Platforms,
|
||||
|};
|
||||
|
||||
|
@ -74,7 +67,7 @@ type HasteMapOptions = {|
|
|||
fastfs: FastFS,
|
||||
moduleCache: ModuleCache,
|
||||
preferNativePlatform: true,
|
||||
helpers: Helpers,
|
||||
helpers: DependencyGraphHelpers,
|
||||
platforms: Platforms,
|
||||
|};
|
||||
|
||||
|
@ -90,7 +83,7 @@ type ResolutionRequestOptions = {|
|
|||
preferNativePlatform: true,
|
||||
hasteMap: HasteMap,
|
||||
deprecatedAssetMap: DeprecatedAssetMap,
|
||||
helpers: Helpers,
|
||||
helpers: DependencyGraphHelpers,
|
||||
moduleCache: ModuleCache,
|
||||
fastfs: FastFS,
|
||||
shouldThrowOnUnresolvedErrors: () => true,
|
||||
|
|
|
@ -15,7 +15,6 @@ import type { // eslint-disable-line sort-requires
|
|||
DeprecatedAssetMapT,
|
||||
Extensions,
|
||||
HasteMapT,
|
||||
HelpersT,
|
||||
Path,
|
||||
ResolutionRequestT,
|
||||
} from './node-haste.flow';
|
||||
|
@ -25,7 +24,7 @@ import type {
|
|||
TransformedFile,
|
||||
} from '../types.flow';
|
||||
|
||||
const DependencyGraphHelpers: Class<HelpersT> = require('../../node-haste/DependencyGraph/DependencyGraphHelpers');
|
||||
const DependencyGraphHelpers = require('../../node-haste/DependencyGraph/DependencyGraphHelpers');
|
||||
const DeprecatedAssetMap: Class<DeprecatedAssetMapT> = require('../../node-haste/DependencyGraph/DeprecatedAssetMap');
|
||||
const FastFS = require('./FastFS');
|
||||
const HasteMap: Class<HasteMapT> = require('../../node-haste/DependencyGraph/HasteMap');
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
@ -13,12 +16,19 @@ const path = require('path');
|
|||
const NODE_MODULES = path.sep + 'node_modules' + path.sep;
|
||||
|
||||
class DependencyGraphHelpers {
|
||||
constructor({ providesModuleNodeModules, assetExts }) {
|
||||
|
||||
_providesModuleNodeModules: Array<string>;
|
||||
_assetExts: Array<string>;
|
||||
|
||||
constructor({ providesModuleNodeModules, assetExts }: {
|
||||
providesModuleNodeModules: Array<string>,
|
||||
assetExts: Array<string>,
|
||||
}) {
|
||||
this._providesModuleNodeModules = providesModuleNodeModules;
|
||||
this._assetExts = assetExts;
|
||||
}
|
||||
|
||||
isNodeModulesDir(file) {
|
||||
isNodeModulesDir(file: string) {
|
||||
const index = file.lastIndexOf(NODE_MODULES);
|
||||
if (index === -1) {
|
||||
return false;
|
||||
|
@ -35,11 +45,11 @@ class DependencyGraphHelpers {
|
|||
return true;
|
||||
}
|
||||
|
||||
isAssetFile(file) {
|
||||
isAssetFile(file: string) {
|
||||
return this._assetExts.indexOf(this.extname(file)) !== -1;
|
||||
}
|
||||
|
||||
extname(name) {
|
||||
extname(name: string) {
|
||||
return path.extname(name).substr(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ const {join: joinPath, relative: relativePath, extname} = require('path');
|
|||
|
||||
import type {TransformedCode} from '../JSTransformer/worker/worker';
|
||||
import type Cache from './Cache';
|
||||
import type DependencyGraphHelpers from './DependencyGraph/DependencyGraphHelpers';
|
||||
import type ModuleCache from './ModuleCache';
|
||||
import type FastFs from './fastfs';
|
||||
|
||||
|
@ -44,8 +45,6 @@ export type Options = {
|
|||
cacheTransformResults?: boolean,
|
||||
};
|
||||
|
||||
export type DepGraphHelpers = {isNodeModulesDir: (filePath: string) => boolean};
|
||||
|
||||
export type ConstructorArgs = {
|
||||
file: string,
|
||||
fastfs: FastFs,
|
||||
|
@ -53,7 +52,7 @@ export type ConstructorArgs = {
|
|||
cache: Cache,
|
||||
transformCode: ?TransformCode,
|
||||
transformCacheKey: ?string,
|
||||
depGraphHelpers: DepGraphHelpers,
|
||||
depGraphHelpers: DependencyGraphHelpers,
|
||||
options: Options,
|
||||
};
|
||||
|
||||
|
@ -67,7 +66,7 @@ class Module {
|
|||
_cache: Cache;
|
||||
_transformCode: ?TransformCode;
|
||||
_transformCacheKey: ?string;
|
||||
_depGraphHelpers: DepGraphHelpers;
|
||||
_depGraphHelpers: DependencyGraphHelpers;
|
||||
_options: Options;
|
||||
|
||||
_docBlock: Promise<{id?: string, moduleDocBlock: {[key: string]: mixed}}>;
|
||||
|
|
|
@ -17,8 +17,8 @@ const Package = require('./Package');
|
|||
const Polyfill = require('./Polyfill');
|
||||
|
||||
import type Cache from './Cache';
|
||||
import type DependencyGraphHelpers from './DependencyGraph/DependencyGraphHelpers';
|
||||
import type {
|
||||
DepGraphHelpers,
|
||||
TransformCode,
|
||||
Options as ModuleOptions,
|
||||
} from './Module';
|
||||
|
@ -32,7 +32,7 @@ class ModuleCache {
|
|||
_cache: Cache;
|
||||
_transformCode: TransformCode;
|
||||
_transformCacheKey: string;
|
||||
_depGraphHelpers: DepGraphHelpers;
|
||||
_depGraphHelpers: DependencyGraphHelpers;
|
||||
_platforms: mixed;
|
||||
_assetDependencies: mixed;
|
||||
_moduleOptions: ModuleOptions;
|
||||
|
@ -52,7 +52,7 @@ class ModuleCache {
|
|||
cache: Cache,
|
||||
transformCode: TransformCode,
|
||||
transformCacheKey: string,
|
||||
depGraphHelpers: DepGraphHelpers,
|
||||
depGraphHelpers: DependencyGraphHelpers,
|
||||
assetDependencies: mixed,
|
||||
moduleOptions: ModuleOptions,
|
||||
}, platforms: mixed) {
|
||||
|
|
|
@ -59,7 +59,7 @@ class DependencyGraph {
|
|||
forceNodeFilesystemAPI: boolean,
|
||||
assetRoots_DEPRECATED: Array<string>,
|
||||
assetExts: Array<string>,
|
||||
providesModuleNodeModules: mixed,
|
||||
providesModuleNodeModules: Array<string>,
|
||||
platforms: Set<mixed>,
|
||||
preferNativePlatform: boolean,
|
||||
extensions: Array<string>,
|
||||
|
@ -118,7 +118,7 @@ class DependencyGraph {
|
|||
forceNodeFilesystemAPI?: boolean,
|
||||
assetRoots_DEPRECATED: Array<string>,
|
||||
assetExts: Array<string>,
|
||||
providesModuleNodeModules: mixed,
|
||||
providesModuleNodeModules: Array<string>,
|
||||
platforms: mixed,
|
||||
preferNativePlatform: boolean,
|
||||
cache: Cache,
|
||||
|
|
Loading…
Reference in New Issue