`getTransformOptions` can only return promises

Summary: Changes the contract for `getTransformOptions` so that it has to return a promises. That allows call sites to get rid of special logic / wrapping.

Reviewed By: jeanlauliac

Differential Revision: D4905959

fbshipit-source-id: c7d434c0766984e25987de1d769594e7c922d691
This commit is contained in:
David Aurelio 2017-04-18 11:12:54 -07:00 committed by Facebook Github Bot
parent f47ed2b5b9
commit 50f0ade13d
1 changed files with 5 additions and 7 deletions

View File

@ -57,7 +57,7 @@ export type GetTransformOptions = (
mainModuleName: string,
options: {},
getDependencies: string => Promise<Array<string>>,
) => ExtraTransformOptions | Promise<ExtraTransformOptions>;
) => Promise<ExtraTransformOptions>;
type Asset = {
__packager_asset: boolean,
@ -762,13 +762,11 @@ class Bundler {
const getDependencies = (entryFile: string) =>
this.getDependencies({...options, entryFile})
.then(r => r.dependencies.map(d => d.path));
const extraOptions = this._getTransformOptions
const extraOptions: Promise<?ExtraTransformOptions> = this._getTransformOptions
? this._getTransformOptions(mainModuleName, options, getDependencies)
: null;
return Promise.resolve(extraOptions)
.then(extraOpts => {
return {...options, ...extraOpts};
});
: Promise.resolve(null);
return extraOptions.then(extraOpts => ({...options, ...extraOpts}));
}
getResolver(): Promise<Resolver> {