Remove unneeded params from `getTransformOptions()`

Reviewed By: jeanlauliac

Differential Revision: D5880687

fbshipit-source-id: ef9683b1272133a9b38005cb8ba43d80b9ac6ec8
This commit is contained in:
Rafael Oleza 2017-09-21 09:17:49 -07:00 committed by Facebook Github Bot
parent f700c9e54d
commit e736518c43
3 changed files with 17 additions and 21 deletions

View File

@ -580,7 +580,7 @@ class Bundler {
minify = !dev, minify = !dev,
hot = false, hot = false,
generateSourceMaps = false, generateSourceMaps = false,
bundlingOptions, transformerOptions,
}: { }: {
entryFile: string, entryFile: string,
+rootEntryFile: string, +rootEntryFile: string,
@ -589,25 +589,23 @@ class Bundler {
minify?: boolean, minify?: boolean,
hot?: boolean, hot?: boolean,
generateSourceMaps?: boolean, generateSourceMaps?: boolean,
bundlingOptions?: BundlingOptions, transformerOptions?: JSTransformerOptions,
}): Promise<Array<string>> { }): Promise<Array<string>> {
if (!bundlingOptions) { if (!transformerOptions) {
bundlingOptions = await this.getTransformOptions(rootEntryFile, { transformerOptions = (await this.getTransformOptions(rootEntryFile, {
enableBabelRCLookup: this._opts.enableBabelRCLookup,
dev, dev,
generateSourceMaps, generateSourceMaps,
hot, hot,
minify, minify,
platform, platform,
prependPolyfills: false, prependPolyfills: false,
projectRoots: this._projectRoots, })).transformer;
});
} }
const notNullOptions = bundlingOptions; const notNullOptions = transformerOptions;
return this._resolverPromise.then(resolver => 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( const bundlingOptions: BundlingOptions = await this.getTransformOptions(
rootEntryFile, rootEntryFile,
{ {
enableBabelRCLookup: this._opts.enableBabelRCLookup,
dev, dev,
platform, platform,
hot, hot,
generateSourceMaps, generateSourceMaps,
minify, minify,
projectRoots: this._projectRoots,
prependPolyfills, prependPolyfills,
}, },
); );
@ -885,20 +881,20 @@ class Bundler {
async getTransformOptions( async getTransformOptions(
mainModuleName: string, mainModuleName: string,
options: {| options: {|
enableBabelRCLookup: boolean,
dev: boolean, dev: boolean,
generateSourceMaps: boolean, generateSourceMaps: boolean,
hot: boolean, hot: boolean,
minify: boolean, minify: boolean,
platform: ?string, platform: ?string,
projectRoots: $ReadOnlyArray<string>,
+prependPolyfills: boolean, +prependPolyfills: boolean,
|}, |},
): Promise<BundlingOptions> { ): Promise<BundlingOptions> {
const getDependencies = (entryFile: string) => const getDependencies = (entryFile: string) =>
this.getDependencies({ this.getDependencies({
...options, ...options,
enableBabelRCLookup: this._opts.enableBabelRCLookup,
entryFile, entryFile,
projectRoots: this._projectRoots,
rootEntryFile: entryFile, rootEntryFile: entryFile,
prependPolyfills: false, prependPolyfills: false,
}).then(r => r.dependencies.map(d => d.path)); }).then(r => r.dependencies.map(d => d.path));
@ -920,13 +916,13 @@ class Bundler {
minify: options.minify, minify: options.minify,
platform, platform,
transform: { transform: {
enableBabelRCLookup: options.enableBabelRCLookup, enableBabelRCLookup: this._opts.enableBabelRCLookup,
dev, dev,
generateSourceMaps: options.generateSourceMaps, generateSourceMaps: options.generateSourceMaps,
hot, hot,
inlineRequires: transform.inlineRequires || false, inlineRequires: transform.inlineRequires || false,
platform, platform,
projectRoot: options.projectRoots[0], projectRoot: this._projectRoots[0],
}, },
}, },
preloadedModules: extraOptions.preloadedModules, preloadedModules: extraOptions.preloadedModules,

View File

@ -37,6 +37,7 @@ class DeltaCalculator extends EventEmitter {
_bundler: Bundler; _bundler: Bundler;
_resolver: Resolver; _resolver: Resolver;
_options: BundleOptions; _options: BundleOptions;
_transformerOptions: ?JSTransformerOptions;
_dependencies: Set<string> = new Set(); _dependencies: Set<string> = new Set();
_shallowDependencies: Map<string, Set<string>> = new Map(); _shallowDependencies: Map<string, Set<string>> = new Map();
@ -44,7 +45,6 @@ class DeltaCalculator extends EventEmitter {
_currentBuildPromise: ?Promise<DeltaResult>; _currentBuildPromise: ?Promise<DeltaResult>;
_dependencyPairs: Map<string, $ReadOnlyArray<[string, Module]>> = new Map(); _dependencyPairs: Map<string, $ReadOnlyArray<[string, Module]>> = new Map();
_modulesByName: Map<string, Module> = new Map(); _modulesByName: Map<string, Module> = new Map();
_lastBundlingOptions: ?BundlingOptions;
_inverseDependencies: Map<string, Set<string>> = new Map(); _inverseDependencies: Map<string, Set<string>> = new Map();
constructor(bundler: Bundler, resolver: Resolver, options: BundleOptions) { 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). * any module very fast (since the options object instance will be the same).
*/ */
getTransformerOptions(): JSTransformerOptions { getTransformerOptions(): JSTransformerOptions {
if (!this._lastBundlingOptions) { if (!this._transformerOptions) {
throw new Error('Calculate a bundle first'); 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 response = await this._getAllDependencies();
const currentDependencies = response.dependencies; const currentDependencies = response.dependencies;
this._lastBundlingOptions = response.options; this._transformerOptions = response.options.transformer;
currentDependencies.forEach(module => { currentDependencies.forEach(module => {
const dependencyPairs = response.getResolvedDependencyPairs(module); const dependencyPairs = response.getResolvedDependencyPairs(module);
@ -364,7 +364,7 @@ class DeltaCalculator extends EventEmitter {
entryFile: module.path, entryFile: module.path,
rootEntryFile: this._options.entryFile, rootEntryFile: this._options.entryFile,
generateSourceMaps: false, generateSourceMaps: false,
bundlingOptions: this._lastBundlingOptions || undefined, transformerOptions: this._transformerOptions || undefined,
}); });
return new Set(dependencies); return new Set(dependencies);

View File

@ -373,7 +373,7 @@ class Server {
minify, minify,
hot, hot,
generateSourceMaps: false, generateSourceMaps: false,
bundlingOptions, transformOptions: bundlingOptions && bundlingOptions.transformer,
}); });
}); });
} }