-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.ts
118 lines (110 loc) · 2.85 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { defineConfig } from 'rollup';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import json from '@rollup/plugin-json';
import cleanup from 'rollup-plugin-cleanup';
import { preserveShebangs } from 'rollup-plugin-preserve-shebangs';
const commonPlugins = [
// Allow json resolution
json(),
// Compile TypeScript files
typescript(),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
commonjs({ sourceMap: false }),
cleanup({ comments: ['srcmaps'] }),
];
// CLI for diff-builder
const cliConfig = defineConfig({
input: 'src/bin/cli.ts',
output: [
{
file: 'dist/bin/diff-builder',
name: 'diff-builder',
format: 'cjs',
sourcemap: false,
},
],
external: [
'fs',
'path',
'commander',
'child_process',
'os',
],
plugins: commonPlugins.concat([
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve({ preferBuiltins: false }),
preserveShebangs(),
]),
watch: {
include: 'src/**',
},
});
// diff-builder API
const builderApiConfig = defineConfig({
input: 'src/diff-builder/index.ts',
output: [
{
file: 'dist/api/builder/cjs/index.js',
format: 'cjs',
sourcemap: false,
},
{
file: 'dist/api/builder/es/index.js',
format: 'esm',
sourcemap: false,
},
],
external: [
'fs',
'path',
'crypto',
'child_process',
'os',
],
plugins: commonPlugins.concat([
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve({ preferBuiltins: false }),
]),
watch: {
include: 'src/**',
},
treeshake: {
moduleSideEffects: false,
},
});
// diff-updater API
const updaterApiConfig = defineConfig({
input: 'src/diff-updater/index.ts',
output: [
{
file: 'dist/api/updater/cjs/index.js',
format: 'cjs',
sourcemap: false,
},
{
file: 'dist/api/updater/es/index.js',
format: 'esm',
sourcemap: false,
},
],
plugins: commonPlugins.concat([
resolve({ browser: true }),
]),
watch: {
include: 'src/**',
},
treeshake: {
moduleSideEffects: false,
},
});
export default [
cliConfig,
builderApiConfig,
updaterApiConfig,
];