-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.js
40 lines (30 loc) · 998 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var babelPresetEs2015,
commonJsPlugin,
es2015PluginList,
es2015WebpackPluginList;
babelPresetEs2015 = require('babel-preset-es2015');
try {
// npm ^3
commonJsPlugin = require('babel-plugin-transform-es2015-modules-commonjs');
} catch (error) {
}
if (!commonJsPlugin) {
try {
// npm ^2
commonJsPlugin = require('babel-preset-es2015/node_modules/babel-plugin-transform-es2015-modules-commonjs');
} catch (error) {
}
}
if (!commonJsPlugin) {
throw new Error('Cannot resolve "babel-plugin-transform-es2015-modules-commonjs".');
}
es2015PluginList = babelPresetEs2015.plugins;
es2015WebpackPluginList = es2015PluginList.filter(function (es2015Plugin) {
return es2015Plugin !== commonJsPlugin;
});
if (es2015PluginList.length !== es2015WebpackPluginList.length + 1) {
throw new Error('Cannot remove "babel-plugin-transform-es2015-modules-commonjs" from the plugin list.');
}
module.exports = {
plugins: es2015WebpackPluginList
};