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
This commit is contained in:
Jean Lauliac 2017-07-07 04:01:34 -07:00 committed by Facebook Github Bot
parent 7450484d94
commit 029483d796
1 changed files with 4 additions and 0 deletions

View File

@ -13,6 +13,10 @@ require('./setupNodePolyfills');
var _only = []; var _only = [];
function registerOnly(onlyList) { 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)); require('babel-register')(config(onlyList));
} }