From 4877acd35c45e83f97cdb70c1eee7477b6dbc790 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Tue, 9 May 2017 13:40:09 -0700 Subject: [PATCH] Custom build options: Move transform options into own property Summary: Moves custom transform options into their own property when returning custom properties. This helps both transitioning to a `select` function as well as implementing RAM bundle support for the new buck integration Reviewed By: jeanlauliac Differential Revision: D5028075 fbshipit-source-id: 25fe3072023cc063deef537a12012d4bb3173579 --- packages/metro-bundler/src/Bundler/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/metro-bundler/src/Bundler/index.js b/packages/metro-bundler/src/Bundler/index.js index 371cda2a..d64820e9 100644 --- a/packages/metro-bundler/src/Bundler/index.js +++ b/packages/metro-bundler/src/Bundler/index.js @@ -53,11 +53,11 @@ export type BundlingOptions = {| +transformer: JSTransformerOptions, |}; -export type ExtraTransformOptions = {| - +inlineRequires?: {+blacklist: {[string]: true}} | boolean, +export type ExtraTransformOptions = { +preloadedModules?: {[path: string]: true} | false, +ramGroups?: Array, -|}; + +transform?: {+inlineRequires?: {+blacklist: {[string]: true}} | boolean}, +}; export type GetTransformOptionsOpts = {| dev: boolean, @@ -799,9 +799,12 @@ class Bundler { .then(r => r.dependencies.map(d => d.path)); const {dev, hot, platform} = options; - const extraOptions = this._getTransformOptions + const extraOptions: ExtraTransformOptions = this._getTransformOptions ? await this._getTransformOptions(mainModuleName, {dev, hot, platform}, getDependencies) : {}; + + const {transform = {}} = extraOptions; + return { transformer: { dev, @@ -811,7 +814,7 @@ class Bundler { dev, generateSourceMaps: options.generateSourceMaps, hot, - inlineRequires: extraOptions.inlineRequires || false, + inlineRequires: transform.inlineRequires || false, platform, projectRoot: options.projectRoots[0], }