-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrollup.config.js
42 lines (38 loc) · 1.33 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
import babel from '@rollup/plugin-babel';
import typescript from '@rollup/plugin-typescript';
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';
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', '@graphql-tools/schema']) :
['@graphql-tools/schema'];
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(),
typescript(),
babel({
extensions: ['.ts'],
exclude: 'node_modules/**',
babelHelpers: 'bundled'
})
],
output: {
exports: FORMAT==='es' ? null : 'named'
},
};