-
Notifications
You must be signed in to change notification settings - Fork 6
/
rollup.config.js
41 lines (37 loc) · 1.09 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
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 { visualizer } from 'rollup-plugin-visualizer';
const FORMAT = process.env.FORMAT;
const externalDeps = [
'@apollo/client',
'graphql',
'lodash',
'mitt'
];
const getExternalDeps = id => externalDeps.find(pkgName => id.includes('/node_modules/' + pkgName + '/'));
export default {
...(FORMAT==='es' && { external: getExternalDeps }),
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'
}),
...(process.env.visualize ? [visualizer({ open: true }) ] : [])
],
output: {
exports: FORMAT==='es' ? null : 'named'
}
};