forked from znck/grammarly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
126 lines (122 loc) · 3.23 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
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
119
120
121
122
123
124
125
126
import json from '@rollup/plugin-json'
import nodeResolve from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import typescript from '@rollup/plugin-typescript'
import size from 'rollup-plugin-filesize'
import dts from 'rollup-plugin-dts'
import Path from 'path'
function deps(fileName) {
return Array.from(Object.keys(require(fileName).dependencies || {}))
}
function abs(fileName) {
return Path.resolve(__dirname, fileName)
}
/** @type {import('rollup').RollupOptions[]} */
const configs = [
{
input: './packages/grammarly-api/src/index.ts',
output: {
format: 'esm',
file: './packages/grammarly-api/dist/index.d.ts',
},
plugins: [dts()],
},
{
input: './packages/grammarly-language-server/src/index.ts',
output: {
format: 'esm',
file: './packages/grammarly-language-server/dist/index.d.ts',
},
plugins: [dts()],
},
{
input: './packages/grammarly-language-client/src/index.ts',
output: {
format: 'esm',
file: './packages/grammarly-language-client/dist/index.d.ts',
},
plugins: [dts()],
},
{
input: './packages/grammarly-api/src/index.ts',
output: [
{
format: 'cjs',
file: './packages/grammarly-api/dist/index.cjs.js',
sourcemap: true,
},
{
format: 'esm',
file: './packages/grammarly-api/dist/index.esm.js',
sourcemap: true,
},
],
plugins: [
replace({
values: {
__DEV__: `process.env.NODE_ENV !== 'production'`,
},
}),
nodeResolve(),
json(),
typescript({ tsconfig: abs('./packages/grammarly-api/tsconfig.json') }),
size(),
],
external: [...deps('./packages/grammarly-api/package.json'), 'ws', 'util'],
},
{
input: './packages/grammarly-language-server/src/index.ts',
output: [
{
format: 'cjs',
file: './packages/grammarly-language-server/dist/index.cjs.js',
sourcemap: true,
},
{
format: 'esm',
file: './packages/grammarly-language-server/dist/index.esm.js',
sourcemap: true,
},
],
plugins: [
replace({
values: {
__DEV__: `process.env.NODE_ENV !== 'production'`,
},
}),
// nodeResolve(),
json(),
typescript({ tsconfig: abs('./packages/grammarly-language-server/tsconfig.json') }),
size(),
],
external: [...deps('./packages/grammarly-language-server/package.json'), 'crypto', 'util', 'events'],
},
{
input: './packages/grammarly-language-client/src/index.ts',
output: [
{
format: 'cjs',
file: './packages/grammarly-language-client/dist/index.cjs.js',
sourcemap: true,
},
{
format: 'esm',
file: './packages/grammarly-language-client/dist/index.esm.js',
sourcemap: true,
},
],
plugins: [
replace({
values: {
__DEV__: `process.env.NODE_ENV !== 'production'`,
},
}),
// nodeResolve(),
json(),
typescript({ tsconfig: abs('./packages/grammarly-language-client/tsconfig.json') }),
size(),
],
external: [...deps('./packages/grammarly-language-client/package.json')],
},
]
export default configs