diff --git a/.changeset/lemon-panthers-try.md b/.changeset/lemon-panthers-try.md new file mode 100644 index 000000000000..18533a276903 --- /dev/null +++ b/.changeset/lemon-panthers-try.md @@ -0,0 +1,7 @@ +--- +swc_core: patch +swc_ecma_minifier: patch +swc_ecma_transforms_optimization: patch +--- + +chore(ci): Fix CI diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).1.normal.js index f4fb101df113..8e75384df4b8 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).1.normal.js @@ -1,267 +1,138 @@ //// [awaitUsingDeclarations.1.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - var d1 = _usingCtx.a({ +await using d1 = { + async [Symbol.asyncDispose] () {} +} +async function af() { + await using d3 = { async [Symbol.asyncDispose] () {} - }); - async function af() { - try { - var _usingCtx = _using_ctx(); - const d3 = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); - await null; - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); - } } - async function* ag() { - try { - var _usingCtx = _using_ctx(); - const d5 = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); - yield; - await null; - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); + ; + await null; +} +async function* ag() { + await using d5 = { + async [Symbol.asyncDispose] () {} + } + ; + yield; + await null; +} +const a = async ()=>{ + await using d6 = { + async [Symbol.asyncDispose] () {} + } + ; +}; +class C1 { + async am() { + await using d13 = { + async [Symbol.asyncDispose] () {} + } + ; + await null; + } + async *ag() { + await using d15 = { + async [Symbol.asyncDispose] () {} } + ; + yield; + await null; } - const a = async ()=>{ - try { - var _usingCtx = _using_ctx(); - const d6 = _usingCtx.a({ + constructor(){ + this.a = async ()=>{ + await using d7 = { async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); - } - }; - class C1 { - async am() { - try { - var _usingCtx = _using_ctx(); - const d13 = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); - await null; - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); } - } - async *ag() { - try { - var _usingCtx = _using_ctx(); - const d15 = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); - yield; - await null; - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); - } - } - constructor(){ - this.a = async ()=>{ - try { - var _usingCtx = _using_ctx(); - const d7 = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); - } - }; - } + ; + }; } - { - try { - var _usingCtx1 = _using_ctx(); - const d19 = _usingCtx1.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx1.e = _; - } finally{ - await _usingCtx1.d(); +} +{ + await using d19 = { + async [Symbol.asyncDispose] () {} + } + ; +}switch(Math.random()){ + case 0: + await using d20 = { + async [Symbol.asyncDispose] () {} + } + ; + break; + case 1: + await using d21 = { + async [Symbol.asyncDispose] () {} + } + ; + break; +} +if (true) switch(0){ + case 0: + await using d22 = { + async [Symbol.asyncDispose] () {} } + ; + break; +} +try { + await using d23 = { + async [Symbol.asyncDispose] () {} } - switch(Math.random()){ - case 0: - try { - var _usingCtx2 = _using_ctx(); - const d20 = _usingCtx2.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx2.e = _; - } finally{ - await _usingCtx2.d(); - } - case 1: - try { - var _usingCtx3 = _using_ctx(); - const d21 = _usingCtx3.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx3.e = _; - } finally{ - await _usingCtx3.d(); - } + ; +} catch { + await using d24 = { + async [Symbol.asyncDispose] () {} } - if (true) switch(0){ - case 0: - try { - var _usingCtx4 = _using_ctx(); - const d22 = _usingCtx4.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx4.e = _; - } finally{ - await _usingCtx4.d(); - } + ; +} finally{ + await using d25 = { + async [Symbol.asyncDispose] () {} } - try { - try { - var _usingCtx5 = _using_ctx(); - const d23 = _usingCtx5.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx5.e = _; - } finally{ - await _usingCtx5.d(); - } - } catch { - try { - var _usingCtx6 = _using_ctx(); - const d24 = _usingCtx6.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx6.e = _; - } finally{ - await _usingCtx6.d(); - } - } finally{ - try { - var _usingCtx7 = _using_ctx(); - const d25 = _usingCtx7.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx7.e = _; - } finally{ - await _usingCtx7.d(); - } + ; +} +if (true) { + await using d26 = { + async [Symbol.asyncDispose] () {} } - if (true) { - try { - var _usingCtx8 = _using_ctx(); - const d26 = _usingCtx8.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx8.e = _; - } finally{ - await _usingCtx8.d(); - } - } else { - try { - var _usingCtx9 = _using_ctx(); - const d27 = _usingCtx9.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx9.e = _; - } finally{ - await _usingCtx9.d(); - } + ; +} else { + await using d27 = { + async [Symbol.asyncDispose] () {} } - while(true){ - try { - var _usingCtx10 = _using_ctx(); - const d28 = _usingCtx10.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx10.e = _; - } finally{ - await _usingCtx10.d(); - } + ; +} +while(true){ + await using d28 = { + async [Symbol.asyncDispose] () {} } - do { - try { - var _usingCtx11 = _using_ctx(); - const d29 = _usingCtx11.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx11.e = _; - } finally{ - await _usingCtx11.d(); - } - }while (true) - for(;;){ - try { - var _usingCtx12 = _using_ctx(); - const d30 = _usingCtx12.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx12.e = _; - } finally{ - await _usingCtx12.d(); - } + ; + break; +} +do { + await using d29 = { + async [Symbol.asyncDispose] () {} } - for(const x in {}){ - try { - var _usingCtx13 = _using_ctx(); - const d31 = _usingCtx13.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx13.e = _; - } finally{ - await _usingCtx13.d(); - } + ; + break; +}while (true) +for(;;){ + await using d30 = { + async [Symbol.asyncDispose] () {} } - for (const x of []){ - try { - var _usingCtx14 = _using_ctx(); - const d32 = _usingCtx14.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx14.e = _; - } finally{ - await _usingCtx14.d(); - } + ; + break; +} +for(const x in {}){ + await using d31 = { + async [Symbol.asyncDispose] () {} } -} catch (_) { - _usingCtx.e = _; -} finally{ - await _usingCtx.d(); + ; +} +for (const x of []){ + await using d32 = { + async [Symbol.asyncDispose] () {} + } + ; } export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).2.minified.js index db8011a13132..a24672f1aec9 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=esnext).2.minified.js @@ -1,154 +1,62 @@ //// [awaitUsingDeclarations.1.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); - try { - var _usingCtx1 = _using_ctx(); - _usingCtx1.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx1.e = _; - } finally{ - await _usingCtx1.d(); - } - switch(Math.random()){ - case 0: - try { - var _usingCtx2 = _using_ctx(); - _usingCtx2.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx2.e = _; - } finally{ - await _usingCtx2.d(); - } - case 1: - try { - var _usingCtx3 = _using_ctx(); - _usingCtx3.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx3.e = _; - } finally{ - await _usingCtx3.d(); - } - } - try { - var _usingCtx4 = _using_ctx(); - _usingCtx4.a({ +await using d1 = { + async [Symbol.asyncDispose] () {} +} +await using d19 = { + async [Symbol.asyncDispose] () {} +} +switch(Math.random()){ + case 0: + await using d20 = { async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx4.e = _; - } finally{ - await _usingCtx4.d(); - } - try { - try { - var _usingCtx5 = _using_ctx(); - _usingCtx5.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx5.e = _; - } finally{ - await _usingCtx5.d(); - } - } catch { - try { - var _usingCtx6 = _using_ctx(); - _usingCtx6.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx6.e = _; - } finally{ - await _usingCtx6.d(); - } - } finally{ - try { - var _usingCtx7 = _using_ctx(); - _usingCtx7.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx7.e = _; - } finally{ - await _usingCtx7.d(); } - } - try { - var _usingCtx8 = _using_ctx(); - _usingCtx8.a({ + break; + case 1: + await using d21 = { async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx8.e = _; - } finally{ - await _usingCtx8.d(); + } +} +await using d22 = { + async [Symbol.asyncDispose] () {} +} +try { + await using d23 = { + async [Symbol.asyncDispose] () {} } - for(;;)try { - var _usingCtx10 = _using_ctx(); - _usingCtx10.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx10.e = _; - } finally{ - await _usingCtx10.d(); +} catch { + await using d24 = { + async [Symbol.asyncDispose] () {} } - for(;;)try { - var _usingCtx11 = _using_ctx(); - _usingCtx11.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx11.e = _; - } finally{ - await _usingCtx11.d(); +} finally{ + await using d25 = { + async [Symbol.asyncDispose] () {} } - for(;;)try { - var _usingCtx12 = _using_ctx(); - _usingCtx12.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx12.e = _; - } finally{ - await _usingCtx12.d(); +} +await using d26 = { + async [Symbol.asyncDispose] () {} +} +for(;;){ + await using d28 = { + async [Symbol.asyncDispose] () {} } - for(let x in {})try { - var _usingCtx13 = _using_ctx(); - _usingCtx13.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx13.e = _; - } finally{ - await _usingCtx13.d(); + break; +} +for(;;){ + await using d29 = { + async [Symbol.asyncDispose] () {} } - for (let x of [])try { - var _usingCtx14 = _using_ctx(); - _usingCtx14.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx14.e = _; - } finally{ - await _usingCtx14.d(); + break; +} +for(;;){ + await using d30 = { + async [Symbol.asyncDispose] () {} } -} catch (_) { - _usingCtx.e = _; -} finally{ - await _usingCtx.d(); + break; +} +for(let x in {})await using d31 = { + async [Symbol.asyncDispose] () {} +} +for (let x of [])await using d32 = { + async [Symbol.asyncDispose] () {} } +export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.1.normal.js index 015814bfd05a..42dce7c9dbe5 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.1.normal.js @@ -1,12 +1,5 @@ //// [awaitUsingDeclarations.12.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; async function f() { - try { - var _usingCtx = _using_ctx(); - const x = _usingCtx.a({}); - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); - } + await using x = {} + ; } diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.2.minified.js index aab4b1d8155a..b20fa1fa672f 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.12.2.minified.js @@ -1,2 +1 @@ //// [awaitUsingDeclarations.12.ts] -import "@swc/helpers/_/_using_ctx"; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.1.normal.js index 5c4f259e5fe0..a704b8831a61 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.1.normal.js @@ -1,20 +1,6 @@ //// [awaitUsingDeclarations.13.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - var x = _usingCtx.a(null); - function f() { - try { - var _usingCtx = _using_ctx(); - const x = _usingCtx.a(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); - } - } -} catch (_) { - _usingCtx.e = _; -} finally{ - await _usingCtx.d(); +await using x = null +function f() { + await using x = null + ; } diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.2.minified.js index 5ae54041146f..b28c4ffd4093 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.13.2.minified.js @@ -1,10 +1,2 @@ //// [awaitUsingDeclarations.13.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.a(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - await _usingCtx.d(); -} +await using x = null diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.1.normal.js index 9790c4791081..13ec252e4e62 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.1.normal.js @@ -1,14 +1,7 @@ //// [awaitUsingDeclarations.15.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; async function f() { - try { - var _usingCtx = _using_ctx(); - const _ = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); + await using _ = { + async [Symbol.asyncDispose] () {} } + ; } diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.2.minified.js index 9ef0acd65b91..a80aa01962fa 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.15.2.minified.js @@ -1,2 +1 @@ //// [awaitUsingDeclarations.15.ts] -import "@swc/helpers/_/_using_ctx"; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).1.normal.js index 5e64ce262f0e..5089cb17fb99 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).1.normal.js @@ -1,16 +1,9 @@ //// [awaitUsingDeclarations.2.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; { - try { - var _usingCtx = _using_ctx(); - const d1 = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }), d2 = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); + await using d1 = { + async [Symbol.asyncDispose] () {} + }, d2 = { + async [Symbol.asyncDispose] () {} } + ; }export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).2.minified.js index b0930ba472dd..4e2501bb89da 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.2(target=esnext).2.minified.js @@ -1,14 +1,7 @@ //// [awaitUsingDeclarations.2.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }), _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); -} catch (_) { - _usingCtx.e = _; -} finally{ - await _usingCtx.d(); +await using d1 = { + async [Symbol.asyncDispose] () {} +}, d2 = { + async [Symbol.asyncDispose] () {} } +export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).1.normal.js index 645f4b1c1805..bbc02b6cbfd1 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).1.normal.js @@ -1,16 +1,9 @@ //// [awaitUsingDeclarations.3.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; { - try { - var _usingCtx = _using_ctx(); - const d1 = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }), d2 = _usingCtx.a(null), d3 = _usingCtx.a(undefined), d4 = _usingCtx.a({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); + await using d1 = { + async [Symbol.asyncDispose] () {} + }, d2 = null, d3 = undefined, d4 = { + [Symbol.dispose] () {} } + ; }export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).2.minified.js index f2f521bcbbcd..375a99335715 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.3(target=esnext).2.minified.js @@ -1,14 +1,7 @@ //// [awaitUsingDeclarations.3.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }), _usingCtx.a(null), _usingCtx.a(void 0), _usingCtx.a({ - [Symbol.dispose] () {} - }); -} catch (_) { - _usingCtx.e = _; -} finally{ - await _usingCtx.d(); +await using d1 = { + async [Symbol.asyncDispose] () {} +}, d2 = null, d3 = void 0, d4 = { + [Symbol.dispose] () {} } +export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.1.normal.js index e3f89b0810d8..e007d7ded823 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.1.normal.js @@ -1,12 +1,5 @@ //// [awaitUsingDeclarations.9.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; { - try { - var _usingCtx = _using_ctx(); - const a = _usingCtx.a(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); - } + await using a = null + ; }export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.2.minified.js index 10b581c62b46..15415176f800 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.9.2.minified.js @@ -1,10 +1,3 @@ //// [awaitUsingDeclarations.9.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.a(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - await _usingCtx.d(); -} +await using a = null +export { }; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).1.normal.js index 51c6a9728631..486397d3a71b 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).1.normal.js @@ -1,7 +1,6 @@ //// [awaitUsingDeclarationsInForAwaitOf.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; async function main() { - for await (const d1 of [ + for await (await using d1 of [ { async [Symbol.asyncDispose] () {} }, @@ -10,14 +9,5 @@ async function main() { }, null, undefined - ]){ - try { - var _usingCtx = _using_ctx(); - {} - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } + ]){} } diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).2.minified.js index 35eb661ced31..c966aa67d5da 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForAwaitOf(target=esnext).2.minified.js @@ -1,2 +1 @@ //// [awaitUsingDeclarationsInForAwaitOf.ts] -import "@swc/helpers/_/_using_ctx"; diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).1.normal.js index b539d27f7acb..3af7fa2c6335 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).1.normal.js @@ -1,7 +1,6 @@ //// [awaitUsingDeclarationsInForOf.1.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; async function main() { - for (const d1 of [ + for (await using d1 of [ { async [Symbol.asyncDispose] () {} }, @@ -10,14 +9,5 @@ async function main() { }, null, undefined - ]){ - try { - var _usingCtx = _using_ctx(); - {} - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } + ]){} } diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).2.minified.js index 7cfe7407750d..595b77faf6b9 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarationsInForOf.1(target=esnext).2.minified.js @@ -1,2 +1 @@ //// [awaitUsingDeclarationsInForOf.1.ts] -import "@swc/helpers/_/_using_ctx"; diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod14.1.normal.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod14.1.normal.js index fd5061b60e2c..69e7a88484c8 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod14.1.normal.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod14.1.normal.js @@ -1,7 +1,6 @@ //// [decoratorOnClassMethod14.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; class Foo { + @decorator foo() { return 0; } @@ -11,9 +10,3 @@ class Foo { }; } } -_ts_decorate([ - decorator, - _ts_metadata("design:type", Function), - _ts_metadata("design:paramtypes", []), - _ts_metadata("design:returntype", void 0) -], Foo.prototype, "foo", null); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod14.2.minified.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod14.2.minified.js index 122781d6ac11..7fa87d1c98ec 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod14.2.minified.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod14.2.minified.js @@ -1,16 +1 @@ //// [decoratorOnClassMethod14.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; -_ts_decorate([ - decorator, - _ts_metadata("design:type", Function), - _ts_metadata("design:paramtypes", []), - _ts_metadata("design:returntype", void 0) -], (class { - foo() { - return 0; - } - constructor(){ - this.prop = ()=>0; - } -}).prototype, "foo", null); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod15.1.normal.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod15.1.normal.js index 3469288fbbf8..d752697a2294 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod15.1.normal.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod15.1.normal.js @@ -1,7 +1,6 @@ //// [decoratorOnClassMethod15.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; class Foo { + @decorator foo() { return 0; } @@ -9,9 +8,3 @@ class Foo { this.prop = 1; } } -_ts_decorate([ - decorator, - _ts_metadata("design:type", Function), - _ts_metadata("design:paramtypes", []), - _ts_metadata("design:returntype", void 0) -], Foo.prototype, "foo", null); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod15.2.minified.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod15.2.minified.js index 119f32ae4a02..4277bfb19229 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod15.2.minified.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod15.2.minified.js @@ -1,16 +1 @@ //// [decoratorOnClassMethod15.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; -_ts_decorate([ - decorator, - _ts_metadata("design:type", Function), - _ts_metadata("design:paramtypes", []), - _ts_metadata("design:returntype", void 0) -], (class { - foo() { - return 0; - } - constructor(){ - this.prop = 1; - } -}).prototype, "foo", null); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod16.1.normal.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod16.1.normal.js index 57c1fd676811..672c5d7989d8 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod16.1.normal.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod16.1.normal.js @@ -1,14 +1,7 @@ //// [decoratorOnClassMethod16.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; class Foo { + @decorator foo() { return 0; } } -_ts_decorate([ - decorator, - _ts_metadata("design:type", Function), - _ts_metadata("design:paramtypes", []), - _ts_metadata("design:returntype", void 0) -], Foo.prototype, "foo", null); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod16.2.minified.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod16.2.minified.js index 6825f2a25134..ed100fcc0dfc 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod16.2.minified.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod16.2.minified.js @@ -1,13 +1 @@ //// [decoratorOnClassMethod16.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; -_ts_decorate([ - decorator, - _ts_metadata("design:type", Function), - _ts_metadata("design:paramtypes", []), - _ts_metadata("design:returntype", void 0) -], (class { - foo() { - return 0; - } -}).prototype, "foo", null); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod18.1.normal.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod18.1.normal.js index 5dafbd9caa37..52505360e685 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod18.1.normal.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod18.1.normal.js @@ -1,7 +1,3 @@ //// [decoratorOnClassMethod18.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; class Foo { } -_ts_decorate([ - decorator() -], Foo.prototype, "p2", void 0); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod18.2.minified.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod18.2.minified.js index 448fb14ee2d3..50e405e02fed 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod18.2.minified.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod18.2.minified.js @@ -1,6 +1 @@ //// [decoratorOnClassMethod18.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -_ts_decorate([ - decorator() -], (class { -}).prototype, "p2", void 0); diff --git a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).1.normal.js index 73c4480e1d09..848ac78dcdc3 100644 --- a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).1.normal.js @@ -1,5 +1,5 @@ //// [typeOfThisInStaticMembers10.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +@foo class C { static{ this.a = 1; @@ -8,9 +8,7 @@ class C { this.b = this.a + 1; } } -C = _ts_decorate([ - foo -], C); +@foo class D extends C { static{ this.c = 2; @@ -39,9 +37,6 @@ class D extends C { this.c = v + 1; } } -D = _ts_decorate([ - foo -], D); class CC { static{ this.a = 1; diff --git a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).2.minified.js index 704545d184f2..5753d39849c7 100644 --- a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers10(target=esnext).2.minified.js @@ -1,5 +1,5 @@ //// [typeOfThisInStaticMembers10.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +@foo class C { static{ this.a = 1; @@ -8,9 +8,7 @@ class C { this.b = this.a + 1; } } -C = _ts_decorate([ - foo -], C); +@foo class D extends C { static{ this.c = 2; @@ -39,9 +37,6 @@ class D extends C { this.c = v + 1; } } -D = _ts_decorate([ - foo -], D); class CC { static{ this.a = 1; diff --git a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).1.normal.js index 814b7b99ddd2..57e76e3e494d 100644 --- a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).1.normal.js @@ -1,12 +1,10 @@ //// [typeOfThisInStaticMembers11.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +@foo class C { static a = 1; static b = this.a + 1; } -C = _ts_decorate([ - foo -], C); +@foo class D extends C { static c = 2; static d = this.c + 1; @@ -25,9 +23,6 @@ class D extends C { this.c = v + 1; } } -D = _ts_decorate([ - foo -], D); class CC { static a = 1; static b = this.a + 1; diff --git a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).2.minified.js index 744520a09fa5..320901b62061 100644 --- a/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/typeOfThisInStaticMembers11(target=esnext).2.minified.js @@ -1,12 +1,10 @@ //// [typeOfThisInStaticMembers11.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +@foo class C { static a = 1; static b = this.a + 1; } -C = _ts_decorate([ - foo -], C); +@foo class D extends C { static c = 2; static d = this.c + 1; @@ -25,9 +23,6 @@ class D extends C { this.c = v + 1; } } -D = _ts_decorate([ - foo -], D); class CC { static a = 1; static b = this.a + 1; diff --git a/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).1.normal.js index d5c775efd175..dd226bf40ae6 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).1.normal.js @@ -1,407 +1,211 @@ //// [usingDeclarations.1.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - var d1 = _usingCtx.u({ +using d1 = { + [Symbol.dispose] () {} +} +function f() { + using d2 = { [Symbol.dispose] () {} - }); - function f() { - try { - var _usingCtx = _using_ctx(); - const d2 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } } - async function af() { - try { - var _usingCtx = _using_ctx(); - const d3 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - await null; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + ; +} +async function af() { + using d3 = { + [Symbol.dispose] () {} } - function* g() { - try { - var _usingCtx = _using_ctx(); - const d4 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - yield; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + ; + await null; +} +function* g() { + using d4 = { + [Symbol.dispose] () {} } - async function* ag() { - try { - var _usingCtx = _using_ctx(); - const d5 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - yield; - await null; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + ; + yield; +} +async function* ag() { + using d5 = { + [Symbol.dispose] () {} } - const a = ()=>{ - try { - var _usingCtx = _using_ctx(); - const d6 = _usingCtx.u({ + ; + yield; + await null; +} +const a = ()=>{ + using d6 = { + [Symbol.dispose] () {} + } + ; +}; +class C1 { + constructor(){ + this.a = ()=>{ + using d7 = { [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - }; - class C1 { - constructor(){ - this.a = ()=>{ - try { - var _usingCtx = _using_ctx(); - const d7 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - }; - try { - var _usingCtx = _using_ctx(); - const d8 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } - static{ - try { - var _usingCtx = _using_ctx(); - const d9 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); } + ; + }; + using d8 = { + [Symbol.dispose] () {} } - m() { - try { - var _usingCtx = _using_ctx(); - const d10 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } - get x() { - try { - var _usingCtx = _using_ctx(); - const d11 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - return 0; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + ; + } + static{ + using d9 = { + [Symbol.dispose] () {} } - set x(v) { - try { - var _usingCtx = _using_ctx(); - const d12 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + ; + } + m() { + using d10 = { + [Symbol.dispose] () {} } - async am() { - try { - var _usingCtx = _using_ctx(); - const d13 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - await null; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + ; + } + get x() { + using d11 = { + [Symbol.dispose] () {} } - *g() { - try { - var _usingCtx = _using_ctx(); - const d14 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - yield; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + ; + return 0; + } + set x(v) { + using d12 = { + [Symbol.dispose] () {} } - async *ag() { - try { - var _usingCtx = _using_ctx(); - const d15 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - yield; - await null; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + ; + } + async am() { + using d13 = { + [Symbol.dispose] () {} } + ; + await null; } - class C2 extends C1 { - constructor(){ - try { - var _usingCtx = _using_ctx(); - const d16 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - super(); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + *g() { + using d14 = { + [Symbol.dispose] () {} } + ; + yield; } - class C3 extends C1 { - constructor(){ - try { - var _usingCtx = _using_ctx(); - const d17 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - super(), this.y = 1; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + async *ag() { + using d15 = { + [Symbol.dispose] () {} } + ; + yield; + await null; } - var N; - (function(N) { - try { - var _usingCtx = _using_ctx(); - var d18 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); +} +class C2 extends C1 { + constructor(){ + using d16 = { + [Symbol.dispose] () {} } - })(N || (N = {})); - { - try { - var _usingCtx1 = _using_ctx(); - const d19 = _usingCtx1.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx1.e = _; - } finally{ - _usingCtx1.d(); + ; + super(); + } +} +class C3 extends C1 { + constructor(){ + using d17 = { + [Symbol.dispose] () {} } + ; + super(), this.y = 1; } - switch(Math.random()){ - case 0: - try { - var _usingCtx2 = _using_ctx(); - const d20 = _usingCtx2.u({ - [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx2.e = _; - } finally{ - _usingCtx2.d(); - } - case 1: - try { - var _usingCtx3 = _using_ctx(); - const d21 = _usingCtx3.u({ - [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx3.e = _; - } finally{ - _usingCtx3.d(); - } +} +var N; +(function(N) { + using d18 = { + [Symbol.dispose] () {} } - if (true) switch(0){ - case 0: - try { - var _usingCtx4 = _using_ctx(); - const d22 = _usingCtx4.u({ - [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx4.e = _; - } finally{ - _usingCtx4.d(); - } +})(N || (N = {})); +{ + using d19 = { + [Symbol.dispose] () {} } - try { - try { - var _usingCtx5 = _using_ctx(); - const d23 = _usingCtx5.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx5.e = _; - } finally{ - _usingCtx5.d(); + ; +}switch(Math.random()){ + case 0: + using d20 = { + [Symbol.dispose] () {} } - } catch { - try { - var _usingCtx6 = _using_ctx(); - const d24 = _usingCtx6.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx6.e = _; - } finally{ - _usingCtx6.d(); + ; + break; + case 1: + using d21 = { + [Symbol.dispose] () {} } - } finally{ - try { - var _usingCtx7 = _using_ctx(); - const d25 = _usingCtx7.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx7.e = _; - } finally{ - _usingCtx7.d(); + ; + break; +} +if (true) switch(0){ + case 0: + using d22 = { + [Symbol.dispose] () {} } + ; + break; +} +try { + using d23 = { + [Symbol.dispose] () {} } - if (true) { - try { - var _usingCtx8 = _using_ctx(); - const d26 = _usingCtx8.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx8.e = _; - } finally{ - _usingCtx8.d(); - } - } else { - try { - var _usingCtx9 = _using_ctx(); - const d27 = _usingCtx9.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx9.e = _; - } finally{ - _usingCtx9.d(); - } + ; +} catch { + using d24 = { + [Symbol.dispose] () {} } - while(true){ - try { - var _usingCtx10 = _using_ctx(); - const d28 = _usingCtx10.u({ - [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx10.e = _; - } finally{ - _usingCtx10.d(); - } + ; +} finally{ + using d25 = { + [Symbol.dispose] () {} } - do { - try { - var _usingCtx11 = _using_ctx(); - const d29 = _usingCtx11.u({ - [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx11.e = _; - } finally{ - _usingCtx11.d(); - } - }while (true) - for(;;){ - try { - var _usingCtx12 = _using_ctx(); - const d30 = _usingCtx12.u({ - [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx12.e = _; - } finally{ - _usingCtx12.d(); - } + ; +} +if (true) { + using d26 = { + [Symbol.dispose] () {} } - for(const x in {}){ - try { - var _usingCtx13 = _using_ctx(); - const d31 = _usingCtx13.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx13.e = _; - } finally{ - _usingCtx13.d(); - } + ; +} else { + using d27 = { + [Symbol.dispose] () {} } - for (const x of []){ - try { - var _usingCtx14 = _using_ctx(); - const d32 = _usingCtx14.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx14.e = _; - } finally{ - _usingCtx14.d(); - } + ; +} +while(true){ + using d28 = { + [Symbol.dispose] () {} } -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); + ; + break; +} +do { + using d29 = { + [Symbol.dispose] () {} + } + ; + break; +}while (true) +for(;;){ + using d30 = { + [Symbol.dispose] () {} + } + ; + break; +} +for(const x in {}){ + using d31 = { + [Symbol.dispose] () {} + } + ; +} +for (const x of []){ + using d32 = { + [Symbol.dispose] () {} + } + ; } export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).2.minified.js index c757c3f676a5..5d79f0847483 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.1(target=esnext).2.minified.js @@ -1,276 +1,119 @@ //// [usingDeclarations.1.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var N, _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }); - class C1 { - constructor(){ - this.a = ()=>{ - try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - }; - try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } - static{ - try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } - m() { - try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } - get x() { - try { - var _usingCtx = _using_ctx(); - return _usingCtx.u({ - [Symbol.dispose] () {} - }), 0; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } - set x(v) { - try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } - async am() { - try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }), await null; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } - *g() { - try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }), yield; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } - async *ag() { - try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }), yield, await null; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); +var N; +using d1 = { + [Symbol.dispose] () {} +} +class C1 { + constructor(){ + this.a = ()=>{ + using d7 = { + [Symbol.dispose] () {} } + }; + using d8 = { + [Symbol.dispose] () {} } } - !function(N) { - try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - }(N || (N = {})); - try { - var _usingCtx1 = _using_ctx(); - _usingCtx1.u({ + static{ + using d9 = { [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx1.e = _; - } finally{ - _usingCtx1.d(); - } - switch(Math.random()){ - case 0: - try { - var _usingCtx2 = _using_ctx(); - _usingCtx2.u({ - [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx2.e = _; - } finally{ - _usingCtx2.d(); - } - case 1: - try { - var _usingCtx3 = _using_ctx(); - _usingCtx3.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx3.e = _; - } finally{ - _usingCtx3.d(); - } + } } - try { - var _usingCtx4 = _using_ctx(); - _usingCtx4.u({ + m() { + using d10 = { [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx4.e = _; - } finally{ - _usingCtx4.d(); - } - try { - try { - var _usingCtx5 = _using_ctx(); - _usingCtx5.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx5.e = _; - } finally{ - _usingCtx5.d(); } - } catch { - try { - var _usingCtx6 = _using_ctx(); - _usingCtx6.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx6.e = _; - } finally{ - _usingCtx6.d(); + } + get x() { + using d11 = { + [Symbol.dispose] () {} } - } finally{ - try { - var _usingCtx7 = _using_ctx(); - _usingCtx7.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx7.e = _; - } finally{ - _usingCtx7.d(); + return 0; + } + set x(v) { + using d12 = { + [Symbol.dispose] () {} } } - try { - var _usingCtx8 = _using_ctx(); - _usingCtx8.u({ + async am() { + using d13 = { [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx8.e = _; - } finally{ - _usingCtx8.d(); + } + await null; } - for(;;)try { - var _usingCtx10 = _using_ctx(); - _usingCtx10.u({ + *g() { + using d14 = { [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx10.e = _; - } finally{ - _usingCtx10.d(); + } + yield; } - for(;;)try { - var _usingCtx11 = _using_ctx(); - _usingCtx11.u({ + async *ag() { + using d15 = { [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx11.e = _; - } finally{ - _usingCtx11.d(); + } + yield, await null; + } +} +!function(N) { + using d18 = { + [Symbol.dispose] () {} } - for(;;)try { - var _usingCtx12 = _using_ctx(); - _usingCtx12.u({ +}(N || (N = {})); +using d19 = { + [Symbol.dispose] () {} +} +switch(Math.random()){ + case 0: + using d20 = { [Symbol.dispose] () {} - }); + } break; - } catch (_) { - _usingCtx12.e = _; - } finally{ - _usingCtx12.d(); - } - for(let x in {})try { - var _usingCtx13 = _using_ctx(); - _usingCtx13.u({ + case 1: + using d21 = { [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx13.e = _; - } finally{ - _usingCtx13.d(); + } +} +using d22 = { + [Symbol.dispose] () {} +} +try { + using d23 = { + [Symbol.dispose] () {} } - for (let x of [])try { - var _usingCtx14 = _using_ctx(); - _usingCtx14.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx14.e = _; - } finally{ - _usingCtx14.d(); +} catch { + using d24 = { + [Symbol.dispose] () {} } -} catch (_) { - _usingCtx.e = _; } finally{ - _usingCtx.d(); + using d25 = { + [Symbol.dispose] () {} + } +} +using d26 = { + [Symbol.dispose] () {} +} +for(;;){ + using d28 = { + [Symbol.dispose] () {} + } + break; +} +for(;;){ + using d29 = { + [Symbol.dispose] () {} + } + break; +} +for(;;){ + using d30 = { + [Symbol.dispose] () {} + } + break; +} +for(let x in {})using d31 = { + [Symbol.dispose] () {} +} +for (let x of [])using d32 = { + [Symbol.dispose] () {} } +export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarations.14.1.normal.js b/crates/swc/tests/tsc-references/usingDeclarations.14.1.normal.js index cfbfba2ad869..f5feea9b25c3 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.14.1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.14.1.normal.js @@ -1,10 +1,2 @@ //// [usingDeclarations.14.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - var x = _usingCtx.u({}); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); -} +using x = {} diff --git a/crates/swc/tests/tsc-references/usingDeclarations.14.2.minified.js b/crates/swc/tests/tsc-references/usingDeclarations.14.2.minified.js index e50f2dc1dea4..f5feea9b25c3 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.14.2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.14.2.minified.js @@ -1,10 +1,2 @@ //// [usingDeclarations.14.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.u({}); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); -} +using x = {} diff --git a/crates/swc/tests/tsc-references/usingDeclarations.15.1.normal.js b/crates/swc/tests/tsc-references/usingDeclarations.15.1.normal.js index bea8776ea040..f51b8f73778c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.15.1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.15.1.normal.js @@ -1,13 +1,5 @@ //// [usingDeclarations.15.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - var _ = _usingCtx.u({ - [Symbol.dispose] () {} - }); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using _ = { + [Symbol.dispose] () {} } export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarations.15.2.minified.js b/crates/swc/tests/tsc-references/usingDeclarations.15.2.minified.js index a1f9133d0799..f51b8f73778c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.15.2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.15.2.minified.js @@ -1,12 +1,5 @@ //// [usingDeclarations.15.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using _ = { + [Symbol.dispose] () {} } +export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).1.normal.js index ebd9d72663f3..6d1c7712f296 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).1.normal.js @@ -1,16 +1,9 @@ //// [usingDeclarations.2.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; { - try { - var _usingCtx = _using_ctx(); - const d1 = _usingCtx.u({ - [Symbol.dispose] () {} - }), d2 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); + using d1 = { + [Symbol.dispose] () {} + }, d2 = { + [Symbol.dispose] () {} } + ; } diff --git a/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).2.minified.js index 45ef9b4d6f41..3671aefc108a 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.2(target=esnext).2.minified.js @@ -1,14 +1,6 @@ //// [usingDeclarations.2.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }), _usingCtx.u({ - [Symbol.dispose] () {} - }); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using d1 = { + [Symbol.dispose] () {} +}, d2 = { + [Symbol.dispose] () {} } diff --git a/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).1.normal.js index 6f27d83c73a8..4043e7154267 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).1.normal.js @@ -1,16 +1,9 @@ //// [usingDeclarations.3.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; { - try { - var _usingCtx = _using_ctx(); - const d1 = _usingCtx.u({ - [Symbol.dispose] () {} - }), d2 = _usingCtx.u(null), d3 = _usingCtx.u(undefined), d4 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); + using d1 = { + [Symbol.dispose] () {} + }, d2 = null, d3 = undefined, d4 = { + [Symbol.dispose] () {} } + ; } diff --git a/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).2.minified.js index d9daab6fa430..9cf93e3b8ba0 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.3(target=esnext).2.minified.js @@ -1,14 +1,6 @@ //// [usingDeclarations.3.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }), _usingCtx.u(null), _usingCtx.u(void 0), _usingCtx.u({ - [Symbol.dispose] () {} - }); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using d1 = { + [Symbol.dispose] () {} +}, d2 = null, d3 = void 0, d4 = { + [Symbol.dispose] () {} } diff --git a/crates/swc/tests/tsc-references/usingDeclarations.9.1.normal.js b/crates/swc/tests/tsc-references/usingDeclarations.9.1.normal.js index 970efa4e9e24..3a2079d76250 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.9.1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.9.1.normal.js @@ -1,12 +1,5 @@ //// [usingDeclarations.9.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; { - try { - var _usingCtx = _using_ctx(); - const a = _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using a = null + ; } diff --git a/crates/swc/tests/tsc-references/usingDeclarations.9.2.minified.js b/crates/swc/tests/tsc-references/usingDeclarations.9.2.minified.js index 838a1525bee2..8896bff0f17d 100644 --- a/crates/swc/tests/tsc-references/usingDeclarations.9.2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarations.9.2.minified.js @@ -1,10 +1,2 @@ //// [usingDeclarations.9.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); -} +using a = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.1.normal.js index fb0905592aa1..64f638f25e34 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.1.normal.js @@ -1,17 +1,9 @@ //// [usingDeclarationsDeclarationEmit.1.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; +using r1 = { + [Symbol.dispose] () {} +} export { r1 }; -export { r2 }; -try { - var _usingCtx = _using_ctx(); - var r1 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - var r2 = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); -} catch (_) { - _usingCtx.e = _; -} finally{ - await _usingCtx.d(); +await using r2 = { + async [Symbol.asyncDispose] () {} } +export { r2 }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.2.minified.js index 4222545f0b31..093c8aed77fd 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.1.2.minified.js @@ -1,14 +1,8 @@ //// [usingDeclarationsDeclarationEmit.1.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(), r1 = _usingCtx.u({ - [Symbol.dispose] () {} - }), r2 = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); -} catch (_) { - _usingCtx.e = _; -} finally{ - await _usingCtx.d(); +using r1 = { + [Symbol.dispose] () {} +} +await using r2 = { + async [Symbol.asyncDispose] () {} } export { r1, r2 }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.1.normal.js index 5c38eddf239d..fe3fccbcf40a 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.1.normal.js @@ -1,16 +1,8 @@ //// [usingDeclarationsDeclarationEmit.2.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - var r1 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - var r2 = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); -} catch (_) { - _usingCtx.e = _; -} finally{ - await _usingCtx.d(); +using r1 = { + [Symbol.dispose] () {} +} +await using r2 = { + async [Symbol.asyncDispose] () {} } export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.2.minified.js index 58dec52a1ed4..fe3fccbcf40a 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsDeclarationEmit.2.2.minified.js @@ -1,14 +1,8 @@ //// [usingDeclarationsDeclarationEmit.2.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.u({ - [Symbol.dispose] () {} - }), _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); -} catch (_) { - _usingCtx.e = _; -} finally{ - await _usingCtx.d(); +using r1 = { + [Symbol.dispose] () {} } +await using r2 = { + async [Symbol.asyncDispose] () {} +} +export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).1.normal.js index c7af45306326..087377eccea6 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).1.normal.js @@ -1,20 +1,10 @@ //// [usingDeclarationsInForAwaitOf.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; async function main() { - for await (const d1 of [ + for await (using d1 of [ { [Symbol.dispose] () {} }, null, undefined - ]){ - try { - var _usingCtx = _using_ctx(); - {} - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } + ]){} } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).2.minified.js index d4aece823eb8..f8d980c11c08 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsInForAwaitOf(target=esnext).2.minified.js @@ -1,2 +1 @@ //// [usingDeclarationsInForAwaitOf.ts] -import "@swc/helpers/_/_using_ctx"; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).1.normal.js index 800b83760a49..e6deb8d99972 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).1.normal.js @@ -1,18 +1,8 @@ //// [usingDeclarationsInForOf.1.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -for (const d1 of [ +for (using d1 of [ { [Symbol.dispose] () {} }, null, undefined -]){ - try { - var _usingCtx = _using_ctx(); - {} - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } -} +]){} diff --git a/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).2.minified.js index 834d99aa8f7b..7d5eedb7dc8f 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsInForOf.1(target=esnext).2.minified.js @@ -1,15 +1,8 @@ //// [usingDeclarationsInForOf.1.ts] -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -for (let d1 of [ +for (using d1 of [ { [Symbol.dispose] () {} }, null, void 0 -])try { - var _usingCtx = _using_ctx(); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); -} +]); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).1.normal.js index b29dc452d1fe..165d29c37ea4 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).1.normal.js @@ -3,18 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); -const _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - var before = _usingCtx.u(null); - class C { - } - C = _ts_decorate._([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).2.minified.js index c4a2f9568a0f..87827813aa9b 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).2.minified.js @@ -2,17 +2,4 @@ Object.defineProperty(exports, "__esModule", { value: !0 }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - _usingCtx.u(null); - class C { - } - C = _ts_decorate._([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); -} +using before = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).1.normal.js index 036b36e82eb7..d2dbe1ae7608 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).1.normal.js @@ -1,17 +1,6 @@ //// [usingDeclarationsWithLegacyClassDecorators.1.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - var before = _usingCtx.u(null); - class C { - } - C = _ts_decorate([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).2.minified.js index 89afdaf62485..11a587afae4a 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=es6,target=esnext).2.minified.js @@ -1,16 +1,3 @@ //// [usingDeclarationsWithLegacyClassDecorators.1.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.u(null); - class C { - } - C = _ts_decorate([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); -} +using before = null +export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).1.normal.js index bf6171222432..9806e3db0199 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).1.normal.js @@ -1,33 +1,14 @@ //// [usingDeclarationsWithLegacyClassDecorators.1.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { +System.register([], function(_export, _context) { "use strict"; - var _ts_decorate, _using_ctx; + var C; return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - var before = _usingCtx.u(null); - class C { - } - C = _ts_decorate([ - dec - ], C); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using before = null + C = @dec + class C { + }; } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).2.minified.js index eb06e75805f5..5860636c58ab 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).2.minified.js @@ -1,32 +1,9 @@ //// [usingDeclarationsWithLegacyClassDecorators.1.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { - var _ts_decorate, _using_ctx; +System.register([], function(_export, _context) { return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - _usingCtx.u(null); - class C { - } - C = _ts_decorate([ - dec - ], C); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using before = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).1.normal.js index abdfcde66ed6..6c62feb5287a 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).1.normal.js @@ -6,21 +6,10 @@ Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "default", { enumerable: true, get: function() { - return _class; + return _default; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); -const _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - var _class = class _class { - }; - _class = _ts_decorate._([ - dec - ], _class); - var after = _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class _default { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).2.minified.js index 025220975440..e6c8b99eb38e 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).2.minified.js @@ -4,18 +4,10 @@ Object.defineProperty(exports, "__esModule", { }), Object.defineProperty(exports, "default", { enumerable: !0, get: function() { - return _class; + return _default; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(), _class = class { - }; - _class = _ts_decorate._([ - dec - ], _class), _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class _default { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).1.normal.js index ffed1694dcb1..ecf1ec216856 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).1.normal.js @@ -1,17 +1,5 @@ //// [usingDeclarationsWithLegacyClassDecorators.10.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -export { _class as default }; -try { - var _usingCtx = _using_ctx(); - var _class = class _class { - }; - _class = _ts_decorate([ - dec - ], _class); - var after = _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +export default @dec +class { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).2.minified.js index 8b1e6147911a..ecf1ec216856 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=es6,target=esnext).2.minified.js @@ -1,15 +1,5 @@ //// [usingDeclarationsWithLegacyClassDecorators.10.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(), _class = class { - }; - _class = _ts_decorate([ - dec - ], _class), _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +export default @dec +class { } -export { _class as default }; +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).1.normal.js index 881ecb69908c..87a21074b5df 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).1.normal.js @@ -1,33 +1,13 @@ //// [usingDeclarationsWithLegacyClassDecorators.10.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { +System.register([], function(_export, _context) { "use strict"; - var _ts_decorate, _using_ctx; + _export("default", @dec + class { + }); return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - var _class = class _class { - }; - _export("default", _class = _ts_decorate([ - dec - ], _class)); - var after = _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using after = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).2.minified.js index 118dd094ae31..f6db4491104c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).2.minified.js @@ -1,30 +1,11 @@ //// [usingDeclarationsWithLegacyClassDecorators.10.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { - var _ts_decorate, _using_ctx; - return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], +System.register([], function(_export, _context) { + return _export("default", @dec + class { + }), { + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(), _class = class { - }; - _export("default", _class = _ts_decorate([ - dec - ], _class)), _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using after = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).1.normal.js index 5cbd98dbc701..1edd1acf28fe 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).1.normal.js @@ -9,18 +9,7 @@ Object.defineProperty(exports, "C", { return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); -const _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - class C { - } - C = _ts_decorate._([ - dec - ], C); - var after = _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).2.minified.js index 892d8ceeb02b..d966acbb5f0e 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).2.minified.js @@ -7,16 +7,7 @@ Object.defineProperty(exports, "__esModule", { return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - class C1 { - } - C1 = _ts_decorate._([ - dec - ], C1), _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).1.normal.js index 2daa7fe9636f..8705007ccb8f 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).1.normal.js @@ -1,17 +1,6 @@ //// [usingDeclarationsWithLegacyClassDecorators.11.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -export { C }; -try { - var _usingCtx = _using_ctx(); - class C { - } - C = _ts_decorate([ - dec - ], C); - var after = _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +export { C }; +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).2.minified.js index 74007d040bac..0356f412e6f1 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=es6,target=esnext).2.minified.js @@ -1,16 +1,6 @@ //// [usingDeclarationsWithLegacyClassDecorators.11.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - class C { - } - C = _ts_decorate([ - dec - ], C), _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +using after = null export { C }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).1.normal.js index 7d98f05d9d82..f0ccad931f6c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).1.normal.js @@ -1,33 +1,14 @@ //// [usingDeclarationsWithLegacyClassDecorators.11.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { +System.register([], function(_export, _context) { "use strict"; - var _ts_decorate, _using_ctx; + var C; return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - class C { - } - _export("C", C = _ts_decorate([ - dec - ], C)); - var after = _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + _export("C", C = @dec + class C { + }); + using after = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).2.minified.js index 1f6e0fa7f09c..8ddf4fcfcafb 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).2.minified.js @@ -1,31 +1,12 @@ //// [usingDeclarationsWithLegacyClassDecorators.11.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { - var _ts_decorate, _using_ctx; +System.register([], function(_export, _context) { return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - class C { - } - _export("C", C = _ts_decorate([ - dec - ], C)), _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + _export("C", @dec + class { + }); + using after = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).1.normal.js index eaef720a233d..df42af76969f 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).1.normal.js @@ -9,18 +9,7 @@ Object.defineProperty(exports, "D", { return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); -const _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - class C { - } - C = _ts_decorate._([ - dec - ], C); - var after = _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).2.minified.js index e9dd78c1b36d..28aec2731e69 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).2.minified.js @@ -7,16 +7,7 @@ Object.defineProperty(exports, "__esModule", { return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - class C1 { - } - C1 = _ts_decorate._([ - dec - ], C1), _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).1.normal.js index a21418310128..5730b47c51e2 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).1.normal.js @@ -1,17 +1,6 @@ //// [usingDeclarationsWithLegacyClassDecorators.12.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -export { C as D }; -try { - var _usingCtx = _using_ctx(); - class C { - } - C = _ts_decorate([ - dec - ], C); - var after = _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +export { C as D }; +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).2.minified.js index 96a12738b3e3..6c76452cfa64 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=es6,target=esnext).2.minified.js @@ -1,16 +1,6 @@ //// [usingDeclarationsWithLegacyClassDecorators.12.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - class C { - } - C = _ts_decorate([ - dec - ], C), _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +using after = null export { C as D }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).1.normal.js index 8aae998a8767..c1c9143b3030 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).1.normal.js @@ -1,33 +1,14 @@ //// [usingDeclarationsWithLegacyClassDecorators.12.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { +System.register([], function(_export, _context) { "use strict"; - var _ts_decorate, _using_ctx; + var C; return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - class C { - } - _export("D", C = _ts_decorate([ - dec - ], C)); - var after = _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + _export("D", C = @dec + class C { + }); + using after = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).2.minified.js index 0d8a2fe98456..84172012e65b 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).2.minified.js @@ -1,31 +1,12 @@ //// [usingDeclarationsWithLegacyClassDecorators.12.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { - var _ts_decorate, _using_ctx; +System.register([], function(_export, _context) { return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - class C { - } - _export("D", C = _ts_decorate([ - dec - ], C)), _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + _export("D", @dec + class { + }); + using after = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).1.normal.js index 0deba7a50d7f..81b834ce4206 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).1.normal.js @@ -6,23 +6,10 @@ Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "C", { enumerable: true, get: function() { - return _C; + return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); -const _using_ctx = require("@swc/helpers/_/_using_ctx"); -var _C; -try { - var _usingCtx = _using_ctx._(); - var before = _usingCtx.u(null); - class C { - } - _C = C; - C = _ts_decorate._([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).2.minified.js index f3849d640a99..39ae36b1431c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).2.minified.js @@ -4,20 +4,10 @@ Object.defineProperty(exports, "__esModule", { }), Object.defineProperty(exports, "C", { enumerable: !0, get: function() { - return _C; + return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _C, _usingCtx = _using_ctx._(); - _usingCtx.u(null); - class C { - } - _C = C, C = _ts_decorate._([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).1.normal.js index 27865d30b109..fc2b90b581c0 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).1.normal.js @@ -1,19 +1,5 @@ //// [usingDeclarationsWithLegacyClassDecorators.2.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -var _C; -try { - var _usingCtx = _using_ctx(); - var before = _usingCtx.u(null); - class C { - } - _C = C; - C = _ts_decorate([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +export class C { } -export { _C as C }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).2.minified.js index 7e5c750c71b3..fc2b90b581c0 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=es6,target=esnext).2.minified.js @@ -1,17 +1,5 @@ //// [usingDeclarationsWithLegacyClassDecorators.2.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _C, _usingCtx = _using_ctx(); - _usingCtx.u(null); - class C { - } - _C = C, C = _ts_decorate([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +export class C { } -export { _C as C }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).1.normal.js index 98691c8149e1..342eee2ce895 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).1.normal.js @@ -1,35 +1,15 @@ //// [usingDeclarationsWithLegacyClassDecorators.2.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { +System.register([], function(_export, _context) { "use strict"; - var _ts_decorate, _using_ctx, _C; + var C; _export("C", void 0); return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - var before = _usingCtx.u(null); - class C { - } - _export("C", _C = C); - C = _ts_decorate([ - dec - ], C); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using before = null + _export("C", C = @dec + class C { + }); } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).2.minified.js index f7a8aae41569..90e57fc5d8ab 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).2.minified.js @@ -1,32 +1,12 @@ //// [usingDeclarationsWithLegacyClassDecorators.2.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { - var _ts_decorate, _using_ctx; +System.register([], function(_export, _context) { return _export("C", void 0), { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - _usingCtx.u(null); - class C { - } - _export("C", C), C = _ts_decorate([ - dec - ], C); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using before = null + _export("C", @dec + class { + }); } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).1.normal.js index cdfae9e0bf96..c5c6fd8468b6 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).1.normal.js @@ -9,18 +9,7 @@ Object.defineProperty(exports, "default", { return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); -const _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - var before = _usingCtx.u(null); - var C = class C { - }; - C = _ts_decorate._([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).2.minified.js index 8a31f307ff05..3b5844f85c1a 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).2.minified.js @@ -7,17 +7,7 @@ Object.defineProperty(exports, "__esModule", { return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - _usingCtx.u(null); - var C = class { - }; - C = _ts_decorate._([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).1.normal.js index 06cb6c24d36c..477d017ae912 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).1.normal.js @@ -1,17 +1,5 @@ //// [usingDeclarationsWithLegacyClassDecorators.3.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -export { C as default }; -try { - var _usingCtx = _using_ctx(); - var before = _usingCtx.u(null); - var C = class C { - }; - C = _ts_decorate([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +export default @dec +class C { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).2.minified.js index 904b8a4b8e8d..477d017ae912 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=es6,target=esnext).2.minified.js @@ -1,17 +1,5 @@ //// [usingDeclarationsWithLegacyClassDecorators.3.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.u(null); - var C = class { - }; - C = _ts_decorate([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +export default @dec +class C { } -export { C as default }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).1.normal.js index 728117336184..27e022cc05ec 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).1.normal.js @@ -1,33 +1,15 @@ //// [usingDeclarationsWithLegacyClassDecorators.3.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { +System.register([], function(_export, _context) { "use strict"; - var _ts_decorate, _using_ctx; + var C; + _export("default", void 0); return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - var before = _usingCtx.u(null); - var C = class C { - }; - _export("default", C = _ts_decorate([ - dec - ], C)); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using before = null + _export("default", C = @dec + class C { + }); } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).2.minified.js index 068fe6225f59..505f03ed65b7 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).2.minified.js @@ -1,32 +1,12 @@ //// [usingDeclarationsWithLegacyClassDecorators.3.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { - var _ts_decorate, _using_ctx; - return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], +System.register([], function(_export, _context) { + return _export("default", void 0), { + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - _usingCtx.u(null); - var C = class { - }; - _export("default", C = _ts_decorate([ - dec - ], C)); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using before = null + _export("default", @dec + class { + }); } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).1.normal.js index 40ccb45028ff..01e84a330808 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).1.normal.js @@ -6,21 +6,10 @@ Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "default", { enumerable: true, get: function() { - return _class; + return _default; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); -const _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - var before = _usingCtx.u(null); - var _class = class _class { - }; - _class = _ts_decorate._([ - dec - ], _class); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class _default { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).2.minified.js index 651b4dbc09d5..23c421fb14e4 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).2.minified.js @@ -4,20 +4,10 @@ Object.defineProperty(exports, "__esModule", { }), Object.defineProperty(exports, "default", { enumerable: !0, get: function() { - return _class; + return _default; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - _usingCtx.u(null); - var _class = class { - }; - _class = _ts_decorate._([ - dec - ], _class); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class _default { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).1.normal.js index 494956940d4a..de9adc6a1e80 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).1.normal.js @@ -1,17 +1,5 @@ //// [usingDeclarationsWithLegacyClassDecorators.4.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -export { _class as default }; -try { - var _usingCtx = _using_ctx(); - var before = _usingCtx.u(null); - var _class = class _class { - }; - _class = _ts_decorate([ - dec - ], _class); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +export default @dec +class { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).2.minified.js index 16fd923fd420..de9adc6a1e80 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=es6,target=esnext).2.minified.js @@ -1,17 +1,5 @@ //// [usingDeclarationsWithLegacyClassDecorators.4.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.u(null); - var _class = class { - }; - _class = _ts_decorate([ - dec - ], _class); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +export default @dec +class { } -export { _class as default }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).1.normal.js index d19071f6100c..9716a0790f15 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).1.normal.js @@ -1,33 +1,13 @@ //// [usingDeclarationsWithLegacyClassDecorators.4.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { +System.register([], function(_export, _context) { "use strict"; - var _ts_decorate, _using_ctx; + _export("default", @dec + class { + }); return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - var before = _usingCtx.u(null); - var _class = class _class { - }; - _export("default", _class = _ts_decorate([ - dec - ], _class)); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using before = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).2.minified.js index f2954e1f4b1b..11b0d43d5fae 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).2.minified.js @@ -1,32 +1,11 @@ //// [usingDeclarationsWithLegacyClassDecorators.4.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { - var _ts_decorate, _using_ctx; - return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], +System.register([], function(_export, _context) { + return _export("default", @dec + class { + }), { + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - _usingCtx.u(null); - var _class = class { - }; - _export("default", _class = _ts_decorate([ - dec - ], _class)); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using before = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).1.normal.js index 3ec36fd8d880..0e134120f21c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).1.normal.js @@ -9,18 +9,7 @@ Object.defineProperty(exports, "C", { return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); -const _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - var before = _usingCtx.u(null); - class C { - } - C = _ts_decorate._([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).2.minified.js index b6b98e01017c..701811d4adda 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).2.minified.js @@ -7,17 +7,7 @@ Object.defineProperty(exports, "__esModule", { return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - _usingCtx.u(null); - class C1 { - } - C1 = _ts_decorate._([ - dec - ], C1); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).1.normal.js index 5ca6582ea6a7..d3353880c89c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).1.normal.js @@ -1,17 +1,6 @@ //// [usingDeclarationsWithLegacyClassDecorators.5.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -export { C }; -try { - var _usingCtx = _using_ctx(); - var before = _usingCtx.u(null); - class C { - } - C = _ts_decorate([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } +export { C }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).2.minified.js index 07486ef3ac46..d3353880c89c 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=es6,target=esnext).2.minified.js @@ -1,17 +1,6 @@ //// [usingDeclarationsWithLegacyClassDecorators.5.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.u(null); - class C { - } - C = _ts_decorate([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } export { C }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).1.normal.js index 3c77cb98fa4e..2938ae1accf7 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).1.normal.js @@ -1,33 +1,14 @@ //// [usingDeclarationsWithLegacyClassDecorators.5.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { +System.register([], function(_export, _context) { "use strict"; - var _ts_decorate, _using_ctx; + var C; return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - var before = _usingCtx.u(null); - class C { - } - _export("C", C = _ts_decorate([ - dec - ], C)); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using before = null + _export("C", C = @dec + class C { + }); } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).2.minified.js index 93eeefd42634..07a0d2eb025f 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).2.minified.js @@ -1,32 +1,12 @@ //// [usingDeclarationsWithLegacyClassDecorators.5.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { - var _ts_decorate, _using_ctx; +System.register([], function(_export, _context) { return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - _usingCtx.u(null); - class C { - } - _export("C", C = _ts_decorate([ - dec - ], C)); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using before = null + _export("C", @dec + class { + }); } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).1.normal.js index 68c7b549b012..63be7eef33fd 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).1.normal.js @@ -9,18 +9,7 @@ Object.defineProperty(exports, "D", { return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); -const _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - var before = _usingCtx.u(null); - class C { - } - C = _ts_decorate._([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).2.minified.js index 336700d32d3e..845f07857c16 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).2.minified.js @@ -7,17 +7,7 @@ Object.defineProperty(exports, "__esModule", { return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - _usingCtx.u(null); - class C1 { - } - C1 = _ts_decorate._([ - dec - ], C1); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).1.normal.js index 34a460c4368c..7e5a8e8ab334 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).1.normal.js @@ -1,17 +1,6 @@ //// [usingDeclarationsWithLegacyClassDecorators.6.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -export { C as D }; -try { - var _usingCtx = _using_ctx(); - var before = _usingCtx.u(null); - class C { - } - C = _ts_decorate([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } +export { C as D }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).2.minified.js index 0bcad536860c..7e5a8e8ab334 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=es6,target=esnext).2.minified.js @@ -1,17 +1,6 @@ //// [usingDeclarationsWithLegacyClassDecorators.6.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - _usingCtx.u(null); - class C { - } - C = _ts_decorate([ - dec - ], C); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +using before = null +@dec +class C { } export { C as D }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).1.normal.js index ddf501115f38..2e468a511367 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).1.normal.js @@ -1,33 +1,14 @@ //// [usingDeclarationsWithLegacyClassDecorators.6.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { +System.register([], function(_export, _context) { "use strict"; - var _ts_decorate, _using_ctx; + var C; return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - var before = _usingCtx.u(null); - class C { - } - _export("D", C = _ts_decorate([ - dec - ], C)); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using before = null + _export("D", C = @dec + class C { + }); } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).2.minified.js index 8ed7bef15037..2821ed43a920 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).2.minified.js @@ -1,32 +1,12 @@ //// [usingDeclarationsWithLegacyClassDecorators.6.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { - var _ts_decorate, _using_ctx; +System.register([], function(_export, _context) { return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - _usingCtx.u(null); - class C { - } - _export("D", C = _ts_decorate([ - dec - ], C)); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using before = null + _export("D", @dec + class { + }); } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).1.normal.js index 9c2698aaab74..a07e4e1b78d5 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).1.normal.js @@ -3,18 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); -const _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - class C { - } - C = _ts_decorate._([ - dec - ], C); - var after = _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).2.minified.js index dd66a6ff87ea..cc7fdd02b2a0 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).2.minified.js @@ -2,16 +2,4 @@ Object.defineProperty(exports, "__esModule", { value: !0 }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - class C { - } - C = _ts_decorate._([ - dec - ], C), _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); -} +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).1.normal.js index 853a3b6b62e6..c4d480c8af3f 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).1.normal.js @@ -1,17 +1,6 @@ //// [usingDeclarationsWithLegacyClassDecorators.7.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - class C { - } - C = _ts_decorate([ - dec - ], C); - var after = _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +using after = null export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).2.minified.js index 86d340d23276..c92fb055da73 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=es6,target=esnext).2.minified.js @@ -1,15 +1,3 @@ //// [usingDeclarationsWithLegacyClassDecorators.7.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(); - class C { - } - C = _ts_decorate([ - dec - ], C), _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); -} +using after = null +export { }; diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).1.normal.js index 2e8581f536ce..9b5a38280397 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).1.normal.js @@ -1,33 +1,14 @@ //// [usingDeclarationsWithLegacyClassDecorators.7.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { +System.register([], function(_export, _context) { "use strict"; - var _ts_decorate, _using_ctx; + var C; return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - class C { - } - C = _ts_decorate([ - dec - ], C); - var after = _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + C = @dec + class C { + }; + using after = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).2.minified.js index 59a9df2f1e1e..55c846507e0d 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).2.minified.js @@ -1,31 +1,9 @@ //// [usingDeclarationsWithLegacyClassDecorators.7.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { - var _ts_decorate, _using_ctx; +System.register([], function(_export, _context) { return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - class C { - } - C = _ts_decorate([ - dec - ], C), _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + using after = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).1.normal.js index 8ae1ece99a0f..859f122834ca 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).1.normal.js @@ -6,23 +6,10 @@ Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "C", { enumerable: true, get: function() { - return _C; + return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); -const _using_ctx = require("@swc/helpers/_/_using_ctx"); -var _C; -try { - var _usingCtx = _using_ctx._(); - class C { - } - _C = C; - C = _ts_decorate._([ - dec - ], C); - var after = _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).2.minified.js index 6ba8203d51f1..f01dcec32b70 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).2.minified.js @@ -4,19 +4,10 @@ Object.defineProperty(exports, "__esModule", { }), Object.defineProperty(exports, "C", { enumerable: !0, get: function() { - return _C; + return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _C, _usingCtx = _using_ctx._(); - class C { - } - _C = C, C = _ts_decorate._([ - dec - ], C), _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).1.normal.js index aa6a7ceef736..b620e670aee8 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).1.normal.js @@ -1,19 +1,5 @@ //// [usingDeclarationsWithLegacyClassDecorators.8.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -var _C; -try { - var _usingCtx = _using_ctx(); - class C { - } - _C = C; - C = _ts_decorate([ - dec - ], C); - var after = _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +export class C { } -export { _C as C }; +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).2.minified.js index 10cbe3e0e41f..b620e670aee8 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=es6,target=esnext).2.minified.js @@ -1,16 +1,5 @@ //// [usingDeclarationsWithLegacyClassDecorators.8.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _C, _usingCtx = _using_ctx(); - class C { - } - _C = C, C = _ts_decorate([ - dec - ], C), _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +export class C { } -export { _C as C }; +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).1.normal.js index d1024d13d7db..4814954e2497 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).1.normal.js @@ -1,35 +1,15 @@ //// [usingDeclarationsWithLegacyClassDecorators.8.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { +System.register([], function(_export, _context) { "use strict"; - var _ts_decorate, _using_ctx, _C; + var C; _export("C", void 0); return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - class C { - } - _export("C", _C = C); - C = _ts_decorate([ - dec - ], C); - var after = _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + _export("C", C = @dec + class C { + }); + using after = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).2.minified.js index b85e72b2b16e..e7975bd6529e 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).2.minified.js @@ -1,31 +1,12 @@ //// [usingDeclarationsWithLegacyClassDecorators.8.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { - var _ts_decorate, _using_ctx; +System.register([], function(_export, _context) { return _export("C", void 0), { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - class C { - } - _export("C", C), C = _ts_decorate([ - dec - ], C), _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + _export("C", @dec + class { + }); + using after = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).1.normal.js index a4bd4accb1a7..b3c66ba0fa17 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).1.normal.js @@ -9,18 +9,7 @@ Object.defineProperty(exports, "default", { return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"); -const _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(); - var C = class C { - }; - C = _ts_decorate._([ - dec - ], C); - var after = _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).2.minified.js index 6c68fbfb6168..63a2c22842e8 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).2.minified.js @@ -7,15 +7,7 @@ Object.defineProperty(exports, "__esModule", { return C; } }); -const _ts_decorate = require("@swc/helpers/_/_ts_decorate"), _using_ctx = require("@swc/helpers/_/_using_ctx"); -try { - var _usingCtx = _using_ctx._(), C = class { - }; - C = _ts_decorate._([ - dec - ], C), _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +@dec +class C { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).1.normal.js index 7084d7b2830d..11fe9281f286 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).1.normal.js @@ -1,17 +1,5 @@ //// [usingDeclarationsWithLegacyClassDecorators.9.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -export { C as default }; -try { - var _usingCtx = _using_ctx(); - var C = class C { - }; - C = _ts_decorate([ - dec - ], C); - var after = _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +export default @dec +class C { } +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).2.minified.js index 7110630aa11e..11fe9281f286 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=es6,target=esnext).2.minified.js @@ -1,15 +1,5 @@ //// [usingDeclarationsWithLegacyClassDecorators.9.ts] -import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -import { _ as _using_ctx } from "@swc/helpers/_/_using_ctx"; -try { - var _usingCtx = _using_ctx(), C = class { - }; - C = _ts_decorate([ - dec - ], C), _usingCtx.u(null); -} catch (_) { - _usingCtx.e = _; -} finally{ - _usingCtx.d(); +export default @dec +class C { } -export { C as default }; +using after = null diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).1.normal.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).1.normal.js index a9d1eccb0f2b..94f1cab24712 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).1.normal.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).1.normal.js @@ -1,33 +1,15 @@ //// [usingDeclarationsWithLegacyClassDecorators.9.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { +System.register([], function(_export, _context) { "use strict"; - var _ts_decorate, _using_ctx; + var C; + _export("default", void 0); return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(); - var C = class C { - }; - _export("default", C = _ts_decorate([ - dec - ], C)); - var after = _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + _export("default", C = @dec + class C { + }); + using after = null } }; }); diff --git a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).2.minified.js b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).2.minified.js index b6ba6d8a9800..160712158c13 100644 --- a/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).2.minified.js +++ b/crates/swc/tests/tsc-references/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).2.minified.js @@ -1,30 +1,12 @@ //// [usingDeclarationsWithLegacyClassDecorators.9.ts] -System.register([ - "@swc/helpers/_/_ts_decorate", - "@swc/helpers/_/_using_ctx" -], function(_export, _context) { - var _ts_decorate, _using_ctx; - return { - setters: [ - function(_ts_decorate1) { - _ts_decorate = _ts_decorate1._; - }, - function(_using_ctx1) { - _using_ctx = _using_ctx1._; - } - ], +System.register([], function(_export, _context) { + return _export("default", void 0), { + setters: [], execute: function() { - try { - var _usingCtx = _using_ctx(), C = class { - }; - _export("default", C = _ts_decorate([ - dec - ], C)), _usingCtx.u(null); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + _export("default", @dec + class { + }); + using after = null } }; }); diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 9d9d68ddf12b..66f7d77c73e8 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -2321,21 +2321,6 @@ impl VisitMut for Optimizer<'_> { } } - #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] - fn visit_mut_script(&mut self, s: &mut Script) { - let ctx = Ctx { - top_level: true, - ..self.ctx - }; - s.visit_mut_children_with(&mut *self.with_ctx(ctx)); - - if self.vars.inline_with_multi_replacer(s) { - self.changed = true; - } - - drop_invalid_stmts(&mut s.body); - } - #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] fn visit_mut_module_items(&mut self, stmts: &mut Vec) { let ctx = Ctx { @@ -2457,6 +2442,21 @@ impl VisitMut for Optimizer<'_> { } } + #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] + fn visit_mut_script(&mut self, s: &mut Script) { + let ctx = Ctx { + top_level: true, + ..self.ctx + }; + s.visit_mut_children_with(&mut *self.with_ctx(ctx)); + + if self.vars.inline_with_multi_replacer(s) { + self.changed = true; + } + + drop_invalid_stmts(&mut s.body); + } + #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] fn visit_mut_seq_expr(&mut self, n: &mut SeqExpr) { let should_preserve_zero = n @@ -2595,6 +2595,7 @@ impl VisitMut for Optimizer<'_> { return; } } + _ => {} } @@ -2910,6 +2911,20 @@ impl VisitMut for Optimizer<'_> { n.visit_mut_children_with(&mut *self.with_ctx(ctx)); } + #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] + fn visit_mut_using_decl(&mut self, n: &mut UsingDecl) { + let ctx = Ctx { + is_update_arg: false, + has_const_ann: false, + var_kind: None, + ..self.ctx + }; + + for decl in n.decls.iter_mut() { + decl.init.visit_mut_with(&mut *self.with_ctx(ctx)); + } + } + #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] fn visit_mut_var_decl(&mut self, n: &mut VarDecl) { { diff --git a/crates/swc_ecma_minifier/src/compress/pure/vars.rs b/crates/swc_ecma_minifier/src/compress/pure/vars.rs index 4ce68a2e3a69..7e3ada1a06e4 100644 --- a/crates/swc_ecma_minifier/src/compress/pure/vars.rs +++ b/crates/swc_ecma_minifier/src/compress/pure/vars.rs @@ -431,7 +431,7 @@ impl VisitMut for VarMover { fn visit_mut_var_declarators(&mut self, d: &mut Vec) { d.visit_mut_children_with(self); - if self.var_decl_kind.unwrap() != self.target { + if self.var_decl_kind != Some(self.target) { return; } diff --git a/crates/swc_ecma_transforms_optimization/src/simplify/dce/mod.rs b/crates/swc_ecma_transforms_optimization/src/simplify/dce/mod.rs index 56d85c701c99..d3132804829f 100644 --- a/crates/swc_ecma_transforms_optimization/src/simplify/dce/mod.rs +++ b/crates/swc_ecma_transforms_optimization/src/simplify/dce/mod.rs @@ -683,13 +683,6 @@ impl VisitMut for TreeShaker { self.in_block_stmt = old_in_block_stmt; } - fn visit_mut_function(&mut self, n: &mut Function) { - let old_in_fn = self.in_fn; - self.in_fn = true; - n.visit_mut_children_with(self); - self.in_fn = old_in_fn; - } - fn visit_mut_decl(&mut self, n: &mut Decl) { n.visit_mut_children_with(self); @@ -827,6 +820,30 @@ impl VisitMut for TreeShaker { } } + fn visit_mut_expr_or_spreads(&mut self, n: &mut Vec) { + self.visit_mut_par(cpu_count() * 8, n); + } + + fn visit_mut_exprs(&mut self, n: &mut Vec>) { + self.visit_mut_par(cpu_count() * 8, n); + } + + fn visit_mut_for_head(&mut self, n: &mut ForHead) { + match n { + ForHead::VarDecl(..) | ForHead::UsingDecl(..) => {} + ForHead::Pat(v) => { + v.visit_mut_with(self); + } + } + } + + fn visit_mut_function(&mut self, n: &mut Function) { + let old_in_fn = self.in_fn; + self.in_fn = true; + n.visit_mut_children_with(self); + self.in_fn = old_in_fn; + } + fn visit_mut_import_specifiers(&mut self, ss: &mut Vec) { ss.retain(|s| { let local = match s { @@ -878,6 +895,41 @@ impl VisitMut for TreeShaker { }) } + fn visit_mut_module_item(&mut self, n: &mut ModuleItem) { + match n { + ModuleItem::ModuleDecl(ModuleDecl::Import(i)) => { + let is_for_side_effect = i.specifiers.is_empty(); + + i.visit_mut_with(self); + + if !self.config.preserve_imports_with_side_effects + && !is_for_side_effect + && i.specifiers.is_empty() + { + debug!("Dropping an import because it's not used"); + self.changed = true; + *n = EmptyStmt { span: DUMMY_SP }.into(); + } + } + _ => { + n.visit_mut_children_with(self); + } + } + debug_assert_valid(n); + } + + fn visit_mut_module_items(&mut self, s: &mut Vec) { + self.visit_mut_stmt_likes(s); + } + + fn visit_mut_opt_vec_expr_or_spreads(&mut self, n: &mut Vec>) { + self.visit_mut_par(cpu_count() * 8, n); + } + + fn visit_mut_prop_or_spreads(&mut self, n: &mut Vec) { + self.visit_mut_par(cpu_count() * 8, n); + } + fn visit_mut_script(&mut self, m: &mut Script) { let _tracing = span!(Level::ERROR, "tree-shaker", pass = self.pass).entered(); @@ -906,33 +958,6 @@ impl VisitMut for TreeShaker { }) } - fn visit_mut_module_item(&mut self, n: &mut ModuleItem) { - match n { - ModuleItem::ModuleDecl(ModuleDecl::Import(i)) => { - let is_for_side_effect = i.specifiers.is_empty(); - - i.visit_mut_with(self); - - if !self.config.preserve_imports_with_side_effects - && !is_for_side_effect - && i.specifiers.is_empty() - { - debug!("Dropping an import because it's not used"); - self.changed = true; - *n = EmptyStmt { span: DUMMY_SP }.into(); - } - } - _ => { - n.visit_mut_children_with(self); - } - } - debug_assert_valid(n); - } - - fn visit_mut_module_items(&mut self, s: &mut Vec) { - self.visit_mut_stmt_likes(s); - } - fn visit_mut_stmt(&mut self, s: &mut Stmt) { s.visit_mut_children_with(self); @@ -995,21 +1020,17 @@ impl VisitMut for TreeShaker { self.visit_mut_stmt_likes(s); } - fn visit_mut_var_decl_or_expr(&mut self, n: &mut VarDeclOrExpr) { - match n { - VarDeclOrExpr::VarDecl(..) => {} - VarDeclOrExpr::Expr(v) => { - v.visit_mut_with(self); - } + fn visit_mut_unary_expr(&mut self, n: &mut UnaryExpr) { + if matches!(n.op, op!("delete")) { + return; } + n.visit_mut_children_with(self); } - fn visit_mut_for_head(&mut self, n: &mut ForHead) { - match n { - ForHead::VarDecl(..) | ForHead::UsingDecl(..) => {} - ForHead::Pat(v) => { - v.visit_mut_with(self); - } + #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] + fn visit_mut_using_decl(&mut self, n: &mut UsingDecl) { + for decl in n.decls.iter_mut() { + decl.init.visit_mut_with(self); } } @@ -1020,6 +1041,15 @@ impl VisitMut for TreeShaker { self.var_decl_kind = old_var_decl_kind; } + fn visit_mut_var_decl_or_expr(&mut self, n: &mut VarDeclOrExpr) { + match n { + VarDeclOrExpr::VarDecl(..) => {} + VarDeclOrExpr::Expr(v) => { + v.visit_mut_with(self); + } + } + } + fn visit_mut_var_declarator(&mut self, v: &mut VarDeclarator) { v.visit_mut_children_with(self); @@ -1055,29 +1085,6 @@ impl VisitMut for TreeShaker { fn visit_mut_with_stmt(&mut self, n: &mut WithStmt) { n.obj.visit_mut_with(self); } - - fn visit_mut_unary_expr(&mut self, n: &mut UnaryExpr) { - if matches!(n.op, op!("delete")) { - return; - } - n.visit_mut_children_with(self); - } - - fn visit_mut_prop_or_spreads(&mut self, n: &mut Vec) { - self.visit_mut_par(cpu_count() * 8, n); - } - - fn visit_mut_expr_or_spreads(&mut self, n: &mut Vec) { - self.visit_mut_par(cpu_count() * 8, n); - } - - fn visit_mut_opt_vec_expr_or_spreads(&mut self, n: &mut Vec>) { - self.visit_mut_par(cpu_count() * 8, n); - } - - fn visit_mut_exprs(&mut self, n: &mut Vec>) { - self.visit_mut_par(cpu_count() * 8, n); - } } impl Scope<'_> {