From 50f0ade13df116dab38f8d6a224aaea9343543c2 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Tue, 18 Apr 2017 11:12:54 -0700 Subject: [PATCH] `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 --- packager/src/Bundler/index.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packager/src/Bundler/index.js b/packager/src/Bundler/index.js index 9ca16e0f5..3bba3e840 100644 --- a/packager/src/Bundler/index.js +++ b/packager/src/Bundler/index.js @@ -57,7 +57,7 @@ export type GetTransformOptions = ( mainModuleName: string, options: {}, getDependencies: string => Promise>, -) => ExtraTransformOptions | Promise; +) => Promise; 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 = 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 {