Donny/강동윤
14ea705f27
build(cargo): Update rustc to nightly-2023-11-04
( #8221 )
...
**Breaking Changes**:
- `Mark::default()` is now identical as `Mark::new()`.
**Description:**
I want to see if inlining is improved
2023-11-04 21:47:10 +00:00
Donny/강동윤
1a26be2a27
feat(es/codegen): Respect ascii_only: false
for StrLit
( #8217 )
...
**Related issue:**
- Closes #8189
2023-11-04 04:15:58 +00:00
Donny/강동윤
dd805e95a4
feat(es/minifier): Respect inline level and preserve native names ( #8205 )
...
**Description:**
Note: Preserving native names is a hack, but it's used by `terser` and it's the only way to preserve the name of `class AbortSignal` while mangling without `keep_classnames: true`. We can special case `AbortSignal`, but let's just follow `terser`.
**Related issue:**
- https://github.com/vercel/next.js/pull/57904
2023-11-02 08:59:59 +09:00
Austaras
bb02cdd26e
refactor(es/minifier): Simplify analyzer context ( #8164 )
2023-10-27 18:16:00 +00:00
Donny/강동윤
35601e4dcb
fix(es/minifier): Abort function inliner if keep_fnames
is true
( #8145 )
...
**Related issue:**
- https://github.com/vercel/next.js/issues/56408
2023-10-19 20:20:54 +00:00
magic-akari
7da3f52485
feat(es/minifier): Evaluate more toFixed
expressions ( #8109 )
2023-10-13 15:07:00 +09:00
Austaras
2db10e9fd1
fix(es/resolver): Correctly resolve global value ( #7893 )
...
**Related issue:**
- Closes #7685
2023-08-31 05:54:18 +00:00
Donny/강동윤
7fe01e64dd
fix(es/minifier): Don't inline properties if the var is not fn-local
( #7839 )
...
**Related issue:**
- https://github.com/vercel/next.js/issues/54192 .
2023-08-22 11:04:15 +09:00
Austaras
f8ca366cc1
fix(es/minifier): Abort seq inliner if var is not fn_local or reassigned ( #7804 )
...
**Description:**
It turns out that the original implementation of `infect`is incomplete
because it cannot cover function param, and the new implementation
introduced in #7772 is redundant because what
[terser](https://github.com/terser/terser/blob/master/lib/compress/tighten-body.js#L909C18-L909C28 )
do is basically checking `fn_local`
**Related issue:**
- Closes #7784
2023-08-17 05:15:59 +00:00
Austaras
5ea6f27eb0
fix(es/minifier): Handle synthesized export default expression ( #7707 )
...
**Related issue:**
- Closes #7634 .
2023-07-31 04:10:18 +00:00
Austaras
9893bd2d43
refactor(es/minifier): Respect toplevel
and module
options ( #7671 )
2023-07-20 11:35:08 +09:00
Donny/강동윤
a65be14a00
fix(es/minifier): Do not reuse identifier used for import bindings ( #7639 )
...
**Related issue:**
- Closes #7634 .
2023-07-18 04:11:00 +00:00
Austaras
04b0f6d823
feat(es/minifier): Drop recursively used var declaration ( #7649 )
2023-07-15 05:54:34 +09:00
Donny/강동윤
aa83584634
refactor(es/ast): Reimplement optional chaining ( #7441 )
...
**Related issue:**
- Closes #7003 .
- Closes #7156 .
2023-06-12 06:47:40 +00:00
Austaras
62075faeaa
feat(es/minifier): Remove unused labels ( #7478 )
2023-06-07 04:23:40 +00:00
Austaras
5dbbbea2ef
fix(es/minifier): Mark all function params as potential property mutation ( #7409 )
...
**Description:**
This issue is more severe than I originally thought. It raises not in
array indexing, but in function calls and property mutation. We should
treat all function arguments as potentially be property mutated,
otherwise following example
```js
class A {
a = 1
toString() {
return this.a
}
}
const a = new A()
function foo(x) {
x.a++
}
const b = a + 1
foo(a)
console.log(b)
```
would be error(It should log 2, but logs 3 after compress).
As the result, massive regressions is unavoidable, since some of these
optimizations may indeed cause error. Part of them can be mitigated with
following optimization -- allow inline of ident even if its original
value is mutated. Consider
```js
export function foo(x) {
const y = x
x.a = 1
y.b = 2
}
```
If x is a primitive value, all mutations to its properties are ignored;
if x is a object, then y refers to the same object no matter what
mutation is performed.
And there's still room for more, currently following code
```js
export function foo(x) {
const y = Math.floor(x);
g(y);
}
```
But I'd rather do it in a separate PR.
**Related issue:**
- Closes #7402 .
2023-05-18 01:19:17 +00:00
Donny/강동윤
f9cdd741c2
test(es/minifier): Enable more terser tests ( #7396 )
2023-05-16 03:21:08 +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
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/강동윤
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
Austaras
1318afe2b4
fix(es/minifier): Bailout regex optimization on invalid flags ( #7020 )
2023-03-07 11:05:04 +09:00
Austaras
06cbb9002d
feat(es/minifier): Optimize calls to Boolean
/Number
/String
/Symbol
( #7006 )
2023-03-04 04:14:14 +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/강동윤
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/강동윤
631dd7872b
feat(es/renamer): Support safari10
from the name mangler ( #6801 )
2023-01-13 05:00:13 +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
HeYunfei
b5d31cc2da
fix(es/utils): Fix detection of hoisting ( #6738 )
2023-01-03 03:12:01 +00:00
Donny/강동윤
5d52ae971e
feat(es/minifier): Implement trivial optimizations ( #6256 )
...
**Description:**
1. Evaluate `Number.toString()`.
2. Mark some terser tests as passing where our output is better.
2022-11-02 01:21:32 +00:00
Donny/강동윤
743a1aab4f
feat(es/minfiier): Compute more with sequential inliner ( #6169 )
2022-10-27 00:50:52 +00:00
Donny/강동윤
01edb4fff4
test(es/minifier): Organize terser tests ( #6247 )
2022-10-25 05:12:30 +00:00
Donny/강동윤
ec9a80aae0
feat(es/minifier): Respect options ( #6245 )
2022-10-25 04:00:16 +00:00
Donny/강동윤
780b5de678
fix(es/minifier): Fix detection of direct eval
( #6215 )
2022-10-21 12:18:10 +09:00
Donny/강동윤
ea03ce1a82
refactor(es/minifier): Don't create invalid nodes ( #6191 )
...
**Description:**
A sequential expression should have at leat two elements.
2022-10-21 00:33:40 +00:00
Donny/강동윤
12443db39a
feat(es/minifier): Merge functions using sequential inliner ( #6148 )
2022-10-20 02:24:09 +00:00
Donny/강동윤
842abd4575
fix(es/minifier): Remove wrong rule ( #6201 )
...
**Related issue:**
- https://github.com/vercel/next.js/issues/41527 .
2022-10-19 02:14:38 +00:00
Donny/강동윤
3f0fcf4fa9
feat(es/minifier): Make sequential inliner self-repeat ( #6168 )
2022-10-18 02:13:39 +00:00
Donny/강동윤
aec5cdacc6
fix(es/minifier): Preserve this
of tagged template literals ( #6165 )
...
**Related issue:**
- Closes https://github.com/swc-project/swc/issues/6146
2022-10-15 09:11:20 +00:00
Austaras
b40d486253
fix(es/minifier): Consider function body cost while inlining function ( #5342 )
2022-10-15 05:47:56 +00:00
Donny/강동윤
d334c6e783
feat(es/minifier): Ignore return value if a param of IIFE is not used ( #6115 )
2022-10-14 02:58:00 +00:00
Donny/강동윤
ec0d6d5a0d
feat(es/minifier): Improve trivial rules ( #6136 )
2022-10-13 23:34:30 +00:00
Donny/강동윤
c37839fc62
feat(es/minifier): Swap more binary expressions ( #6134 )
2022-10-13 03:45:05 +00:00
Donny/강동윤
66196a65be
feat(es/minifier): Inline pure array literal partially ( #6099 )
2022-10-12 02:29:40 +00:00
Austaras
5a23949f12
feat(es/minifier): Inline and remove vars in one pass ( #6093 )
2022-10-12 01:52:58 +00:00
Donny/강동윤
6365acc9f5
test(es/minifier): Organize terser tests ( #6116 )
...
**Description:**
Our minifier is better than terser in some cases, so we don't need to match the output of terser exactly.
2022-10-11 08:25:11 +00:00
Donny/강동윤
9ce3df091f
feat(es/minifier): Distinguish calls in alias analyzer ( #6080 )
...
**Description:**
This PR improves the alias analyzer by distinguishing call and reference, thus reducing the number of identifiers.
---
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2022-10-08 03:15:18 +00:00
Austaras
ac150c7ced
feat(es/minifier): Use usage_count
in sequential inliner ( #6071 )
2022-10-06 17:27:34 +00:00
Austaras
c9427f1ec4
fix(es/minifier): Improve infection analysis ( #6044 )
2022-10-06 18:12:09 +09:00
Donny/강동윤
36d467e7d7
fix(es/minifier): Fix analysis of var declaration after usage ( #6043 )
...
**Description:**
`var_initialized` should be `true` even if the declaration of variable comes after its usage.
**Related issue:**
- Closes https://github.com/swc-project/swc/issues/6039 .
2022-10-06 02:09:13 +00:00
Donny/강동윤
c5fb774487
fix(es/minifier): Don't skip unresolved identifiers ( #6050 )
...
**Related issue:**
- Closes https://github.com/swc-project/swc/issues/6049
2022-10-05 11:44:51 +00:00