1 | /**
|
2 | * Copyright (c) 2015-present, Facebook, Inc.
|
3 | * All rights reserved.
|
4 | *
|
5 | * This source code is licensed under the BSD-style license found in the
|
6 | * LICENSE file in the root directory of this source tree. An additional grant
|
7 | * of patent rights can be found in the PATENTS file in the same directory.
|
8 | */
|
9 | ;
|
10 |
|
11 | /**
|
12 | * Manually resolve all default Babel plugins.
|
13 | * `babel.transform` will attempt to resolve all base plugins relative to
|
14 | * the file it's compiling. This makes sure that we're using the plugins
|
15 | * installed in the react-native package.
|
16 | */
|
17 | function resolvePlugins(plugins) {
|
18 | return plugins.map(function(plugin) {
|
19 | // Normalise plugin to an array.
|
20 | if (!Array.isArray(plugin)) {
|
21 | plugin = [plugin];
|
22 | }
|
23 | // Only resolve the plugin if it's a string reference.
|
24 | if (typeof plugin[0] === 'string') {
|
25 | plugin[0] = require('babel-plugin-' + plugin[0]);
|
26 | plugin[0] = plugin[0].__esModule ? plugin[0].default : plugin[0];
|
27 | }
|
28 | return plugin;
|
29 | });
|
30 | }
|
31 |
|
32 | module.exports = resolvePlugins;
|