7086cmd
f9ae70c74a
feat(minifier): minify basic arithmetic calculations. ( #6280 )
...
It uses to_string to check which is shorter, which is extremely tough. Waiting for further refactor.
2024-10-07 10:41:06 +00:00
camchenry
4008afe512
feat(minifier): fold array and object constructors ( #6257 )
...
This will fold expressions like `new Object()` to `{}`, and `new Array()` to `[]`. Based on the closure compiler tests: b7e380b632/test/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntaxTest.java (L78) .
This is outside my usual area, so feedback is welcome.
NOTE: this was previously a full stack of PRs, but Graphite decided to stop working completely for some reason and only gave me this error when I submitted a PR:
```
ERROR: Failed to submit PR for 10-02-feat_minifier_fold_single_arg_new_array_expressions:
{}
```
so I decided to just completely remake this stack and submit as 1 PR.
2024-10-07 06:02:07 +00:00
7086cmd
37cbabbac4
fix(minifier): should not handle the strict operation for bool comparison. ( #6261 )
2024-10-03 12:16:10 +00:00
7086cmd
23b646484c
feat(minifier): fold true / false comparison. ( #6225 )
...
Input:
```js
a == false
```
Previous:
```js
a == !1
```
Current:
```js
a == 0
```
Only handle it when it is non-plus, non-relation binary expressions. Align with [Closure Compiler](https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520SIMPLE_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%2540formatting%2520pretty_print%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250Ax%2520%253C%253C%2520true%253B%250A%250Ax%2520%252B%2520true%253B%250A%250Ax%2520-%2520true%253B%250A%250Ax%2520%257C%2520true%253B%250A%250Ax%2520%2525%2520true%253B%250A%250Ay%2520!%253D%2520false%253B%250A%250Af()%2520%253D%253D%2520false%253B%250A%250Ax%2520instanceof%2520true%250A%250Ax%2520**%2520true%250A%250Ax%2520%2526%2520true%250A%250Ax%2520%255E%2520false%250A%250Ax%2520%253D%253D%2520(x%2520instanceof%2520false)%250A%250Ax%2520instanceof%2520(x%2520%253C%253C%2520true)%250A%250Ax%2520%253D%253D%2520fake(false) ).
2024-10-02 13:37:17 +00:00
7086cmd
585ccdad8c
feat(minifier): support subtraction assignment. ( #6214 )
...
Due to the potential for string concatenation when using the `+=` operator, we should only handle the scenario when using the `-=` operator.
2024-10-02 01:42:56 +00:00
7086cmd
cca0034e8b
feat(minifier): handle positive NaN and Infinity. ( #6207 )
...
`+NaN` -> `NaN`, `+Infinity` -> `Infinity`.
2024-10-01 10:12:19 +00:00
Boshen
5c323a2105
feat(minifier): loop compressor passes ( #6013 )
2024-09-24 03:09:35 +00:00
Boshen
612f638bcd
chore: change just c to run cargo conformance
2024-09-22 23:50:30 +08:00
Boshen
f4aefb57d8
fix(codegen): print let[0] as (let)[0] ( #5947 )
2024-09-21 15:09:55 +00:00
Boshen
d901772daa
feat(codegen): implement minify number from terser ( #5929 )
2024-09-20 14:42:28 +00:00
Boshen
6bc13f6cd4
feat(minifier): add MinimizeConditions pass ( #5747 )
...
I expect small performance regression.
But managed to improve the following case from react.developmement.js
```
oxc main ❯ diff before.js after.js
670c670
< if (!(dispatcher !== null)) throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.");
---
> if (dispatcher === null) throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.");
```
2024-09-13 08:31:45 +00:00
Boshen
748e6f80fe
chore(minsize): update minsize.snap
2024-09-12 19:02:46 +08:00
Boshen
94d3c31933
fix(minifier): avoid removing function declaration from KeepVar ( #4722 )
2024-08-07 05:09:32 +00:00
Boshen
a558492bf9
feat(codegen): implement BinaryExpressionVisitor ( #4548 )
...
part of https://github.com/oxc-project/backlog/issues/58
`monitor-oxc` run: https://github.com/oxc-project/monitor-oxc/actions/runs/10179047831
binary expression stack length tally using `counts` in top 100 npm packages from monitor-oxc:
```
29772 counts
( 1) 17652 (59.3%, 59.3%): 0
( 2) 5772 (19.4%, 78.7%): 1
( 3) 3204 (10.8%, 89.4%): 2
( 4) 1276 ( 4.3%, 93.7%): 3
( 5) 616 ( 2.1%, 95.8%): 4
( 6) 308 ( 1.0%, 96.8%): 5
( 7) 202 ( 0.7%, 97.5%): 6
( 8) 168 ( 0.6%, 98.1%): 7
( 9) 114 ( 0.4%, 98.5%): 9
( 10) 90 ( 0.3%, 98.8%): 8
( 11) 84 ( 0.3%, 99.0%): 13
( 12) 58 ( 0.2%, 99.2%): 10
( 13) 48 ( 0.2%, 99.4%): 12
( 14) 32 ( 0.1%, 99.5%): 11
( 15) 20 ( 0.1%, 99.6%): 134
( 16) 16 ( 0.1%, 99.6%): 18
( 17) 16 ( 0.1%, 99.7%): 20
( 18) 12 ( 0.0%, 99.7%): 19
( 19) 12 ( 0.0%, 99.8%): 35
( 20) 12 ( 0.0%, 99.8%): 51
( 21) 10 ( 0.0%, 99.8%): 15
( 22) 6 ( 0.0%, 99.9%): 17
( 23) 6 ( 0.0%, 99.9%): 21
( 24) 6 ( 0.0%, 99.9%): 45
( 25) 4 ( 0.0%, 99.9%): 14
( 26) 4 ( 0.0%, 99.9%): 26
( 27) 4 ( 0.0%, 99.9%): 53
( 28) 2 ( 0.0%, 99.9%): 172
( 29) 2 ( 0.0%, 99.9%): 214
( 30) 2 ( 0.0%,100.0%): 22
( 31) 2 ( 0.0%,100.0%): 27
( 32) 2 ( 0.0%,100.0%): 28
( 33) 2 ( 0.0%,100.0%): 29
( 34) 2 ( 0.0%,100.0%): 31
( 35) 2 ( 0.0%,100.0%): 36
( 36) 2 ( 0.0%,100.0%): 46
( 37) 2 ( 0.0%,100.0%): 55
```
2024-07-31 12:44:19 +00:00
Boshen
35654e665c
feat(codegen): align operator precedence with esbuild ( #4509 )
...
closes #4339
2024-07-28 11:48:51 +00:00
Boshen
6a94e3f573
fix(codegen): fixes for esbuild test cases ( #4503 )
2024-07-28 08:57:15 +00:00
Boshen
33e96e23e4
feat(tasks/minsize): include esbuild minified size ( #4202 )
2024-07-11 13:02:32 +00:00
Boshen
bb646f2bf9
feat(tasks/minsize): show target size for easier comparison ( #4201 )
2024-07-11 12:38:45 +00:00
Boshen
e3e663bae4
feat(mangler): initialize crate and integrate into minifier ( #4197 )
2024-07-11 10:35:13 +00:00
Boshen
ca0b4fa08a
refactor(tasks): clean up test files and remove libs.txt ( #4172 )
2024-07-10 17:38:06 +00:00
Boshen
d77ec9f95a
chore: remove trailing whitespaces for all files; add .editorconfig ( #3639 )
2024-06-12 15:47:26 +08:00
Boshen
f366d9bd7c
chore(minsize): remove brotlic because it takes too long to compile ( #2954 )
2024-04-13 13:24:25 +08:00
Boshen
ef8aaa7bf1
feat(minifier): re-enable mangler ( #972 )
2023-10-10 14:32:58 +08:00
Don Isaac
fd899be4a9
feat(minifier): compress undefined variable declarations ( #532 )
2023-07-10 10:33:42 +08:00
Wenzhe Wang
a32320646d
feat(minfier): try fold and or operator ( #472 )
2023-06-28 14:58:55 +08:00
阿良仔
1182985bb0
feat(minifier): implement try_fold_shift ( #478 )
...
* feat: implement `try_fold_shift`
* update minsize
2023-06-27 04:44:23 +08:00
Wenzhe Wang
cb94937ba6
feat(minifier): fold string string comparison ( #471 )
2023-06-26 22:37:50 +08:00
Wenzhe Wang
b8f5e3ad92
feat(minifier): try reduce void ( #457 )
2023-06-23 00:10:46 +08:00
Boshen
d30735677b
refactor(semantic): merge semantic2 crate into semantic crate ( #460 )
2023-06-19 20:20:59 +08:00
Wenzhe Wang
5d10f96051
feat(minifier): try fold unary expression ( #430 )
2023-06-16 00:08:14 +08:00
u9g
db624da84d
Reimplement more of the closure var rename step ( #447 )
...
Co-authored-by: Boshen <boshenc@gmail.com>
closes #442
2023-06-15 23:37:04 +08:00
Boshen
a79480b078
feat(minifier): separate mangler pass ( #439 )
2023-06-14 10:46:13 +08:00
Boshen
5c91fd54e3
feat(minifier): print [-In] Context ( #428 )
2023-06-11 16:44:48 +08:00
Wenzhe Wang
7c79fbc026
feat(minifier): try fold typeof ( #408 )
2023-06-07 10:44:28 +08:00
Wenzhe Wang
ddc129262d
feat(minifer): minify number ( #405 )
2023-06-03 21:24:39 +08:00
Boshen
f8125af850
feat(minimizer): print parentheses
2023-06-01 22:45:26 +08:00
Wenzhe Wang
4109c8b8a5
feat(parser): distinguish exponential number ( #399 )
2023-06-01 15:15:22 +08:00
Wenzhe Wang
a20d5b55cd
feat(minifier): may add space before binaryOperator ( #380 )
2023-05-27 19:18:06 +08:00
Wenzhe Wang
a0b9628177
feat(minifer): distinguish-op-lessthan ( #391 )
2023-05-27 17:04:54 +08:00
Boshen
829f945479
chore(minifier): add a few passing tests
2023-05-27 12:27:25 +08:00
Boshen
8ea9e38ee5
feat(minifier): remove redundant curly braces from block statements ( #390 )
2023-05-27 10:52:15 +08:00
Boshen
ee6f18091b
chore(minsize): add newlines in between for better diff
2023-05-25 22:42:11 +08:00
Boshen
c4a67b6cfb
feat(minifier): fold return undefined to return ( #387 )
2023-05-25 22:37:55 +08:00
Boshen
f5b57944e2
feat(minifier): print shorter numbers ( #381 )
2023-05-24 22:03:50 +08:00
Yoni Feng
c1d1846714
Add Brotli size to minsize task output ( #377 )
2023-05-23 17:00:49 +08:00
Boshen
dee09da60b
feat(minifier): implement peephole reorder constant expression from closure compiler ( #376 )
2023-05-23 12:29:29 +08:00
Boshen
827cef3311
chore(minsize): use default version of flate2 (removes 2 extra dependencies)
2023-05-23 00:32:00 +08:00
Boshen
42dd639e74
chore(minsize): update snapshot
2023-05-22 12:29:52 +08:00
Boshen
009fc5f285
feat(minifier): minify Infinity
2023-05-21 22:01:47 +08:00
Boshen
f8828db68c
feat(semantic2): slot based mangler ( #364 )
2023-05-20 19:00:57 +08:00