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
|
* @flow
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import DependencyGraphHelpers from '../../node-haste/DependencyGraph/DependencyGraphHelpers';
|
||||||
|
|
||||||
type ModuleID = string;
|
type ModuleID = string;
|
||||||
export type Path = string;
|
export type Path = string;
|
||||||
type Platform = string;
|
type Platform = string;
|
||||||
|
@ -45,21 +49,10 @@ export type FastFS = {
|
||||||
matches(directory: Path, pattern: RegExp): Array<Path>,
|
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 = {|
|
type DeprecatedAssetMapOptions = {|
|
||||||
assetExts: Extensions,
|
assetExts: Extensions,
|
||||||
files: Array<Path>,
|
files: Array<Path>,
|
||||||
helpers: Helpers,
|
helpers: DependencyGraphHelpers,
|
||||||
platforms: Platforms,
|
platforms: Platforms,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
|
@ -74,7 +67,7 @@ type HasteMapOptions = {|
|
||||||
fastfs: FastFS,
|
fastfs: FastFS,
|
||||||
moduleCache: ModuleCache,
|
moduleCache: ModuleCache,
|
||||||
preferNativePlatform: true,
|
preferNativePlatform: true,
|
||||||
helpers: Helpers,
|
helpers: DependencyGraphHelpers,
|
||||||
platforms: Platforms,
|
platforms: Platforms,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
|
@ -90,7 +83,7 @@ type ResolutionRequestOptions = {|
|
||||||
preferNativePlatform: true,
|
preferNativePlatform: true,
|
||||||
hasteMap: HasteMap,
|
hasteMap: HasteMap,
|
||||||
deprecatedAssetMap: DeprecatedAssetMap,
|
deprecatedAssetMap: DeprecatedAssetMap,
|
||||||
helpers: Helpers,
|
helpers: DependencyGraphHelpers,
|
||||||
moduleCache: ModuleCache,
|
moduleCache: ModuleCache,
|
||||||
fastfs: FastFS,
|
fastfs: FastFS,
|
||||||
shouldThrowOnUnresolvedErrors: () => true,
|
shouldThrowOnUnresolvedErrors: () => true,
|
||||||
|
|
|
@ -15,7 +15,6 @@ import type { // eslint-disable-line sort-requires
|
||||||
DeprecatedAssetMapT,
|
DeprecatedAssetMapT,
|
||||||
Extensions,
|
Extensions,
|
||||||
HasteMapT,
|
HasteMapT,
|
||||||
HelpersT,
|
|
||||||
Path,
|
Path,
|
||||||
ResolutionRequestT,
|
ResolutionRequestT,
|
||||||
} from './node-haste.flow';
|
} from './node-haste.flow';
|
||||||
|
@ -25,7 +24,7 @@ import type {
|
||||||
TransformedFile,
|
TransformedFile,
|
||||||
} from '../types.flow';
|
} 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 DeprecatedAssetMap: Class<DeprecatedAssetMapT> = require('../../node-haste/DependencyGraph/DeprecatedAssetMap');
|
||||||
const FastFS = require('./FastFS');
|
const FastFS = require('./FastFS');
|
||||||
const HasteMap: Class<HasteMapT> = require('../../node-haste/DependencyGraph/HasteMap');
|
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
|
* 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
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
@ -13,12 +16,19 @@ const path = require('path');
|
||||||
const NODE_MODULES = path.sep + 'node_modules' + path.sep;
|
const NODE_MODULES = path.sep + 'node_modules' + path.sep;
|
||||||
|
|
||||||
class DependencyGraphHelpers {
|
class DependencyGraphHelpers {
|
||||||
constructor({ providesModuleNodeModules, assetExts }) {
|
|
||||||
|
_providesModuleNodeModules: Array<string>;
|
||||||
|
_assetExts: Array<string>;
|
||||||
|
|
||||||
|
constructor({ providesModuleNodeModules, assetExts }: {
|
||||||
|
providesModuleNodeModules: Array<string>,
|
||||||
|
assetExts: Array<string>,
|
||||||
|
}) {
|
||||||
this._providesModuleNodeModules = providesModuleNodeModules;
|
this._providesModuleNodeModules = providesModuleNodeModules;
|
||||||
this._assetExts = assetExts;
|
this._assetExts = assetExts;
|
||||||
}
|
}
|
||||||
|
|
||||||
isNodeModulesDir(file) {
|
isNodeModulesDir(file: string) {
|
||||||
const index = file.lastIndexOf(NODE_MODULES);
|
const index = file.lastIndexOf(NODE_MODULES);
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -35,11 +45,11 @@ class DependencyGraphHelpers {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
isAssetFile(file) {
|
isAssetFile(file: string) {
|
||||||
return this._assetExts.indexOf(this.extname(file)) !== -1;
|
return this._assetExts.indexOf(this.extname(file)) !== -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
extname(name) {
|
extname(name: string) {
|
||||||
return path.extname(name).substr(1);
|
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 {TransformedCode} from '../JSTransformer/worker/worker';
|
||||||
import type Cache from './Cache';
|
import type Cache from './Cache';
|
||||||
|
import type DependencyGraphHelpers from './DependencyGraph/DependencyGraphHelpers';
|
||||||
import type ModuleCache from './ModuleCache';
|
import type ModuleCache from './ModuleCache';
|
||||||
import type FastFs from './fastfs';
|
import type FastFs from './fastfs';
|
||||||
|
|
||||||
|
@ -44,8 +45,6 @@ export type Options = {
|
||||||
cacheTransformResults?: boolean,
|
cacheTransformResults?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DepGraphHelpers = {isNodeModulesDir: (filePath: string) => boolean};
|
|
||||||
|
|
||||||
export type ConstructorArgs = {
|
export type ConstructorArgs = {
|
||||||
file: string,
|
file: string,
|
||||||
fastfs: FastFs,
|
fastfs: FastFs,
|
||||||
|
@ -53,7 +52,7 @@ export type ConstructorArgs = {
|
||||||
cache: Cache,
|
cache: Cache,
|
||||||
transformCode: ?TransformCode,
|
transformCode: ?TransformCode,
|
||||||
transformCacheKey: ?string,
|
transformCacheKey: ?string,
|
||||||
depGraphHelpers: DepGraphHelpers,
|
depGraphHelpers: DependencyGraphHelpers,
|
||||||
options: Options,
|
options: Options,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -67,7 +66,7 @@ class Module {
|
||||||
_cache: Cache;
|
_cache: Cache;
|
||||||
_transformCode: ?TransformCode;
|
_transformCode: ?TransformCode;
|
||||||
_transformCacheKey: ?string;
|
_transformCacheKey: ?string;
|
||||||
_depGraphHelpers: DepGraphHelpers;
|
_depGraphHelpers: DependencyGraphHelpers;
|
||||||
_options: Options;
|
_options: Options;
|
||||||
|
|
||||||
_docBlock: Promise<{id?: string, moduleDocBlock: {[key: string]: mixed}}>;
|
_docBlock: Promise<{id?: string, moduleDocBlock: {[key: string]: mixed}}>;
|
||||||
|
|
|
@ -17,8 +17,8 @@ const Package = require('./Package');
|
||||||
const Polyfill = require('./Polyfill');
|
const Polyfill = require('./Polyfill');
|
||||||
|
|
||||||
import type Cache from './Cache';
|
import type Cache from './Cache';
|
||||||
|
import type DependencyGraphHelpers from './DependencyGraph/DependencyGraphHelpers';
|
||||||
import type {
|
import type {
|
||||||
DepGraphHelpers,
|
|
||||||
TransformCode,
|
TransformCode,
|
||||||
Options as ModuleOptions,
|
Options as ModuleOptions,
|
||||||
} from './Module';
|
} from './Module';
|
||||||
|
@ -32,7 +32,7 @@ class ModuleCache {
|
||||||
_cache: Cache;
|
_cache: Cache;
|
||||||
_transformCode: TransformCode;
|
_transformCode: TransformCode;
|
||||||
_transformCacheKey: string;
|
_transformCacheKey: string;
|
||||||
_depGraphHelpers: DepGraphHelpers;
|
_depGraphHelpers: DependencyGraphHelpers;
|
||||||
_platforms: mixed;
|
_platforms: mixed;
|
||||||
_assetDependencies: mixed;
|
_assetDependencies: mixed;
|
||||||
_moduleOptions: ModuleOptions;
|
_moduleOptions: ModuleOptions;
|
||||||
|
@ -52,7 +52,7 @@ class ModuleCache {
|
||||||
cache: Cache,
|
cache: Cache,
|
||||||
transformCode: TransformCode,
|
transformCode: TransformCode,
|
||||||
transformCacheKey: string,
|
transformCacheKey: string,
|
||||||
depGraphHelpers: DepGraphHelpers,
|
depGraphHelpers: DependencyGraphHelpers,
|
||||||
assetDependencies: mixed,
|
assetDependencies: mixed,
|
||||||
moduleOptions: ModuleOptions,
|
moduleOptions: ModuleOptions,
|
||||||
}, platforms: mixed) {
|
}, platforms: mixed) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ class DependencyGraph {
|
||||||
forceNodeFilesystemAPI: boolean,
|
forceNodeFilesystemAPI: boolean,
|
||||||
assetRoots_DEPRECATED: Array<string>,
|
assetRoots_DEPRECATED: Array<string>,
|
||||||
assetExts: Array<string>,
|
assetExts: Array<string>,
|
||||||
providesModuleNodeModules: mixed,
|
providesModuleNodeModules: Array<string>,
|
||||||
platforms: Set<mixed>,
|
platforms: Set<mixed>,
|
||||||
preferNativePlatform: boolean,
|
preferNativePlatform: boolean,
|
||||||
extensions: Array<string>,
|
extensions: Array<string>,
|
||||||
|
@ -118,7 +118,7 @@ class DependencyGraph {
|
||||||
forceNodeFilesystemAPI?: boolean,
|
forceNodeFilesystemAPI?: boolean,
|
||||||
assetRoots_DEPRECATED: Array<string>,
|
assetRoots_DEPRECATED: Array<string>,
|
||||||
assetExts: Array<string>,
|
assetExts: Array<string>,
|
||||||
providesModuleNodeModules: mixed,
|
providesModuleNodeModules: Array<string>,
|
||||||
platforms: mixed,
|
platforms: mixed,
|
||||||
preferNativePlatform: boolean,
|
preferNativePlatform: boolean,
|
||||||
cache: Cache,
|
cache: Cache,
|
||||||
|
|
Loading…
Reference in New Issue