1
- import * as CleanCSS from "clean-css" ;
2
- import RelateUrl = require ( "relateurl" ) ;
1
+ import type * as CleanCSS from "clean-css" ;
2
+ import type * as RelateUrl from "relateurl" ;
3
3
import type * as Terser from "terser" with { "resolution-mode" : "import" } ;
4
4
5
- export function minify ( value : string , options ?: MinifierOptions ) : Promise < string > ;
6
-
7
- declare namespace _default {
8
- export { type MinifierOptions , minify } ;
9
- }
10
-
11
- export { _default as default } ;
12
-
13
5
/**
14
6
* Most of the options are disabled by default
15
7
*/
16
8
export interface MinifierOptions {
17
9
/**
18
- * Treat attributes in case sensitive manner (useful for custom HTML tags)
10
+ * Treat attributes in case- sensitive manner (useful for custom HTML tags)
19
11
* @default false
20
12
*/
21
13
caseSensitive ?: boolean ;
@@ -119,12 +111,24 @@ export interface MinifierOptions {
119
111
*/
120
112
includeAutoGeneratedTags ?: boolean ;
121
113
114
+ /**
115
+ * Array of custom element names to treat as inline, along with the built-in ones
116
+ * @default []
117
+ */
118
+ inlineCustomElements ?: ArrayLike < string > ;
119
+
122
120
/**
123
121
* Keep the trailing slash on singleton elements
124
122
* @default false
125
123
*/
126
124
keepClosingSlash ?: boolean ;
127
125
126
+ /**
127
+ * Function for logging (`message` is usually a string or an Error)
128
+ * @default undefined
129
+ */
130
+ log ?: ( message : unknown ) => void ;
131
+
128
132
/**
129
133
* Maximum input length to prevent ReDoS attacks (disabled by default)
130
134
* @default undefined
@@ -143,26 +147,23 @@ export interface MinifierOptions {
143
147
*
144
148
* @default false
145
149
*/
146
- minifyCSS ?: boolean | CleanCSS . Options | ( ( text : string , type ?: string ) => string ) ;
150
+ minifyCSS ?: boolean | CleanCSS . Options | ( ( text : string , type ?: string ) => string | Promise < string > ) ;
147
151
148
152
/**
149
153
* Minify JavaScript in script elements and event attributes
150
154
* (uses [Terser](https://github.com/terser/terser))
151
155
*
152
- * This property is loosely typed due to dtslint restrictions.
153
- * It also accepts `import("terser").MinifyOptions`
154
- *
155
156
* @default false
156
157
*/
157
- minifyJS ?: boolean | Terser . MinifyOptions | ( ( text : string , inline ?: boolean ) => string ) ;
158
+ minifyJS ?: boolean | Terser . MinifyOptions | ( ( text : string , inline ?: boolean ) => string | Promise < string > ) ;
158
159
159
160
/**
160
161
* Minify URLs in various attributes
161
162
* (uses [relateurl](https://github.com/stevenvachon/relateurl))
162
163
*
163
164
* @default false
164
165
*/
165
- minifyURLs ?: boolean | string | RelateUrl . Options | ( ( text : string ) => string ) ;
166
+ minifyURLs ?: boolean | string | RelateUrl . Options | ( ( text : string ) => string | Promise < string > ) ;
166
167
167
168
/**
168
169
* Never add a newline before a tag that closes an element
@@ -199,9 +200,9 @@ export interface MinifierOptions {
199
200
processScripts ?: string [ ] ;
200
201
201
202
/**
202
- * Type of quote to use for attribute values (“'” or “"” )
203
+ * Type of quote to use for attribute values (`'` or `"` )
203
204
*/
204
- quoteCharacter ?: string ;
205
+ quoteCharacter ?: "'" | "\"" ;
205
206
206
207
/**
207
208
* [Remove quotes around attributes when possible](http://perfectionkills.com/experimenting-with-html-minifier#remove_attribute_quotes)
@@ -285,3 +286,8 @@ export interface MinifierOptions {
285
286
*/
286
287
useShortDoctype ?: boolean ;
287
288
}
289
+
290
+ export function minify ( value : string , options ?: MinifierOptions ) : Promise < string > ;
291
+
292
+ declare const _default : { minify : typeof minify } ;
293
+ export default _default ;
0 commit comments