-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
87 lines (84 loc) · 2.02 KB
/
rollup.config.ts
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
import pkg from './package.json';
const babelRuntimeVersion = pkg.devDependencies['@babel/runtime'].replace(
/^[^0-9]*/,
''
);
const config = [
{
output: {
file: pkg.main,
format: 'cjs',
},
},
{
output: {
file: pkg.module,
format: 'es',
},
},
].map(({ output }) => ({
input: 'src/index.ts',
output,
treeshake: {
propertyReadSideEffects: false,
},
plugins: [
resolve(),
commonjs(),
typescript({
tsconfigDefaults: {
exclude: [
// all TS test files, regardless whether co-located or in test/ etc
'**/*.spec.ts',
'**/*.test.ts',
'**/*.spec.tsx',
'**/*.test.tsx',
// TS defaults below
'node_modules',
],
compilerOptions: {
sourceMap: false,
declaration: false,
jsx: 'react',
},
},
tsconfigOverride: {
compilerOptions: {
target: 'esnext',
declaration: false,
declarationMap: false,
emitDeclarationOnly: false,
},
},
}),
babel({
exclude: 'node_modules/**',
plugins: [
'@babel/plugin-transform-runtime',
{
version: babelRuntimeVersion,
useESModules: output.format === 'es',
},
],
babelHelpers: 'runtime',
}),
terser({
output: { comments: false },
compress: {
unsafe: true,
keep_infinity: true,
pure_getters: true,
passes: 10,
},
ecma: output.format === 'es' ? 2020 : 5,
}),
],
external: [...Object.keys(pkg.devDependencies)],
}));
export default config;