Commit Graph

585 Commits

Author SHA1 Message Date
Donny/강동윤
45f671d8d8
fix(es/renamer): Fix renaming of default-exported declarations (#9135)
**Related issue:**

 - Closes #9129
2024-07-04 21:08:45 +09:00
Levi
570c47a9ac
feat(es/minifier): Handle more indexing expression (#8750)
**Related issue:**

 - Closes #8747
2024-07-02 10:15:45 +09:00
Donny/강동윤
5520b236dd
refactor(es/parser): Rename EsConfig and TsConfig (#9094)
**Description:**

`EsConfig` and `TsConfig` sound like a general configuration for the whole language, while actually it's only about parsing.

To avoid a breaking change, I created type aliases that will work without changing the code, while warning the users.

**Related issue:**

 - Closes #9089.
2024-06-22 01:56:37 +09:00
Donny/강동윤
675916ccbd
perf(es/minifier): Do not visit var init multiple times (#9039)
**Description:**

I mistakenly introduced a performance regression with https://github.com/swc-project/swc/pull/9032. It makes the minifier visit the initializer of variables multiple times - once while normal visiting and once in `hoist_props_of_vars`. This PR fixes it.
2024-06-12 12:24:28 +09:00
Donny/강동윤
cb16994a8d
fix(es/minifier): Visit RHS while hoisting properties (#9032)
**Description:**

Handles 

```js
var FRUITS = { MANGO: "mango" }, getMangoLabel = (label) => label[FRUITS.MANGO];
```

while hoisting properties. In the code above, the initializer of the second variable declarator should be visited after hoisting the first variable declarator. Otherwise `FRUITS.MANGO` cannot be handled.


**Related issue:**

 - Closes #9030
2024-06-11 20:20:39 +09:00
Donny/강동윤
6669343b4a
fix(es/minifier): Fix typescript enum detection (#9031)
**Description:**

This reverts commit cc8c1550dd because it caused a regression in the next.js canary.

 - Canary version: `15.0.0-canary.12`


**Related issue:**

 - Reverts #8986
2024-06-11 14:59:42 +09:00
Donny/강동윤
54ac992781
feat(es/renamer): Workaround a bug of Safari (#9029)
**Related issue:**

 - Closes #9015
2024-06-10 11:29:24 +09:00
Donny/강동윤
9f8e24a76c
fix(es/minifier): Fix evaluation of -0 as a string (#9011)
**Related issue:**

 - Closes #9010

---------

Co-authored-by: magic-akari <akari.ccino@gmail.com>
2024-06-02 19:32:44 +09:00
Donny/강동윤
2879a4d42b
fix(es/minifier): Do not index a string with a surrogate pair (#9013)
**Related issue:**

 - Closes #9008
2024-06-02 03:35:43 +00:00
Donny/강동윤
8a29577cc5
fix(es/minifier): Fix comparison of -0.0 (#9012)
**Related issue:**

 - Closes #9007
2024-06-02 03:10:55 +00:00
Donny/강동윤
0d9ecf39c1
fix(es/resolver): Fix hoisting of const and let (#8987)
**Description:**

 - Repro: https://github.com/kdy1/repro-next-66237

**Related issue:**

 - https://github.com/vercel/next.js/issues/66237
2024-06-01 23:18:34 +09:00
Donny/강동윤
e764ff6f64
fix(es/minifier): Preserve unused special properties (#9005)
**Related issue:**

 - https://github.com/vercel/next.js/issues/66378
2024-05-31 03:13:43 +00:00
Donny/강동윤
cc8c1550dd
feat(es/minifier): Detect TypeScript enum initialization pattern (#8986)
**Description:**

We can optimize
```js
var Foo;
Foo || Foo = {};
```

This code looks strange, but 
```ts
enum Foo {
    a = 1,
    b = 2,
}
```

transpiles to

```js
var Foo;
(function(Foo) {
    Foo[Foo["a"] = 1] = "a";
    Foo[Foo["b"] = 2] = "b";
})(Foo || (Foo = {}));

```

and after minification it becomes

```js
var Foo, Foo1;
(Foo1 = Foo || (Foo = {}))[Foo1.a = 1] = "a", Foo1[Foo1.b = 2] = "b";

```
2024-05-30 14:01:07 +00:00
Donny/강동윤
c0dc5e44ab
test(es/minifier): Update the passing terser test list (#8984) 2024-05-27 22:45:44 +09:00
Donny/강동윤
a753c8d191
fix(es/minifier): Mark usage in TaggedTpl as ref (#8975)
**Related issue:**

 - Closes #8974
2024-05-24 05:11:00 +00:00
Donny/강동윤
2a43df4984
fix(es/minifier): Fix comparison of -0.0 and 0 (#8973)
**Related issue:**

 - Closes #8972
2024-05-24 09:16:42 +09:00
Donny/강동윤
545ec51b51
fix(es/minifier): Add type check to & and | (#8965)
**Related issue:**

 - Closes #8964
2024-05-22 11:27:00 +09:00
Donny/강동윤
02729f24d8
fix(es/minifier): Abort property hoisting on eval (#8957)
**Description:**

 - Repro: https://github.com/kdy1/repro-next-46887-2


**Related issue:**

- https://github.com/vercel/next.js/issues/46887#issuecomment-2113264586
2024-05-16 11:35:45 +09:00
Donny/강동윤
255485e373
fix(es/minifier): Abort array property inliner if the array is used as a ref (#8956)
**Description:**

Repro:
 - https://github.com/kdy1/repro-next-46887

**Related issue:**

 - https://github.com/vercel/next.js/issues/46887
2024-05-16 11:09:41 +09:00
Donny/강동윤
3046d71daa
fix(es/minifier): Abort seq inliner on ** (#8947)
**Related issue:**

 - Closes #8942
2024-05-13 01:11:46 +00:00
Donny/강동윤
772c50fd76
fix(es/minifier): Fix evaluation of String.charCodeAt (#8946)
**Related issue:**

 - Closes #8943
2024-05-13 00:46:29 +00:00
Donny/강동윤
6362ff4ba8
fix(es/ast): Pin version of unicodes (#8941)
**Description:**

https://github.com/swc-project/swc/issues/8940#issuecomment-2102423586

> I found part of the problem:
> 
> U+30FB was added to `ID_Continue` from Unicode version 14 to 15, but v8 is using an older version of unicode ... which I can't find the exact version.
> 
> I spent 2 hours searching for all the missing pieces, I give up.
> 
> Let me back port unicode version 14.

**Related issue:**

 - Closes #8940
2024-05-10 11:23:52 +09:00
Austaras
5a3456c254
fix(es/minifier): Don't invoke IIFE containing reserved words (#8939)
**Description:**

`inline` and `seq inline` should apply this change too.

**Related issue:**

 - Closes #8622
2024-05-09 06:54:25 +00:00
Donny/강동윤
257afc92c9
fix(es/minifier): Abort inliner on mutation via property (#8938)
**Related issue:**

 - Closes #8937
2024-05-09 10:49:41 +09:00
Donny/강동윤
c9d72cdc6a
fix(es/minifier): Fix operand handling of ** (#8933)
**Related issue:**

 - Closes #8924
2024-05-08 01:37:57 +00:00
Donny/강동윤
4d4a7a9bcb
fix(es/minifier): Consider side effects of operands of binary expressions (#8929)
**Related issue:**

 - Closes #8923
2024-05-07 05:27:08 +00:00
Donny/강동윤
86e2bb04ac
fix(es/minifier): Increment ref_count while invoking IIFE (#8904)
**Related issue:**

 - Closes #8880
2024-04-30 09:11:23 +09:00
Donny/강동윤
be359fa753
fix(es/minifier): Do not add vars if eval exists (#8888)
**Related issue:**

 - Closes #8886

---------

Co-authored-by: austaras <austaras@outlook.com>
2024-04-27 13:44:25 +09:00
Austaras
cd4548fd8c
fix(es/minifier): Abort seq inline on recursive usage (#8887)
**Related issue:**

 - Closes #8841
2024-04-23 12:34:14 +00:00
Donny/강동윤
740c0bb00a
fix(es/minifier): Remove raw of strings after modification (#8865)
**Related issue:**

 - Closes #8864
2024-04-16 04:39:54 +00:00
David E Disch
df2e056f29
refactor(es/minifier): Remove mangle.safari10 (#8857)
**Related issue:**

 - Closes #8837
2024-04-16 03:05:43 +00:00
Donny/강동윤
ca9c76b46f
build(cargo): Update rustc to nightly-2024-04-03 (#8821) 2024-04-16 02:20:47 +00:00
Austaras
f6ba92b033
fix(es/resolver): Correctly check strict mode (#8851)
**Related issue:**

 - Closes #8842
2024-04-13 02:38:10 +00:00
magic-akari
7a89e5da3b
fix(es/minifier): Handle switch cases (#8854)
**Related issue:**

- Closes #8813
2024-04-13 02:11:32 +00:00
Austaras
a7a32c4b6c
fix(es/utils): Preserve optional chain effect (#8850)
**Related issue:**

 - Closes #8844
2024-04-12 08:33:01 +00:00
Donny/강동윤
ebb68db24d
fix(es/minifier): Abort IIFE invoker in function parameters (#8828)
**Related issue:**

 - Closes #8826
2024-04-09 15:22:38 +09:00
Donny/강동윤
811308c352
fix(es/minifier): Respect top_retain for top-level functions (#8814) 2024-04-05 00:02:51 +00:00
Donny/강동윤
47714c52ce
feat(es/minifier): Evaluate spread of arrays (#8811)
**Related issue:**

 - Closes #8808
2024-04-04 06:56:29 +00:00
Donny/강동윤
730ded2a26
fix(es/minifier): Abort fn inliner if there's a spread arg (#8809)
**Description:**


**Related issue:**

 - Closes #8806
2024-04-04 15:24:31 +09:00
Donny/강동윤
9f98a7026d
fix(es/minifier): Abort eval on valueOf or toString (#8763)
**Related issue:**

 - Closes #8704
 - Closes #8705
2024-03-20 02:35:24 +00:00
Donny/강동윤
95761b76bf
fix(es/minifier): Make Finalizer handle hoisted_props correctly (#8738)
**Related issue:**

 - Closes #8737
2024-03-13 02:21:15 +00:00
Donny/강동윤
312f0d8427
fix(es/minifier): Fix removal of array pattern bindings (#8730)
**Related issue:**

 - Closes #8670
2024-03-12 06:24:36 +00:00
Donny/강동윤
aa0154d2d8
fix(es/minifier): Fix evaluation of array literals with void 0 (#8733)
**Related issue:**

 - Closes #8706
2024-03-12 14:58:52 +09:00
Donny/강동윤
102241b812
fix(es/minifier): Handle cyclic references while dropping unused properties (#8725)
**Related issue:**

 - Closes #8714
2024-03-11 07:59:22 +00:00
Donny/강동윤
23f9635d2c
fix(es/minifier): Do not evaluate slice calls with negative index (#8726)
**Related issue:**

 - Closes #8715.
2024-03-11 06:52:57 +00:00
Donny/강동윤
f3fbd9d549
fix(es/minifier): Fix eval of toString of array with holes (#8727)
**Related issue:**

 - Closes #8717.
2024-03-11 04:56:31 +00:00
Donny/강동윤
606921700e
fix(es/minifier): Do not drop used properties (#8703)
**Related issue:**

 - Closes #8692
2024-03-07 07:18:26 +00:00
xc2
e1791340cd
fix(es/codegen): Fix replacement when inline_script is on (#8659)
**Description:**


The replacements for `inline_script` might be with mistake


40682c8d1f/crates/swc_ecma_codegen/src/lib.rs (L649)

which in terser is:

![image](https://github.com/swc-project/swc/assets/18117084/e843e125-c001-44d1-9572-15bec355a34e)



0ef05847fa/lib/output.js (L414)


**Related issue:**

https://github.com/web-infra-dev/rspack/issues/5757
2024-02-26 02:48:06 +00:00
Donny/강동윤
97153206ad
fix(es/minifier): Abort property hoister on this usage (#8647)
**Related issue:**

 - Closes #8643
2024-02-19 13:09:15 +09:00
Donny/강동윤
8cd4813067
feat(es/minifier): Remove unused parameters of arrow functions (#8636)
**Related issue:**

 - Closes #8626
2024-02-14 02:09:11 +00:00