forked from rollup/rollup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.d.ts
260 lines (252 loc) · 5.8 KB
/
types.d.ts
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
import type { SourceMap } from 'magic-string';
import type { RollupBuild, RollupError, RollupLog, RollupOptions } from '../src/rollup/types';
export interface TestConfigBase {
/**
* Description of the test. Determines the name of the test in the test
* runner.
*/
description: string;
/**
* Only run this test if the major Node version is high enough.
*/
minNodeVersion?: number;
/**
* Only run this test on Windows.
*/
onlyWindows?: boolean;
/**
* Skip this test.
*/
skip?: boolean;
/**
* Do not run this test on Windows.
*/
skipIfWindows?: boolean;
/**
* Only run this test. Should never be committed.
*/
solo?: boolean;
}
export interface TestConfigBrowser extends TestConfigBase {
/**
* Expected error when running rollup.rollup()
*/
error?: RollupError;
/**
* Expected warning codes. Any of these warnings will not cause the test to
* fail.
*/
expectedWarnings?: string[];
/**
* Expected error when running bundle.generate().
*/
generateError?: RollupError;
/**
* Rollup options for bundling.
*/
options?: RollupOptions;
}
export interface TestConfigChunkingForm extends TestConfigBase {
/**
* Called after the test is run.
*/
after?: () => void;
/**
* Called before the test is run.
*/
before?: () => void;
/**
* Expected warning codes. Any of these warnings will not cause the test to
* fail.
*/
expectedWarnings?: string[];
/**
* Assert the expected logs.
*/
logs?: RollupLog[];
/**
* The directory to bundle the code in.
*/
nestedDir?: string;
/**
* Rollup options for bundling.
*/
options?: RollupOptions;
/**
* Execute the AMD module.
*/
runAmd?:
| boolean
| {
exports?: (exportObject: any) => void | Promise<void>;
};
}
export interface TestConfigCli extends TestConfigBase {
/**
* Assert the stderr stream, return true to abort the test.
*/
abortOnStderr?: (data: string) => boolean | void | Promise<boolean | void>;
/**
* Called after the test is run.
*/
after?: (error: Error | null, stdout: string, stderr: string) => void | Promise<void>;
/**
* Called before the test is run.
*/
before?: () => void | Promise<void>;
command?: string;
cwd?: string;
/**
* Environment variables to set for the test.
*/
env?: Record<string, string | boolean | undefined>;
/**
* Test the expected error. Assertions about the test output will only
* be performed afterward if you return "true" or do not supply this option.
*/
error?: (error: Error) => boolean | void;
/**
* Execute the bundled code.
*/
execute?: boolean;
/**
* Run assertions against the exports of the bundle after executing it.
*/
exports?: (exportObject: any) => void | Promise<void>;
/**
* Run assertions against the generated code when bundling to stdout.
*/
result?: (code: string) => void;
retry?: number;
/**
* Display generated output in console.
*/
show?: boolean;
/**
* Assert the stderr of the build. Assertions about the test output will only
* be performed afterward if you return "true" or do not supply this option.
*/
stderr?: (stderr: string) => boolean | undefined;
/**
* Run assertions after the command has finished.
*/
test?: () => void;
}
export interface TestConfigFileHash extends TestConfigBase {
options1: RollupOptions;
options2: RollupOptions;
}
export interface TestConfigForm extends TestConfigBase {
/**
* Called after the test is run.
*/
after?: () => void | Promise<void>;
/**
* Called before the test is run.
*/
before?: () => void | Promise<void>;
/**
* Expected warning codes. Any of these warnings will not cause the test to
* fail.
*/
expectedWarnings?: string[];
/**
* Output formats to test.
*/
formats?: string[];
/**
* Assert the expected logs.
*/
logs?: RollupLog[];
/**
* Rollup options for bundling.
*/
options?: RollupOptions;
/**
* Verify that the AST returned by SWC is the same as the one returned by
* Acorn. The default behavior is to verify.
*/
verifyAst?: boolean;
}
export interface TestConfigFunction extends TestConfigBase {
/**
* Called after the test is run.
*/
after?: () => void | Promise<void>;
/**
* Called before the test is run.
*/
before?: () => void | Promise<void>;
/**
* Make assertions against the generated Rollup output object.
*/
bundle?: (bundle: RollupBuild) => void | Promise<void>;
/**
* Make assertions against the generated code.
*/
code?: (code: string | Record<string, string>) => void;
/**
* Injected global variables and functions. You can also use this to mock
* "require" calls.
*/
context?: Record<string, any>;
/**
* Expected error when running rollup.rollup()
*/
error?: RollupError;
/**
* Assetions for the exports of the bundle.
*/
exports?: (exportObject: any) => void | Promise<void>;
/**
* Expected error when running bundle.generate().
*/
generateError?: RollupError;
/**
* Assert the expected logs.
*/
logs?: RollupLog[];
/**
* Rollup options for bundling.
*/
options?: RollupOptions;
/**
* Make assertions against an expected runtime error.
*/
runtimeError?: (error: Error) => void;
/**
* Display generated output in console.
*/
show?: boolean;
/**
* Make assertions on the expected warnings.
*/
warnings?: RollupError[] | ((warnings: RollupError[]) => boolean | void);
/**
* Verify that the AST returned by SWC is the same as the one returned by
* Acorn. The default behavior is to verify.
*/
verifyAst?: boolean;
}
export interface TestConfigSourcemap extends TestConfigBase {
/**
* Output formats to test.
*/
formats?: string[];
/**
* Rollup options for bundling.
*/
options?: RollupOptions;
/**
* Generate the bundle and run assertions.
*/
test: (
code: string,
map: SourceMap,
options: { fileName: string; format: string }
) => void | Promise<void>;
/**
* List expected warnings.
*/
warnings?: RollupError[];
}