From 029483d796ec59223af8a933e5cc19fc26c7e224 Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Fri, 7 Jul 2017 04:01:34 -0700 Subject: [PATCH] metro-bundler: tweak babel-register callsite Summary: This fixes https://github.com/facebook/react-native/issues/14530 on my local repro. The reason the original problem appears is because when requiring the preset itself, what I think is a bug in babel-register kicks in and it starts transforming the presets themselves. That fails because these preset don't actually have the correct transforms plugins installed/specified in their `package.json` (they do it at prepublish time). Closes https://github.com/facebook/metro-bundler/pull/21 Reviewed By: cpojer Differential Revision: D5380795 Pulled By: jeanlauliac fbshipit-source-id: 023fd6b36dc7ebd26961878edd71d423ea9856b5 --- packages/metro-bundler/src/babelRegisterOnly.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/metro-bundler/src/babelRegisterOnly.js b/packages/metro-bundler/src/babelRegisterOnly.js index fbb839da..1e0cf109 100644 --- a/packages/metro-bundler/src/babelRegisterOnly.js +++ b/packages/metro-bundler/src/babelRegisterOnly.js @@ -13,6 +13,10 @@ require('./setupNodePolyfills'); var _only = []; function registerOnly(onlyList) { + // This prevents `babel-register` from transforming the code of the + // plugins/presets that we are require-ing themselves before setting up the + // actual config. + require('babel-register')({only: [], babelrc: false}); require('babel-register')(config(onlyList)); }