1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | function resolvePlugins(plugins, prefix) {
|
18 | return plugins.map(plugin => resolvePlugin(plugin, prefix));
|
19 | }
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | function resolvePlugin(plugin, prefix = '@babel/plugin-') {
|
25 |
|
26 | if (!Array.isArray(plugin)) {
|
27 | plugin = [plugin];
|
28 | }
|
29 |
|
30 | if (typeof plugin[0] === 'string') {
|
31 | plugin[0] = require(prefix + plugin[0]);
|
32 | plugin[0] = plugin[0].__esModule ? plugin[0].default : plugin[0];
|
33 | }
|
34 | return plugin;
|
35 | }
|
36 |
|
37 | module.exports = resolvePlugins;
|
38 | module.exports.resolvePlugin = resolvePlugin;
|
39 | module.exports.resolvePluginAs = (prefix, plugin) =>
|
40 | resolvePlugin(plugin, prefix);
|
41 | module.exports.resolvePluginsAs = (prefix, plugins) =>
|
42 | resolvePlugins(plugins, prefix);
|