diff --git a/packages/metro-bundler/src/Bundler/index.js b/packages/metro-bundler/src/Bundler/index.js index 0d338217..6d633950 100644 --- a/packages/metro-bundler/src/Bundler/index.js +++ b/packages/metro-bundler/src/Bundler/index.js @@ -564,7 +564,7 @@ class Bundler { }); } - getShallowDependencies({ + async getShallowDependencies({ entryFile, rootEntryFile, platform, @@ -572,6 +572,7 @@ class Bundler { minify = !dev, hot = false, generateSourceMaps = false, + bundlingOptions, }: { entryFile: string, +rootEntryFile: string, @@ -580,19 +581,24 @@ class Bundler { minify?: boolean, hot?: boolean, generateSourceMaps?: boolean, + bundlingOptions?: BundlingOptions, }): Promise> { - return this.getTransformOptions(rootEntryFile, { - enableBabelRCLookup: this._opts.enableBabelRCLookup, - dev, - generateSourceMaps, - hot, - minify, - platform, - projectRoots: this._projectRoots, - }).then(bundlingOptions => - this._resolverPromise.then(resolver => - resolver.getShallowDependencies(entryFile, bundlingOptions.transformer), - ), + if (!bundlingOptions) { + bundlingOptions = await this.getTransformOptions(rootEntryFile, { + enableBabelRCLookup: this._opts.enableBabelRCLookup, + dev, + generateSourceMaps, + hot, + minify, + platform, + projectRoots: this._projectRoots, + }); + } + + const notNullOptions = bundlingOptions; + + return this._resolverPromise.then(resolver => + resolver.getShallowDependencies(entryFile, notNullOptions.transformer), ); } diff --git a/packages/metro-bundler/src/Server/index.js b/packages/metro-bundler/src/Server/index.js index 0016cee0..0fc27019 100644 --- a/packages/metro-bundler/src/Server/index.js +++ b/packages/metro-bundler/src/Server/index.js @@ -33,6 +33,7 @@ const { import type Module, {HasteImpl} from '../node-haste/Module'; import type {IncomingMessage, ServerResponse} from 'http'; import type ResolutionResponse from '../node-haste/DependencyGraph/ResolutionResponse'; +import type {BundlingOptions} from '../Bundler'; import type Bundle from '../Bundler/Bundle'; import type HMRBundle from '../Bundler/HMRBundle'; import type {Reporter} from '../lib/reporting'; @@ -124,6 +125,7 @@ type DependencyOptions = {| +platform: ?string, +recursive: boolean, +rootEntryFile: string, + +bundlingOptions?: BundlingOptions, |}; type BuildInfo = {| @@ -342,7 +344,14 @@ class Server { options.platform != null ? options.platform : parsePlatformFilePath(options.entryFile, this._platforms).platform; - const {entryFile, dev, minify, hot, rootEntryFile} = options; + const { + entryFile, + dev, + minify, + hot, + rootEntryFile, + bundlingOptions, + } = options; return this._bundler.getShallowDependencies({ entryFile, rootEntryFile, @@ -351,6 +360,7 @@ class Server { minify, hot, generateSourceMaps: false, + bundlingOptions, }); }); }