Boshen
cfb51f2551
refactor(minifier): fuse ast passes ( #8184 )
2024-12-29 14:57:20 +00:00
Boshen
8149e34bf0
feat(minifier): optional catch binding when es target >= es2019 ( #8180 )
2024-12-29 12:27:33 +00:00
Boshen
ad146bbb90
feat(codegen): print real newline when \n is inside template literals ( #8178 )
2024-12-29 12:20:47 +00:00
sapphi-red
75d5f17dbd
fix(minifier): minify string PropertyKey ( #8177 )
...
#8169 added `if self.in_fixed_loop` in `try_compress_property_key`. Because `exit_property_key` was not called for `PeepholeOptimizations`, `try_compress_property_key` was never called.
refs #8147
2024-12-29 07:49:42 +00:00
sapphi-red
fc43ec530e
feat(minifier): fold string.length / array.length ( #8172 )
2024-12-29 07:14:13 +00:00
Boshen
29dc0dc070
feat(minifier): change foo['bar'] -> foo.bar ( #8169 )
2024-12-29 04:09:42 +00:00
翠 / green
3c5718d68b
feat(minifier): fold typeof foo == undefined into foo == undefined when possible ( #8160 )
2024-12-29 11:49:57 +08:00
翠 / green
9d62284202
chore(tasks): print diff for minify idempotency assertion ( #8161 )
...
Made the assertion error output more easier to understand.
Example output:

---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-29 00:55:45 +08:00
翠 / green
f3a36e1dbf
feat(minifier): fold typeof foo != "undefined" into typeof foo < "u" ( #8159 )
2024-12-29 00:50:56 +08:00
Boshen
37c9959611
feat(minifier): normalize Infinity into f64::Infinity ( #8148 )
2024-12-28 06:05:04 +00:00
Boshen
8fb71f518f
feat(minifier): minify string PropertyKey ( #8147 )
2024-12-27 15:09:41 +00:00
Boshen
2b2a37347c
feat(minifier): minimize a + 'b' + 'c' -> a + 'bc' ( #8137 )
2024-12-27 05:46:51 +00:00
Boshen
213364a400
feat(minifier): minimize if (x) if (y) z -> if (x && y) z ( #8136 )
2024-12-27 02:44:47 +00:00
Boshen
6b51e6dff1
feat(minifier): minimize if(foo) bar else baz -> foo ? bar : baz ( #8133 )
2024-12-26 16:21:34 +00:00
Boshen
f615bfa773
feat(minifier): minimize if (x) return; return 1 -> return x ? void 0 : 1 ( #8130 )
2024-12-26 15:36:25 +00:00
Yuichiro Yamashita
e676fdfd83
chore(tasks): use assert_eq! instead of assert! (tasks/minsize/src/lib.rs) ( #8129 )
...
related to https://github.com/oxc-project/oxc/pull/8124
2024-12-26 13:54:05 +00:00
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