Boshen
f0b1ee5a06
feat(minifier): minimize if(!x) foo() -> x || foo() ( #8122 )
2024-12-26 09:42:34 +00:00
Boshen
f8200a8882
feat(minifier): minimize if(foo) bar -> foo && bar ( #8121 )
2024-12-26 09:01:38 +00:00
Boshen
72d996709e
feat(minifier): add Normalize ast pass ( #8120 )
2024-12-26 07:02:45 +00:00
Boshen
fef0b25fd3
feat(minifier): collapse var into for loop initializer ( #8119 )
...
`var a = 0; for(;a<0;a++) {}` => `for(var a = 0;a<0;a++) {}`
2024-12-26 05:22:02 +00:00
Boshen
2331ea85d9
feat(minifier): typeof foo === 'number' => typeof foo == 'number' ( #8112 )
2024-12-25 14:52:58 +00:00
Boshen
e594c3988d
refactor(minifier): clean up peephole_substitute_alternate_syntax.rs ( #8111 )
2024-12-25 13:54:51 +00:00
Boshen
47276679f5
feat(codegen): minify arrow expr (x) => y -> x => y ( #8078 )
2024-12-24 14:25:01 +00:00
Boshen
0562830549
feat(codegen): minify string with backtick when needed ( #8095 )
2024-12-24 13:39:31 +00:00
Boshen
6237c0527f
feat(codegen): minify more whitespace ( #8089 )
2024-12-24 09:54:13 +00:00
Boshen
8b8cbcd2db
feat(codegen): minify case "foo" -> case"foo" ( #8085 )
2024-12-24 01:07:58 +00:00
Boshen
f8f067bfc6
feat(codegen): minify class method async*fn(){} ( #8083 )
2024-12-24 00:35:29 +00:00
Boshen
618b6aa085
feat(codege): minify whitespace in object getter / setter ( #8080 )
2024-12-23 16:36:03 +00:00
Boshen
1d5ae817d7
feat(codegen): minify const [foo] = bar -> const[foo]=bar ( #8079 )
2024-12-23 16:20:37 +00:00
Boshen
373279b7f4
feat(codegen): balance string quotes when minify whitespace ( #8072 )
2024-12-23 13:24:22 +00:00
翠 / green
1932f1e0a0
feat(minifier): fold foo === undefined || foo === null ( #8063 )
...
This PR implements folding `foo === undefined || foo === null` into `foo
== null`.
I checked the minified output diff this time, so hoping that there isn't
a bug.
2024-12-23 00:10:44 +08:00
Boshen
23b563730f
feat(tasks/minsize): save minified file
2024-12-21 18:57:36 +08:00
翠 / green
de8a86e356
fix(minifier): incorrect minification in try_fold_left_child_op ( #7949 )
...
fixes #7944
2024-12-17 10:40:22 +08:00
翠 / green
db9e93b554
feat(mangler): mangle top level variables ( #7907 )
...
Adds `top_level` option which is similar to [terser's `toplevel`
option](https://terser.org/docs/cli-usage/#cli-mangle-options ).
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-15 21:31:41 +08:00
翠 / green
075bd165a8
feat(minifier): fold bitwise operation ( #7908 )
...
This PR implements constant evaluation for bitwise operations (`&`, `|`,
`^`).
I wanted to play around with the minifier a bit 🙂
2024-12-15 21:27:05 +08:00
overlookmotel
3de4a43761
test(minifier): reformat minsize table ( #7678 )
...
Reformat the table which `minsize` task outputs. I always found the column headings confusing previously.
2024-12-05 12:16:29 +00:00
Boshen
d0b78f7361
feat(codegen): minify whitespace for some expressions ( #7671 )
...
part of #7638
2024-12-05 06:59:17 +00:00
Boshen
62a8c5eb59
chore(minifier): temporary remove try_fold_if_block_one and try_fold_if_one_child ( #7536 )
...
They are not idempotent.
2024-11-29 05:05:07 +00:00
Boshen
625a5bad02
refactor(minifier): improve ast passes ( #7518 )
2024-11-28 09:33:31 +00:00
7086cmd
97af341cac
feat(minifier): minify alternated one child if block ( #7231 )
2024-11-26 15:00:16 +00:00
Ethan Goh
ac0d25c426
feat(minifier): minify one child if statement expression ( #7230 )
2024-11-26 22:48:27 +08:00
Boshen
c133693e5c
perf(minifier): fuse ast passes ( #7493 )
2024-11-26 14:30:04 +00:00
Dunqing
58db9ef322
refactor(codegen): do not print unnecessary parentheses if both sides use the same logical operator ( #7325 )
...
As shown by the changing tests, we don't need to print parentheses for them.
### Comparison
In [esbuild](https://esbuild.github.io/try/#dAAwLjI0LjAAAGEgPz8gKGIgPz8gKGMgPz8gZCkpOwooYSA/PyAoYiA/PyAoYyA/PyBkKSkpOwooYSB8fCAoYiB8fCBjKSkgfHwgZDsKYSB8fCAoYiB8fCAoYyB8fCBkKSk7CmEgJiYgKChiICYmIGMpICYmIGQp ), it will print parentheses as-is, in [SWC](https://play.swc.rs/?version=1.9.2&code=H4sIAAAAAAAAA0tUsLdX0EgCk8kgMkVT05pLIxGLMES8pgYkDiSTNTVBVIo1F5IgUDFIDKQ2UUFNTUEDKAykkjVBZIomAGEbiHtuAAAA&config=H4sIAAAAAAAAA1VQzW7DIAy%2B9ykin6tlyrHXTb3ttCdA1GmpACPbSIuqvPuAJml6w9%2Bv8ePQdXAXC6fuUZ5lSIYFeZsLIlNU81cQ0CmhWHZJ4biyKpVSztiQ%2BUmAGr6iVhPK8DkMsOJsoozEYd%2BQBb9xdBHPxF%2FeiJwd%2BossuVsVo7G68xXIhUSsv5TZYi27qSY59T1K%2BJBbn56W48vAOaoLTWuyUjDqLCz0%2FPYDTyRVNxovyw4QXHTjtF%2FdUiglIu%2FCKjXx6jf%2FYc1v6RDokhu5HL0etq5U0gLFu8BLuTZu6eDkZ7W3s8%2F%2FYy0r4MUBAAA%3D ), we have the same output now
2024-11-19 10:31:53 +00:00
Boshen
c7f44c439d
chore(tasks/minsize): enable idempotency test
2024-10-26 10:35:01 +08:00
Boshen
741571f645
refactor(minifier): remove extra compress options ( #6893 )
...
Closure Compiler and ESBuild does not have these kind of granularity.
2024-10-26 01:30:13 +00:00
camc314
860cbca446
feat(minifier): implement folding simple arrow fns ( #6875 )
...
basically
```ts
const foo = () => {
return baz
}
```
becomes
```ts
const foo = () => baz
```
2024-10-25 10:26:33 +00:00
camc314
b4bc300ebf
feat(minifier): improve folding block stmts ( #6793 )
2024-10-23 04:13:58 +00:00
Boshen
8b25131d11
refactor(minifier): binary operations use ConstantEvaluation ( #6700 )
2024-10-20 15:13:27 +00:00
Boshen
f4cdc56577
refactor(minifier): use constant folding unary expression from oxc_ecmascript ( #6647 )
2024-10-17 15:30:38 +00:00
Boshen
389d2615d0
fix(minifier): ~~ operator should only work on numbers ( #6598 )
2024-10-15 16:37:00 +00:00
Boshen
435a89c6e4
refactor(oxc): remove useless allocator.alloc(program) calls ( #6571 )
2024-10-15 02:21:20 +00:00
dalaoshu
97c8a3608f
feat(minifier): implement collapse-variable-declarations ( #6464 )
2024-10-13 23:01:50 +08:00
camc314
14d0590b0b
feat(minifier): implement folding of simple function calls (Boolean) ( #6484 )
...
Basically `Boolean(true)` -> `true` or `Boolean(foo)` -> `!!foo`
2024-10-13 06:26:32 +00:00
camc314
7fbc7b6dae
feat(minifier): implement folding of simple function calls (String) ( #6483 )
...
basically `String(foo)` -> `foo + ''`
2024-10-13 06:26:31 +00:00
7086cmd
06ea1216af
feat(minifier): fold for statement ( #6450 )
2024-10-11 08:33:23 +00:00
camc314
9dc4ee9c98
feat(minifier): implement block stmt support for StatementFusion ( #6422 )
2024-10-10 14:41:04 +00:00
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
Boshen
020bb80b65
refactor(codegen)!: change to CodegenReturn::code and CodegenReturn::map ( #6310 )
2024-10-06 05:05:47 +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
camchenry
02d5637dbc
perf(ast-tools): use FxHashMap over std::collections::HashMap ( #5997 )
2024-09-23 18:28:54 +00:00
Boshen
612f638bcd
chore: change just c to run cargo conformance
2024-09-22 23:50:30 +08:00