-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrollup.config.js
51 lines (47 loc) · 1.49 KB
/
rollup.config.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
41
42
43
44
45
46
47
48
49
50
51
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import nodeResolve from '@rollup/plugin-node-resolve';
import { readdirSync } from 'fs';
import path from 'path';
import executable from 'rollup-plugin-executable';
const getCommands = (dir) => {
const result = [];
const commands = readdirSync(dir, { withFileTypes: true });
commands.forEach(item => {
if (item.isDirectory()) {
result.push(...getCommands(path.join(dir, item.name)));
} else if (item.name.endsWith('ts')) {
result.push(path.join(dir, item.name));
}
});
return result;
}
const commands = getCommands('./src/commands');
export default [
...[ 'index.js', ...commands.map(item => item.replace('src/', '').replace('ts', 'js')) ].map(file => ({
input: `./dist/src/${file}`,
output: {
file: `./lib/${file}`,
format: 'es',
sourcemap: 'inline'
},
external: [ /node_modules/ ],
plugins: [
json(),
commonjs(),
nodeResolve({
preferBuiltins: true
}),
executable()
],
onwarn(warning, rollupWarn) {
// Remove some of the warnings noise:
// - CIRCULAR_DEPENDENCY -> not sure if this is an issue
// - THIS_IS_UNDEFINED -> result of using typescript polyfills
// - EVAL -> sometimes people just use eval. Deal with it.
if (warning.code !== 'CIRCULAR_DEPENDENCY' && warning.code !== 'THIS_IS_UNDEFINED' && warning.code !== 'EVAL') {
rollupWarn(warning);
}
}
}))
]