-
Notifications
You must be signed in to change notification settings - Fork 8
/
rollup.config.js
82 lines (81 loc) · 2.42 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
81
82
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import dts from "rollup-plugin-dts";
import pkg from './package.json';
export default [
{
input: 'src/TestRail.ts',
external: ['stream'],
output: {
file: 'dist/TestRail.d.ts',
format: 'es',
footer: '\n// @ts-ignore\nexport = TestRail;',
},
plugins: [
dts.default(),
{
generateBundle(_, bundle) {
for (const file of Object.values(bundle)) {
file.code = file.code.replace(/declare const ([\w$]+): typeof (\w+);/g, 'type $1 = $2;');
}
}
}
],
},
{
input: 'src/TestRail.ts',
external: [],
output: [
{
file: pkg.browser,
format: 'es',
exports: 'default',
sourcemap: true,
},
{
file: pkg.jsdelivr,
format: 'umd',
exports: 'default',
sourcemap: true,
name: 'TestRail',
},
{
file: pkg.main,
format: 'cjs',
exports: 'default',
strict: false,
sourcemap: true,
banner: `'use strict';\n`
+ `const http = require('http');\n`
+ `const https = require('https');\n`
+ `const nodeFetch = require('node-fetch');\n`
+ `const FormData = require('form-data');\n\n`
+ `const options = { keepAlive: true };\n`
+ `const httpAgent = new http.Agent(options);\n`
+ `const httpsAgent = new https.Agent(options);\n`
+ `const agent = (url) => url.protocol === 'http:' ? httpAgent : httpsAgent;\n`
+ `const fetch = (url, init) => nodeFetch(url, { agent, ...init });\n`,
},
{
file: pkg.module,
format: 'es',
exports: 'default',
sourcemap: true,
banner: ``
+ `import http from 'http';\n`
+ `import https from 'https';\n`
+ `import nodeFetch from 'node-fetch';\n`
+ `import FormData from 'form-data';\n\n`
+ `const options = { keepAlive: true };\n`
+ `const httpAgent = new http.Agent(options);\n`
+ `const httpsAgent = new https.Agent(options);\n`
+ `const agent = (url) => url.protocol === 'http:' ? httpAgent : httpsAgent;\n`
+ `const fetch = (url, init) => nodeFetch(url, { agent, ...init });\n`,
},
],
plugins: [
typescript({ tsconfig: './tsconfig.json' }),
terser()
],
}
];