forked from stainless-api/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
139 lines (126 loc) · 3.11 KB
/
types.ts
File metadata and controls
139 lines (126 loc) · 3.11 KB
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
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import type { RawSourceMap } from 'source-map';
/**
* Request to the minifier
* @public
*/
export interface IModuleMinificationRequest {
/**
* Identity of the request. Will be included in the response.
*/
hash: string;
/**
* The raw code fragment
*/
code: string;
/**
* File name to show for the source code in the source map
*/
nameForMap: string | undefined;
/**
* Reserved variable names, e.g. __WEBPACK_EXTERNAL_MODULE_1__
*/
externals: string[] | undefined;
}
/**
* Result from the minifier function when an error is encountered.
* @public
*/
export interface IModuleMinificationErrorResult {
/**
* Identity of the request
*/
hash: string;
/**
* The error encountered, to be added to the current compilation's error collection.
*/
error: Error;
/**
* Marker property to always return the same result shape.
*/
code?: undefined;
/**
* Marker property to always return the same result shape.
*/
map?: undefined;
}
/**
* Result from the minifier on a successful minification.
* @public
*/
export interface IModuleMinificationSuccessResult {
/**
* Identity of the request
*/
hash: string;
/**
* The error property being `undefined` indicates success.
*/
error: undefined;
/**
* The minified code.
*/
code: string;
/**
* Marker property to always return the same result shape.
*/
map?: RawSourceMap;
}
/**
* Result from the minifier.
* @public
*/
export type IModuleMinificationResult = IModuleMinificationErrorResult | IModuleMinificationSuccessResult;
/**
* Callback passed to a minifier function
* @public
*/
export interface IModuleMinificationCallback {
(result: IModuleMinificationResult): void;
}
/**
* An async function called to minify a chunk of code
* @public
*/
export interface IModuleMinifierFunction {
(request: IModuleMinificationRequest, callback: IModuleMinificationCallback): void;
}
/**
* Metadata from the minifier for the plugin
* @public
*/
export interface IMinifierConnection {
/**
* Hash of the configuration of this minifier, for cache busting.
*/
configHash: string;
/**
* @deprecated Use {@link IMinifierConnection.disconnectAsync} instead.
*/
disconnect(): Promise<void>;
/**
* Callback to be invoked when done with the minifier
*/
disconnectAsync(): Promise<void>;
}
/**
* Object that can be invoked to minify code.
* @public
*/
export interface IModuleMinifier {
/**
* Asynchronously minify a module
*/
minify: IModuleMinifierFunction;
/**
* @deprecated Use {@link IModuleMinifier.connectAsync} instead.
*/
connect(): Promise<IMinifierConnection>;
/**
* Prevents the minifier from shutting down until the returned `disconnect()` callback is invoked.
* The callback may be used to surface errors encountered by the minifier that may not be relevant to a specific file.
* It should be called to allow the minifier to cleanup
*/
connectAsync(): Promise<IMinifierConnection>;
}