Skip to content

Commit

Permalink
Ensure correct Babel plugin locations in packager transform
Browse files Browse the repository at this point in the history
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 facebook#4248

Reviewed By: svcscm

Differential Revision: D2679651

Pulled By: davidaurelio

fb-gh-sync-id: 0cdef1e738ba28c09c811432a71047f80540ed7b
  • Loading branch information
sebmck authored and facebook-github-bot-6 committed Nov 20, 2015
1 parent 1195f9c commit 06e5140
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packager/transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 06e5140

Please sign in to comment.