bun-types 1.3.3-canary.20251112T140644 → 1.3.3-canary.20251114T140703
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun.d.ts +25 -1
- package/docs/bundler/css.mdx +2 -2
- package/docs/bundler/esbuild.mdx +52 -8
- package/docs/bundler/executables.mdx +1 -1
- package/docs/bundler/html-static.mdx +17 -3
- package/docs/bundler/index.mdx +19 -1
- package/docs/bundler/loaders.mdx +108 -13
- package/docs/bundler/minifier.mdx +343 -363
- package/docs/bundler/plugins.mdx +15 -1
- package/docs/guides/deployment/google-cloud-run.mdx +2 -5
- package/docs/guides/ecosystem/{edgedb.mdx → gel.mdx} +42 -38
- package/docs/guides/test/snapshot.mdx +2 -2
- package/docs/pm/cli/pm.mdx +1 -1
- package/docs/pm/workspaces.mdx +1 -2
- package/docs/quickstart.mdx +199 -193
- package/docs/runtime/bunfig.mdx +1 -0
- package/docs/runtime/file-types.mdx +84 -3
- package/docs/runtime/module-resolution.mdx +11 -2
- package/docs/runtime/plugins.mdx +15 -1
- package/docs/runtime/s3.mdx +1 -1
- package/package.json +1 -1
|
@@ -103,13 +103,13 @@ Renames local variables and function names to shorter identifiers using frequenc
|
|
|
103
103
|
Converts boolean literals to shorter expressions.
|
|
104
104
|
|
|
105
105
|
```ts Input
|
|
106
|
-
true
|
|
107
|
-
false
|
|
106
|
+
true
|
|
107
|
+
false
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
```
|
|
111
|
-
!0
|
|
112
|
-
!1
|
|
110
|
+
```js Output
|
|
111
|
+
!0
|
|
112
|
+
!1
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
### Boolean algebra optimizations
|
|
@@ -119,21 +119,21 @@ false;
|
|
|
119
119
|
Simplifies boolean expressions using logical rules.
|
|
120
120
|
|
|
121
121
|
```ts Input
|
|
122
|
-
!!x
|
|
123
|
-
x === true
|
|
124
|
-
x && true
|
|
125
|
-
x || false
|
|
126
|
-
!true
|
|
127
|
-
!false
|
|
122
|
+
!!x
|
|
123
|
+
x === true
|
|
124
|
+
x && true
|
|
125
|
+
x || false
|
|
126
|
+
!true
|
|
127
|
+
!false
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
```
|
|
131
|
-
x
|
|
132
|
-
x
|
|
133
|
-
x
|
|
134
|
-
x
|
|
135
|
-
!1
|
|
136
|
-
!0
|
|
130
|
+
```js Output
|
|
131
|
+
x
|
|
132
|
+
x
|
|
133
|
+
x
|
|
134
|
+
x
|
|
135
|
+
!1
|
|
136
|
+
!0
|
|
137
137
|
```
|
|
138
138
|
|
|
139
139
|
### Undefined shortening
|
|
@@ -143,13 +143,13 @@ x;
|
|
|
143
143
|
Replaces `undefined` with shorter equivalent.
|
|
144
144
|
|
|
145
145
|
```ts Input
|
|
146
|
-
undefined
|
|
146
|
+
undefined
|
|
147
147
|
let x = undefined;
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
-
```
|
|
151
|
-
void 0
|
|
152
|
-
let x
|
|
150
|
+
```js Output
|
|
151
|
+
void 0
|
|
152
|
+
let x=void 0;
|
|
153
153
|
```
|
|
154
154
|
|
|
155
155
|
### Undefined equality optimization
|
|
@@ -159,13 +159,13 @@ let x = void 0;
|
|
|
159
159
|
Optimizes loose equality checks with undefined.
|
|
160
160
|
|
|
161
161
|
```ts Input
|
|
162
|
-
x == undefined
|
|
163
|
-
x != undefined
|
|
162
|
+
x == undefined
|
|
163
|
+
x != undefined
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
-
```
|
|
167
|
-
x == null
|
|
168
|
-
x != null
|
|
166
|
+
```js Output
|
|
167
|
+
x == null
|
|
168
|
+
x != null
|
|
169
169
|
```
|
|
170
170
|
|
|
171
171
|
### Infinity shortening
|
|
@@ -175,11 +175,13 @@ x != null;
|
|
|
175
175
|
Converts Infinity to mathematical expressions.
|
|
176
176
|
|
|
177
177
|
```ts Input
|
|
178
|
-
Infinity
|
|
178
|
+
Infinity
|
|
179
|
+
-Infinity
|
|
179
180
|
```
|
|
180
181
|
|
|
181
|
-
```
|
|
182
|
-
1
|
|
182
|
+
```js Output
|
|
183
|
+
1/0
|
|
184
|
+
-1/0
|
|
183
185
|
```
|
|
184
186
|
|
|
185
187
|
### Typeof optimizations
|
|
@@ -189,25 +191,25 @@ Infinity - Infinity;
|
|
|
189
191
|
Optimizes typeof comparisons and evaluates constant typeof expressions.
|
|
190
192
|
|
|
191
193
|
```ts Input
|
|
192
|
-
typeof x ===
|
|
193
|
-
typeof x !==
|
|
194
|
-
typeof require
|
|
195
|
-
typeof null
|
|
196
|
-
typeof true
|
|
197
|
-
typeof 123
|
|
198
|
-
typeof "str"
|
|
199
|
-
typeof 123n
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
```
|
|
203
|
-
typeof x
|
|
204
|
-
typeof x
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
194
|
+
typeof x === 'undefined'
|
|
195
|
+
typeof x !== 'undefined'
|
|
196
|
+
typeof require
|
|
197
|
+
typeof null
|
|
198
|
+
typeof true
|
|
199
|
+
typeof 123
|
|
200
|
+
typeof "str"
|
|
201
|
+
typeof 123n
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
```js Output
|
|
205
|
+
typeof x>'u'
|
|
206
|
+
typeof x<'u'
|
|
207
|
+
"function"
|
|
208
|
+
"object"
|
|
209
|
+
"boolean"
|
|
210
|
+
"number"
|
|
211
|
+
"string"
|
|
212
|
+
"bigint"
|
|
211
213
|
```
|
|
212
214
|
|
|
213
215
|
### Number formatting
|
|
@@ -217,17 +219,19 @@ typeof x < "u";
|
|
|
217
219
|
Formats numbers in the most compact representation.
|
|
218
220
|
|
|
219
221
|
```ts Input
|
|
220
|
-
10000
|
|
221
|
-
100000
|
|
222
|
-
1000000
|
|
223
|
-
1.0
|
|
222
|
+
10000
|
|
223
|
+
100000
|
|
224
|
+
1000000
|
|
225
|
+
1.0
|
|
226
|
+
-42.0
|
|
224
227
|
```
|
|
225
228
|
|
|
226
|
-
```
|
|
227
|
-
1e4
|
|
228
|
-
1e5
|
|
229
|
-
1e6
|
|
230
|
-
1
|
|
229
|
+
```js Output
|
|
230
|
+
1e4
|
|
231
|
+
1e5
|
|
232
|
+
1e6
|
|
233
|
+
1
|
|
234
|
+
-42
|
|
231
235
|
```
|
|
232
236
|
|
|
233
237
|
### Arithmetic constant folding
|
|
@@ -237,21 +241,21 @@ Formats numbers in the most compact representation.
|
|
|
237
241
|
Evaluates arithmetic operations at compile time.
|
|
238
242
|
|
|
239
243
|
```ts Input
|
|
240
|
-
1 + 2
|
|
241
|
-
10 - 5
|
|
242
|
-
3 * 4
|
|
243
|
-
10 / 2
|
|
244
|
-
10 % 3
|
|
245
|
-
2 ** 3
|
|
244
|
+
1 + 2
|
|
245
|
+
10 - 5
|
|
246
|
+
3 * 4
|
|
247
|
+
10 / 2
|
|
248
|
+
10 % 3
|
|
249
|
+
2 ** 3
|
|
246
250
|
```
|
|
247
251
|
|
|
248
|
-
```
|
|
249
|
-
3
|
|
250
|
-
5
|
|
251
|
-
12
|
|
252
|
-
5
|
|
253
|
-
1
|
|
254
|
-
8
|
|
252
|
+
```js Output
|
|
253
|
+
3
|
|
254
|
+
5
|
|
255
|
+
12
|
|
256
|
+
5
|
|
257
|
+
1
|
|
258
|
+
8
|
|
255
259
|
```
|
|
256
260
|
|
|
257
261
|
### Bitwise constant folding
|
|
@@ -261,20 +265,21 @@ Evaluates arithmetic operations at compile time.
|
|
|
261
265
|
Evaluates bitwise operations at compile time.
|
|
262
266
|
|
|
263
267
|
```ts Input
|
|
264
|
-
5 & 3
|
|
265
|
-
5 | 3
|
|
266
|
-
5 ^ 3
|
|
267
|
-
8 << 2
|
|
268
|
-
32 >> 2
|
|
269
|
-
~5
|
|
268
|
+
5 & 3
|
|
269
|
+
5 | 3
|
|
270
|
+
5 ^ 3
|
|
271
|
+
8 << 2
|
|
272
|
+
32 >> 2
|
|
273
|
+
~5
|
|
270
274
|
```
|
|
271
275
|
|
|
272
|
-
```
|
|
273
|
-
1
|
|
274
|
-
7
|
|
275
|
-
6
|
|
276
|
-
32
|
|
277
|
-
8
|
|
276
|
+
```js Output
|
|
277
|
+
1
|
|
278
|
+
7
|
|
279
|
+
6
|
|
280
|
+
32
|
|
281
|
+
8
|
|
282
|
+
-6
|
|
278
283
|
```
|
|
279
284
|
|
|
280
285
|
### String concatenation
|
|
@@ -284,15 +289,15 @@ Evaluates bitwise operations at compile time.
|
|
|
284
289
|
Combines string literals at compile time.
|
|
285
290
|
|
|
286
291
|
```ts Input
|
|
287
|
-
"a" + "b"
|
|
288
|
-
"x" + 123
|
|
289
|
-
"foo" + "bar" + "baz"
|
|
292
|
+
"a" + "b"
|
|
293
|
+
"x" + 123
|
|
294
|
+
"foo" + "bar" + "baz"
|
|
290
295
|
```
|
|
291
296
|
|
|
292
|
-
```
|
|
293
|
-
"ab"
|
|
294
|
-
"x123"
|
|
295
|
-
"foobarbaz"
|
|
297
|
+
```js Output
|
|
298
|
+
"ab"
|
|
299
|
+
"x123"
|
|
300
|
+
"foobarbaz"
|
|
296
301
|
```
|
|
297
302
|
|
|
298
303
|
### String indexing
|
|
@@ -302,13 +307,13 @@ Combines string literals at compile time.
|
|
|
302
307
|
Evaluates string character access at compile time.
|
|
303
308
|
|
|
304
309
|
```ts Input
|
|
305
|
-
"foo"[2]
|
|
306
|
-
"hello"[0]
|
|
310
|
+
"foo"[2]
|
|
311
|
+
"hello"[0]
|
|
307
312
|
```
|
|
308
313
|
|
|
309
|
-
```
|
|
310
|
-
"o"
|
|
311
|
-
"h"
|
|
314
|
+
```js Output
|
|
315
|
+
"o"
|
|
316
|
+
"h"
|
|
312
317
|
```
|
|
313
318
|
|
|
314
319
|
### Template literal folding
|
|
@@ -318,12 +323,13 @@ Evaluates string character access at compile time.
|
|
|
318
323
|
Evaluates template literals with constant expressions.
|
|
319
324
|
|
|
320
325
|
```ts Input
|
|
321
|
-
`a${123}b
|
|
326
|
+
`a${123}b`
|
|
327
|
+
`result: ${5 + 10}`
|
|
322
328
|
```
|
|
323
329
|
|
|
324
|
-
```
|
|
325
|
-
"a123b"
|
|
326
|
-
"result: 15"
|
|
330
|
+
```js Output
|
|
331
|
+
"a123b"
|
|
332
|
+
"result: 15"
|
|
327
333
|
```
|
|
328
334
|
|
|
329
335
|
### Template literal to string conversion
|
|
@@ -333,13 +339,14 @@ Evaluates template literals with constant expressions.
|
|
|
333
339
|
Converts simple template literals to regular strings.
|
|
334
340
|
|
|
335
341
|
```ts Input
|
|
336
|
-
`Hello World
|
|
337
|
-
Line
|
|
342
|
+
`Hello World`
|
|
343
|
+
`Line 1
|
|
344
|
+
Line 2`
|
|
338
345
|
```
|
|
339
346
|
|
|
340
|
-
```
|
|
341
|
-
"Hello World"
|
|
342
|
-
"Line 1\nLine 2"
|
|
347
|
+
```js Output
|
|
348
|
+
"Hello World"
|
|
349
|
+
"Line 1\nLine 2"
|
|
343
350
|
```
|
|
344
351
|
|
|
345
352
|
### String quote optimization
|
|
@@ -349,14 +356,15 @@ Line 2`;
|
|
|
349
356
|
Chooses the optimal quote character to minimize escapes.
|
|
350
357
|
|
|
351
358
|
```ts Input
|
|
352
|
-
"It's a string"
|
|
353
|
-
'He said "hello"'
|
|
359
|
+
"It's a string"
|
|
360
|
+
'He said "hello"'
|
|
361
|
+
`Simple string`
|
|
354
362
|
```
|
|
355
363
|
|
|
356
|
-
```
|
|
357
|
-
"It's a string"
|
|
358
|
-
'He said "hello"'
|
|
359
|
-
"Simple string"
|
|
364
|
+
```js Output
|
|
365
|
+
"It's a string"
|
|
366
|
+
'He said "hello"'
|
|
367
|
+
"Simple string"
|
|
360
368
|
```
|
|
361
369
|
|
|
362
370
|
### Array spread inlining
|
|
@@ -370,8 +378,9 @@ Inlines array spread operations with constant arrays.
|
|
|
370
378
|
[...[a, b]]
|
|
371
379
|
```
|
|
372
380
|
|
|
373
|
-
```
|
|
374
|
-
[1,
|
|
381
|
+
```js Output
|
|
382
|
+
[1,2,3,4]
|
|
383
|
+
[a,b]
|
|
375
384
|
```
|
|
376
385
|
|
|
377
386
|
### Array indexing
|
|
@@ -386,10 +395,10 @@ Evaluates constant array access at compile time.
|
|
|
386
395
|
['a', , 'c'][1]
|
|
387
396
|
```
|
|
388
397
|
|
|
389
|
-
```
|
|
390
|
-
x
|
|
391
|
-
|
|
392
|
-
void 0
|
|
398
|
+
```js Output
|
|
399
|
+
x
|
|
400
|
+
'b'
|
|
401
|
+
void 0
|
|
393
402
|
```
|
|
394
403
|
|
|
395
404
|
### Property access optimization
|
|
@@ -399,17 +408,17 @@ void 0;
|
|
|
399
408
|
Converts bracket notation to dot notation when possible.
|
|
400
409
|
|
|
401
410
|
```ts Input
|
|
402
|
-
obj["property"]
|
|
403
|
-
obj["validName"]
|
|
404
|
-
obj["123"]
|
|
405
|
-
obj["invalid-name"]
|
|
411
|
+
obj["property"]
|
|
412
|
+
obj["validName"]
|
|
413
|
+
obj["123"]
|
|
414
|
+
obj["invalid-name"]
|
|
406
415
|
```
|
|
407
416
|
|
|
408
|
-
```
|
|
409
|
-
obj.property
|
|
410
|
-
obj.validName
|
|
411
|
-
obj["123"]
|
|
412
|
-
obj["invalid-name"]
|
|
417
|
+
```js Output
|
|
418
|
+
obj.property
|
|
419
|
+
obj.validName
|
|
420
|
+
obj["123"]
|
|
421
|
+
obj["invalid-name"]
|
|
413
422
|
```
|
|
414
423
|
|
|
415
424
|
### Comparison folding
|
|
@@ -419,19 +428,19 @@ obj["invalid-name"];
|
|
|
419
428
|
Evaluates constant comparisons at compile time.
|
|
420
429
|
|
|
421
430
|
```ts Input
|
|
422
|
-
3 < 5
|
|
423
|
-
5 > 3
|
|
424
|
-
3 <= 3
|
|
425
|
-
5 >= 6
|
|
426
|
-
"a" < "b"
|
|
431
|
+
3 < 5
|
|
432
|
+
5 > 3
|
|
433
|
+
3 <= 3
|
|
434
|
+
5 >= 6
|
|
435
|
+
"a" < "b"
|
|
427
436
|
```
|
|
428
437
|
|
|
429
|
-
```
|
|
430
|
-
!0
|
|
431
|
-
!0
|
|
432
|
-
!0
|
|
433
|
-
!1
|
|
434
|
-
!0
|
|
438
|
+
```js Output
|
|
439
|
+
!0
|
|
440
|
+
!0
|
|
441
|
+
!0
|
|
442
|
+
!1
|
|
443
|
+
!0
|
|
435
444
|
```
|
|
436
445
|
|
|
437
446
|
### Logical operation folding
|
|
@@ -441,17 +450,17 @@ Evaluates constant comparisons at compile time.
|
|
|
441
450
|
Simplifies logical operations with constant values.
|
|
442
451
|
|
|
443
452
|
```ts Input
|
|
444
|
-
true && x
|
|
445
|
-
false && x
|
|
446
|
-
true || x
|
|
447
|
-
false || x
|
|
453
|
+
true && x
|
|
454
|
+
false && x
|
|
455
|
+
true || x
|
|
456
|
+
false || x
|
|
448
457
|
```
|
|
449
458
|
|
|
450
|
-
```
|
|
451
|
-
x
|
|
452
|
-
!1
|
|
453
|
-
!0
|
|
454
|
-
x
|
|
459
|
+
```js Output
|
|
460
|
+
x
|
|
461
|
+
!1
|
|
462
|
+
!0
|
|
463
|
+
x
|
|
455
464
|
```
|
|
456
465
|
|
|
457
466
|
### Nullish coalescing folding
|
|
@@ -461,15 +470,15 @@ x;
|
|
|
461
470
|
Evaluates nullish coalescing with known values.
|
|
462
471
|
|
|
463
472
|
```ts Input
|
|
464
|
-
null ?? x
|
|
465
|
-
undefined ?? x
|
|
466
|
-
42 ?? x
|
|
473
|
+
null ?? x
|
|
474
|
+
undefined ?? x
|
|
475
|
+
42 ?? x
|
|
467
476
|
```
|
|
468
477
|
|
|
469
|
-
```
|
|
470
|
-
x
|
|
471
|
-
x
|
|
472
|
-
42
|
|
478
|
+
```js Output
|
|
479
|
+
x
|
|
480
|
+
x
|
|
481
|
+
42
|
|
473
482
|
```
|
|
474
483
|
|
|
475
484
|
### Comma expression simplification
|
|
@@ -479,12 +488,13 @@ x;
|
|
|
479
488
|
Removes side-effect-free expressions from comma sequences.
|
|
480
489
|
|
|
481
490
|
```ts Input
|
|
482
|
-
(0, x)
|
|
491
|
+
(0, x)
|
|
492
|
+
(123, "str", x)
|
|
483
493
|
```
|
|
484
494
|
|
|
485
|
-
```
|
|
486
|
-
x
|
|
487
|
-
x
|
|
495
|
+
```js Output
|
|
496
|
+
x
|
|
497
|
+
x
|
|
488
498
|
```
|
|
489
499
|
|
|
490
500
|
### Ternary conditional folding
|
|
@@ -494,17 +504,17 @@ x;
|
|
|
494
504
|
Evaluates conditional expressions with constant conditions.
|
|
495
505
|
|
|
496
506
|
```ts Input
|
|
497
|
-
true ? a : b
|
|
498
|
-
false ? a : b
|
|
499
|
-
x ? true : false
|
|
500
|
-
x ? false : true
|
|
507
|
+
true ? a : b
|
|
508
|
+
false ? a : b
|
|
509
|
+
x ? true : false
|
|
510
|
+
x ? false : true
|
|
501
511
|
```
|
|
502
512
|
|
|
503
|
-
```
|
|
504
|
-
a
|
|
505
|
-
b
|
|
506
|
-
x
|
|
507
|
-
!
|
|
513
|
+
```js Output
|
|
514
|
+
a
|
|
515
|
+
b
|
|
516
|
+
x ? !0 : !1
|
|
517
|
+
x ? !1 : !0
|
|
508
518
|
```
|
|
509
519
|
|
|
510
520
|
### Unary expression folding
|
|
@@ -514,17 +524,22 @@ x;
|
|
|
514
524
|
Simplifies unary operations.
|
|
515
525
|
|
|
516
526
|
```ts Input
|
|
517
|
-
+123
|
|
518
|
-
|
|
519
|
-
|
|
527
|
+
+123
|
|
528
|
+
+"123"
|
|
529
|
+
-(-x)
|
|
530
|
+
~~x
|
|
531
|
+
!!x
|
|
520
532
|
```
|
|
521
533
|
|
|
522
|
-
```
|
|
523
|
-
123
|
|
524
|
-
123
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
x
|
|
534
|
+
```js Output
|
|
535
|
+
123
|
|
536
|
+
123
|
|
537
|
+
123
|
|
538
|
+
123
|
|
539
|
+
x
|
|
540
|
+
~~x
|
|
541
|
+
!!x
|
|
542
|
+
x
|
|
528
543
|
```
|
|
529
544
|
|
|
530
545
|
### Double negation removal
|
|
@@ -534,13 +549,13 @@ x;
|
|
|
534
549
|
Removes unnecessary double negations.
|
|
535
550
|
|
|
536
551
|
```ts Input
|
|
537
|
-
!!x
|
|
538
|
-
!!!x
|
|
552
|
+
!!x
|
|
553
|
+
!!!x
|
|
539
554
|
```
|
|
540
555
|
|
|
541
|
-
```
|
|
542
|
-
x
|
|
543
|
-
!x
|
|
556
|
+
```js Output
|
|
557
|
+
x
|
|
558
|
+
!x
|
|
544
559
|
```
|
|
545
560
|
|
|
546
561
|
### If statement optimization
|
|
@@ -552,18 +567,15 @@ Optimizes if statements with constant conditions.
|
|
|
552
567
|
```ts Input
|
|
553
568
|
if (true) x;
|
|
554
569
|
if (false) x;
|
|
555
|
-
if (x) {
|
|
556
|
-
|
|
557
|
-
}
|
|
558
|
-
if (x) {
|
|
559
|
-
} else y;
|
|
570
|
+
if (x) { a; }
|
|
571
|
+
if (x) {} else y;
|
|
560
572
|
```
|
|
561
573
|
|
|
562
|
-
```
|
|
574
|
+
```js Output
|
|
563
575
|
x;
|
|
564
576
|
// removed
|
|
565
|
-
if
|
|
566
|
-
if
|
|
577
|
+
if(x)a;
|
|
578
|
+
if(!x)y;
|
|
567
579
|
```
|
|
568
580
|
|
|
569
581
|
### Dead code elimination
|
|
@@ -582,10 +594,8 @@ function foo() {
|
|
|
582
594
|
}
|
|
583
595
|
```
|
|
584
596
|
|
|
585
|
-
```
|
|
586
|
-
function foo()
|
|
587
|
-
return x;
|
|
588
|
-
}
|
|
597
|
+
```js Output
|
|
598
|
+
function foo(){return x}
|
|
589
599
|
```
|
|
590
600
|
|
|
591
601
|
### Unreachable branch removal
|
|
@@ -600,7 +610,7 @@ while (false) {
|
|
|
600
610
|
}
|
|
601
611
|
```
|
|
602
612
|
|
|
603
|
-
```
|
|
613
|
+
```js Output
|
|
604
614
|
// removed entirely
|
|
605
615
|
```
|
|
606
616
|
|
|
@@ -611,13 +621,12 @@ while (false) {
|
|
|
611
621
|
Removes empty blocks and unnecessary braces.
|
|
612
622
|
|
|
613
623
|
```ts Input
|
|
614
|
-
{
|
|
615
|
-
}
|
|
616
|
-
if (x) {
|
|
617
|
-
}
|
|
624
|
+
{ }
|
|
625
|
+
if (x) { }
|
|
618
626
|
```
|
|
619
627
|
|
|
620
|
-
```
|
|
628
|
+
```js Output
|
|
629
|
+
;
|
|
621
630
|
// removed
|
|
622
631
|
```
|
|
623
632
|
|
|
@@ -633,8 +642,8 @@ if (condition) {
|
|
|
633
642
|
}
|
|
634
643
|
```
|
|
635
644
|
|
|
636
|
-
```
|
|
637
|
-
if
|
|
645
|
+
```js Output
|
|
646
|
+
if(condition)doSomething();
|
|
638
647
|
```
|
|
639
648
|
|
|
640
649
|
### TypeScript enum inlining
|
|
@@ -644,16 +653,12 @@ if (condition) doSomething();
|
|
|
644
653
|
Inlines TypeScript enum values at compile time.
|
|
645
654
|
|
|
646
655
|
```ts Input
|
|
647
|
-
enum Color {
|
|
648
|
-
Red,
|
|
649
|
-
Green,
|
|
650
|
-
Blue,
|
|
651
|
-
}
|
|
656
|
+
enum Color { Red, Green, Blue }
|
|
652
657
|
const x = Color.Red;
|
|
653
658
|
```
|
|
654
659
|
|
|
655
|
-
```
|
|
656
|
-
const x
|
|
660
|
+
```js Output
|
|
661
|
+
const x=0;
|
|
657
662
|
```
|
|
658
663
|
|
|
659
664
|
### Pure annotation support
|
|
@@ -667,7 +672,7 @@ const x = /*@__PURE__*/ expensive();
|
|
|
667
672
|
// If x is unused...
|
|
668
673
|
```
|
|
669
674
|
|
|
670
|
-
```
|
|
675
|
+
```js Output
|
|
671
676
|
// removed entirely
|
|
672
677
|
```
|
|
673
678
|
|
|
@@ -684,11 +689,8 @@ function calculateSum(firstNumber, secondNumber) {
|
|
|
684
689
|
}
|
|
685
690
|
```
|
|
686
691
|
|
|
687
|
-
```
|
|
688
|
-
function a(b,
|
|
689
|
-
const d = b + c;
|
|
690
|
-
return d;
|
|
691
|
-
}
|
|
692
|
+
```js Output
|
|
693
|
+
function a(b,c){const d=b+c;return d}
|
|
692
694
|
```
|
|
693
695
|
|
|
694
696
|
**Naming strategy:**
|
|
@@ -713,16 +715,13 @@ Removes all unnecessary whitespace.
|
|
|
713
715
|
|
|
714
716
|
```ts Input
|
|
715
717
|
function add(a, b) {
|
|
716
|
-
|
|
718
|
+
return a + b;
|
|
717
719
|
}
|
|
718
720
|
let x = 10;
|
|
719
721
|
```
|
|
720
722
|
|
|
721
|
-
```
|
|
722
|
-
function add(a,
|
|
723
|
-
return a + b;
|
|
724
|
-
}
|
|
725
|
-
let x = 10;
|
|
723
|
+
```js Output
|
|
724
|
+
function add(a,b){return a+b;}let x=10;
|
|
726
725
|
```
|
|
727
726
|
|
|
728
727
|
### Semicolon optimization
|
|
@@ -737,10 +736,8 @@ let b = 2;
|
|
|
737
736
|
return a + b;
|
|
738
737
|
```
|
|
739
738
|
|
|
740
|
-
```
|
|
741
|
-
let a =
|
|
742
|
-
let b = 2;
|
|
743
|
-
return a + b;
|
|
739
|
+
```js Output
|
|
740
|
+
let a=1;let b=2;return a+b
|
|
744
741
|
```
|
|
745
742
|
|
|
746
743
|
### Operator spacing removal
|
|
@@ -750,15 +747,15 @@ return a + b;
|
|
|
750
747
|
Removes spaces around operators.
|
|
751
748
|
|
|
752
749
|
```ts Input
|
|
753
|
-
a + b
|
|
754
|
-
x = y * z
|
|
755
|
-
|
|
750
|
+
a + b
|
|
751
|
+
x = y * z
|
|
752
|
+
foo && bar || baz
|
|
756
753
|
```
|
|
757
754
|
|
|
758
|
-
```
|
|
759
|
-
a
|
|
760
|
-
x
|
|
761
|
-
|
|
755
|
+
```js Output
|
|
756
|
+
a+b
|
|
757
|
+
x=y*z
|
|
758
|
+
foo&&bar||baz
|
|
762
759
|
```
|
|
763
760
|
|
|
764
761
|
### Comment removal
|
|
@@ -771,14 +768,12 @@ Removes comments except important license comments.
|
|
|
771
768
|
// This comment is removed
|
|
772
769
|
/* So is this */
|
|
773
770
|
/*! But this license comment is kept */
|
|
774
|
-
function test() {
|
|
775
|
-
/* inline comment */
|
|
776
|
-
}
|
|
771
|
+
function test() { /* inline comment */ }
|
|
777
772
|
```
|
|
778
773
|
|
|
779
|
-
```
|
|
774
|
+
```js Output
|
|
780
775
|
/*! But this license comment is kept */
|
|
781
|
-
function test()
|
|
776
|
+
function test(){}
|
|
782
777
|
```
|
|
783
778
|
|
|
784
779
|
### Object and array formatting
|
|
@@ -789,15 +784,14 @@ Removes whitespace in object and array literals.
|
|
|
789
784
|
|
|
790
785
|
```ts Input
|
|
791
786
|
const obj = {
|
|
792
|
-
|
|
793
|
-
|
|
787
|
+
name: "John",
|
|
788
|
+
age: 30
|
|
794
789
|
};
|
|
795
790
|
const arr = [1, 2, 3];
|
|
796
791
|
```
|
|
797
792
|
|
|
798
|
-
```
|
|
799
|
-
const obj
|
|
800
|
-
const arr = [1, 2, 3];
|
|
793
|
+
```js Output
|
|
794
|
+
const obj={name:"John",age:30};const arr=[1,2,3];
|
|
801
795
|
```
|
|
802
796
|
|
|
803
797
|
### Control flow formatting
|
|
@@ -808,16 +802,15 @@ Removes whitespace in control structures.
|
|
|
808
802
|
|
|
809
803
|
```ts Input
|
|
810
804
|
if (condition) {
|
|
811
|
-
|
|
805
|
+
doSomething();
|
|
812
806
|
}
|
|
813
807
|
for (let i = 0; i < 10; i++) {
|
|
814
|
-
|
|
808
|
+
console.log(i);
|
|
815
809
|
}
|
|
816
810
|
```
|
|
817
811
|
|
|
818
|
-
```
|
|
819
|
-
if
|
|
820
|
-
for (let i = 0; i < 10; i++) console.log(i);
|
|
812
|
+
```js Output
|
|
813
|
+
if(condition)doSomething();for(let i=0;i<10;i++)console.log(i);
|
|
821
814
|
```
|
|
822
815
|
|
|
823
816
|
### Function formatting
|
|
@@ -828,16 +821,13 @@ Removes whitespace in function declarations.
|
|
|
828
821
|
|
|
829
822
|
```ts Input
|
|
830
823
|
function myFunction(param1, param2) {
|
|
831
|
-
|
|
824
|
+
return param1 + param2;
|
|
832
825
|
}
|
|
833
826
|
const arrow = (a, b) => a + b;
|
|
834
827
|
```
|
|
835
828
|
|
|
836
|
-
```
|
|
837
|
-
function myFunction(a, b)
|
|
838
|
-
return a + b;
|
|
839
|
-
}
|
|
840
|
-
const arrow = (a, b) => a + b;
|
|
829
|
+
```js Output
|
|
830
|
+
function myFunction(a,b){return a+b}const arrow=(a,b)=>a+b;
|
|
841
831
|
```
|
|
842
832
|
|
|
843
833
|
### Parentheses minimization
|
|
@@ -847,14 +837,15 @@ const arrow = (a, b) => a + b;
|
|
|
847
837
|
Only adds parentheses when necessary for operator precedence.
|
|
848
838
|
|
|
849
839
|
```ts Input
|
|
850
|
-
(a + b) * c
|
|
851
|
-
a + (b * c)
|
|
840
|
+
(a + b) * c
|
|
841
|
+
a + (b * c)
|
|
842
|
+
((x))
|
|
852
843
|
```
|
|
853
844
|
|
|
854
|
-
```
|
|
855
|
-
(a
|
|
856
|
-
a
|
|
857
|
-
x
|
|
845
|
+
```js Output
|
|
846
|
+
(a+b)*c
|
|
847
|
+
a+b*c
|
|
848
|
+
x
|
|
858
849
|
```
|
|
859
850
|
|
|
860
851
|
### Property mangling
|
|
@@ -863,12 +854,12 @@ x;
|
|
|
863
854
|
|
|
864
855
|
Renames object properties to shorter names when configured.
|
|
865
856
|
|
|
866
|
-
```ts
|
|
857
|
+
```ts Input
|
|
867
858
|
obj.longPropertyName
|
|
868
859
|
```
|
|
869
860
|
|
|
870
|
-
```
|
|
871
|
-
obj.a
|
|
861
|
+
```js Output (with property mangling enabled)
|
|
862
|
+
obj.a
|
|
872
863
|
```
|
|
873
864
|
|
|
874
865
|
### Template literal value folding
|
|
@@ -878,15 +869,19 @@ obj.a;
|
|
|
878
869
|
Converts non-string interpolated values to strings and folds them into the template.
|
|
879
870
|
|
|
880
871
|
```ts Input
|
|
881
|
-
`hello ${123}
|
|
872
|
+
`hello ${123}`
|
|
873
|
+
`value: ${true}`
|
|
874
|
+
`result: ${null}`
|
|
875
|
+
`status: ${undefined}`
|
|
876
|
+
`big: ${10n}`
|
|
882
877
|
```
|
|
883
878
|
|
|
884
|
-
```
|
|
885
|
-
"hello 123"
|
|
886
|
-
"value: true"
|
|
887
|
-
"result: null"
|
|
888
|
-
"status: undefined"
|
|
889
|
-
"big: 10"
|
|
879
|
+
```js Output
|
|
880
|
+
"hello 123"
|
|
881
|
+
"value: true"
|
|
882
|
+
"result: null"
|
|
883
|
+
"status: undefined"
|
|
884
|
+
"big: 10"
|
|
890
885
|
```
|
|
891
886
|
|
|
892
887
|
### String length constant folding
|
|
@@ -896,13 +891,13 @@ Converts non-string interpolated values to strings and folds them into the templ
|
|
|
896
891
|
Evaluates `.length` property on string literals at compile time.
|
|
897
892
|
|
|
898
893
|
```ts Input
|
|
899
|
-
"hello world".length
|
|
900
|
-
"test".length
|
|
894
|
+
"hello world".length
|
|
895
|
+
"test".length
|
|
901
896
|
```
|
|
902
897
|
|
|
903
|
-
```
|
|
904
|
-
11
|
|
905
|
-
4
|
|
898
|
+
```js Output
|
|
899
|
+
11
|
|
900
|
+
4
|
|
906
901
|
```
|
|
907
902
|
|
|
908
903
|
### Constructor call simplification
|
|
@@ -912,22 +907,19 @@ Evaluates `.length` property on string literals at compile time.
|
|
|
912
907
|
Simplifies constructor calls for built-in types.
|
|
913
908
|
|
|
914
909
|
```ts Input
|
|
915
|
-
new Object()
|
|
916
|
-
new Object(null)
|
|
917
|
-
new Object({
|
|
918
|
-
new Array()
|
|
919
|
-
new Array(x, y)
|
|
910
|
+
new Object()
|
|
911
|
+
new Object(null)
|
|
912
|
+
new Object({a: 1})
|
|
913
|
+
new Array()
|
|
914
|
+
new Array(x, y)
|
|
920
915
|
```
|
|
921
916
|
|
|
922
|
-
```
|
|
923
|
-
{
|
|
924
|
-
}
|
|
925
|
-
{
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
a: 1;
|
|
929
|
-
}
|
|
930
|
-
[][(x, y)];
|
|
917
|
+
```js Output
|
|
918
|
+
{}
|
|
919
|
+
{}
|
|
920
|
+
{a:1}
|
|
921
|
+
[]
|
|
922
|
+
[x,y]
|
|
931
923
|
```
|
|
932
924
|
|
|
933
925
|
### Single property object inlining
|
|
@@ -937,11 +929,11 @@ new Array(x, y);
|
|
|
937
929
|
Inlines property access for objects with a single property.
|
|
938
930
|
|
|
939
931
|
```ts Input
|
|
940
|
-
({
|
|
932
|
+
({fn: () => console.log('hi')}).fn()
|
|
941
933
|
```
|
|
942
934
|
|
|
943
|
-
```
|
|
944
|
-
(() => console.log(
|
|
935
|
+
```js Output
|
|
936
|
+
(() => console.log('hi'))()
|
|
945
937
|
```
|
|
946
938
|
|
|
947
939
|
### String charCodeAt constant folding
|
|
@@ -951,13 +943,13 @@ Inlines property access for objects with a single property.
|
|
|
951
943
|
Evaluates `charCodeAt()` on string literals for ASCII characters.
|
|
952
944
|
|
|
953
945
|
```ts Input
|
|
954
|
-
"hello".charCodeAt(1)
|
|
955
|
-
"A".charCodeAt(0)
|
|
946
|
+
"hello".charCodeAt(1)
|
|
947
|
+
"A".charCodeAt(0)
|
|
956
948
|
```
|
|
957
949
|
|
|
958
|
-
```
|
|
959
|
-
101
|
|
960
|
-
65
|
|
950
|
+
```js Output
|
|
951
|
+
101
|
|
952
|
+
65
|
|
961
953
|
```
|
|
962
954
|
|
|
963
955
|
### Void 0 equality to null equality
|
|
@@ -967,13 +959,13 @@ Evaluates `charCodeAt()` on string literals for ASCII characters.
|
|
|
967
959
|
Converts loose equality checks with `void 0` to `null` since they're equivalent.
|
|
968
960
|
|
|
969
961
|
```ts Input
|
|
970
|
-
x == void 0
|
|
971
|
-
x != void 0
|
|
962
|
+
x == void 0
|
|
963
|
+
x != void 0
|
|
972
964
|
```
|
|
973
965
|
|
|
974
|
-
```
|
|
975
|
-
x == null
|
|
976
|
-
x != null
|
|
966
|
+
```js Output
|
|
967
|
+
x == null
|
|
968
|
+
x != null
|
|
977
969
|
```
|
|
978
970
|
|
|
979
971
|
### Negation operator optimization
|
|
@@ -983,12 +975,13 @@ x != null;
|
|
|
983
975
|
Moves negation operator through comma expressions.
|
|
984
976
|
|
|
985
977
|
```ts Input
|
|
986
|
-
-(a, b)
|
|
978
|
+
-(a, b)
|
|
979
|
+
-(x, y, z)
|
|
987
980
|
```
|
|
988
981
|
|
|
989
|
-
```
|
|
990
|
-
|
|
991
|
-
|
|
982
|
+
```js Output
|
|
983
|
+
a,-b
|
|
984
|
+
x,y,-z
|
|
992
985
|
```
|
|
993
986
|
|
|
994
987
|
### Import.meta property inlining
|
|
@@ -998,17 +991,17 @@ Moves negation operator through comma expressions.
|
|
|
998
991
|
Inlines `import.meta` properties at build time when values are known.
|
|
999
992
|
|
|
1000
993
|
```ts Input
|
|
1001
|
-
import.meta.dir
|
|
1002
|
-
import.meta.file
|
|
1003
|
-
import.meta.path
|
|
1004
|
-
import.meta.url
|
|
994
|
+
import.meta.dir
|
|
995
|
+
import.meta.file
|
|
996
|
+
import.meta.path
|
|
997
|
+
import.meta.url
|
|
1005
998
|
```
|
|
1006
999
|
|
|
1007
|
-
```
|
|
1008
|
-
"/path/to/directory"
|
|
1009
|
-
"filename.js"
|
|
1010
|
-
"/full/path/to/file.js"
|
|
1011
|
-
"file:///full/path/to/file.js"
|
|
1000
|
+
```js Output
|
|
1001
|
+
"/path/to/directory"
|
|
1002
|
+
"filename.js"
|
|
1003
|
+
"/full/path/to/file.js"
|
|
1004
|
+
"file:///full/path/to/file.js"
|
|
1012
1005
|
```
|
|
1013
1006
|
|
|
1014
1007
|
### Variable declaration merging
|
|
@@ -1024,11 +1017,9 @@ const c = 3;
|
|
|
1024
1017
|
const d = 4;
|
|
1025
1018
|
```
|
|
1026
1019
|
|
|
1027
|
-
```
|
|
1028
|
-
let a
|
|
1029
|
-
|
|
1030
|
-
const c = 3,
|
|
1031
|
-
d = 4;
|
|
1020
|
+
```js Output
|
|
1021
|
+
let a=1,b=2;
|
|
1022
|
+
const c=3,d=4;
|
|
1032
1023
|
```
|
|
1033
1024
|
|
|
1034
1025
|
### Expression statement merging
|
|
@@ -1043,8 +1034,8 @@ console.log(2);
|
|
|
1043
1034
|
console.log(3);
|
|
1044
1035
|
```
|
|
1045
1036
|
|
|
1046
|
-
```
|
|
1047
|
-
|
|
1037
|
+
```js Output
|
|
1038
|
+
console.log(1),console.log(2),console.log(3);
|
|
1048
1039
|
```
|
|
1049
1040
|
|
|
1050
1041
|
### Return statement merging
|
|
@@ -1058,8 +1049,8 @@ console.log(x);
|
|
|
1058
1049
|
return y;
|
|
1059
1050
|
```
|
|
1060
1051
|
|
|
1061
|
-
```
|
|
1062
|
-
return
|
|
1052
|
+
```js Output
|
|
1053
|
+
return console.log(x),y;
|
|
1063
1054
|
```
|
|
1064
1055
|
|
|
1065
1056
|
### Throw statement merging
|
|
@@ -1073,8 +1064,8 @@ console.log(x);
|
|
|
1073
1064
|
throw new Error();
|
|
1074
1065
|
```
|
|
1075
1066
|
|
|
1076
|
-
```
|
|
1077
|
-
throw
|
|
1067
|
+
```js Output
|
|
1068
|
+
throw(console.log(x),new Error());
|
|
1078
1069
|
```
|
|
1079
1070
|
|
|
1080
1071
|
### TypeScript enum cross-module inlining
|
|
@@ -1083,7 +1074,8 @@ throw (console.log(x), new Error());
|
|
|
1083
1074
|
|
|
1084
1075
|
Inlines enum values across module boundaries.
|
|
1085
1076
|
|
|
1086
|
-
```ts
|
|
1077
|
+
```ts Input
|
|
1078
|
+
// lib.ts
|
|
1087
1079
|
export enum Color { Red, Green, Blue }
|
|
1088
1080
|
|
|
1089
1081
|
// Input (main.ts)
|
|
@@ -1091,8 +1083,8 @@ import { Color } from './lib';
|
|
|
1091
1083
|
const x = Color.Red;
|
|
1092
1084
|
```
|
|
1093
1085
|
|
|
1094
|
-
```
|
|
1095
|
-
const x
|
|
1086
|
+
```js Output
|
|
1087
|
+
const x=0;
|
|
1096
1088
|
```
|
|
1097
1089
|
|
|
1098
1090
|
### Computed property enum inlining
|
|
@@ -1102,14 +1094,12 @@ const x = 0;
|
|
|
1102
1094
|
Inlines enum values used as computed object properties.
|
|
1103
1095
|
|
|
1104
1096
|
```ts Input
|
|
1105
|
-
enum Keys {
|
|
1106
|
-
|
|
1107
|
-
}
|
|
1108
|
-
const obj = { [Keys.FOO]: value };
|
|
1097
|
+
enum Keys { FOO = 'foo' }
|
|
1098
|
+
const obj = { [Keys.FOO]: value }
|
|
1109
1099
|
```
|
|
1110
1100
|
|
|
1111
|
-
```
|
|
1112
|
-
const obj
|
|
1101
|
+
```js Output
|
|
1102
|
+
const obj={foo:value}
|
|
1113
1103
|
```
|
|
1114
1104
|
|
|
1115
1105
|
### String number to numeric index
|
|
@@ -1119,13 +1109,13 @@ const obj = { foo: value };
|
|
|
1119
1109
|
Converts string numeric property access to numeric index.
|
|
1120
1110
|
|
|
1121
1111
|
```ts Input
|
|
1122
|
-
obj["0"]
|
|
1123
|
-
arr["5"]
|
|
1112
|
+
obj["0"]
|
|
1113
|
+
arr["5"]
|
|
1124
1114
|
```
|
|
1125
1115
|
|
|
1126
|
-
```
|
|
1127
|
-
obj[0]
|
|
1128
|
-
arr[5]
|
|
1116
|
+
```js Output
|
|
1117
|
+
obj[0]
|
|
1118
|
+
arr[5]
|
|
1129
1119
|
```
|
|
1130
1120
|
|
|
1131
1121
|
### Arrow function body shortening
|
|
@@ -1135,17 +1125,13 @@ arr[5];
|
|
|
1135
1125
|
Uses expression body syntax when an arrow function only returns a value.
|
|
1136
1126
|
|
|
1137
1127
|
```ts Input
|
|
1138
|
-
() => {
|
|
1139
|
-
|
|
1140
|
-
};
|
|
1141
|
-
a => {
|
|
1142
|
-
return a + 1;
|
|
1143
|
-
};
|
|
1128
|
+
() => { return x; }
|
|
1129
|
+
(a) => { return a + 1; }
|
|
1144
1130
|
```
|
|
1145
1131
|
|
|
1146
|
-
```
|
|
1147
|
-
() => x
|
|
1148
|
-
a => a + 1
|
|
1132
|
+
```js Output
|
|
1133
|
+
() => x
|
|
1134
|
+
a => a + 1
|
|
1149
1135
|
```
|
|
1150
1136
|
|
|
1151
1137
|
### Object property shorthand
|
|
@@ -1159,13 +1145,9 @@ Uses shorthand syntax when property name and value identifier match.
|
|
|
1159
1145
|
{ name: name, age: age }
|
|
1160
1146
|
```
|
|
1161
1147
|
|
|
1162
|
-
```
|
|
1163
|
-
{
|
|
1164
|
-
|
|
1165
|
-
}
|
|
1166
|
-
{
|
|
1167
|
-
(name, age);
|
|
1168
|
-
}
|
|
1148
|
+
```js Output
|
|
1149
|
+
{ x, y }
|
|
1150
|
+
{ name, age }
|
|
1169
1151
|
```
|
|
1170
1152
|
|
|
1171
1153
|
### Method shorthand
|
|
@@ -1181,7 +1163,7 @@ Uses method shorthand syntax in object literals.
|
|
|
1181
1163
|
}
|
|
1182
1164
|
```
|
|
1183
1165
|
|
|
1184
|
-
```
|
|
1166
|
+
```js Output
|
|
1185
1167
|
{
|
|
1186
1168
|
foo() {},
|
|
1187
1169
|
async bar() {}
|
|
@@ -1201,10 +1183,8 @@ function test() {
|
|
|
1201
1183
|
}
|
|
1202
1184
|
```
|
|
1203
1185
|
|
|
1204
|
-
```
|
|
1205
|
-
function test()
|
|
1206
|
-
return x;
|
|
1207
|
-
}
|
|
1186
|
+
```js Output
|
|
1187
|
+
function test(){return x}
|
|
1208
1188
|
```
|
|
1209
1189
|
|
|
1210
1190
|
### Drop console calls
|
|
@@ -1219,10 +1199,10 @@ console.warn("warning");
|
|
|
1219
1199
|
x = console.error("error");
|
|
1220
1200
|
```
|
|
1221
1201
|
|
|
1222
|
-
```
|
|
1202
|
+
```js Output
|
|
1223
1203
|
void 0;
|
|
1224
1204
|
void 0;
|
|
1225
|
-
x
|
|
1205
|
+
x=void 0;
|
|
1226
1206
|
```
|
|
1227
1207
|
|
|
1228
1208
|
### Drop custom function calls
|
|
@@ -1231,12 +1211,12 @@ x = void 0;
|
|
|
1231
1211
|
|
|
1232
1212
|
Removes calls to specified global functions or methods.
|
|
1233
1213
|
|
|
1234
|
-
```ts
|
|
1214
|
+
```ts Input
|
|
1235
1215
|
assert(condition);
|
|
1236
1216
|
obj.assert(test);
|
|
1237
1217
|
```
|
|
1238
1218
|
|
|
1239
|
-
```
|
|
1219
|
+
```js Output with --drop=assert
|
|
1240
1220
|
void 0;
|
|
1241
1221
|
void 0;
|
|
1242
1222
|
```
|
|
@@ -1268,7 +1248,7 @@ This preserves the `.name` property on functions and classes while still minifyi
|
|
|
1268
1248
|
|
|
1269
1249
|
Using all three minification modes together:
|
|
1270
1250
|
|
|
1271
|
-
```ts
|
|
1251
|
+
```ts input.ts (158 bytes)
|
|
1272
1252
|
const myVariable = 42;
|
|
1273
1253
|
|
|
1274
1254
|
const myFunction = () => {
|
|
@@ -1280,7 +1260,7 @@ const myFunction = () => {
|
|
|
1280
1260
|
const output = myFunction();
|
|
1281
1261
|
```
|
|
1282
1262
|
|
|
1283
|
-
```
|
|
1263
|
+
```js output.js
|
|
1284
1264
|
// Output with --minify (49 bytes, 69% reduction)
|
|
1285
1265
|
const a=42,b=()=>{const c=!0,d=void 0;return c?a:d},e=b();
|
|
1286
1266
|
```
|