mirror of https://github.com/status-im/metro.git
Remove unneeded params from `getTransformOptions()`
Reviewed By: jeanlauliac Differential Revision: D5880687 fbshipit-source-id: ef9683b1272133a9b38005cb8ba43d80b9ac6ec8
This commit is contained in:
parent
f700c9e54d
commit
e736518c43
|
@ -580,7 +580,7 @@ class Bundler {
|
|||
minify = !dev,
|
||||
hot = false,
|
||||
generateSourceMaps = false,
|
||||
bundlingOptions,
|
||||
transformerOptions,
|
||||
}: {
|
||||
entryFile: string,
|
||||
+rootEntryFile: string,
|
||||
|
@ -589,25 +589,23 @@ class Bundler {
|
|||
minify?: boolean,
|
||||
hot?: boolean,
|
||||
generateSourceMaps?: boolean,
|
||||
bundlingOptions?: BundlingOptions,
|
||||
transformerOptions?: JSTransformerOptions,
|
||||
}): Promise<Array<string>> {
|
||||
if (!bundlingOptions) {
|
||||
bundlingOptions = await this.getTransformOptions(rootEntryFile, {
|
||||
enableBabelRCLookup: this._opts.enableBabelRCLookup,
|
||||
if (!transformerOptions) {
|
||||
transformerOptions = (await this.getTransformOptions(rootEntryFile, {
|
||||
dev,
|
||||
generateSourceMaps,
|
||||
hot,
|
||||
minify,
|
||||
platform,
|
||||
prependPolyfills: false,
|
||||
projectRoots: this._projectRoots,
|
||||
});
|
||||
})).transformer;
|
||||
}
|
||||
|
||||
const notNullOptions = bundlingOptions;
|
||||
const notNullOptions = transformerOptions;
|
||||
|
||||
return this._resolverPromise.then(resolver =>
|
||||
resolver.getShallowDependencies(entryFile, notNullOptions.transformer),
|
||||
resolver.getShallowDependencies(entryFile, notNullOptions),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -645,13 +643,11 @@ class Bundler {
|
|||
const bundlingOptions: BundlingOptions = await this.getTransformOptions(
|
||||
rootEntryFile,
|
||||
{
|
||||
enableBabelRCLookup: this._opts.enableBabelRCLookup,
|
||||
dev,
|
||||
platform,
|
||||
hot,
|
||||
generateSourceMaps,
|
||||
minify,
|
||||
projectRoots: this._projectRoots,
|
||||
prependPolyfills,
|
||||
},
|
||||
);
|
||||
|
@ -885,20 +881,20 @@ class Bundler {
|
|||
async getTransformOptions(
|
||||
mainModuleName: string,
|
||||
options: {|
|
||||
enableBabelRCLookup: boolean,
|
||||
dev: boolean,
|
||||
generateSourceMaps: boolean,
|
||||
hot: boolean,
|
||||
minify: boolean,
|
||||
platform: ?string,
|
||||
projectRoots: $ReadOnlyArray<string>,
|
||||
+prependPolyfills: boolean,
|
||||
|},
|
||||
): Promise<BundlingOptions> {
|
||||
const getDependencies = (entryFile: string) =>
|
||||
this.getDependencies({
|
||||
...options,
|
||||
enableBabelRCLookup: this._opts.enableBabelRCLookup,
|
||||
entryFile,
|
||||
projectRoots: this._projectRoots,
|
||||
rootEntryFile: entryFile,
|
||||
prependPolyfills: false,
|
||||
}).then(r => r.dependencies.map(d => d.path));
|
||||
|
@ -920,13 +916,13 @@ class Bundler {
|
|||
minify: options.minify,
|
||||
platform,
|
||||
transform: {
|
||||
enableBabelRCLookup: options.enableBabelRCLookup,
|
||||
enableBabelRCLookup: this._opts.enableBabelRCLookup,
|
||||
dev,
|
||||
generateSourceMaps: options.generateSourceMaps,
|
||||
hot,
|
||||
inlineRequires: transform.inlineRequires || false,
|
||||
platform,
|
||||
projectRoot: options.projectRoots[0],
|
||||
projectRoot: this._projectRoots[0],
|
||||
},
|
||||
},
|
||||
preloadedModules: extraOptions.preloadedModules,
|
||||
|
|
|
@ -37,6 +37,7 @@ class DeltaCalculator extends EventEmitter {
|
|||
_bundler: Bundler;
|
||||
_resolver: Resolver;
|
||||
_options: BundleOptions;
|
||||
_transformerOptions: ?JSTransformerOptions;
|
||||
|
||||
_dependencies: Set<string> = new Set();
|
||||
_shallowDependencies: Map<string, Set<string>> = new Map();
|
||||
|
@ -44,7 +45,6 @@ class DeltaCalculator extends EventEmitter {
|
|||
_currentBuildPromise: ?Promise<DeltaResult>;
|
||||
_dependencyPairs: Map<string, $ReadOnlyArray<[string, Module]>> = new Map();
|
||||
_modulesByName: Map<string, Module> = new Map();
|
||||
_lastBundlingOptions: ?BundlingOptions;
|
||||
_inverseDependencies: Map<string, Set<string>> = new Map();
|
||||
|
||||
constructor(bundler: Bundler, resolver: Resolver, options: BundleOptions) {
|
||||
|
@ -124,10 +124,10 @@ class DeltaCalculator extends EventEmitter {
|
|||
* any module very fast (since the options object instance will be the same).
|
||||
*/
|
||||
getTransformerOptions(): JSTransformerOptions {
|
||||
if (!this._lastBundlingOptions) {
|
||||
if (!this._transformerOptions) {
|
||||
throw new Error('Calculate a bundle first');
|
||||
}
|
||||
return this._lastBundlingOptions.transformer;
|
||||
return this._transformerOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -274,7 +274,7 @@ class DeltaCalculator extends EventEmitter {
|
|||
const response = await this._getAllDependencies();
|
||||
const currentDependencies = response.dependencies;
|
||||
|
||||
this._lastBundlingOptions = response.options;
|
||||
this._transformerOptions = response.options.transformer;
|
||||
|
||||
currentDependencies.forEach(module => {
|
||||
const dependencyPairs = response.getResolvedDependencyPairs(module);
|
||||
|
@ -364,7 +364,7 @@ class DeltaCalculator extends EventEmitter {
|
|||
entryFile: module.path,
|
||||
rootEntryFile: this._options.entryFile,
|
||||
generateSourceMaps: false,
|
||||
bundlingOptions: this._lastBundlingOptions || undefined,
|
||||
transformerOptions: this._transformerOptions || undefined,
|
||||
});
|
||||
|
||||
return new Set(dependencies);
|
||||
|
|
|
@ -373,7 +373,7 @@ class Server {
|
|||
minify,
|
||||
hot,
|
||||
generateSourceMaps: false,
|
||||
bundlingOptions,
|
||||
transformOptions: bundlingOptions && bundlingOptions.transformer,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue