From 9194b9da80b9c7e1bd31d5ecffa981f34e6baf3a Mon Sep 17 00:00:00 2001 From: James Ide Date: Wed, 26 Jul 2017 15:28:20 -0700 Subject: [PATCH] Control whether Metro tells Babel to lookup .babelrc files Summary: This adds support to RN's configuration file to let people turn off Babel's behavior of looking up .babelrc files. Most of the support for this feature is in Metro (https://github.com/facebook/metro-bundler/pull/31). Closes https://github.com/facebook/react-native/pull/15136 Differential Revision: D5483241 Pulled By: jeanlauliac fbshipit-source-id: c78096c1574c9f844c9f34aff73e6f97cb0b5e45 --- local-cli/server/runServer.js | 1 + local-cli/util/Config.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/local-cli/server/runServer.js b/local-cli/server/runServer.js index 1541e0e5cfffe4..90e92e70dd7517 100644 --- a/local-cli/server/runServer.js +++ b/local-cli/server/runServer.js @@ -158,6 +158,7 @@ function getPackagerServer(args, config) { assetExts: defaultAssetExts.concat(args.assetExts), blacklistRE: config.getBlacklistRE(), cacheVersion: '3', + enableBabelRCLookup: config.getEnableBabelRCLookup(), extraNodeModules: config.extraNodeModules, getTransformOptions: config.getTransformOptions, hasteImpl: config.hasteImpl, diff --git a/local-cli/util/Config.js b/local-cli/util/Config.js index 3085969f86ffc4..24d618a4a4590f 100644 --- a/local-cli/util/Config.js +++ b/local-cli/util/Config.js @@ -49,6 +49,13 @@ export type ConfigT = { */ getBlacklistRE(): RegExp, + /** + * Specify whether or not to enable Babel's behavior for looking up .babelrc + * files. If false, only the .babelrc file (if one exists) in the main project + * root is used. + */ + getEnableBabelRCLookup(): boolean, + /** * Specify any additional polyfill modules that should be processed * before regular module loading. @@ -158,6 +165,7 @@ const Config = { extraNodeModules: Object.create(null), getAssetExts: () => [], getBlacklistRE: () => blacklist(), + getEnableBabelRCLookup: () => true, getPlatforms: () => [], getPolyfillModuleNames: () => [], getProjectRoots: () => {