forked from Zimbra/zm-api-js-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
61 lines (57 loc) · 2.16 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
import babel from 'rollup-plugin-babel';
import typescript from 'rollup-plugin-typescript2';
import graphql from 'rollup-plugin-graphql';
import localResolve from 'rollup-plugin-local-resolve';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import pkg from './package.json';
import * as graphqlType from 'graphql/type';
import * as graphqlLanguage from 'graphql/language';
import * as graphqlExecution from 'graphql/execution';
import * as graphqlSubscription from 'graphql/subscription';
import * as graphqlError from 'graphql/error';
import * as graphqlUtilities from 'graphql/utilities';
import * as graphqlValidators from 'graphql/validation';
let FORMAT = process.env.FORMAT;
// graphql-tools currently has a rollup build failure, so always call it an external until they fix it
// otherwise, make all npm production dependencies external, plus their subpath usages
// throughout the codebase, which rollup doesn't automatically pick up on
let external = FORMAT==='es' ?
Object.keys(pkg.dependencies)
.concat(
['castArray', 'get','isError', 'isObject', 'mapValues', 'reduce', 'omitBy', 'uniqBy', 'concat', 'uniqBy', 'differenceBy', 'forEach'].map(v => 'lodash/'+v),
['graphql/language/printer', 'graphql/type']) :
['graphql-tools'];
export default {
external,
context: 'commonjsGlobal', // what should "this" be at the top level when it is used by another module
plugins: [
graphql(),
localResolve(),
nodeResolve({
extensions: [ '.js', '.ts', '.json' ]
}),
commonjs({
namedExports: {
// 'graphql-tools': [ 'makeExecutableSchema' ],
'graphql/type': Object.keys(graphqlType),
'graphql/language': Object.keys(graphqlLanguage),
'graphql/execution': Object.keys(graphqlExecution),
'graphql/subscription': Object.keys(graphqlSubscription),
'graphql/error': Object.keys(graphqlError),
'graphql/utilities': Object.keys(graphqlUtilities),
'graphql/validation': Object.keys(graphqlValidators)
}
}),
typescript({
typescript: require('typescript')
}),
babel({
extensions: ['.ts'],
exclude: 'node_modules/**'
})
],
output: {
exports: FORMAT==='es' ? null : 'named'
},
};