diff --git a/packages/metro-bundler/src/Bundler/__tests__/Bundler-test.js b/packages/metro-bundler/src/Bundler/__tests__/Bundler-test.js index b4becd75..dd13c5ea 100644 --- a/packages/metro-bundler/src/Bundler/__tests__/Bundler-test.js +++ b/packages/metro-bundler/src/Bundler/__tests__/Bundler-test.js @@ -270,14 +270,20 @@ describe('Bundler', function() { // jest calledWith does not support jasmine.any expect(getDependencies.mock.calls[0].slice(0, -2)).toEqual([ '/root/foo.js', - {dev: true, recursive: true}, - {minify: false, + {dev: true, platform: undefined, recursive: true}, + { dev: true, + minify: false, + platform: undefined, transform: { dev: true, - hot: false, generateSourceMaps: false, + hot: false, + inlineRequires: false, + platform: undefined, + preloadedModules: undefined, projectRoots, + ramGroups: undefined, }, }, ]) diff --git a/packages/metro-bundler/src/Bundler/index.js b/packages/metro-bundler/src/Bundler/index.js index 3bba3e84..eb0252eb 100644 --- a/packages/metro-bundler/src/Bundler/index.js +++ b/packages/metro-bundler/src/Bundler/index.js @@ -751,22 +751,31 @@ class Bundler { getTransformOptions( mainModuleName: string, - options: { - dev?: boolean, - generateSourceMaps?: boolean, - hot?: boolean, + options: {| + dev: boolean, + generateSourceMaps: boolean, + hot: boolean, platform: string, projectRoots: Array, - }, + |}, ): Promise { const getDependencies = (entryFile: string) => this.getDependencies({...options, entryFile}) .then(r => r.dependencies.map(d => d.path)); - const extraOptions: Promise = this._getTransformOptions + const extraOptions: Promise = this._getTransformOptions ? this._getTransformOptions(mainModuleName, options, getDependencies) - : Promise.resolve(null); - return extraOptions.then(extraOpts => ({...options, ...extraOpts})); + : Promise.resolve({}); + return extraOptions.then(extraOpts => ({ + dev: options.dev, + generateSourceMaps: options.generateSourceMaps, + hot: options.hot, + inlineRequires: extraOpts.inlineRequires || false, + platform: options.platform, + preloadedModules: extraOpts.preloadedModules, + projectRoots: options.projectRoots, + ramGroups: extraOpts.ramGroups, + })); } getResolver(): Promise { diff --git a/packages/metro-bundler/src/JSTransformer/worker/worker.js b/packages/metro-bundler/src/JSTransformer/worker/worker.js index e29099e0..0e075651 100644 --- a/packages/metro-bundler/src/JSTransformer/worker/worker.js +++ b/packages/metro-bundler/src/JSTransformer/worker/worker.js @@ -18,7 +18,7 @@ const invariant = require('fbjs/lib/invariant'); const minify = require('./minify'); import type {LogEntry} from '../../Logger/Types'; -import type {Ast, SourceMap, TransformOptions as BabelTransformOptions} from 'babel-core'; +import type {Ast, SourceMap} from 'babel-core'; export type TransformedCode = { code: string, @@ -35,23 +35,23 @@ type Transformer = { ) => {ast: ?Ast, code: string, map: ?SourceMap} }; -export type TransformOptions = { +export type TransformOptions = {| +dev: boolean, +generateSourceMaps: boolean, +hot: boolean, +inlineRequires: {+blacklist: {[string]: true}} | boolean, +platform: string, - +preloadedModules?: Array | false, + +preloadedModules: ?Array | false, +projectRoots: Array, - +ramGroups?: Array, -} & BabelTransformOptions; + +ramGroups: ?Array, +|}; -export type Options = { +export type Options = {| +dev: boolean, +minify: boolean, +platform: string, +transform: TransformOptions, -}; +|}; export type Data = { result: TransformedCode, diff --git a/packages/metro-bundler/src/lib/ModuleTransport.js b/packages/metro-bundler/src/lib/ModuleTransport.js index 14133660..6f2fd801 100644 --- a/packages/metro-bundler/src/lib/ModuleTransport.js +++ b/packages/metro-bundler/src/lib/ModuleTransport.js @@ -19,7 +19,7 @@ type SourceMapOrMappings = MixedSourceMap | Array; type Metadata = { dependencies?: ?Array, dependencyPairs?: Array<[mixed, {path: string}]>, - preloaded?: boolean, + preloaded: ?boolean, }; class ModuleTransport {