7086cmd
a2977655c8
refactor(minifier): use map and and_then instead of let else ( #7178 )
...
For the test case, Closure Compiler doesn't handle this at all in the REPL! If it's necessary, I will turn it back.
This PR uses builtin `and_then` and `map` method, which is better instead of a lot of `if let Some`.
2024-11-09 11:48:48 +00:00
overlookmotel
97caae16e2
refactor(minifier): do not use AstBuilder::*_from_* methods ( #7072 )
...
Preparation for #7073 . Avoid using `AstBuilder::*_from_*` methods to construct enums, use explicit construction instead.
Before:
```rs
let ident = self.ast.binding_pattern_kind_from_binding_identifier(ident);
```
After:
```rs
let ident = BindingPatternKind::BindingIdentifier(ident);
```
Often this produces shorter code, as well as (in my opinion) being easier to read.
2024-11-02 01:22:56 +00:00
Boshen
2c7ac29ece
refactor(minifier): remove Tri, use Option<bool> instead ( #6912 )
2024-10-26 04:28:34 +00: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
Boshen
8bcaf59cf9
feat(minifier): late peeophole optimization ( #6882 )
2024-10-25 16:12:29 +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
Boshen
442975408b
feat(ecmascript): constant eval null to number ( #6879 )
2024-10-25 04:23:24 +00:00
camc314
c26020e553
feat(minifier): implement folding String.prototype.replaceAll ( #6871 )
2024-10-25 01:29:57 +00:00
camc314
50744f341b
feat(minifier): implement folding String.prototype.replace ( #6870 )
2024-10-25 01:29:57 +00:00
camc314
fccf82e4df
feat(minifier): implement folding substring string fns ( #6869 )
2024-10-25 01:29:56 +00:00
camc314
322f9d44b7
chore(minifier): remove planned minification for String.substr as its deprecated ( #6868 )
...
According to mdn, `String.prototype.substr()` has been deprecated, hence i do not think it makes sense to attempt to optimize this code.
This pull request removes the test cases along with the placeholder code for minification of this method
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
2024-10-24 14:53:22 +00:00
camc314
e6a5a1b11c
feat(minifier): implement folding charCodeAt string fns ( #6475 )
2024-10-24 14:37:50 +00:00
Boshen
a47c70e425
fix(minifier): fix remaining runtime bugs ( #6855 )
2024-10-24 12:22:18 +00:00
Boshen
686727fc96
fix(minifier): reference read has side effect ( #6851 )
2024-10-24 08:32:38 +00:00
Boshen
c658d9336d
fix(minifier): keep template literals with expressions ( #6849 )
2024-10-24 08:12:44 +00:00
Boshen
fd57e00108
feat(ecmascript): add abstract_relational_comparison to dce ( #6846 )
...
I removed bigint comparisons because they were incorrect
2024-10-24 06:46:07 +00:00
Boshen
ca799936b0
fix(minifier): do not dce object literals yet ( #6839 )
...
closes #6769
2024-10-24 01:05:07 +00:00
Boshen
ec5a19b880
fix(minifier): do not remove binary expressions ( #6829 )
2024-10-23 16:07:29 +00:00
Boshen
22355f73f3
fix(minifier): do not remove undefined for destructuring patterns ( #6828 )
2024-10-23 15:42:04 +00:00
Boshen
2f6ad42348
fix(codegen): print negative bigint 1n- -1n correctly after constant folding ( #6798 )
...
closes #6767
2024-10-23 04:56:50 +00:00
camc314
b4bc300ebf
feat(minifier): improve folding block stmts ( #6793 )
2024-10-23 04:13:58 +00:00
camc314
7c51b2fd9d
chore(minifier): remove duplicate minifier test ( #6792 )
...
these tests already exist below (and have been enabled)
34fe7c00a3/crates/oxc_minifier/src/ast_passes/peephole_remove_dead_code.rs (L576-L597)
i suspect this was left in as a copy/pasta error
2024-10-23 04:07:50 +00:00
Boshen
8b25131d11
refactor(minifier): binary operations use ConstantEvaluation ( #6700 )
2024-10-20 15:13:27 +00:00
7086cmd
34fe7c00a3
feat(minifier): dce meaningless labeled statements ( #6688 )
2024-10-19 15:48:54 +00:00
Boshen
1a90ec4b85
refactor(rust): backport v1.82.0 changes to main branch first ( #6690 )
2024-10-19 14:30:55 +00:00
Boshen
f4cdc56577
refactor(minifier): use constant folding unary expression from oxc_ecmascript ( #6647 )
2024-10-17 15:30:38 +00:00
Boshen
e5ed6a56a8
feat(codegen): print negative numbers ( #6624 )
2024-10-16 22:38:54 +00:00
Boshen
389d2615d0
fix(minifier): ~~ operator should only work on numbers ( #6598 )
2024-10-15 16:37:00 +00:00
Boshen
16bea12f9c
fix(minifier): use to_js_string() instead of fs64::to_string ( #6597 )
2024-10-15 16:16:26 +00:00
camc314
071e5643f3
feat(minifier): finish implementing folding object expressions ( #6586 )
2024-10-15 15:51:34 +00:00
camc314
590925a40c
feat(minifier): finish implementing folding array expressions ( #6575 )
2024-10-15 15:43:09 +00:00
magic-akari
a71e8a00bf
fix(minifier): Preserve init variable declarations when removing for statements during DCE ( #6551 )
...
- Closes : #6547
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-15 16:51:30 +08:00
Boshen
e56188037c
feat(ecmascript): add constant_evaluation and side_effects code ( #6550 )
...
I intend to move most of the constant evaluation code into the crate.
2024-10-15 05:15:46 +00:00
camc314
ef237cf8ff
feat(minifier): complete implementation of statement fusion ( #6566 )
...
- enables all test in statement fusion
- implements some more node in `may_have_side_effects`
2024-10-15 02:14:49 +00:00
Boshen
3556062213
feat(ecmascript): add ConstantEvaluation ( #6549 )
2024-10-14 07:53:44 +00:00
Boshen
67ad08a056
refactor(minifier): unify ValueType ( #6545 )
2024-10-14 04:21:42 +00:00
dalaoshu
97c8a3608f
feat(minifier): implement collapse-variable-declarations ( #6464 )
2024-10-13 23:01:50 +08:00
Boshen
6d041fb469
refactor(ecmascript): remove NumberValue ( #6519 )
2024-10-13 14:11:37 +00:00
Boshen
6f2253886d
feat(ecmascript): add ToBoolean, ToNumber, ToString ( #6502 )
2024-10-13 11:03:08 +00:00
camc314
096e590483
feat(minifier): implement folding charAt string fns ( #6436 )
2024-10-13 06:41:05 +00:00
camc314
e5a6f5de6a
feat(minifier): implement converting template literals to strings ( #6486 )
...
basically:
```
`hello ${"world"}`
```
now becomes:
```
"hello world"
```
2024-10-13 06:26:32 +00: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
Boshen
bbca743689
refactor(minifier): move string methods to oxc_ecmascript ( #6472 )
2024-10-12 09:40:43 +00:00
Boshen
856cab5000
refactor(ecmascript): move ToInt32 from oxc_syntax to oxc_ecmascript ( #6471 )
2024-10-12 09:29:46 +00:00
7086cmd
702c049ebc
refactor(minifier): move compress block to dce ( #6468 )
2024-10-12 07:59:44 +00:00
camc314
a4f57a42e8
feat(minifier): implement folding indexOf and lastIndexOf string fns ( #6435 )
2024-10-12 04:36:13 +00:00
7086cmd
3677ef81e9
feat(minifier): dce ExpressionStatements with no side effect ( #6457 )
...
Not sure about the performance. Just have a try.
2024-10-11 13:40:44 +00:00
7086cmd
06ea1216af
feat(minifier): fold for statement ( #6450 )
2024-10-11 08:33:23 +00:00
Boshen
46a38c63ff
refactor(minifier): remove allow clippy::unused_self ( #6441 )
2024-10-11 02:54:25 +00:00