diff --git a/packages/metro-bundler/src/Bundler/__tests__/Bundler-test.js b/packages/metro-bundler/src/Bundler/__tests__/Bundler-test.js index a14a971c..2f107604 100644 --- a/packages/metro-bundler/src/Bundler/__tests__/Bundler-test.js +++ b/packages/metro-bundler/src/Bundler/__tests__/Bundler-test.js @@ -41,6 +41,7 @@ var commonOptions = { allowBundleUpdates: false, assetExts: defaults.assetExts, cacheVersion: 'smth', + enableBabelRCLookup: true, extraNodeModules: {}, platforms: defaults.platforms, resetCache: false, @@ -176,6 +177,7 @@ describe('Bundler', function() { minify: false, platform: undefined, transform: { + enableBabelRCLookup: true, dev: true, generateSourceMaps: false, hot: false, diff --git a/packages/metro-bundler/src/Bundler/index.js b/packages/metro-bundler/src/Bundler/index.js index 2b979480..0109abe8 100644 --- a/packages/metro-bundler/src/Bundler/index.js +++ b/packages/metro-bundler/src/Bundler/index.js @@ -124,6 +124,7 @@ type Options = {| +assetServer: AssetServer, +blacklistRE?: RegExp, +cacheVersion: string, + +enableBabelRCLookup: boolean, +extraNodeModules: {}, +getPolyfills: ({platform: ?string}) => $ReadOnlyArray, +getTransformOptions?: GetTransformOptions, @@ -545,6 +546,7 @@ class Bundler { return this.getTransformOptions( entryFile, { + enableBabelRCLookup: this._opts.enableBabelRCLookup, dev, generateSourceMaps, hot, @@ -587,6 +589,7 @@ class Bundler { const bundlingOptions: BundlingOptions = await this.getTransformOptions( entryFile, { + enableBabelRCLookup: this._opts.enableBabelRCLookup, dev, platform, hot, @@ -797,6 +800,7 @@ class Bundler { async getTransformOptions( mainModuleName: string, options: {| + enableBabelRCLookup: boolean, dev: boolean, generateSourceMaps: boolean, hot: boolean, @@ -822,6 +826,7 @@ class Bundler { minify: options.minify, platform, transform: { + enableBabelRCLookup: options.enableBabelRCLookup, dev, generateSourceMaps: options.generateSourceMaps, hot, diff --git a/packages/metro-bundler/src/JSTransformer/worker/index.js b/packages/metro-bundler/src/JSTransformer/worker/index.js index 914e7b0d..a25913f7 100644 --- a/packages/metro-bundler/src/JSTransformer/worker/index.js +++ b/packages/metro-bundler/src/JSTransformer/worker/index.js @@ -43,6 +43,7 @@ export type Transformer = { }; export type TransformOptionsStrict = {| + +enableBabelRCLookup: boolean, +dev: boolean, +generateSourceMaps: boolean, +hot: boolean, @@ -52,6 +53,7 @@ export type TransformOptionsStrict = {| |}; export type TransformOptions = { + +enableBabelRCLookup?: boolean, +dev?: boolean, +generateSourceMaps?: boolean, +hot?: boolean, diff --git a/packages/metro-bundler/src/Server/index.js b/packages/metro-bundler/src/Server/index.js index bc38cb26..afd3eb1a 100644 --- a/packages/metro-bundler/src/Server/index.js +++ b/packages/metro-bundler/src/Server/index.js @@ -70,6 +70,7 @@ type Options = { assetExts?: Array, blacklistRE?: RegExp, cacheVersion?: string, + enableBabelRCLookup?: boolean, extraNodeModules?: {}, getPolyfills: ({platform: ?string}) => $ReadOnlyArray, getTransformOptions?: GetTransformOptions, @@ -131,6 +132,7 @@ class Server { assetExts: Array, blacklistRE: void | RegExp, cacheVersion: string, + enableBabelRCLookup: boolean, extraNodeModules: {}, getPolyfills: ({platform: ?string}) => $ReadOnlyArray, getTransformOptions?: GetTransformOptions, @@ -176,6 +178,10 @@ class Server { assetExts: options.assetExts || defaults.assetExts, blacklistRE: options.blacklistRE, cacheVersion: options.cacheVersion || '1.0', + enableBabelRCLookup: + options.enableBabelRCLookup != null + ? options.enableBabelRCLookup + : true, extraNodeModules: options.extraNodeModules || {}, getPolyfills: options.getPolyfills, getTransformOptions: options.getTransformOptions, diff --git a/packages/metro-bundler/src/index.js b/packages/metro-bundler/src/index.js index 2729a957..829bcb12 100644 --- a/packages/metro-bundler/src/index.js +++ b/packages/metro-bundler/src/index.js @@ -36,6 +36,7 @@ type Options = {| +sourceExts: ?Array, +transformCache: TransformCache, +transformModulePath: string, + enableBabelRCLookup?: boolean, getPolyfills: ({platform: ?string}) => $ReadOnlyArray, globalTransformCache: ?GlobalTransformCache, hasteImpl?: HasteImpl, diff --git a/packages/metro-bundler/src/transformer.js b/packages/metro-bundler/src/transformer.js index 54ed8bd5..c0b0ab34 100644 --- a/packages/metro-bundler/src/transformer.js +++ b/packages/metro-bundler/src/transformer.js @@ -87,6 +87,9 @@ function buildBabelConfig(filename, options) { const babelRC = getBabelRC(options.projectRoot); const extraConfig = { + babelrc: typeof options.enableBabelRCLookup === 'boolean' + ? options.enableBabelRCLookup + : true, code: false, filename, };