-
Notifications
You must be signed in to change notification settings - Fork 198
/
rollup-tests.config.js
92 lines (88 loc) · 2.82 KB
/
rollup-tests.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
import { babel } from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import virtual from '@rollup/plugin-virtual';
import { readFileSync } from 'fs';
import { string } from 'rollup-plugin-string';
export default {
input: 'build/scripts/test-inputs.js', // Input file generated by gulp task
output: {
file: 'build/scripts/tests.bundle.js',
format: 'es',
sourcemap: true,
},
treeshake: false,
// Suppress a warning (https://rollupjs.org/guide/en/#error-this-is-undefined)
// due to https://github.com/babel/babel/issues/9149.
//
// Any code string other than "undefined" which evaluates to `undefined` will work here.
context: 'void(0)',
plugins: [
// Replace some problematic dependencies which are imported but not actually
// used with stubs. Per @rollup/plugin-virtual's docs, this must be listed
// first.
virtual({
// Enzyme dependency used in its "Static Rendering" mode, which we don't use.
'cheerio/lib/utils': '',
cheerio: '',
// Node modules that are not available in the browser.
crypto: '',
util: '',
}),
replace({
preventAssignment: true,
values: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
__VERSION__: JSON.parse(readFileSync('./package.json').toString())
.version,
},
}),
nodeResolve({
browser: true,
extensions: ['.js', '.ts', '.tsx'],
// Disallow use of browser polyfills for Node builtin modules. We're
// trying to avoid dependencies which rely on these.
//
// There are a couple of references to Node builtins that are stubbed by
// configuration for the `virtual` plugin above.
preferBuiltins: false,
}),
commonjs({
include: 'node_modules/**',
}),
string({
include: '**/*.{html,svg}',
}),
json(),
// The Babel transform generates additional code for code coverage.
// Place it last to minimize amount of code parsed by subsequent plugins.
babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**',
extensions: ['.js', '.ts', '.tsx'],
presets: [
[
'@babel/preset-react',
{
// Turn off the `development` setting in tests to prevent warnings
// about `this`. See https://github.com/babel/babel/issues/9149.
development: false,
runtime: 'automatic',
importSource: 'preact',
},
],
],
plugins: [
'mockable-imports',
[
'babel-plugin-istanbul',
{
exclude: ['**/test/**/*.js', '**/test-util/**'],
},
],
],
}),
],
};