forked from apollographql/apollo-link
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
105 lines (98 loc) · 2.34 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
import sourcemaps from 'rollup-plugin-sourcemaps';
import node from 'rollup-plugin-node-resolve';
import typescript from 'typescript';
import typescriptPlugin from 'rollup-plugin-typescript2';
import invariantPlugin from 'rollup-plugin-invariant';
export const globals = {
// Apollo
'apollo-client': 'apollo.core',
'apollo-link': 'apolloLink.core',
'apollo-link-batch': 'apolloLink.batch',
'apollo-link-http-common': 'apolloLink.httpCommon',
'apollo-utilities': 'apolloUtilities',
'zen-observable-ts': 'apolloLink.zenObservable',
'subscriptions-transport-ws': 'subscriptions-transport-ws',
// GraphQL
'graphql/language/printer': 'graphql.printer',
'graphql/execution/execute': 'graphql.execute',
// TypeScript
'tslib': 'tslib',
// Other
'ts-invariant': 'invariant',
'zen-observable': 'Observable',
};
export default name => [
{
input: 'src/index.ts',
output: {
file: 'lib/bundle.umd.js',
format: 'umd',
name: `apolloLink.${name}`,
globals,
sourcemap: true,
exports: 'named',
},
external: Object.keys(globals),
onwarn,
plugins: [
node({ module: true }),
typescriptPlugin({
typescript,
tsconfig: './tsconfig.json',
tsconfigOverride: {
compilerOptions: {
module: "es2015",
},
},
}),
invariantPlugin({
errorCodes: true,
}),
sourcemaps()
],
},
{
input: 'src/index.ts',
output: {
file: 'lib/bundle.esm.js',
format: 'esm',
globals,
sourcemap: true,
},
external: Object.keys(globals),
onwarn,
plugins: [
node({ module: true }),
typescriptPlugin({
typescript,
tsconfig: './tsconfig.json',
tsconfigOverride: {
compilerOptions: {
module: "es2015",
},
},
}),
invariantPlugin({
errorCodes: true,
}),
sourcemaps()
],
},
{
input: 'lib/bundle.esm.js',
output: {
file: 'lib/bundle.cjs.js',
format: 'cjs',
globals,
sourcemap: true,
},
external: Object.keys(globals),
onwarn,
}
];
export function onwarn(message) {
const suppressed = ['UNRESOLVED_IMPORT', 'THIS_IS_UNDEFINED'];
if (!suppressed.find(code => message.code === code)) {
return console.warn(message.message);
}
}