Commit Graph

1870 Commits

Author SHA1 Message Date
SWC Bot
90aaabaf15 chore: Bump crates 2024-03-06 04:41:56 +00:00
SWC Bot
98aa9824d5 chore: Bump crates 2024-03-04 10:08:47 +00:00
SWC Bot
7a5c7df195 chore: Bump crates 2024-03-04 07:48:09 +00:00
SWC Bot
5ae0a2f858 chore: Bump crates 2024-03-04 01:49:57 +00:00
SWC Bot
5dc40d347b chore: Bump crates 2024-03-02 10:24:52 +00:00
SWC Bot
1603569a75 chore: Bump crates 2024-02-26 02:49:45 +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
SWC Bot
4154cfa8cb chore: Bump crates 2024-02-23 00:15:59 +00:00
SWC Bot
7c5113b6a9 chore: Bump crates 2024-02-22 02:56:23 +00:00
SWC Bot
359ae7a16a chore: Bump crates 2024-02-21 10:22:20 +00:00
magic-akari
3bf3a62505
doc(es/minifier): Update examples code (#8652)
**Related issue:**

- Closes #8651 

The core logic of SWC is correct, but there are incorrect code examples in our code repository.
2024-02-21 02:11:19 +00:00
SWC Bot
5cab610db1 chore: Bump crates 2024-02-20 01:27:25 +00:00
SWC Bot
463cd3bf4c chore: Bump crates 2024-02-20 00:55:31 +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
SWC Bot
d7434beaf8 chore: Bump crates 2024-02-19 03:15:59 +00:00
SWC Bot
84c05b5eec chore: Bump crates 2024-02-14 03:23:28 +00:00
SWC Bot
cb95f0478c chore: Bump crates 2024-02-14 02:41:18 +00:00
SWC Bot
09bedecff6 chore: Bump crates 2024-02-14 02:10:39 +00: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
SWC Bot
6cca7cbfe8 chore: Bump crates 2024-02-13 05:14:07 +00:00
Donny/강동윤
6726b631e6
build(cargo): Update rustc to nightly-2024-02-06 (#8618) 2024-02-13 13:32:49 +09:00
SWC Bot
9ad0f9fedb chore: Bump crates 2024-02-13 02:58:35 +00:00
SWC Bot
906cca43c1 chore: Bump crates 2024-02-08 01:51:17 +00:00
SWC Bot
f7baf240ba chore: Bump crates 2024-02-07 07:25:27 +00:00
SWC Bot
927b14a2e4 chore: Bump crates 2024-02-07 03:27:01 +00:00
Donny/강동윤
3122e944a8
feat(es/minifier): Implement correct hoist_props (#8593)
**Description:**

 - The option `hoist_props` now does what it's supposed to do.
- Dropping of unused properties now does not drop properties too aggressively.
- The initializer of a dropped variable declaration is now properly visited.
- Indexing with string literals is not marked as a dynamic index anymore. This is required to handle codes like c3f67ceb1e/crates/swc_ecma_minifier/tests/terser/compress/hoist_props/name_collision_1/input.js (L1-L7).
2024-02-07 03:25:27 +00:00
SWC Bot
7a3b5545cd chore: Bump crates 2024-02-06 02:47:51 +00:00
SWC Bot
3ee12cf56d chore: Bump crates 2024-02-06 02:12:03 +00:00
SWC Bot
48524e2ae8 chore: Bump crates 2024-02-05 06:34:30 +00:00
Donny/강동윤
7f2a2c1e40
refactor(es/ast): Improve type definitions of patterns (#8532)
**Description:**

 - Copy `AssignmentTarget` from `oxc`.
 - Use `BindingIdentifier` in more places.

**Related issue:**
 
 - Closes #8026
2024-02-05 15:32:52 +09:00
SWC Bot
47e7b89a1b chore: Bump crates 2024-02-04 06:19:41 +00:00
Donny/강동윤
fd997d3712
feat(es/minifier): Respect more options (#8582)
**Description:**

This PR makes the ES minifier respect more options.

Changes:
 - `reduce_vars` now enables IIFE invoker.
 - `reduce_vars` now enables seq inliner.
 - `top_retain` is now respected by seq inliner.
 - `arguments` is now ignored by seq inliner.

---------

Co-authored-by: austaras <austaras@outlook.com>
2024-02-02 12:35:58 +00:00
Donny/강동윤
a7c5255ad1
fix(es/minifier): Fix top-level check (#8583)
**Description:**

Our logic for checking top-level was wrong.
2024-02-02 01:45:41 +00:00
SWC Bot
ef21736584 chore: Bump crates 2024-02-02 01:19:28 +00:00
SWC Bot
386c391081 chore: Bump crates 2024-02-02 00:43:47 +00:00
Donny/강동윤
18e0b53fbb
feat(es/minifier): Inline more IIFE arguments (#8584)
**Description:**

We can inline more.
2024-02-02 09:42:15 +09:00
SWC Bot
429c1bae44 chore: Bump crates 2024-01-31 08:50:09 +00:00
SWC Bot
f5ee6d1d7f chore: Bump crates 2024-01-30 04:42:21 +00:00
Donny/강동윤
8b86638970
test(es/minifer): Update the passing terser test list (#8573) 2024-01-30 04:40:52 +00:00
SWC Bot
ba1da1de3c chore: Bump crates 2024-01-29 10:27:13 +00:00
SWC Bot
a5c56a9e14 chore: Bump crates 2024-01-28 12:35:38 +00:00
Donny/강동윤
07634a05ba
fix(es/codegen): Do not produce octal literals (#8565) 2024-01-28 12:34:03 +00:00
SWC Bot
160043a2d3 chore: Bump crates 2024-01-27 04:57:56 +00:00
SWC Bot
5f9b7b4c8b chore: Bump crates 2024-01-25 07:20:48 +00:00
SWC Bot
c3fd9d081e chore: Bump crates 2024-01-24 02:04:25 +00:00
Donny/강동윤
043ee85d08
fix(common): Fix source map generation with inputSourceMap (#8546)
**Description:**

- This PR fixes the source map generation when `inputSourceMap` is specified.
- This PR fixes `minify()` not accepting parsed source map in the option.


**Related issue:**

 - Closes #8372.
2024-01-24 02:02:45 +00:00
Donny/강동윤
aa70131c55
fix(es/minifier): Fix a bug related to inliner and the variable scoping (#8542)
**Related issue:**

 - Closes #8246
2024-01-24 01:12:02 +00:00
SWC Bot
2d15177ca9 chore: Bump crates 2024-01-23 08:38:01 +00:00
SWC Bot
12be23cfb5 chore: Bump crates 2024-01-23 04:25:38 +00:00
SWC Bot
990f291d43 chore: Bump crates 2024-01-21 15:30:11 +00:00
SWC Bot
9c23f1cf38 chore: Bump crates 2024-01-21 12:37:38 +00:00
SWC Bot
6210bf19de chore: Bump crates 2024-01-21 03:08:11 +00:00
SWC Bot
1ca0d65c29 chore: Bump crates 2024-01-21 02:34:11 +00:00
SWC Bot
e63a5c7e95 chore: Bump crates 2024-01-19 02:14:55 +00:00
Donny/강동윤
9f1ce3acd6
fix(es/codegen): Fix codegen of \\0 (#8433)
**Related issue:**

 - Closes #8431
2024-01-19 02:11:05 +00:00
SWC Bot
fefe9636f0 chore: Publish crates 2024-01-19 01:27:20 +00:00
SWC Bot
3c00098dbe chore: Publish crates 2024-01-19 00:45:54 +00:00
Donny/강동윤
4946a11137
fix(es/minifier): Fix a bug in tpl string <-> string logic (#8510)
**Related issue:**

 - Closes #8496
2024-01-19 00:44:19 +00:00
SWC Bot
0763e7e6d6 chore: Publish crates 2024-01-16 04:43:01 +00:00
SWC Bot
99d74f319f chore: Publish crates 2024-01-16 04:01:42 +00:00
SWC Bot
37d36eb24b chore: Publish crates 2024-01-14 08:12:45 +00:00
SWC Bot
9cf91a375b chore: Publish crates 2024-01-09 18:56:56 +00:00
Donny/강동윤
f7c4934e59
fix(es/minifier): Correctly escape more characters (#8490)
**Related issue:**

 - Closes #8484
2024-01-09 18:55:25 +00:00
SWC Bot
a73ddc221e chore: Publish crates 2024-01-09 18:27:36 +00:00
SWC Bot
d9a79a0a39 chore: Publish crates 2024-01-04 12:28:02 +00:00
SWC Bot
4e860c988d chore: Publish crates 2024-01-04 04:49:50 +00:00
SWC Bot
8997ed1547 chore: Publish crates 2024-01-04 04:25:54 +00:00
Austaras
82bd8070cb
fix(es/resolver): Resolve top-level undefined, NaN, and Infinity correctly (#8471)
**Description:**

For following code
```js
var NaN = 1
console.log(NaN)
```
Result would be

|Envirnoment|Result|
|-|-|
|Non strict script(browser, nodejs repl)|NaN|
|Non strict script(nodejs script)|1|
|Strict script(browser, nodejs repl)|runtime error|
|Strict script(nodejs script)|1|
|ESM|1|

So SWC choose to behave like browser in script mode and confirm to esm
standard.


**Related issue:**

 - Closes #8465
2024-01-04 04:24:14 +00:00
SWC Bot
68b9646681 chore: Publish crates 2024-01-03 20:18:10 +00:00
SWC Bot
f2ede40e38 chore: Publish crates 2024-01-03 06:58:23 +00:00
SWC Bot
cddb0165bb chore: Publish crates 2024-01-03 05:41:28 +00:00
SWC Bot
a4e91af934 chore: Publish crates 2024-01-03 04:45:13 +00:00
Austaras
b676e75cdd
test(es/minifier): Enable script mode for terser_exec and mangle (#8474) 2024-01-02 06:00:26 +00:00
Austaras
1120336f23
test(es/minifier): Enable non esm mode for tests (#8472) 2024-01-02 04:33:39 +00:00
SWC Bot
98920ca78d chore: Publish crates 2024-01-02 02:10:29 +00:00
SWC Bot
e3f25c2011 chore: Publish crates 2023-12-29 12:26:47 +00:00
SWC Bot
4229e7b99b chore: Publish crates 2023-12-29 08:49:51 +00:00
SWC Bot
3492e6f13e chore: Publish crates 2023-12-28 23:58:04 +00:00
Austaras
1e44e57a09
fix(es/renamer): Correctly check top level (#8456)
**Related issue:**

 - Closes #8451.
 - Closes #8185.
2023-12-28 23:56:38 +00:00
SWC Bot
d6dd1f9240 chore: Publish crates 2023-12-24 01:32:20 +00:00
SWC Bot
611d7175d4 chore: Publish crates 2023-12-22 03:27:18 +00:00
SWC Bot
37bb0e3bde chore: Publish crates 2023-12-21 09:19:08 +00:00
SWC Bot
d6cd2146fa chore: Publish crates 2023-12-17 08:43:12 +00:00
SWC Bot
45f62f7886 chore: Publish crates 2023-12-17 06:48:43 +00:00
SWC Bot
dd9ed9c565 chore: Publish crates 2023-12-12 06:14:41 +00:00
SWC Bot
f736c3c2df chore: Publish crates 2023-12-12 05:55:01 +00:00
SWC Bot
f202a2839f chore: Publish crates 2023-12-12 04:39:47 +00:00
SWC Bot
602584dd62 chore: Publish crates 2023-12-11 03:07:28 +00:00
magic-akari
a69f172aac
fix(es/fixer): Preserve parenthesis for optional chaining (#8399)
**Related issue:**
 - Closes #8398
2023-12-11 03:05:58 +00:00
SWC Bot
2aebd5fa2f chore: Publish crates 2023-12-08 14:01:33 +00:00
SWC Bot
595f13c019 chore: Publish crates 2023-12-08 07:18:16 +00:00
SWC Bot
dbeb869463 chore: Publish crates 2023-12-08 06:00:21 +00:00
SWC Bot
0bde652b5c chore: Publish crates 2023-12-08 01:58:57 +00:00
SWC Bot
6ef6cf6f35 chore: Publish crates 2023-12-07 16:22:39 +00:00
SWC Bot
7327f257d2 chore: Publish crates 2023-12-04 09:00:34 +00:00
SWC Bot
c6e64148b0 chore: Publish crates 2023-12-03 01:14:41 +00:00
Redfire
91e0fc7250
chore(deps): Update indexmap to v2 (#8370)
**Description:**

Updates `indexmap` to `v2`, reducing dependency duplication. Unfortunately there are still many dependencies that require `v1`, including `rkyv` and `cranelift-egraph` that have no published versions using indexmap `v2`.
2023-12-03 01:12:30 +00:00
SWC Bot
9a41fac89f chore: Publish crates 2023-12-02 23:25:06 +00:00
SWC Bot
c77f987b9b chore: Publish crates 2023-12-02 11:43:08 +00:00
SWC Bot
98c47df37a chore: Publish crates 2023-12-01 20:08:13 +00:00
SWC Bot
0845693536 chore: Publish crates 2023-11-29 14:11:49 +00:00
bohan
2cdea3fbea
fix(es/codegen): Wrap quote for length greater than one (#8351) 2023-11-29 14:09:44 +00:00
SWC Bot
655e95a24d chore: Publish crates 2023-11-29 13:41:46 +00:00
SWC Bot
ddddd20559 chore: Publish crates 2023-11-27 01:56:46 +00:00
SWC Bot
e158c0e5a0 chore: Publish crates 2023-11-26 11:37:59 +00:00
SWC Bot
7e8b6c0f04 chore: Publish crates 2023-11-26 00:50:50 +00:00
SWC Bot
ae6c30b221 chore: Publish crates 2023-11-25 02:45:12 +00:00
Austaras
ed5a9b3f2e
fix(es/minifier): Give up terminate merge if in try with finally (#8342)
**Related issue:**

 - Closes #8337.
 - Closes #8324.
 - Reverts #8328.
2023-11-25 02:43:18 +00:00
SWC Bot
5d94418518 chore: Publish crates 2023-11-23 01:53:53 +00:00
SWC Bot
5ce4b368db chore: Publish crates 2023-11-23 00:57:05 +00:00
Donny/강동윤
01e2c7fc5a
fix(es/minifier): Fix if_return bug related to await and yield (#8328)
**Related issue:**

 - Closes #8324
2023-11-23 00:54:57 +00:00
SWC Bot
14cd8dda29 chore: Publish crates 2023-11-22 23:25:21 +00:00
SWC Bot
185289775f chore: Publish crates 2023-11-22 06:22:12 +00:00
SWC Bot
97d57f0e4f chore: Publish crates 2023-11-21 09:21:47 +00:00
SWC Bot
7cec0ac1a0 chore: Publish crates 2023-11-20 22:51:17 +00:00
SWC Bot
a8bd170634 chore: Publish crates 2023-11-20 22:19:11 +00:00
SWC Bot
38c489c26c chore: Publish crates 2023-11-20 21:59:52 +00:00
SWC Bot
5fa2ed4bfd chore: Publish crates 2023-11-20 06:22:03 +00:00
SWC Bot
af8c1d33f5 chore: Publish crates 2023-11-20 04:30:06 +00:00
SWC Bot
2cd893fb8a chore: Publish crates 2023-11-19 15:13:56 +00:00
Austaras
572ad63e08
fix(es/minifier): Apply new SyntaxContext to inlined Arrow correctly (#8312) 2023-11-20 00:11:38 +09:00
Donny/강동윤
a0048427dd
test(es/minifier): Update test refs (#8310) 2023-11-19 19:16:38 +09:00
SWC Bot
2b368f6731 chore: Publish crates 2023-11-19 06:35:42 +00:00
SWC Bot
f38ad1eeef chore: Publish crates 2023-11-18 00:03:24 +00:00
Austaras
c18a959e3a
fix(es/minifier): Apply new SyntaxContext to inlined Arrow (#8301)
**Related issue:**

 - Closes #8288
2023-11-18 09:01:27 +09:00
SWC Bot
2a2b5ee5b1 chore: Publish crates 2023-11-16 08:52:11 +00:00
SWC Bot
9e8fe38d31 chore: Publish crates 2023-11-16 02:03:19 +00:00
SWC Bot
c566b73bfb chore: Publish crates 2023-11-16 00:20:22 +00:00
Donny/강동윤
7985e02fc8
fix(es/minifier): Remove hack for built-in class names (#8293)
**Description:**

Regarding https://github.com/vercel/next.js/issues/55682, I made a mistake while investigating. I assumed it's `swcMinify`-only but it seems like `node-fetch` is fundamentally incompatible with our minification options.

I thought `node-fetch` works with terser, but it did not, and it **should not**. But as I thought `terser` works, I assumed that `terser` has a hack for `AbortSignal`. And that's how I fixed `swcMinify: true`. The correct fix is `keep_classnames: true` but it will result in +~10% bundle size bloat.
At first, I used the correct way (`keep_classnames: true`), but it resulted in the bundle size bloat, so I mimicked the hack of terser with https://github.com/vercel/next.js/pull/57904.

While working on other minification issues, I found that there's no such hack in `terser` and I need to remove the hack in the SWC minifier.
The repro in https://github.com/vercel/next.js/issues/55682 does not work with `swcMinify: false`, even with next@14. The problem of minifier and node-fetch was not exploited before `serverMinification: true`.


**Related issue:**

 - https://github.com/brix/crypto-js/issues/415
2023-11-16 09:17:42 +09:00
SWC Bot
666c843e7e chore: Publish crates 2023-11-15 23:38:46 +00:00
SWC Bot
c03f84e54e chore: Publish crates 2023-11-15 22:45:18 +00:00
SWC Bot
99617848ef chore: Publish crates 2023-11-15 22:04:42 +00:00
SWC Bot
3bbd340205 chore: Publish crates 2023-11-15 01:09:49 +00:00
Austaras
73fec945b5
fix(es/minifier): Make Finalizer inline literals (#8285)
**Related issue:**

 - Closes #8284
2023-11-15 01:07:37 +00:00
SWC Bot
f86c12b0b4 chore: Publish crates 2023-11-14 21:39:03 +00:00
bohan
f059270348
feat(es/minifier): Support format.inline_script (#8252) 2023-11-14 21:37:05 +00:00
SWC Bot
5fed604276 chore: Publish crates 2023-11-14 20:02:17 +00:00
Donny/강동윤
1ccfc0762c
fix(es/minifier): Respect pure_funcs for tagged tpls (#8280)
**Related issue:**

 - Closes #8275.
2023-11-14 19:59:15 +00:00
SWC Bot
2f6af92232 chore: Publish crates 2023-11-14 16:47:24 +00:00
Austaras
65c3d0e3f4
feat(es/minifier): Swap bin expr to save paren (#8277) 2023-11-14 16:45:24 +00:00
SWC Bot
aa36a53c42 chore: Publish crates 2023-11-14 16:01:17 +00:00
Austaras
20fb5bab32
fix(es/minifier): Keep class with a static block (#8283)
**Related issue:**

 - Closes #8271.
2023-11-15 00:59:14 +09:00
SWC Bot
9c438692c6 chore: Publish crates 2023-11-13 10:03:57 +00:00
SWC Bot
35b95ae430 chore: Publish crates 2023-11-13 03:50:20 +00:00
Austaras
ebcd825225
fix(es/minifier): Enable seq inliner for const declarations (#8255) 2023-11-13 03:47:49 +00:00
SWC Bot
07cc635489 chore: Publish crates 2023-11-11 19:12:50 +00:00
Donny/강동윤
9a0572b968
refactor(swc_node_base): Rename to swc_malloc (#8272)
**Description:**

This is quite convinient.
2023-11-11 19:10:56 +00:00
SWC Bot
2ef3de0021 chore: Publish crates 2023-11-10 13:10:36 +00:00
SWC Bot
6383ac443d chore: Publish crates 2023-11-10 12:34:31 +00:00
SWC Bot
e0525b595e chore: Publish crates 2023-11-10 02:30:21 +00:00