mirror of https://github.com/status-im/metro.git
Clean server.js and runServer.js
Reviewed By: davidaurelio Differential Revision: D7628734 fbshipit-source-id: 3788b35b0f9b5034d9152c5c3b297313fbec231a
This commit is contained in:
parent
a334fd85d2
commit
910a71ba1a
|
@ -25,8 +25,6 @@ import type {
|
|||
Options as WorkerOptions,
|
||||
} from './JSTransformer/worker';
|
||||
import type {DynamicRequiresBehavior} from './ModuleGraph/worker/collectDependencies';
|
||||
import type {GlobalTransformCache} from './lib/GlobalTransformCache';
|
||||
import type {TransformCache} from './lib/TransformCaching';
|
||||
import type {Reporter} from './lib/reporting';
|
||||
import type Module from './node-haste/Module';
|
||||
import type {BabelSourceMap} from '@babel/core';
|
||||
|
@ -79,7 +77,6 @@ export type Options = {|
|
|||
+extraNodeModules: {},
|
||||
+getPolyfills: ({platform: ?string}) => $ReadOnlyArray<string>,
|
||||
+getTransformOptions?: GetTransformOptions,
|
||||
+globalTransformCache: ?GlobalTransformCache,
|
||||
+hasteImplModulePath?: string,
|
||||
+maxWorkers: number,
|
||||
+minifierPath: string,
|
||||
|
@ -90,10 +87,8 @@ export type Options = {|
|
|||
+projectRoots: $ReadOnlyArray<string>,
|
||||
+providesModuleNodeModules?: Array<string>,
|
||||
+reporter: Reporter,
|
||||
+resetCache: boolean,
|
||||
+resolveRequest: ?CustomResolver,
|
||||
+sourceExts: Array<string>,
|
||||
+transformCache: TransformCache,
|
||||
+transformModulePath: string,
|
||||
+watch: boolean,
|
||||
+workerPath: ?string,
|
||||
|
@ -154,7 +149,6 @@ class Bundler {
|
|||
opts.providesModuleNodeModules || defaults.providesModuleNodeModules,
|
||||
reporter: opts.reporter,
|
||||
resolveRequest: opts.resolveRequest,
|
||||
resetCache: opts.resetCache,
|
||||
sourceExts: opts.sourceExts,
|
||||
transformCode: this._cachedTransformCode.bind(this),
|
||||
watch: opts.watch,
|
||||
|
|
|
@ -56,7 +56,6 @@ import type {CacheStore} from 'metro-cache';
|
|||
import type {Delta, Graph} from './DeltaBundler';
|
||||
import type {CustomResolver} from 'metro-resolver';
|
||||
import type {MetroSourceMap} from 'metro-source-map';
|
||||
import type {TransformCache} from './lib/TransformCaching';
|
||||
import type {Symbolicate} from './Server/symbolicate/symbolicate';
|
||||
import type {AssetData} from './Assets';
|
||||
import type {
|
||||
|
@ -125,13 +124,11 @@ class Server {
|
|||
projectRoots: $ReadOnlyArray<string>,
|
||||
providesModuleNodeModules?: Array<string>,
|
||||
reporter: Reporter,
|
||||
resetCache: boolean,
|
||||
resolveRequest: ?CustomResolver,
|
||||
+getModulesRunBeforeMainModule: (entryFilePath: string) => Array<string>,
|
||||
+getRunModuleStatement: (number | string) => string,
|
||||
silent: boolean,
|
||||
+sourceExts: Array<string>,
|
||||
+transformCache: TransformCache,
|
||||
+transformModulePath: string,
|
||||
watch: boolean,
|
||||
workerPath: ?string,
|
||||
|
@ -180,7 +177,6 @@ class Server {
|
|||
getPolyfills: options.getPolyfills,
|
||||
getRunModuleStatement: options.getRunModuleStatement,
|
||||
getTransformOptions: options.getTransformOptions,
|
||||
globalTransformCache: options.globalTransformCache,
|
||||
hasteImplModulePath: options.hasteImplModulePath,
|
||||
maxWorkers,
|
||||
minifierPath:
|
||||
|
@ -194,19 +190,22 @@ class Server {
|
|||
projectRoots: options.projectRoots,
|
||||
providesModuleNodeModules: options.providesModuleNodeModules,
|
||||
reporter,
|
||||
resetCache: options.resetCache || false,
|
||||
resolveRequest: options.resolveRequest,
|
||||
silent: options.silent || false,
|
||||
sourceExts: options.assetTransforms
|
||||
? sourceExts.concat(assetExts)
|
||||
: sourceExts,
|
||||
transformCache: options.transformCache,
|
||||
transformModulePath:
|
||||
options.transformModulePath || defaults.transformModulePath,
|
||||
watch: options.watch || false,
|
||||
workerPath: options.workerPath,
|
||||
};
|
||||
|
||||
if (options.resetCache) {
|
||||
options.cacheStores.forEach(store => store.clear());
|
||||
reporter.update({type: 'transform_cache_reset'});
|
||||
}
|
||||
|
||||
const processFileChange = ({type, filePath}) =>
|
||||
this.onFileChange(type, filePath);
|
||||
|
||||
|
|
|
@ -101,7 +101,6 @@ describe('basic_bundle', () => {
|
|||
getPolyfills: () => [polyfill1, polyfill2],
|
||||
getRunModuleStatement,
|
||||
projectRoots: [INPUT_PATH, POLYFILLS_PATH],
|
||||
transformCache: Metro.TransformCaching.none(),
|
||||
transformModulePath: require.resolve('../../transformer'),
|
||||
nonPersistent: true,
|
||||
enableBabelRCLookup: false, // dont use metro's own babelrc!
|
||||
|
@ -126,7 +125,6 @@ describe('basic_bundle', () => {
|
|||
getPolyfills: () => [],
|
||||
getRunModuleStatement,
|
||||
projectRoots: [INPUT_PATH, POLYFILLS_PATH],
|
||||
transformCache: Metro.TransformCaching.none(),
|
||||
transformModulePath: require.resolve('../../transformer'),
|
||||
nonPersistent: true,
|
||||
enableBabelRCLookup: false, // dont use metro's own babelrc!
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const TransformCaching = require('./lib/TransformCaching');
|
||||
|
||||
const blacklist = require('./blacklist');
|
||||
const debug = require('debug');
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
|
@ -22,7 +20,6 @@ const {fromRawMappings, toSegmentTuple} = require('metro-source-map');
|
|||
|
||||
import type {ConfigT as MetroConfig} from './Config';
|
||||
import type Server from './Server';
|
||||
import type {TransformCache} from './lib/TransformCaching';
|
||||
import type {Options as ServerOptions} from './shared/types.flow';
|
||||
|
||||
exports.createBlacklist = blacklist;
|
||||
|
@ -36,7 +33,6 @@ type Options = {|
|
|||
...ServerOptions,
|
||||
// optional types to force flow errors in `toServerOptions`
|
||||
nonPersistent?: ?boolean,
|
||||
transformCache?: ?TransformCache,
|
||||
verbose?: ?boolean,
|
||||
targetBabelVersion?: number,
|
||||
|};
|
||||
|
@ -51,8 +47,6 @@ type PublicBundleOptions = {
|
|||
+sourceMapUrl?: string,
|
||||
};
|
||||
|
||||
exports.TransformCaching = TransformCaching;
|
||||
|
||||
/**
|
||||
* This is a public API, so we don't trust the value and purposefully downgrade
|
||||
* it as `mixed`. Because it understands `invariant`, Flow ensure that we
|
||||
|
@ -184,7 +178,6 @@ function toServerOptions(options: Options): ServerOptions {
|
|||
getPolyfills: options.getPolyfills,
|
||||
getRunModuleStatement: options.getRunModuleStatement,
|
||||
getTransformOptions: options.getTransformOptions,
|
||||
globalTransformCache: options.globalTransformCache,
|
||||
hasteImplModulePath: options.hasteImplModulePath,
|
||||
maxWorkers: options.maxWorkers,
|
||||
minifierPath: options.minifierPath,
|
||||
|
@ -199,7 +192,6 @@ function toServerOptions(options: Options): ServerOptions {
|
|||
resolveRequest: options.resolveRequest,
|
||||
silent: options.silent,
|
||||
sourceExts: options.sourceExts,
|
||||
transformCache: options.transformCache || TransformCaching.useTempDir(),
|
||||
transformModulePath: options.transformModulePath,
|
||||
watch:
|
||||
typeof options.watch === 'boolean'
|
||||
|
|
|
@ -51,7 +51,6 @@ type Options = {|
|
|||
+projectRoots: $ReadOnlyArray<string>,
|
||||
+providesModuleNodeModules: Array<string>,
|
||||
+reporter: Reporter,
|
||||
+resetCache: boolean,
|
||||
+resolveRequest: ?CustomResolver,
|
||||
+sourceExts: Array<string>,
|
||||
+transformCode: TransformCode,
|
||||
|
@ -111,7 +110,6 @@ class DependencyGraph extends EventEmitter {
|
|||
name: 'metro-' + JEST_HASTE_MAP_CACHE_BREAKER,
|
||||
platforms: Array.from(opts.platforms),
|
||||
providesModuleNodeModules: opts.providesModuleNodeModules,
|
||||
resetCache: opts.resetCache,
|
||||
retainAllFiles: true,
|
||||
roots: opts.projectRoots,
|
||||
throwOnModuleCollision: true,
|
||||
|
@ -199,7 +197,6 @@ class DependencyGraph extends EventEmitter {
|
|||
assetDependencies: [_opts.assetRegistryPath],
|
||||
getClosestPackage: this._getClosestPackage.bind(this),
|
||||
hasteImplModulePath: _opts.hasteImplModulePath,
|
||||
resetCache: _opts.resetCache,
|
||||
roots: _opts.projectRoots,
|
||||
transformCode: _opts.transformCode,
|
||||
},
|
||||
|
|
|
@ -26,7 +26,6 @@ type Options = {|
|
|||
hasteImplModulePath?: string,
|
||||
getClosestPackage: GetClosestPackageFn,
|
||||
roots: $ReadOnlyArray<string>,
|
||||
resetCache: boolean,
|
||||
transformCode: TransformCode,
|
||||
|};
|
||||
|
||||
|
@ -153,7 +152,6 @@ class ModuleCache {
|
|||
|
||||
_getModuleOptions() {
|
||||
return {
|
||||
resetCache: this._opts.resetCache,
|
||||
hasteImplModulePath: this._opts.hasteImplModulePath,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ export type Options = {|
|
|||
getPolyfills: ({platform: ?string}) => $ReadOnlyArray<string>,
|
||||
+getRunModuleStatement: (number | string) => string,
|
||||
getTransformOptions?: GetTransformOptions,
|
||||
globalTransformCache: ?GlobalTransformCache,
|
||||
globalTransformCache?: ?GlobalTransformCache,
|
||||
hasteImplModulePath?: string,
|
||||
maxWorkers?: number,
|
||||
minifierPath?: string,
|
||||
|
@ -107,7 +107,7 @@ export type Options = {|
|
|||
+getModulesRunBeforeMainModule: (entryPoint: string) => Array<string>,
|
||||
silent?: boolean,
|
||||
+sourceExts: ?Array<string>,
|
||||
+transformCache: TransformCache,
|
||||
+transformCache?: TransformCache,
|
||||
transformModulePath?: string,
|
||||
watch?: boolean,
|
||||
workerPath: ?string,
|
||||
|
|
Loading…
Reference in New Issue