mirror of https://github.com/status-im/metro.git
Ensure correct Babel plugin locations in packager transform
Summary: Manually resolve all default Babel plugins. `babel.transform` will attempt to resolve all base plugins relative to the file it's compiling. This makes sure that we're using the plugins installed in the react-native package. **NOTE:** Haven't tested this. Please don't merge until Travis has done CI. Closes https://github.com/facebook/react-native/pull/4248 Reviewed By: svcscm Differential Revision: D2679651 Pulled By: davidaurelio fb-gh-sync-id: 0cdef1e738ba28c09c811432a71047f80540ed7b
This commit is contained in:
parent
b289600a7a
commit
b0b2a27b75
|
@ -37,6 +37,21 @@ function transform(src, filename, options) {
|
|||
}
|
||||
config.plugins = extraPlugins.concat(config.plugins);
|
||||
|
||||
// Manually resolve all default Babel plugins. babel.transform will attempt to resolve
|
||||
// all base plugins relative to the file it's compiling. This makes sure that we're
|
||||
// using the plugins installed in the react-native package.
|
||||
config.plugins = config.plugins.map(function(plugin) {
|
||||
// Normalise plugin to an array.
|
||||
if (!Array.isArray(plugin)) {
|
||||
plugin = [plugin];
|
||||
}
|
||||
// Only resolve the plugin if it's a string reference.
|
||||
if (typeof plugin[0] === 'string') {
|
||||
plugin[0] = require(`babel-plugin-${plugin[0]}`);
|
||||
}
|
||||
return plugin;
|
||||
});
|
||||
|
||||
const result = babel.transform(src, Object.assign({}, babelRC, config));
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue