From 1659c212b2edf1505def54b7222b3b6a633de3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Tue, 1 Oct 2024 17:09:39 +0900 Subject: [PATCH] fix(es/minifier): Ignore using declarations (#9598) --- .changeset/lemon-panthers-try.md | 7 + ...gDeclarations.1(target=esnext).1.normal.js | 379 ++++-------- ...eclarations.1(target=esnext).2.minified.js | 212 ++----- .../awaitUsingDeclarations.12.1.normal.js | 11 +- .../awaitUsingDeclarations.12.2.minified.js | 1 - .../awaitUsingDeclarations.13.1.normal.js | 22 +- .../awaitUsingDeclarations.13.2.minified.js | 10 +- .../awaitUsingDeclarations.15.1.normal.js | 13 +- .../awaitUsingDeclarations.15.2.minified.js | 1 - ...gDeclarations.2(target=esnext).1.normal.js | 17 +- ...eclarations.2(target=esnext).2.minified.js | 17 +- ...gDeclarations.3(target=esnext).1.normal.js | 17 +- ...eclarations.3(target=esnext).2.minified.js | 17 +- .../awaitUsingDeclarations.9.1.normal.js | 11 +- .../awaitUsingDeclarations.9.2.minified.js | 11 +- ...onsInForAwaitOf(target=esnext).1.normal.js | 14 +- ...sInForAwaitOf(target=esnext).2.minified.js | 1 - ...ationsInForOf.1(target=esnext).1.normal.js | 14 +- ...ionsInForOf.1(target=esnext).2.minified.js | 1 - .../decoratorOnClassMethod14.1.normal.js | 9 +- .../decoratorOnClassMethod14.2.minified.js | 15 - .../decoratorOnClassMethod15.1.normal.js | 9 +- .../decoratorOnClassMethod15.2.minified.js | 15 - .../decoratorOnClassMethod16.1.normal.js | 9 +- .../decoratorOnClassMethod16.2.minified.js | 12 - .../decoratorOnClassMethod18.1.normal.js | 4 - .../decoratorOnClassMethod18.2.minified.js | 5 - ...StaticMembers10(target=esnext).1.normal.js | 9 +- ...aticMembers10(target=esnext).2.minified.js | 9 +- ...StaticMembers11(target=esnext).1.normal.js | 9 +- ...aticMembers11(target=esnext).2.minified.js | 9 +- ...gDeclarations.1(target=esnext).1.normal.js | 556 ++++++------------ ...eclarations.1(target=esnext).2.minified.js | 391 ++++-------- .../usingDeclarations.14.1.normal.js | 10 +- .../usingDeclarations.14.2.minified.js | 10 +- .../usingDeclarations.15.1.normal.js | 12 +- .../usingDeclarations.15.2.minified.js | 13 +- ...gDeclarations.2(target=esnext).1.normal.js | 17 +- ...eclarations.2(target=esnext).2.minified.js | 16 +- ...gDeclarations.3(target=esnext).1.normal.js | 17 +- ...eclarations.3(target=esnext).2.minified.js | 16 +- .../usingDeclarations.9.1.normal.js | 11 +- .../usingDeclarations.9.2.minified.js | 10 +- ...gDeclarationsDeclarationEmit.1.1.normal.js | 22 +- ...eclarationsDeclarationEmit.1.2.minified.js | 16 +- ...gDeclarationsDeclarationEmit.2.1.normal.js | 18 +- ...eclarationsDeclarationEmit.2.2.minified.js | 18 +- ...onsInForAwaitOf(target=esnext).1.normal.js | 14 +- ...sInForAwaitOf(target=esnext).2.minified.js | 1 - ...ationsInForOf.1(target=esnext).1.normal.js | 14 +- ...ionsInForOf.1(target=esnext).2.minified.js | 11 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 15 +- ...rs.1(module=es6,target=esnext).1.normal.js | 17 +- ....1(module=es6,target=esnext).2.minified.js | 17 +- ...1(module=system,target=esnext).1.normal.js | 33 +- ...module=system,target=esnext).2.minified.js | 29 +- ...module=commonjs,target=esnext).1.normal.js | 19 +- ...dule=commonjs,target=esnext).2.minified.js | 16 +- ...s.10(module=es6,target=esnext).1.normal.js | 18 +- ...10(module=es6,target=esnext).2.minified.js | 16 +- ...0(module=system,target=esnext).1.normal.js | 32 +- ...module=system,target=esnext).2.minified.js | 31 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 15 +- ...s.11(module=es6,target=esnext).1.normal.js | 19 +- ...11(module=es6,target=esnext).2.minified.js | 16 +- ...1(module=system,target=esnext).1.normal.js | 33 +- ...module=system,target=esnext).2.minified.js | 31 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 15 +- ...s.12(module=es6,target=esnext).1.normal.js | 19 +- ...12(module=es6,target=esnext).2.minified.js | 16 +- ...2(module=system,target=esnext).1.normal.js | 33 +- ...module=system,target=esnext).2.minified.js | 31 +- ...module=commonjs,target=esnext).1.normal.js | 21 +- ...dule=commonjs,target=esnext).2.minified.js | 18 +- ...rs.2(module=es6,target=esnext).1.normal.js | 20 +- ....2(module=es6,target=esnext).2.minified.js | 18 +- ...2(module=system,target=esnext).1.normal.js | 34 +- ...module=system,target=esnext).2.minified.js | 32 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 16 +- ...rs.3(module=es6,target=esnext).1.normal.js | 18 +- ....3(module=es6,target=esnext).2.minified.js | 18 +- ...3(module=system,target=esnext).1.normal.js | 34 +- ...module=system,target=esnext).2.minified.js | 34 +- ...module=commonjs,target=esnext).1.normal.js | 19 +- ...dule=commonjs,target=esnext).2.minified.js | 18 +- ...rs.4(module=es6,target=esnext).1.normal.js | 18 +- ....4(module=es6,target=esnext).2.minified.js | 18 +- ...4(module=system,target=esnext).1.normal.js | 32 +- ...module=system,target=esnext).2.minified.js | 33 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 16 +- ...rs.5(module=es6,target=esnext).1.normal.js | 19 +- ....5(module=es6,target=esnext).2.minified.js | 17 +- ...5(module=system,target=esnext).1.normal.js | 33 +- ...module=system,target=esnext).2.minified.js | 32 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 16 +- ...rs.6(module=es6,target=esnext).1.normal.js | 19 +- ....6(module=es6,target=esnext).2.minified.js | 17 +- ...6(module=system,target=esnext).1.normal.js | 33 +- ...module=system,target=esnext).2.minified.js | 32 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 14 +- ...rs.7(module=es6,target=esnext).1.normal.js | 17 +- ....7(module=es6,target=esnext).2.minified.js | 16 +- ...7(module=system,target=esnext).1.normal.js | 33 +- ...module=system,target=esnext).2.minified.js | 28 +- ...module=commonjs,target=esnext).1.normal.js | 21 +- ...dule=commonjs,target=esnext).2.minified.js | 17 +- ...rs.8(module=es6,target=esnext).1.normal.js | 20 +- ....8(module=es6,target=esnext).2.minified.js | 17 +- ...8(module=system,target=esnext).1.normal.js | 34 +- ...module=system,target=esnext).2.minified.js | 31 +- ...module=commonjs,target=esnext).1.normal.js | 17 +- ...dule=commonjs,target=esnext).2.minified.js | 14 +- ...rs.9(module=es6,target=esnext).1.normal.js | 18 +- ....9(module=es6,target=esnext).2.minified.js | 16 +- ...9(module=system,target=esnext).1.normal.js | 34 +- ...module=system,target=esnext).2.minified.js | 32 +- .../src/compress/optimize/mod.rs | 45 +- .../src/compress/pure/vars.rs | 2 +- .../src/simplify/dce/mod.rs | 147 ++--- 126 files changed, 1005 insertions(+), 2876 deletions(-) create mode 100644 .changeset/lemon-panthers-try.md diff --git a/.changeset/lemon-panthers-try.md b/.changeset/lemon-panthers-try.md new file mode 100644 index 00000000000..18533a27690 --- /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 f4fb101df11..8e75384df4b 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] () {} } - const a = async ()=>{ - try { - var _usingCtx = _using_ctx(); - const d6 = _usingCtx.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - await _usingCtx.d(); + ; + yield; + await null; +} +const a = async ()=>{ + await using d6 = { + async [Symbol.asyncDispose] () {} + } + ; +}; +class C1 { + async am() { + await using d13 = { + async [Symbol.asyncDispose] () {} } - }; - 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(); + ; + await null; + } + async *ag() { + await using d15 = { + async [Symbol.asyncDispose] () {} + } + ; + yield; + await null; + } + constructor(){ + this.a = async ()=>{ + await using d7 = { + async [Symbol.asyncDispose] () {} } - } - 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: - 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(); - } + ; +}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] () {} } - 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(); - } + ; +} catch { + await using d24 = { + 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) { - 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(); - } - } - while(true){ - try { - var _usingCtx10 = _using_ctx(); - const d28 = _usingCtx10.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx10.e = _; - } finally{ - await _usingCtx10.d(); - } - } - 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(); - } - } - for(const x in {}){ - try { - var _usingCtx13 = _using_ctx(); - const d31 = _usingCtx13.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx13.e = _; - } finally{ - await _usingCtx13.d(); - } - } - for (const x of []){ - try { - var _usingCtx14 = _using_ctx(); - const d32 = _usingCtx14.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx14.e = _; - } finally{ - await _usingCtx14.d(); - } - } -} catch (_) { - _usingCtx.e = _; + ; } finally{ - await _usingCtx.d(); + await using d25 = { + async [Symbol.asyncDispose] () {} + } + ; +} +if (true) { + await using d26 = { + async [Symbol.asyncDispose] () {} + } + ; +} else { + await using d27 = { + async [Symbol.asyncDispose] () {} + } + ; +} +while(true){ + await using d28 = { + async [Symbol.asyncDispose] () {} + } + ; + break; +} +do { + await using d29 = { + async [Symbol.asyncDispose] () {} + } + ; + break; +}while (true) +for(;;){ + await using d30 = { + async [Symbol.asyncDispose] () {} + } + ; + break; +} +for(const x in {}){ + await using d31 = { + async [Symbol.asyncDispose] () {} + } + ; +} +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 db8011a1313..a24672f1aec 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({ - 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({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx8.e = _; - } finally{ - await _usingCtx8.d(); - } - for(;;)try { - var _usingCtx10 = _using_ctx(); - _usingCtx10.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx10.e = _; - } finally{ - await _usingCtx10.d(); - } - for(;;)try { - var _usingCtx11 = _using_ctx(); - _usingCtx11.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx11.e = _; - } finally{ - await _usingCtx11.d(); - } - for(;;)try { - var _usingCtx12 = _using_ctx(); - _usingCtx12.a({ - async [Symbol.asyncDispose] () {} - }); - break; - } catch (_) { - _usingCtx12.e = _; - } finally{ - await _usingCtx12.d(); - } - for(let x in {})try { - var _usingCtx13 = _using_ctx(); - _usingCtx13.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx13.e = _; - } finally{ - await _usingCtx13.d(); - } - for (let x of [])try { - var _usingCtx14 = _using_ctx(); - _usingCtx14.a({ - async [Symbol.asyncDispose] () {} - }); - } catch (_) { - _usingCtx14.e = _; - } finally{ - await _usingCtx14.d(); - } -} catch (_) { - _usingCtx.e = _; -} finally{ - await _usingCtx.d(); +await using d1 = { + async [Symbol.asyncDispose] () {} } +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] () {} + } +} +await using d22 = { + async [Symbol.asyncDispose] () {} +} +try { + await using d23 = { + async [Symbol.asyncDispose] () {} + } +} catch { + await using d24 = { + async [Symbol.asyncDispose] () {} + } +} finally{ + await using d25 = { + async [Symbol.asyncDispose] () {} + } +} +await using d26 = { + async [Symbol.asyncDispose] () {} +} +for(;;){ + await using d28 = { + async [Symbol.asyncDispose] () {} + } + break; +} +for(;;){ + await using d29 = { + async [Symbol.asyncDispose] () {} + } + break; +} +for(;;){ + await using d30 = { + async [Symbol.asyncDispose] () {} + } + 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 015814bfd05..42dce7c9dbe 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 aab4b1d8155..b20fa1fa672 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 5c4f259e5fe..a704b8831a6 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 5ae54041146..b28c4ffd409 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 9790c479108..13ec252e4e6 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 9ef0acd65b9..a80aa01962f 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 5e64ce262f0..5089cb17fb9 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 b0930ba472d..4e2501bb89d 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 645f4b1c180..bbc02b6cbfd 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 f2f521bcbbc..375a9933571 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 e3f89b0810d..e007d7ded82 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 10b581c62b4..15415176f80 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 51c6a972863..486397d3a71 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 35eb661ced3..c966aa67d5d 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 b539d27f7ac..3af7fa2c633 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 7cfe7407750..595b77faf6b 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 fd5061b60e2..69e7a88484c 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 122781d6ac1..7fa87d1c98e 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 3469288fbbf..d752697a229 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 119f32ae4a0..4277bfb1922 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 57c1fd67681..672c5d7989d 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 6825f2a2513..ed100fcc0df 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 5dafbd9caa3..52505360e68 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 448fb14ee2d..50e405e02fe 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 73c4480e1d0..848ac78dcdc 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 704545d184f..5753d39849c 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 814b7b99ddd..57e76e3e494 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 744520a09fa..320901b6206 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 d5c775efd17..dd226bf40ae 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(); - } - } - 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(); - } - } - set x(v) { - try { - var _usingCtx = _using_ctx(); - const d12 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } - async am() { - try { - var _usingCtx = _using_ctx(); - const d13 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - await null; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } - *g() { - try { - var _usingCtx = _using_ctx(); - const d14 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - yield; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - } - async *ag() { - try { - var _usingCtx = _using_ctx(); - const d15 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - yield; - await null; - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); } + ; + }; + using d8 = { + [Symbol.dispose] () {} } + ; } - class C2 extends C1 { - constructor(){ - try { - var _usingCtx = _using_ctx(); - const d16 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - super(); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } + static{ + using d9 = { + [Symbol.dispose] () {} } + ; } - 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(); - } + m() { + using d10 = { + [Symbol.dispose] () {} } + ; } - var N; - (function(N) { - try { - var _usingCtx = _using_ctx(); - var d18 = _usingCtx.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - _usingCtx.d(); - } - })(N || (N = {})); - { - try { - var _usingCtx1 = _using_ctx(); - const d19 = _usingCtx1.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx1.e = _; - } finally{ - _usingCtx1.d(); + get x() { + using d11 = { + [Symbol.dispose] () {} } + ; + return 0; } - 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(); - } + set x(v) { + using d12 = { + [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(); - } + async am() { + using d13 = { + [Symbol.dispose] () {} + } + ; + await null; } - try { - try { - var _usingCtx5 = _using_ctx(); - const d23 = _usingCtx5.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx5.e = _; - } finally{ - _usingCtx5.d(); - } - } catch { - try { - var _usingCtx6 = _using_ctx(); - const d24 = _usingCtx6.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx6.e = _; - } finally{ - _usingCtx6.d(); - } - } finally{ - try { - var _usingCtx7 = _using_ctx(); - const d25 = _usingCtx7.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx7.e = _; - } finally{ - _usingCtx7.d(); + *g() { + using d14 = { + [Symbol.dispose] () {} } + ; + yield; } - 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(); + async *ag() { + using d15 = { + [Symbol.dispose] () {} } + ; + yield; + await null; } - while(true){ - try { - var _usingCtx10 = _using_ctx(); - const d28 = _usingCtx10.u({ - [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx10.e = _; - } finally{ - _usingCtx10.d(); +} +class C2 extends C1 { + constructor(){ + using d16 = { + [Symbol.dispose] () {} } + ; + super(); } - 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(); +} +class C3 extends C1 { + constructor(){ + using d17 = { + [Symbol.dispose] () {} } + ; + super(), this.y = 1; } - for(const x in {}){ - try { - var _usingCtx13 = _using_ctx(); - const d31 = _usingCtx13.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx13.e = _; - } finally{ - _usingCtx13.d(); - } +} +var N; +(function(N) { + using d18 = { + [Symbol.dispose] () {} } - for (const x of []){ - try { - var _usingCtx14 = _using_ctx(); - const d32 = _usingCtx14.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx14.e = _; - } finally{ - _usingCtx14.d(); - } +})(N || (N = {})); +{ + using d19 = { + [Symbol.dispose] () {} } -} catch (_) { - _usingCtx.e = _; + ; +}switch(Math.random()){ + case 0: + using d20 = { + [Symbol.dispose] () {} + } + ; + break; + case 1: + using d21 = { + [Symbol.dispose] () {} + } + ; + break; +} +if (true) switch(0){ + case 0: + using d22 = { + [Symbol.dispose] () {} + } + ; + break; +} +try { + using d23 = { + [Symbol.dispose] () {} + } + ; +} catch { + using d24 = { + [Symbol.dispose] () {} + } + ; } finally{ - _usingCtx.d(); + using d25 = { + [Symbol.dispose] () {} + } + ; +} +if (true) { + using d26 = { + [Symbol.dispose] () {} + } + ; +} else { + using d27 = { + [Symbol.dispose] () {} + } + ; +} +while(true){ + using d28 = { + [Symbol.dispose] () {} + } + ; + 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 c757c3f676a..5d79f084748 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(); - } - } - } - !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({ - [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({ - [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(); - } - } finally{ - try { - var _usingCtx7 = _using_ctx(); - _usingCtx7.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx7.e = _; - } finally{ - _usingCtx7.d(); - } - } - try { - var _usingCtx8 = _using_ctx(); - _usingCtx8.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx8.e = _; - } finally{ - _usingCtx8.d(); - } - for(;;)try { - var _usingCtx10 = _using_ctx(); - _usingCtx10.u({ - [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx10.e = _; - } finally{ - _usingCtx10.d(); - } - for(;;)try { - var _usingCtx11 = _using_ctx(); - _usingCtx11.u({ - [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx11.e = _; - } finally{ - _usingCtx11.d(); - } - for(;;)try { - var _usingCtx12 = _using_ctx(); - _usingCtx12.u({ - [Symbol.dispose] () {} - }); - break; - } catch (_) { - _usingCtx12.e = _; - } finally{ - _usingCtx12.d(); - } - for(let x in {})try { - var _usingCtx13 = _using_ctx(); - _usingCtx13.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx13.e = _; - } finally{ - _usingCtx13.d(); - } - for (let x of [])try { - var _usingCtx14 = _using_ctx(); - _usingCtx14.u({ - [Symbol.dispose] () {} - }); - } catch (_) { - _usingCtx14.e = _; - } finally{ - _usingCtx14.d(); - } -} 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] () {} + } + } + static{ + using d9 = { + [Symbol.dispose] () {} + } + } + m() { + using d10 = { + [Symbol.dispose] () {} + } + } + get x() { + using d11 = { + [Symbol.dispose] () {} + } + return 0; + } + set x(v) { + using d12 = { + [Symbol.dispose] () {} + } + } + async am() { + using d13 = { + [Symbol.dispose] () {} + } + await null; + } + *g() { + using d14 = { + [Symbol.dispose] () {} + } + yield; + } + async *ag() { + using d15 = { + [Symbol.dispose] () {} + } + yield, await null; + } +} +!function(N) { + using d18 = { + [Symbol.dispose] () {} + } +}(N || (N = {})); +using d19 = { + [Symbol.dispose] () {} +} +switch(Math.random()){ + case 0: + using d20 = { + [Symbol.dispose] () {} + } + break; + case 1: + using d21 = { + [Symbol.dispose] () {} + } +} +using d22 = { + [Symbol.dispose] () {} +} +try { + using d23 = { + [Symbol.dispose] () {} + } +} catch { + using d24 = { + [Symbol.dispose] () {} + } +} finally{ + 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 cfbfba2ad86..f5feea9b25c 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 e50f2dc1dea..f5feea9b25c 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 bea8776ea04..f51b8f73778 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 a1f9133d079..f51b8f73778 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 ebd9d72663f..6d1c7712f29 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 45ef9b4d6f4..3671aefc108 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 6f27d83c73a..4043e715426 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 d9daab6fa43..9cf93e3b8ba 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 970efa4e9e2..3a2079d7625 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 838a1525bee..8896bff0f17 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 fb0905592aa..64f638f25e3 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"; -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(); +using r1 = { + [Symbol.dispose] () {} } +export { r1 }; +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 4222545f0b3..093c8aed77f 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 5c38eddf239..fe3fccbcf40 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 58dec52a1ed..fe3fccbcf40 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 c7af4530632..087377eccea 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 d4aece823eb..f8d980c11c0 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 800b83760a4..e6deb8d9997 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 834d99aa8f7..7d5eedb7dc8 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 b29dc452d1f..165d29c37ea 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 c4a2f9568a0..87827813aa9 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 036b36e82eb..d2dbe1ae760 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 89afdaf6248..11a587afae4 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 bf617122243..9806e3db019 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 eb06e75805f..5860636c58a 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 abdfcde66ed..6c62feb5287 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 02522097544..e6c8b99eb38 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 ffed1694dcb..ecf1ec21685 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 8b1e6147911..ecf1ec21685 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 881ecb69908..87a21074b5d 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 118dd094ae3..f6db4491104 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 5cbd98dbc70..1edd1acf28f 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 892d8ceeb02..d966acbb5f0 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 2daa7fe9636..8705007ccb8 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 74007d040ba..0356f412e6f 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 7d98f05d9d8..f0ccad931f6 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 1f6e0fa7f09..8ddf4fcfcaf 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 eaef720a233..df42af76969 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 e9dd78c1b36..28aec2731e6 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 a2141831012..5730b47c51e 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 96a12738b3e..6c76452cfa6 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 8aae998a876..c1c9143b303 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 0d8a2fe9845..84172012e65 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 0deba7a50d7..81b834ce420 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 f3849d640a9..39ae36b1431 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 27865d30b10..fc2b90b581c 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 7e5c750c71b..fc2b90b581c 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 98691c8149e..342eee2ce89 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 f7a8aae4156..90e57fc5d8a 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 cdfae9e0bf9..c5c6fd8468b 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 8a31f307ff0..3b5844f85c1 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 06cb6c24d36..477d017ae91 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 904b8a4b8e8..477d017ae91 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 72811733618..27e022cc05e 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 068fe6225f5..505f03ed65b 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 40ccb45028f..01e84a33080 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 651b4dbc09d..23c421fb14e 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 494956940d4..de9adc6a1e8 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 16fd923fd42..de9adc6a1e8 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 d19071f6100..9716a0790f1 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 f2954e1f4b1..11b0d43d5fa 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 3ec36fd8d88..0e134120f21 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 b6b98e01017..701811d4add 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 5ca6582ea6a..d3353880c89 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 07486ef3ac4..d3353880c89 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 3c77cb98fa4..2938ae1accf 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 93eeefd4263..07a0d2eb025 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 68c7b549b01..63be7eef33f 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 336700d32d3..845f07857c1 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 34a460c4368..7e5a8e8ab33 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 0bcad536860..7e5a8e8ab33 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 ddf501115f3..2e468a51136 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 8ed7bef1503..2821ed43a92 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 9c2698aaab7..a07e4e1b78d 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 dd66a6ff87e..cc7fdd02b2a 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 853a3b6b62e..c4d480c8af3 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 86d340d2327..c92fb055da7 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 2e8581f536c..9b5a3828039 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 59a9df2f1e1..55c846507e0 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 8ae1ece99a0..859f122834c 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 6ba8203d51f..f01dcec32b7 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 aa6a7ceef73..b620e670aee 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 10cbe3e0e41..b620e670aee 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 d1024d13d7d..4814954e249 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 b85e72b2b16..e7975bd6529 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 a4bd4accb1a..b3c66ba0fa1 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 6c68fbfb616..63a2c22842e 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 7084d7b2830..11fe9281f28 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 7110630aa11..11fe9281f28 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 a9d1eccb0f2..94f1cab2471 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 b6ba6d8a980..160712158c1 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 9d9d68ddf12..66f7d77c73e 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 4ce68a2e3a6..7e3ada1a06e 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 56d85c701c9..d3132804829 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,34 +895,6 @@ impl VisitMut for TreeShaker { }) } - fn visit_mut_script(&mut self, m: &mut Script) { - let _tracing = span!(Level::ERROR, "tree-shaker", pass = self.pass).entered(); - - if self.bindings.is_empty() { - self.bindings = Arc::new(collect_decls(&*m)) - } - - let mut data = Default::default(); - - { - let mut analyzer = Analyzer { - config: &self.config, - in_var_decl: false, - scope: Default::default(), - data: &mut data, - cur_class_id: Default::default(), - cur_fn_id: Default::default(), - }; - m.visit_with(&mut analyzer); - } - data.subtract_cycles(); - self.data = Arc::new(data); - - HELPERS.set(&Helpers::new(true), || { - m.visit_mut_children_with(self); - }) - } - fn visit_mut_module_item(&mut self, n: &mut ModuleItem) { match n { ModuleItem::ModuleDecl(ModuleDecl::Import(i)) => { @@ -933,6 +922,42 @@ impl VisitMut for TreeShaker { 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(); + + if self.bindings.is_empty() { + self.bindings = Arc::new(collect_decls(&*m)) + } + + let mut data = Default::default(); + + { + let mut analyzer = Analyzer { + config: &self.config, + in_var_decl: false, + scope: Default::default(), + data: &mut data, + cur_class_id: Default::default(), + cur_fn_id: Default::default(), + }; + m.visit_with(&mut analyzer); + } + data.subtract_cycles(); + self.data = Arc::new(data); + + HELPERS.set(&Helpers::new(true), || { + m.visit_mut_children_with(self); + }) + } + 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<'_> {