Commit Graph

445 Commits

Author SHA1 Message Date
Donny/강동윤
0aab90c005
fix(es/minifier): Fix a inliner bug related to Script (#7288)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/7287.
2023-04-19 07:22:48 +00:00
Donny/강동윤
4c06a56e52
fix(es/minifier): Use UTF16 length for str.length (#7275)
**Related issue:**

 - Closes #7274.
2023-04-15 14:50:52 +00:00
Austaras
93a264c9a4
fix(es/renamer): Ensure that param and function body are in same scope (#7271)
**Description:**

The problem arises in L235 of swc_ecma_transforms_base/src/rename/mod.rs

```rs
unit!(visit_mut_fn_decl, FnDecl, true);
```

which calls `get_map` and evals to

```rs
node.visit_children_with(&mut v);
```

with `FnDecl` and `Analyzer` in L132. However, in `Analyzer`, a visit to raw function was not overloaded, so function arguments and function body are considered different scopes.

**Related issue:**

 - Closes #7261.
2023-04-15 04:19:52 +00:00
Donny/강동윤
a44fea1ec8
fix(es/minifier): Fix handling of optional chaining when hoist_props is enabled (#7246)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/7228.
2023-04-13 03:23:29 +00:00
Donny/강동윤
559d1202bc
feat(es/minifier): Support PURE comment of seq exprs (#7245)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/7241.
2023-04-11 04:48:11 +00:00
Donny/강동윤
73bc29eeb0
fix(es/minifier): Don't remove used var decl (#7200)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/7194.
2023-04-05 04:35:37 +00:00
magic-akari
3ca954b9f9
fix(es/helpers): Use snake_case for helpers (#7147)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/7144.
 - Closes https://github.com/swc-project/swc/issues/7118.
2023-03-31 15:15:21 +09:00
Donny/강동윤
0259a7465f
build(cargo): Update rustc to nightly-2023-03-20 (#7170)
**Description:**

This PR also updates `rkyv` to `=0.7.40`.

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6807.
2023-03-30 08:06:02 +00:00
Donny/강동윤
12546c853a
build(cargo): Revert rustc upgrade (#7162)
**Description:**

The `rkyv` bug is not fixed.
2023-03-29 17:48:45 +09:00
Donny/강동윤
e445502072
build(cargo): Update rustc to nightly-2023-03-28 (#7154)
**Description:**

This PR also updates `rkyv` to `=0.7.40`.

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6807.
2023-03-29 06:24:19 +00:00
Donny/강동윤
6d9763e8c0
fix(es/renamer): Don't use symbols used by declarations if eval exists (#7116)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6971.
 - Closes https://github.com/swc-project/swc/issues/7094.
2023-03-22 06:31:43 +00:00
Donny/강동윤
610e1bb581
fix(es/minifier): Don't inline into arrow heads (#7099)
**Related issue:**

 - https://github.com/vercel/next.js/issues/47005
2023-03-22 02:24:13 +00:00
Donny/강동윤
6a570a334c
fix(es/ast): Fix EqIgnoreSpan impl of Number (#7112)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/7111.
2023-03-21 08:46:22 +00:00
Anders Kaseorg
493a4f7042
fix(es/minifier): Remove wrong optimization of new RegExp(…) (#7091) 2023-03-17 03:22:02 +00:00
Donny/강동윤
86295ba8f2
fix(es/minifier): Preserve delete of unresolved variables (#7072)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/7045.
2023-03-15 02:31:08 +00:00
Donny/강동윤
963c460613
refactor: Fix lints using clippy from nightly-2023-03-13 (#6920) 2023-03-14 04:56:21 +00:00
Donny/강동윤
a9fe1d2d22
perf(es/ast): Shrink size of Expr (#7041)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/7019.
2023-03-09 13:34:11 +00:00
Austaras
1318afe2b4
fix(es/minifier): Bailout regex optimization on invalid flags (#7020) 2023-03-07 11:05:04 +09:00
magic-akari
bb2486c459
fix(es/minifier): Don't create invalid property names (#7010) 2023-03-04 17:58:49 +09:00
Austaras
06cbb9002d
feat(es/minifier): Optimize calls to Boolean/Number/String/Symbol (#7006) 2023-03-04 04:14:14 +00:00
Austaras
cfeb088c37
fix(es/minifier): Don't skip expressions with side effects from seq inliner (#7007) 2023-03-04 12:32:15 +09:00
magic-akari
a27ffd2242
feat(es/minifier): Drop unused import bindings (#6967) 2023-02-21 06:22:25 +00:00
magic-akari
1dfadb8790
fix(es/minifier): Fix optimization of expressions in numeric context (#6965) 2023-02-20 05:28:28 +00:00
magic-akari
9382bda786
fix(es/minifier): Fix toFixed, toPrecision, toExponential and toString of Number (#6960) 2023-02-19 23:18:14 +09:00
Donny/강동윤
725d3fb645
fix(es/minifier): Don't skip shorthand properties from sequential inliner (#6918)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6914.
2023-02-09 03:07:31 +00:00
Donny/강동윤
951dafbc1a
fix(es/minifier): Don't break ternary with assignment in test (#6906)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6903.
2023-02-08 02:10:44 +00:00
Donny/강동윤
432dca647b
fix(es/minifier): Respect span hygiene from expr simplifier (#6899)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6896.
2023-02-07 05:14:19 +00:00
Austaras
c0e72ef64a
fix(es/minifier): Track reassign in parent scope (#6865)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6864.
2023-01-28 17:19:19 +00:00
Donny/강동윤
d1687d8e01
feat(es/minifier): Improve compatibility of arrows with terser (#6862)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6123.
2023-01-27 14:36:12 +09:00
Austaras
55225cb994
refactor(es/minifier): Merge cond_init with reassigned (#6850)
**Description:**

And optimize the following situation
```js
export function genElement(el, state) {
    if ('slot' === el.tag) return el1 = el, genChildren(el1);
    if (el.component) {
        var el1
        return 999;
    }
}
```
which rarely happens in hand written JS, but is often generated by swc merge variable pass.
2023-01-26 10:17:33 +09:00
Donny/강동윤
21e14787c5
fix(es/minifier): Don't inline into await from sequential inliner (#6839)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6837.
2023-01-20 08:50:51 +00:00
Donny/강동윤
df702614e1
fix(es/codegen): Fix codegen of string literals with \x000 (#6838)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6836.
2023-01-20 08:08:58 +00:00
Donny/강동윤
ebce18b221
fix(es/renamer): Handle rest params correctly (#6821)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6819.
2023-01-16 06:57:16 +00:00
Donny/강동윤
8f683e3f77
feat(es/minifier): Remove noop spreads (#6803)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6788.
2023-01-13 06:55:04 +00:00
Donny/강동윤
a299fd0418
test(es/minifier): Add a test for an invalid issue (#6802)
**Related issue:**
 
 - https://github.com/vercel/next.js/discussions/30237#discussioncomment-4674405
2023-01-13 05:39:22 +00:00
Donny/강동윤
631dd7872b
feat(es/renamer): Support safari10 from the name mangler (#6801) 2023-01-13 05:00:13 +00:00
Donny/강동윤
c14540905f
fix(es/transform): Apply hygiene and resolver if minify is specified (#6793)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6791.
2023-01-12 07:29:28 +00:00
Donny/강동윤
06770cff04
fix(es/minifier): Make AST compressor respect toplevel (#6775)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/4386.
2023-01-11 07:04:20 +00:00
Donny/강동윤
336b1d8b4d
fix(es/minifier): Don't inline conditionally initialized vars (#6751)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6750.
 - Closes https://github.com/swc-project/swc/issues/6780.
2023-01-11 06:01:56 +00:00
Donny/강동윤
ec7e913815
fix(es/minifier): Make name mangler respect toplevel (#6774)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6418.
2023-01-10 06:42:49 +00:00
HeYunfei
8a6a1cbcf1
feat(es/minifier): Handle boolean in Evaluator (#6756)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/5953.
2023-01-06 08:15:07 +00:00
HeYunfei
a1ccc8afdf
feat(es/minifier): Make name mangler understand block scoping (#6670)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/5090.
 - Closes https://github.com/swc-project/swc/issues/5766.
2023-01-06 03:14:10 +00:00
Donny/강동윤
88d40e8ab8
fix(es/minifier): Fix usage counter to fix infinite loop (#6744)
**Description:**

We skip non-computed property names while checking if we can inline an expression.

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6729.
2023-01-04 04:31:12 +00:00
Donny/강동윤
206c0dbebe
fix(es/compat): Fix syntax context of async-to-generator (#6741)
**Description:**

Previously, the `async-to-generator` produced invalid AST, in the aspect of span hygiene.

[Playground](https://play.swc.rs/?version=1.3.24&code=H4sIAAAAAAAAAz1MbQqAIBT77yn2UyG6gNQJuoSZRCAa7xkk4d1TicZgH7C5%2B4yUYGPgBE7ZuyWazREmSIVpxiMAcumi0C3ANZxyvQ6%2Fqa8CehxjaGNpOAcLaWjn%2F6KhKN1dGaoULSpfHPTdxn8AAAA%3D&config=H4sIAAAAAAAAA0WOSwrDMAxE76K1F22hXfgE3fQQxlWCi39ICsQY3z12cMlOjObNTIUfW9AVsiFGGheXKGYHDVIysiWXBRQId2kxnrEpwF2QovFv9BmJQQtt2D2GVpROIj9u92enfEqMk1MQXHRLGR02hUzIfL1MXP3f2XpFSN9tCPWccWa%2BoF0Zk3P8mcYxoR3Kj7IYzwAAAA%3D%3D).
It generate two bindings for `args` so it's invalid.


**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6730.
2023-01-03 09:45:03 +00:00
HeYunfei
b5d31cc2da
fix(es/utils): Fix detection of hoisting (#6738) 2023-01-03 03:12:01 +00:00
Donny/강동윤
707b1e3cd2
feat(es/minifier): Improve simplification of ?. (#6681)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6492.
2022-12-20 09:34:50 +00:00
Donny/강동윤
7e6ec8d587
fix(es/minifier): Don't inline invalid LHS into an update argument (#6680)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6641.
2022-12-20 07:45:29 +00:00
Donny/강동윤
bb9fab8d03
fix(es/minifier): Abort IIFE invoker completely on eval (#6659)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6628.
2022-12-15 07:49:58 +00:00
Donny/강동윤
7f3e6983e5
test(es/minifier): Enable size tests created from creduce (#6646) 2022-12-14 09:19:51 +00:00
Donny/강동윤
e4e4d6cf6b
fix(es/minifier): Abort sequential inliner on optional chaining (#6637)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6636.
2022-12-14 04:45:47 +00:00