This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
80 lines (78 loc) · 2.5 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
const alias = require('@rollup/plugin-alias');
const replace = require('@rollup/plugin-replace');
const babel = require('rollup-plugin-babel');
const commonjs = require('rollup-plugin-commonjs');
const resolve = require('rollup-plugin-node-resolve');
// const visualizer = require('rollup-plugin-visualizer');
module.exports = [
{
input: 'src/circus-adapter.ts',
output: {
file: 'lib/circus-adapter.js',
format: 'iife',
intro:
'const process = { env: {}, cwd: () => "/" };\n' +
'const Buffer = () => {}',
sourcemap: true,
},
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
alias({
entries: {
'chalk': require.resolve('ansi-colors'),
'ansi-styles': require.resolve('./src/shims/ansi-styles.js'),
'micromatch': require.resolve('./src/shims/micromatch.js'),
// Node builtins
'assert': require.resolve('./src/shims/assert.js'),
'fs': require.resolve('./src/shims/empty-obj.js'),
'module': require.resolve('./src/shims/empty-obj.js'),
'process': require.resolve('./src/shims/empty-obj.js'),
'path': require.resolve(
'rollup-plugin-node-polyfills/polyfills/path',
),
'util': require.resolve(
'rollup-plugin-node-polyfills/polyfills/util',
),
// these are packages we've aliased and patched
// the reason for the yarn alias is so both the original
// and patched versions can exist during dev runs.
'jest-util': 'browser-jest-util',
'jest-snapshot': 'browser-jest-snapshot',
'jest-message-util': 'browser-jest-message-util',
},
}),
resolve({ browser: false, extensions: ['.js', '.ts'] }),
babel({ extensions: ['.js', '.ts'] }),
commonjs(),
// visualizer(),
],
},
{
input: 'src/index.ts',
output: {
file: 'lib/index.js',
format: 'cjs',
sourcemap: true,
},
external: (id) =>
!id.startsWith('.') && !id.startsWith('/') && !id.startsWith('\0'),
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
replace({
'delimiters': ["'", "'"],
'./circus-adapter.ts': '"./circus-adapter"',
}),
resolve({
browser: false,
extensions: ['.js', '.ts'],
preferBuiltins: true,
}),
babel({ extensions: ['.js', '.ts'] }),
commonjs(),
],
},
];