Commit Graph

166 Commits

Author SHA1 Message Date
Donny/강동윤
b34f1adbcc
build(cargo): Update rustc to 2023-07-03 () 2023-07-05 03:50:43 +00:00
Donny/강동윤
c087c82aa3
fix(es/compat): Visit transformed expression in optional chaining pass ()
**Related issue:**

 - Closes .
2023-07-04 06:59:58 +00:00
Justin Ridgewell
990e48e0e8
fix(es/compat): Fix optional chaining ()
**Description:**

This fixes a few bugs with optional chaining:

-
[`a?.c()`](https://play.swc.rs/?version=1.3.64&code=H4sIAAAAAAAAA9PXVwjOyC%2FNSVFISrXi0tdXSFSwtVXIK83JUbBXKM1LSU3LzEtNUbBSSNRL1tC05kq0h9AAouc%2F7DgAAAA%3D&config=H4sIAAAAAAAAA2VSu27DMAzc8xUC5wAZii7ZWnRJgXTKDxAKkyrQwyDpNEbgf69kxI4jexAk3olH3fm%2BMgYoXsFszT3vywchHQm2pa7cwXos28T0LRl4m0qnxJY%2BvD8wRsmHUGDllibGsYsYnN2FJrHWoCKfScudUbsv2LDARewEgI4CM24uezqj7b4oj4aauOpf5EdoT4pHVFxSmNDqS1tjNhvDbVQXKNuAraaA6iysC5DYWI8izs4uwIMOC%2F6cpL%2Bc%2FnanHwwkDVpaDJM5rdBn67y6WHv5eNCVfGpCzibDJ%2FQyw%2Fv1qtqAT0lqHWiQhfjVSumi4m2I3QYUy65RmNl0kdtS8OlvPWxfhTw0lnd45pv%2FstbTLOKuGeyzKYQULwIT08l%2B5BaJVf8PfP2zz7YCAAA%3D)
-
[`a?.b.c()`](https://play.swc.rs/?version=1.3.64&code=H4sIAAAAAAAAA9PXVwjOyC%2FNSVFISrXi0tdXSFSwtVXIK83JUbBXKM1LSU3LzEtNUbBSSNRL0kvW0LTmSrSHsQBsP8xLPAAAAA%3D%3D&config=H4sIAAAAAAAAA2VSu27DMAzc8xUC5wAZii7ZWnRJgXTKDxAKkyrQwyDpNEbgf69kxI4jexAk3olH3fm%2BMgYoXsFszT3vywchHQm2pa7cwXos28T0LRl4m0qnxJY%2BvD8w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8AAAA%3D&config=H4sIAAAAAAAAA2VSu27DMAzc8xUC5wAZii7ZWnRJgXTKDxAKkyrQwyDpNEbgf69kxI4jexAk3olH3fm%2BMgYoXsFszT3vywchHQm2pa7cwXos28T0LRl4m0qnxJY%2BvD8wRsmHUGDllibGsYsYnN2FJrHWoCKfScudUbsv2LDARewEgI4CM24uezqj7b4oj4aauOpf5EdoT4pHVFxSmNDqS1tjNhvDbVQXKNuAraaA6iysC5DYWI8izs4uwIMOC%2F6cpL%2Bc%2FnanHwwkDVpaDJM5rdBn67y6WHv5eNCVfGpCzibDJ%2FQyw%2Fv1qtqAT0lqHWiQhfjVSumi4m2I3QYUy65RmNl0kdtS8OlvPWxfhTw0lnd45pv%2FstbTLOKuGeyzKYQULwIT08l%2B5BaJVf8PfP2zz7YCAAA%3D)
-
[`a?.b[c?.d]`](https://play.swc.rs/?version=1.3.64&code=H4sIAAAAAAAAA9PXVwjOyC%2FNSVFISrXi0tdX0IhPVLBVSNRUsLVVyCvNyVGwVyjLz0xRMFCwUohP1EuK1ohPBipIxq4gWS8l1por0R6oLtkezAYAJs%2FWxmEAAAA%3D&config=H4sIAAAAAAAAA2VSu27DMAzc8xUC5wAZii7ZWnRJgXTKDxAKkyrQwyDpNEbgf69kxI4jexAk3olH3fm%2BMgYoXsFszT3vywchHQm2pa7cwXos28T0LRl4m0qnxJY%2BvD8wRsmHUGDllibGsYsYnN2FJrHWoCKfScudUbsv2LDARewEgI4CM24uezqj7b4oj4aauOpf5EdoT4pHVFxSmNDqS1tjNhvDbVQXKNuAraaA6iysC5DYWI8izs4uwIMOC%2F6cpL%2Bc%2FnanHwwkDVpaDJM5rdBn67y6WHv5eNCVfGpCzibDJ%2FQyw%2Fv1qtqAT0lqHWiQhfjVSumi4m2I3QYUy65RmNl0kdtS8OlvPWxfhTw0lnd45pv%2FstbTLOKuGeyzKYQULwIT08l%2B5BaJVf8PfP2zz7YCAAA%3D)
- [`delete
foo?.bar`](https://play.swc.rs/?version=1.3.64&code=H4sIAAAAAAAAA9PXVwjOyC%2FNSVFISrXi0tdXSMvPV7C1VcgrzclRsFcoKSpNVbBSSEnNSS1JBcnpJSUWcSG49iA%2BAGcLTstEAAAA&config=H4sIAAAAAAAAA1WPSw7CMAxE9zlF5DULYIEEd%2BAQVnCrVPkpTiWqqncnTZMAO3vG42evQkqYWMFDrrnMTcDIFHufFV5cwndWgJRFVlGHBKfmTrxbAxqmIm2HAwnjSKmk%2BHq%2B3GsCjPdMWU5xpipZ7fSw%2FCKVtyESc9vcaRbdaOgfKCoUrH%2FNxayvpCXQccANvkMN1heD5mdL7leJ7QOQNa2NFgEAAA%3D%3D)
- [`function foo(a, b = a?.b)
{}`](https://play.swc.rs/?version=1.3.64&code=H4sIAAAAAAAAA9PXVwjOyC%2FNSVFISrXi0tdXSCvNSy7JzM9TSMvP10jUUUhSsFXQ0NBUsLVTqFYoSyxSiE%2B0VnjUsEyhVlNDU1OhupYLm45Ee70kkCQAp8DQOl8AAAA%3D&config=H4sIAAAAAAAAA22Rz07DMAzG73uKyOdJAw5I7Ii4cBjvYKXuyJQ%2Fle3AqmnvTltIm63cHH%2B%2F%2BPtkXzbGwEks7M1lKIeHMkZpE4e5NbU9HdH2b2QToyYeROVM2wVoinQgxQYV1wgTWr0Za8xuZzhHdYH2BjBrCqjOwnYUEhvrUcTZ6gP84bDia0g%2FOX2%2Ftx8YSDq0tAozMFnoNTuvLsp%2FckNf5FMXKI6ZW%2FRS6ddSzgX4lOTeBzpkIb5dpfRR8TzmJxtQLLtOoVrTSc5rw2W%2F92GXBIp8JJ0Gy9PD48s0dJIhpCZ7qq7cd%2FQLPsMMOTkUrBhAcNG1fcmzuf4AkV7gUzECAAA%3D)

It also optimizes the AST for runtime evaluation. Before, we constructed
a leftwards conditional tree (`(_a_b = (_a = a) == null ? void 0 : _a.b)
== null ? void 0 : _a_b.c`) instead of a rightward tree (`(_a = a) ==
null ? void 0 : (_a_b = _a.b) == null ? void 0 : _a_b.c`), which
required multiple `== null` checks after the first nullish is found.

**Related issue:**

 - Closes .
2023-06-19 12:00:11 +09:00
Donny/강동윤
4644d005d2
fix(es/compat): Fix handling of this of optional chaining pass ()
**Related issue:**

 - Closes .
2023-06-14 13:59:35 +09:00
Donny/강동윤
aa83584634
refactor(es/ast): Reimplement optional chaining ()
**Related issue:**

 - Closes .
 - Closes .
2023-06-12 06:47:40 +00:00
Donny/강동윤
f3d660f972
fix(es/compat): Fix variable scoping of object rest pass. ()
**Related issue:**

 - Closes .
2023-05-24 05:41:57 +00:00
Donny/강동윤
2071f89d4e
fix(es/preset-env): Fix pass ordering ()
**Related issue:**

 - Closes .
 - Closes .
2023-05-23 07:14:37 +00:00
Donny/강동윤
97d0f79142
fix(es/compat): Fix stage 3 decorator pass () 2023-05-23 06:24:05 +00:00
Donny/강동윤
66d52ec849
fix(es/compat): Fix destructuring handling of block_scoping ()
**Related issue:**

 - Closes .
2023-05-22 03:21:50 +00:00
Donny/강동윤
e0de83e862
fix(es/compat): Fix is_setter in parameters pass ()
**Description:**

x-ref: https://vercel.slack.com/archives/C02HY34AKME/p1682667306929829
2023-05-02 02:11:42 +00:00
Fy
66b5b110bf
fix(es/compat): Transform curried function call with optional chaining ()
**Related issue:**

 - Closes 
2023-04-24 05:23:53 +00:00
magic-akari
38dfb91ebc
fix(es/helpers): Remove unnecessary parameters in helper_expr! macro ()
**Description:**

We have moved to snake_case, so the last parameter of helper_expr is unnecessary.
2023-04-20 08:26:34 +00:00
Donny/강동윤
38495a9835
test(es/compat): Add a test for a wrong issue ()
**Related issue:**

 - Closes .
2023-04-20 11:10:25 +09:00
Donny/강동윤
f5c62fbbf8
fix(es/compat): Fix finally handling of generator ()
**Description:**

Update generator implementation to match
e83d61398e/src/compiler/transformers/generators.ts

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/5913.
2023-04-06 09:37:21 +00:00
magic-akari
3ca954b9f9
fix(es/helpers): Use snake_case for helpers ()
**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
magic-akari
23fb8c5563
fix(es/compat): Fix the position for temp var injection () 2023-03-30 17:41:55 +09:00
Donny/강동윤
0259a7465f
build(cargo): Update rustc to nightly-2023-03-20 ()
**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 ()
**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 ()
**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/강동윤
2bc631df87
fix(es/compat): Don't modify private fields from reserved_words pass ()
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/7106.
2023-03-21 09:27:31 +00:00
Austaras
c114f006b4
refactor(es/resolver): Make syntax context for unresolved and top-level stable () 2023-03-20 11:01:19 +09:00
Austaras
0f09e356c3
feat(es/resolver): Make scope context identical to the vars () 2023-03-19 11:57:14 +09:00
Donny/강동윤
963c460613
refactor: Fix lints using clippy from nightly-2023-03-13 () 2023-03-14 04:56:21 +00:00
magic-akari
bb6dde7943
fix(es/compat): Handle useDefineForClassFields: false ()
**BREAKING CHANGE:**

IMPORTANT NOTE: Users of decorators are recommended to configure `"useDefineForClassFields": false` to ensure that your code is properly transpiled.


**Related issue:**
 - Closes https://github.com/swc-project/swc/issues/6985.
2023-03-12 12:56:10 +09:00
magic-akari
b78ce8b7c2
feat(es/compat): Simplify static blocks in classes () 2023-03-11 00:30:49 +00:00
Donny/강동윤
e79d46697c
test(es/compat): Add a test for a fixed issue ()
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6886.
2023-01-31 15:01:57 +00:00
Donny/강동윤
57781e90d3
fix(es/compat): Make optional chaining pass less permissive ()
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6878.
2023-01-31 06:24:23 +00:00
Donny/강동윤
d8088646df
fix(es/compat): Fix optional chaining pass ()
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6762.
2023-01-30 11:14:53 +00:00
Donny/강동윤
e7ea054c63
test(es): Enable execution tests for fixed issues () 2023-01-13 07:30:21 +00:00
Donny/강동윤
7dc5ccb0fc
test(es/compat): Add a test to verify parameters passs ()
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6790.
2023-01-12 15:54:36 +09:00
HeYunfei
a1ccc8afdf
feat(es/minifier): Make name mangler understand block scoping ()
**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
4c2d42261e
fix(es/compat): Prepend generated _loop to the correct scope () 2022-12-09 01:48:29 +00:00
Donny/강동윤
cc4646a4cc
test(ts/compat): Migrate inline tests to fixture testing () 2022-11-28 04:54:38 +00:00
Austaras
c57307d002
refactor(es): Remove settings related to privateInObject () 2022-11-21 08:34:20 +09:00
Austaras
f7072dbb7e
fix(es/compat): Fix consecutive optional call () 2022-11-17 02:00:46 +00:00
Donny/강동윤
81a4bb304a
fix(es/compat): Fix span hygiene of function naming pass ()
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6344.
2022-11-14 06:03:09 +00:00
magic-akari
67286032b1
fix(es/compat): Improve destructuring pass () 2022-11-13 23:52:34 +00:00
Austaras
574502a816
feat(es/utils): Use more unique names for aliases () 2022-11-11 01:57:49 +00:00
Austaras
982012289f
fix(es/compat): Fix this in computed class method names () 2022-11-06 00:20:21 +00:00
Austaras
6cc9e90ef4
fix(es/compat): Handle super access in a private static property () 2022-11-05 15:25:51 +00:00
Alexander Akait
3bea6f7248
fix(es/compat): Fix destructuring of an empty array () 2022-11-02 16:06:52 +09:00
Austaras
aa18612e62
fix(es/compat): Fix new.target in a nested scope () 2022-10-31 02:29:55 +00:00
Austaras
0e2de3069d
fix(es/compat): Fix super method call in loose mode () 2022-10-20 00:20:43 +00:00
Austaras
aefc11b8a7
feat(es/compat): Support readonly and writeonly for private fields () 2022-10-18 05:38:36 +00:00
Donny/강동윤
e6b1dd4731
feat(es/testing): Add an option to test sourcemap () 2022-10-07 05:52:22 +00:00
Donny/강동윤
0c67a3adba
fix(es/compat): Fix handling of deep array pattern of object rest pass () 2022-10-04 23:34:03 +09:00
Donny/강동윤
80da0981bd
feat(es/compat): Support iterator protocol on loose mode () 2022-10-04 21:42:39 +09:00
Austaras
31ffd5a01d
fix(es/renamer): Use a separate scope for the name of FnExpr () 2022-10-01 12:33:19 +09:00
magic-akari
2b2464271a
fix(es/codegen): Remove redundant ; after export default decl () 2022-09-14 06:07:15 +00:00
Donny/강동윤
1ae539aac5
test(es/compat): Add a test for a fixed issue () 2022-08-30 11:09:58 +00:00