From 927ae7e8d38813e65b0bc67cbf6559cbb7f9f6a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Thu, 25 Aug 2022 17:58:37 +0900 Subject: [PATCH] fix(es/compat): Revert generator reimplementation (#5624) --- .../swc/tests/exec/generator/1-object/exec.js | 29 - .../swc/tests/exec/generator/2-array/exec.js | 29 - .../exec/generator/3-object-accessor/exec.js | 31 - .../regenerator/import-path/1/output/index.js | 39 +- .../issues-1xxx/1216/case-1/output/index.js | 77 +- .../issues-1xxx/1216/case-2/output/index.js | 77 +- .../issues-1xxx/1216/case-3/output/index.js | 55 +- .../issues-1xxx/1449/case1/output/index.js | 24 +- .../issues-1xxx/1455/case2/output/index.ts | 37 +- .../issues-1xxx/1477/case1/output/index.js | 21 +- .../issues-1xxx/1575/case1/output/index.js | 21 +- .../issues-1xxx/1575/case2/output/index.js | 21 +- .../fixture/issues-1xxx/1687/output/input.tsx | 32 +- .../issues-1xxx/1718/case1/output/index.ts | 174 +- .../case1/async-generator/output/index.js | 33 +- .../issues-1xxx/1721/case1/output/index.js | 179 +- .../issues-1xxx/1722/case1/output/index.js | 21 +- .../issues-1xxx/1799/case1/output/index.js | 26 +- .../1799/case6-no-jsx/output/index.js | 26 +- .../1918/es5-after-other/output/index.js | 229 +- .../issues-1xxx/1918/es5/output/index.js | 229 +- .../issues-1xxx/1924/case1/output/index.js | 16 +- .../issues-2xxx/2024/full/output/index.js | 36 +- .../2024/no-module/output/index.js | 35 +- .../issues-2xxx/2164/es5/output/index.js | 24 +- .../issues-2xxx/2232/case1/output/index.js | 27 +- .../issues-2xxx/2232/case2/output/index.ts | 27 +- .../issues-2xxx/2248/es5/output/index.js | 27 +- .../issues-2xxx/2413/1/output/index.js | 63 +- .../fixture/issues-2xxx/2717/output/index.ts | 61 +- .../issues-4xxx/4108/1/output/index.ts | 1188 +++--- .../issues-4xxx/4208/1/output/index.ts | 26 +- .../issues-4xxx/4224/1/output/index.js | 40 +- .../issues-4xxx/4224/3/output/index.js | 40 +- .../fixture/issues-4xxx/4226/1/output/exec.js | 21 +- .../fixture/issues-4xxx/4226/3/output/exec.js | 22 +- .../fixture/issues-5xxx/5556/output/index.js | 33 +- .../issues-5xxx/5558/2/output/index.js | 28 +- .../shared/lib/router/1/output/index.ts | 485 ++- .../fixture/sourcemap/002/output/index.js | 33 +- .../fixture/sourcemap/002/output/index.map | 2 +- .../fixture/sourcemap/003/output/index.js | 2 +- .../fixture/sourcemap/003/output/index.map | 2 +- .../fixture/sourcemap/005/output/index.js | 111 +- .../fixture/sourcemap/005/output/index.map | 2 +- .../fixture/sourcemap/006/output/index.js | 111 +- .../fixture/sourcemap/006/output/index.map | 2 +- .../stacktrace/issue-622/output/stacks.txt | 5 +- .../FunctionDeclaration13_es6_es5.1.normal.js | 17 +- ...unctionDeclaration13_es6_es5.2.minified.js | 2 +- .../FunctionDeclaration1_es6_es5.1.normal.js | 15 +- ...FunctionDeclaration1_es6_es5.2.minified.js | 2 +- .../FunctionDeclaration9_es6_es5.1.normal.js | 34 +- ...FunctionDeclaration9_es6_es5.2.minified.js | 2 +- .../FunctionExpression1_es6_es5.1.normal.js | 18 +- .../FunctionExpression1_es6_es5.2.minified.js | 2 +- .../FunctionExpression2_es6_es5.1.normal.js | 18 +- .../FunctionExpression2_es6_es5.2.minified.js | 2 +- ...onPropertyAssignments1_es6_es5.1.normal.js | 18 +- ...PropertyAssignments1_es6_es5.2.minified.js | 2 +- ...onPropertyAssignments5_es6_es5.1.normal.js | 18 +- ...PropertyAssignments5_es6_es5.2.minified.js | 18 +- ...erFunctionDeclaration1_es6_es5.1.normal.js | 18 +- ...FunctionDeclaration1_es6_es5.2.minified.js | 2 +- ...erFunctionDeclaration2_es6_es5.1.normal.js | 18 +- ...FunctionDeclaration2_es6_es5.2.minified.js | 2 +- ...erFunctionDeclaration3_es6_es5.1.normal.js | 18 +- ...FunctionDeclaration3_es6_es5.2.minified.js | 2 +- ...erFunctionDeclaration7_es6_es5.1.normal.js | 18 +- ...FunctionDeclaration7_es6_es5.2.minified.js | 2 +- .../YieldExpression10_es6_es5.1.normal.js | 26 +- .../YieldExpression10_es6_es5.2.minified.js | 2 +- .../YieldExpression11_es6_es5.1.normal.js | 26 +- .../YieldExpression11_es6_es5.2.minified.js | 2 +- .../YieldExpression13_es6_es5.1.normal.js | 22 +- .../YieldExpression13_es6_es5.2.minified.js | 2 +- .../YieldExpression19_es6_es5.1.normal.js | 47 +- .../YieldExpression19_es6_es5.2.minified.js | 2 +- .../YieldExpression3_es6_es5.1.normal.js | 28 +- .../YieldExpression3_es6_es5.2.minified.js | 2 +- .../YieldExpression4_es6_es5.1.normal.js | 28 +- .../YieldExpression4_es6_es5.2.minified.js | 2 +- .../YieldExpression6_es6_es5.1.normal.js | 21 +- .../YieldExpression6_es6_es5.2.minified.js | 15 +- .../YieldExpression7_es6_es5.1.normal.js | 23 +- .../YieldExpression7_es6_es5.2.minified.js | 2 +- .../YieldExpression9_es6_es5.1.normal.js | 26 +- .../YieldExpression9_es6_es5.2.minified.js | 2 +- .../YieldStarExpression4_es6_es5.1.normal.js | 21 +- ...YieldStarExpression4_es6_es5.2.minified.js | 3 +- .../asyncAliasReturnType_es5_es5.1.normal.js | 18 +- ...asyncAliasReturnType_es5_es5.2.minified.js | 2 +- .../asyncAliasReturnType_es6_es5.1.normal.js | 18 +- ...asyncAliasReturnType_es6_es5.2.minified.js | 2 +- ...syncArrowFunction10_es2017_es5.1.normal.js | 20 +- ...ncArrowFunction10_es2017_es5.2.minified.js | 2 +- .../asyncArrowFunction10_es5_es5.1.normal.js | 20 +- ...asyncArrowFunction10_es5_es5.2.minified.js | 2 +- .../asyncArrowFunction10_es6_es5.1.normal.js | 20 +- ...asyncArrowFunction10_es6_es5.2.minified.js | 2 +- .../asyncArrowFunction11_es5_es5.1.normal.js | 37 +- ...asyncArrowFunction11_es5_es5.2.minified.js | 2 +- ...asyncArrowFunction1_es2017_es5.1.normal.js | 18 +- ...yncArrowFunction1_es2017_es5.2.minified.js | 2 +- .../asyncArrowFunction1_es5_es5.1.normal.js | 18 +- .../asyncArrowFunction1_es5_es5.2.minified.js | 2 +- .../asyncArrowFunction1_es6_es5.1.normal.js | 18 +- .../asyncArrowFunction1_es6_es5.2.minified.js | 2 +- ...onCapturesArguments_es2017_es5.1.normal.js | 28 +- ...CapturesArguments_es2017_es5.2.minified.js | 2 +- ...ctionCapturesArguments_es5_es5.1.normal.js | 28 +- ...ionCapturesArguments_es5_es5.2.minified.js | 2 +- ...ctionCapturesArguments_es6_es5.1.normal.js | 28 +- ...ionCapturesArguments_es6_es5.2.minified.js | 2 +- ...unctionCapturesThis_es2017_es5.1.normal.js | 28 +- ...ctionCapturesThis_es2017_es5.2.minified.js | 2 +- ...owFunctionCapturesThis_es5_es5.1.normal.js | 28 +- ...FunctionCapturesThis_es5_es5.2.minified.js | 2 +- ...owFunctionCapturesThis_es6_es5.1.normal.js | 28 +- ...FunctionCapturesThis_es6_es5.2.minified.js | 2 +- ...asyncArrowFunction_allowJs_es5.1.normal.js | 59 +- ...yncArrowFunction_allowJs_es5.2.minified.js | 2 +- ...waitIsolatedModules_es2017_es5.1.normal.js | 382 +- ...itIsolatedModules_es2017_es5.2.minified.js | 2 +- ...ncAwaitIsolatedModules_es5_es5.1.normal.js | 382 +- ...AwaitIsolatedModules_es5_es5.2.minified.js | 2 +- ...ncAwaitIsolatedModules_es6_es5.1.normal.js | 382 +- ...AwaitIsolatedModules_es6_es5.2.minified.js | 2 +- ...syncAwaitNestedClasses_es5_es5.1.normal.js | 26 +- ...ncAwaitNestedClasses_es5_es5.2.minified.js | 24 +- .../asyncAwait_es2017_es5.1.normal.js | 411 +- .../asyncAwait_es2017_es5.2.minified.js | 2 +- .../asyncAwait_es5_es5.1.normal.js | 411 +- .../asyncAwait_es5_es5.2.minified.js | 2 +- .../asyncAwait_es6_es5.1.normal.js | 411 +- .../asyncAwait_es6_es5.2.minified.js | 2 +- ...nctionDeclaration13_es2017_es5.1.normal.js | 20 +- ...tionDeclaration13_es2017_es5.2.minified.js | 2 +- ...cFunctionDeclaration13_es5_es5.1.normal.js | 20 +- ...unctionDeclaration13_es5_es5.2.minified.js | 2 +- ...cFunctionDeclaration13_es6_es5.1.normal.js | 20 +- ...unctionDeclaration13_es6_es5.2.minified.js | 2 +- ...nctionDeclaration14_es2017_es5.1.normal.js | 20 +- ...tionDeclaration14_es2017_es5.2.minified.js | 2 +- ...cFunctionDeclaration14_es5_es5.1.normal.js | 20 +- ...unctionDeclaration14_es5_es5.2.minified.js | 2 +- ...cFunctionDeclaration14_es6_es5.1.normal.js | 20 +- ...unctionDeclaration14_es6_es5.2.minified.js | 2 +- ...unctionDeclaration1_es2017_es5.1.normal.js | 18 +- ...ctionDeclaration1_es2017_es5.2.minified.js | 2 +- ...ncFunctionDeclaration1_es5_es5.1.normal.js | 18 +- ...FunctionDeclaration1_es5_es5.2.minified.js | 2 +- ...ncFunctionDeclaration1_es6_es5.1.normal.js | 18 +- ...FunctionDeclaration1_es6_es5.2.minified.js | 2 +- ...ationCapturesArguments_es5_es5.1.normal.js | 28 +- ...ionCapturesArguments_es5_es5.2.minified.js | 2 +- .../asyncImportedPromise_es5_es5.1.normal.js | 20 +- ...asyncImportedPromise_es5_es5.2.minified.js | 2 +- .../asyncImportedPromise_es6_es5.1.normal.js | 20 +- ...asyncImportedPromise_es6_es5.2.minified.js | 2 +- ...ethodWithSuperConflict_es6_es5.1.normal.js | 100 +- ...hodWithSuperConflict_es6_es5.2.minified.js | 2 +- ...syncMethodWithSuper_es2017_es5.1.normal.js | 92 +- ...ncMethodWithSuper_es2017_es5.2.minified.js | 2 +- .../asyncMethodWithSuper_es5_es5.1.normal.js | 92 +- ...asyncMethodWithSuper_es5_es5.2.minified.js | 2 +- .../asyncMethodWithSuper_es6_es5.1.normal.js | 602 +-- ...asyncMethodWithSuper_es6_es5.2.minified.js | 2 +- .../asyncMultiFile_es5_es5.1.normal.js | 18 +- .../asyncMultiFile_es5_es5.2.minified.js | 2 +- .../asyncMultiFile_es6_es5.1.normal.js | 18 +- .../asyncMultiFile_es6_es5.2.minified.js | 2 +- ...esizedArrowFunction_es2017_es5.1.normal.js | 54 +- ...izedArrowFunction_es2017_es5.2.minified.js | 2 +- ...nthesizedArrowFunction_es5_es5.1.normal.js | 54 +- ...hesizedArrowFunction_es5_es5.2.minified.js | 2 +- ...nthesizedArrowFunction_es6_es5.1.normal.js | 54 +- ...hesizedArrowFunction_es6_es5.2.minified.js | 2 +- .../asyncUseStrict_es2017_es5.1.normal.js | 35 +- .../asyncUseStrict_es2017_es5.2.minified.js | 2 +- .../asyncUseStrict_es5_es5.1.normal.js | 35 +- .../asyncUseStrict_es5_es5.2.minified.js | 2 +- .../asyncUseStrict_es6_es5.1.normal.js | 35 +- .../asyncUseStrict_es6_es5.2.minified.js | 2 +- .../asyncWithVarShadowing_es6_es5.1.normal.js | 952 +++-- ...syncWithVarShadowing_es6_es5.2.minified.js | 2 +- ...itBinaryExpression1_es2017_es5.1.normal.js | 35 +- ...BinaryExpression1_es2017_es5.2.minified.js | 2 +- ...awaitBinaryExpression1_es5_es5.1.normal.js | 35 +- ...aitBinaryExpression1_es5_es5.2.minified.js | 2 +- ...awaitBinaryExpression1_es6_es5.1.normal.js | 35 +- ...aitBinaryExpression1_es6_es5.2.minified.js | 2 +- ...itBinaryExpression2_es2017_es5.1.normal.js | 35 +- ...BinaryExpression2_es2017_es5.2.minified.js | 2 +- ...awaitBinaryExpression2_es5_es5.1.normal.js | 35 +- ...aitBinaryExpression2_es5_es5.2.minified.js | 2 +- ...awaitBinaryExpression2_es6_es5.1.normal.js | 35 +- ...aitBinaryExpression2_es6_es5.2.minified.js | 2 +- ...itBinaryExpression3_es2017_es5.1.normal.js | 30 +- ...BinaryExpression3_es2017_es5.2.minified.js | 2 +- ...awaitBinaryExpression3_es5_es5.1.normal.js | 30 +- ...aitBinaryExpression3_es5_es5.2.minified.js | 2 +- ...awaitBinaryExpression3_es6_es5.1.normal.js | 30 +- ...aitBinaryExpression3_es6_es5.2.minified.js | 2 +- ...itBinaryExpression4_es2017_es5.1.normal.js | 28 +- ...BinaryExpression4_es2017_es5.2.minified.js | 2 +- ...awaitBinaryExpression4_es5_es5.1.normal.js | 28 +- ...aitBinaryExpression4_es5_es5.2.minified.js | 2 +- ...awaitBinaryExpression4_es6_es5.1.normal.js | 28 +- ...aitBinaryExpression4_es6_es5.2.minified.js | 2 +- ...itBinaryExpression5_es2017_es5.1.normal.js | 29 +- ...BinaryExpression5_es2017_es5.2.minified.js | 2 +- ...awaitBinaryExpression5_es5_es5.1.normal.js | 29 +- ...aitBinaryExpression5_es5_es5.2.minified.js | 2 +- ...awaitBinaryExpression5_es6_es5.1.normal.js | 29 +- ...aitBinaryExpression5_es6_es5.2.minified.js | 2 +- ...waitCallExpression1_es2017_es5.1.normal.js | 25 +- ...itCallExpression1_es2017_es5.2.minified.js | 2 +- .../awaitCallExpression1_es5_es5.1.normal.js | 25 +- ...awaitCallExpression1_es5_es5.2.minified.js | 2 +- .../awaitCallExpression1_es6_es5.1.normal.js | 25 +- ...awaitCallExpression1_es6_es5.2.minified.js | 2 +- ...waitCallExpression2_es2017_es5.1.normal.js | 36 +- ...itCallExpression2_es2017_es5.2.minified.js | 2 +- .../awaitCallExpression2_es5_es5.1.normal.js | 36 +- ...awaitCallExpression2_es5_es5.2.minified.js | 2 +- .../awaitCallExpression2_es6_es5.1.normal.js | 36 +- ...awaitCallExpression2_es6_es5.2.minified.js | 2 +- ...waitCallExpression3_es2017_es5.1.normal.js | 37 +- ...itCallExpression3_es2017_es5.2.minified.js | 2 +- .../awaitCallExpression3_es5_es5.1.normal.js | 37 +- ...awaitCallExpression3_es5_es5.2.minified.js | 2 +- .../awaitCallExpression3_es6_es5.1.normal.js | 37 +- ...awaitCallExpression3_es6_es5.2.minified.js | 2 +- ...waitCallExpression4_es2017_es5.1.normal.js | 29 +- ...itCallExpression4_es2017_es5.2.minified.js | 2 +- .../awaitCallExpression4_es5_es5.1.normal.js | 29 +- ...awaitCallExpression4_es5_es5.2.minified.js | 2 +- .../awaitCallExpression4_es6_es5.1.normal.js | 29 +- ...awaitCallExpression4_es6_es5.2.minified.js | 2 +- ...waitCallExpression5_es2017_es5.1.normal.js | 25 +- ...itCallExpression5_es2017_es5.2.minified.js | 2 +- .../awaitCallExpression5_es5_es5.1.normal.js | 25 +- ...awaitCallExpression5_es5_es5.2.minified.js | 2 +- .../awaitCallExpression5_es6_es5.1.normal.js | 25 +- ...awaitCallExpression5_es6_es5.2.minified.js | 2 +- ...waitCallExpression6_es2017_es5.1.normal.js | 37 +- ...itCallExpression6_es2017_es5.2.minified.js | 2 +- .../awaitCallExpression6_es5_es5.1.normal.js | 37 +- ...awaitCallExpression6_es5_es5.2.minified.js | 2 +- .../awaitCallExpression6_es6_es5.1.normal.js | 37 +- ...awaitCallExpression6_es6_es5.2.minified.js | 2 +- ...waitCallExpression7_es2017_es5.1.normal.js | 38 +- ...itCallExpression7_es2017_es5.2.minified.js | 2 +- .../awaitCallExpression7_es5_es5.1.normal.js | 38 +- ...awaitCallExpression7_es5_es5.2.minified.js | 2 +- .../awaitCallExpression7_es6_es5.1.normal.js | 38 +- ...awaitCallExpression7_es6_es5.2.minified.js | 2 +- ...waitCallExpression8_es2017_es5.1.normal.js | 28 +- ...itCallExpression8_es2017_es5.2.minified.js | 2 +- .../awaitCallExpression8_es5_es5.1.normal.js | 28 +- ...awaitCallExpression8_es5_es5.2.minified.js | 2 +- .../awaitCallExpression8_es6_es5.1.normal.js | 28 +- ...awaitCallExpression8_es6_es5.2.minified.js | 2 +- ...waitClassExpression_es2017_es5.1.normal.js | 33 +- ...itClassExpression_es2017_es5.2.minified.js | 2 +- .../awaitClassExpression_es5_es5.1.normal.js | 33 +- ...awaitClassExpression_es5_es5.2.minified.js | 2 +- .../awaitClassExpression_es6_es5.1.normal.js | 33 +- ...awaitClassExpression_es6_es5.2.minified.js | 2 +- ...aitInheritedPromise_es2017_es5.1.normal.js | 26 +- ...tInheritedPromise_es2017_es5.2.minified.js | 2 +- .../awaitUnion_es5_es5.1.normal.js | 64 +- .../awaitUnion_es5_es5.2.minified.js | 2 +- .../awaitUnion_es6_es5.1.normal.js | 64 +- .../awaitUnion_es6_es5.2.minified.js | 2 +- ...ait_unaryExpression_es2017_es5.1.normal.js | 106 +- ...t_unaryExpression_es2017_es5.2.minified.js | 2 +- .../await_unaryExpression_es6_es5.1.normal.js | 106 +- ...wait_unaryExpression_es6_es5.2.minified.js | 2 +- ...tleSkipContextSensitiveBug_es5.1.normal.js | 25 +- ...eSkipContextSensitiveBug_es5.2.minified.js | 2 +- ...eAsyncFunctionAwaitOperand_es5.1.normal.js | 62 +- ...syncFunctionAwaitOperand_es5.2.minified.js | 2 +- ...ypeAsyncFunctionReturnType_es5.1.normal.js | 116 +- ...eAsyncFunctionReturnType_es5.2.minified.js | 2 +- .../controlFlowIIFE_es5.1.normal.js | 51 +- .../controlFlowIIFE_es5.2.minified.js | 2 +- ...tExportInAwaitExpression01_es5.1.normal.js | 28 +- ...xportInAwaitExpression01_es5.2.minified.js | 26 +- ...tExportInAwaitExpression02_es5.1.normal.js | 28 +- ...xportInAwaitExpression02_es5.2.minified.js | 26 +- ...rators.classMethods.es2015_es5.1.normal.js | 246 +- ...tors.classMethods.es2015_es5.2.minified.js | 20 +- ...rators.classMethods.es2018_es5.1.normal.js | 246 +- ...tors.classMethods.es2018_es5.2.minified.js | 20 +- ...enerators.classMethods.es5_es5.1.normal.js | 246 +- ...erators.classMethods.es5_es5.2.minified.js | 20 +- ...unctionDeclarations.es2015_es5.1.normal.js | 204 +- ...ctionDeclarations.es2015_es5.2.minified.js | 16 +- ...unctionDeclarations.es2018_es5.1.normal.js | 204 +- ...ctionDeclarations.es2018_es5.2.minified.js | 16 +- ...s.functionDeclarations.es5_es5.1.normal.js | 204 +- ...functionDeclarations.es5_es5.2.minified.js | 16 +- ...functionExpressions.es2015_es5.1.normal.js | 204 +- ...nctionExpressions.es2015_es5.2.minified.js | 16 +- ...functionExpressions.es2018_es5.1.normal.js | 204 +- ...nctionExpressions.es2018_es5.2.minified.js | 16 +- ...rs.functionExpressions.es5_es5.1.normal.js | 204 +- ....functionExpressions.es5_es5.2.minified.js | 16 +- ...bjectLiteralMethods.es2015_es5.1.normal.js | 204 +- ...ectLiteralMethods.es2015_es5.2.minified.js | 16 +- ...bjectLiteralMethods.es2018_es5.1.normal.js | 204 +- ...ectLiteralMethods.es2018_es5.2.minified.js | 16 +- ...s.objectLiteralMethods.es5_es5.1.normal.js | 204 +- ...objectLiteralMethods.es5_es5.2.minified.js | 16 +- .../emitter.forAwait_es5.1.normal.js | 1036 +++-- .../emitter.forAwait_es5.2.minified.js | 14 +- .../errorOnFunctionReturnType_es5.1.normal.js | 40 +- ...rrorOnFunctionReturnType_es5.2.minified.js | 2 +- .../generatorAssignability_es5.1.normal.js | 776 ++-- .../generatorAssignability_es5.2.minified.js | 3 +- ...eneratorExplicitReturnType_es5.1.normal.js | 112 +- ...eratorExplicitReturnType_es5.2.minified.js | 3 +- .../generatorImplicitAny_es5.1.normal.js | 209 +- .../generatorImplicitAny_es5.2.minified.js | 2 +- ...generatorInAmbientContext5_es5.1.normal.js | 18 +- ...neratorInAmbientContext5_es5.2.minified.js | 2 +- ...generatorInAmbientContext6_es5.1.normal.js | 18 +- ...neratorInAmbientContext6_es5.2.minified.js | 18 +- ...generatorNoImplicitReturns_es5.1.normal.js | 32 +- ...neratorNoImplicitReturns_es5.2.minified.js | 2 +- .../generatorOverloads4_es5.1.normal.js | 18 +- .../generatorOverloads4_es5.2.minified.js | 2 +- .../generatorOverloads5_es5.1.normal.js | 18 +- .../generatorOverloads5_es5.2.minified.js | 2 +- ...eratorReturnContextualType_es5.1.normal.js | 94 +- ...atorReturnContextualType_es5.2.minified.js | 2 +- ...eratorReturnTypeFallback.1_es5.1.normal.js | 23 +- ...atorReturnTypeFallback.1_es5.2.minified.js | 2 +- ...eratorReturnTypeFallback.2_es5.1.normal.js | 23 +- ...atorReturnTypeFallback.2_es5.2.minified.js | 2 +- ...eratorReturnTypeFallback.3_es5.1.normal.js | 25 +- ...atorReturnTypeFallback.3_es5.2.minified.js | 2 +- ...eratorReturnTypeFallback.4_es5.1.normal.js | 25 +- ...atorReturnTypeFallback.4_es5.2.minified.js | 2 +- ...eratorReturnTypeFallback.5_es5.1.normal.js | 23 +- ...atorReturnTypeFallback.5_es5.2.minified.js | 2 +- ...irectReferenceToGlobalType_es5.1.normal.js | 27 +- ...ectReferenceToGlobalType_es5.2.minified.js | 2 +- ...turnTypeInferenceNonStrict_es5.1.normal.js | 649 ++- ...rnTypeInferenceNonStrict_es5.2.minified.js | 3 +- ...neratorReturnTypeInference_es5.1.normal.js | 649 ++- ...ratorReturnTypeInference_es5.2.minified.js | 3 +- .../generatorTypeCheck10_es5.1.normal.js | 17 +- .../generatorTypeCheck10_es5.2.minified.js | 2 +- .../generatorTypeCheck11_es5.1.normal.js | 18 +- .../generatorTypeCheck11_es5.2.minified.js | 2 +- .../generatorTypeCheck12_es5.1.normal.js | 18 +- .../generatorTypeCheck12_es5.2.minified.js | 2 +- .../generatorTypeCheck13_es5.1.normal.js | 26 +- .../generatorTypeCheck13_es5.2.minified.js | 2 +- .../generatorTypeCheck14_es5.1.normal.js | 26 +- .../generatorTypeCheck14_es5.2.minified.js | 2 +- .../generatorTypeCheck15_es5.1.normal.js | 18 +- .../generatorTypeCheck15_es5.2.minified.js | 2 +- .../generatorTypeCheck16_es5.1.normal.js | 17 +- .../generatorTypeCheck16_es5.2.minified.js | 2 +- .../generatorTypeCheck17_es5.1.normal.js | 29 +- .../generatorTypeCheck17_es5.2.minified.js | 2 +- .../generatorTypeCheck18_es5.1.normal.js | 29 +- .../generatorTypeCheck18_es5.2.minified.js | 2 +- .../generatorTypeCheck19_es5.1.normal.js | 33 +- .../generatorTypeCheck19_es5.2.minified.js | 3 +- .../generatorTypeCheck1_es5.1.normal.js | 15 +- .../generatorTypeCheck1_es5.2.minified.js | 2 +- .../generatorTypeCheck20_es5.1.normal.js | 33 +- .../generatorTypeCheck20_es5.2.minified.js | 3 +- .../generatorTypeCheck21_es5.1.normal.js | 29 +- .../generatorTypeCheck21_es5.2.minified.js | 3 +- .../generatorTypeCheck22_es5.1.normal.js | 61 +- .../generatorTypeCheck22_es5.2.minified.js | 3 +- .../generatorTypeCheck23_es5.1.normal.js | 68 +- .../generatorTypeCheck23_es5.2.minified.js | 3 +- .../generatorTypeCheck24_es5.1.normal.js | 71 +- .../generatorTypeCheck24_es5.2.minified.js | 3 +- .../generatorTypeCheck25_es5.1.normal.js | 64 +- .../generatorTypeCheck25_es5.2.minified.js | 3 +- .../generatorTypeCheck26_es5.1.normal.js | 43 +- .../generatorTypeCheck26_es5.2.minified.js | 3 +- .../generatorTypeCheck27_es5.1.normal.js | 51 +- .../generatorTypeCheck27_es5.2.minified.js | 3 +- .../generatorTypeCheck28_es5.1.normal.js | 53 +- .../generatorTypeCheck28_es5.2.minified.js | 3 +- .../generatorTypeCheck29_es5.1.normal.js | 53 +- .../generatorTypeCheck29_es5.2.minified.js | 2 +- .../generatorTypeCheck2_es5.1.normal.js | 15 +- .../generatorTypeCheck2_es5.2.minified.js | 2 +- .../generatorTypeCheck30_es5.1.normal.js | 53 +- .../generatorTypeCheck30_es5.2.minified.js | 2 +- .../generatorTypeCheck31_es5.1.normal.js | 53 +- .../generatorTypeCheck31_es5.2.minified.js | 2 +- .../generatorTypeCheck33_es5.1.normal.js | 47 +- .../generatorTypeCheck33_es5.2.minified.js | 2 +- .../generatorTypeCheck34_es5.1.normal.js | 42 +- .../generatorTypeCheck34_es5.2.minified.js | 2 +- .../generatorTypeCheck35_es5.1.normal.js | 23 +- .../generatorTypeCheck35_es5.2.minified.js | 2 +- .../generatorTypeCheck36_es5.1.normal.js | 29 +- .../generatorTypeCheck36_es5.2.minified.js | 2 +- .../generatorTypeCheck37_es5.1.normal.js | 31 +- .../generatorTypeCheck37_es5.2.minified.js | 2 +- .../generatorTypeCheck3_es5.1.normal.js | 15 +- .../generatorTypeCheck3_es5.2.minified.js | 2 +- .../generatorTypeCheck40_es5.1.normal.js | 30 +- .../generatorTypeCheck40_es5.2.minified.js | 2 +- .../generatorTypeCheck41_es5.1.normal.js | 34 +- .../generatorTypeCheck41_es5.2.minified.js | 2 +- .../generatorTypeCheck42_es5.1.normal.js | 35 +- .../generatorTypeCheck42_es5.2.minified.js | 2 +- .../generatorTypeCheck43_es5.1.normal.js | 49 +- .../generatorTypeCheck43_es5.2.minified.js | 2 +- .../generatorTypeCheck44_es5.1.normal.js | 59 +- .../generatorTypeCheck44_es5.2.minified.js | 2 +- .../generatorTypeCheck45_es5.1.normal.js | 30 +- .../generatorTypeCheck45_es5.2.minified.js | 28 +- .../generatorTypeCheck46_es5.1.normal.js | 56 +- .../generatorTypeCheck46_es5.2.minified.js | 52 +- .../generatorTypeCheck47_es5.1.normal.js | 15 +- .../generatorTypeCheck47_es5.2.minified.js | 2 +- .../generatorTypeCheck48_es5.1.normal.js | 43 +- .../generatorTypeCheck48_es5.2.minified.js | 2 +- .../generatorTypeCheck49_es5.1.normal.js | 23 +- .../generatorTypeCheck49_es5.2.minified.js | 2 +- .../generatorTypeCheck4_es5.1.normal.js | 15 +- .../generatorTypeCheck4_es5.2.minified.js | 2 +- .../generatorTypeCheck50_es5.1.normal.js | 28 +- .../generatorTypeCheck50_es5.2.minified.js | 2 +- .../generatorTypeCheck51_es5.1.normal.js | 44 +- .../generatorTypeCheck51_es5.2.minified.js | 2 +- .../generatorTypeCheck52_es5.1.normal.js | 30 +- .../generatorTypeCheck52_es5.2.minified.js | 2 +- .../generatorTypeCheck53_es5.1.normal.js | 34 +- .../generatorTypeCheck53_es5.2.minified.js | 3 +- .../generatorTypeCheck54_es5.1.normal.js | 35 +- .../generatorTypeCheck54_es5.2.minified.js | 3 +- .../generatorTypeCheck55_es5.1.normal.js | 29 +- .../generatorTypeCheck55_es5.2.minified.js | 2 +- .../generatorTypeCheck56_es5.1.normal.js | 58 +- .../generatorTypeCheck56_es5.2.minified.js | 2 +- .../generatorTypeCheck5_es5.1.normal.js | 15 +- .../generatorTypeCheck5_es5.2.minified.js | 2 +- .../generatorTypeCheck60_es5.1.normal.js | 29 +- .../generatorTypeCheck60_es5.2.minified.js | 2 +- .../generatorTypeCheck62_es5.1.normal.js | 189 +- .../generatorTypeCheck62_es5.2.minified.js | 162 +- .../generatorTypeCheck63_es5.1.normal.js | 211 +- .../generatorTypeCheck63_es5.2.minified.js | 183 +- .../generatorTypeCheck6_es5.1.normal.js | 15 +- .../generatorTypeCheck6_es5.2.minified.js | 2 +- .../generatorTypeCheck7_es5.1.normal.js | 15 +- .../generatorTypeCheck7_es5.2.minified.js | 2 +- .../generatorTypeCheck8_es5.1.normal.js | 15 +- .../generatorTypeCheck8_es5.2.minified.js | 2 +- .../generatorTypeCheck9_es5.1.normal.js | 15 +- .../generatorTypeCheck9_es5.2.minified.js | 2 +- ...neratorYieldContextualType_es5.1.normal.js | 62 +- ...ratorYieldContextualType_es5.2.minified.js | 50 +- ...mportCallExpression3ES2020_es5.1.normal.js | 33 +- ...ortCallExpression3ES2020_es5.2.minified.js | 30 +- ...mportCallExpression4ES2020_es5.1.normal.js | 28 +- ...ortCallExpression4ES2020_es5.2.minified.js | 2 +- ...tCallExpressionAsyncES2020_es5.1.normal.js | 137 +- ...allExpressionAsyncES2020_es5.2.minified.js | 122 +- ...tCallExpressionAsyncES3AMD_es5.1.normal.js | 137 +- ...allExpressionAsyncES3AMD_es5.2.minified.js | 122 +- ...tCallExpressionAsyncES3CJS_es5.1.normal.js | 137 +- ...allExpressionAsyncES3CJS_es5.2.minified.js | 122 +- ...llExpressionAsyncES3System_es5.1.normal.js | 137 +- ...ExpressionAsyncES3System_es5.2.minified.js | 122 +- ...tCallExpressionAsyncES3UMD_es5.1.normal.js | 137 +- ...allExpressionAsyncES3UMD_es5.2.minified.js | 122 +- ...tCallExpressionAsyncES5AMD_es5.1.normal.js | 137 +- ...allExpressionAsyncES5AMD_es5.2.minified.js | 122 +- ...tCallExpressionAsyncES5CJS_es5.1.normal.js | 137 +- ...allExpressionAsyncES5CJS_es5.2.minified.js | 122 +- ...llExpressionAsyncES5System_es5.1.normal.js | 137 +- ...ExpressionAsyncES5System_es5.2.minified.js | 122 +- ...tCallExpressionAsyncES5UMD_es5.1.normal.js | 137 +- ...allExpressionAsyncES5UMD_es5.2.minified.js | 122 +- ...tCallExpressionAsyncES6AMD_es5.1.normal.js | 137 +- ...allExpressionAsyncES6AMD_es5.2.minified.js | 122 +- ...tCallExpressionAsyncES6CJS_es5.1.normal.js | 137 +- ...allExpressionAsyncES6CJS_es5.2.minified.js | 122 +- ...llExpressionAsyncES6System_es5.1.normal.js | 137 +- ...ExpressionAsyncES6System_es5.2.minified.js | 122 +- ...tCallExpressionAsyncES6UMD_es5.1.normal.js | 137 +- ...allExpressionAsyncES6UMD_es5.2.minified.js | 122 +- ...importCallExpressionInAMD3_es5.1.normal.js | 33 +- ...portCallExpressionInAMD3_es5.2.minified.js | 30 +- ...importCallExpressionInAMD4_es5.1.normal.js | 54 +- ...portCallExpressionInAMD4_es5.2.minified.js | 26 +- ...importCallExpressionInCJS2_es5.1.normal.js | 53 +- ...portCallExpressionInCJS2_es5.2.minified.js | 47 +- ...importCallExpressionInCJS4_es5.1.normal.js | 33 +- ...portCallExpressionInCJS4_es5.2.minified.js | 30 +- ...importCallExpressionInCJS5_es5.1.normal.js | 54 +- ...portCallExpressionInCJS5_es5.2.minified.js | 26 +- ...xpressionInExportEqualsAMD_es5.1.normal.js | 28 +- ...ressionInExportEqualsAMD_es5.2.minified.js | 26 +- ...xpressionInExportEqualsCJS_es5.1.normal.js | 28 +- ...ressionInExportEqualsCJS_es5.2.minified.js | 26 +- ...xpressionInExportEqualsUMD_es5.1.normal.js | 28 +- ...ressionInExportEqualsUMD_es5.2.minified.js | 26 +- ...ortCallExpressionInSystem3_es5.1.normal.js | 33 +- ...tCallExpressionInSystem3_es5.2.minified.js | 30 +- ...ortCallExpressionInSystem4_es5.1.normal.js | 54 +- ...tCallExpressionInSystem4_es5.2.minified.js | 26 +- ...importCallExpressionInUMD3_es5.1.normal.js | 33 +- ...portCallExpressionInUMD3_es5.2.minified.js | 30 +- ...importCallExpressionInUMD4_es5.1.normal.js | 54 +- ...portCallExpressionInUMD4_es5.2.minified.js | 26 +- ...importCallExpressionInUMD5_es5.1.normal.js | 28 +- ...portCallExpressionInUMD5_es5.2.minified.js | 2 +- ...rtCallExpressionNestedAMD2_es5.1.normal.js | 35 +- ...CallExpressionNestedAMD2_es5.2.minified.js | 2 +- ...ortCallExpressionNestedAMD_es5.1.normal.js | 35 +- ...tCallExpressionNestedAMD_es5.2.minified.js | 2 +- ...rtCallExpressionNestedCJS2_es5.1.normal.js | 35 +- ...CallExpressionNestedCJS2_es5.2.minified.js | 2 +- ...ortCallExpressionNestedCJS_es5.1.normal.js | 35 +- ...tCallExpressionNestedCJS_es5.2.minified.js | 2 +- ...allExpressionNestedES20152_es5.1.normal.js | 35 +- ...lExpressionNestedES20152_es5.2.minified.js | 2 +- ...CallExpressionNestedES2015_es5.1.normal.js | 35 +- ...llExpressionNestedES2015_es5.2.minified.js | 2 +- ...allExpressionNestedES20202_es5.1.normal.js | 35 +- ...lExpressionNestedES20202_es5.2.minified.js | 2 +- ...CallExpressionNestedES2020_es5.1.normal.js | 35 +- ...llExpressionNestedES2020_es5.2.minified.js | 2 +- ...allExpressionNestedSystem2_es5.1.normal.js | 35 +- ...lExpressionNestedSystem2_es5.2.minified.js | 2 +- ...CallExpressionNestedSystem_es5.1.normal.js | 35 +- ...llExpressionNestedSystem_es5.2.minified.js | 2 +- ...rtCallExpressionNestedUMD2_es5.1.normal.js | 35 +- ...CallExpressionNestedUMD2_es5.2.minified.js | 2 +- ...ortCallExpressionNestedUMD_es5.1.normal.js | 35 +- ...tCallExpressionNestedUMD_es5.2.minified.js | 2 +- ...ssionNoModuleKindSpecified_es5.1.normal.js | 28 +- ...ionNoModuleKindSpecified_es5.2.minified.js | 2 +- ...pressionReturnPromiseOfAny_es5.1.normal.js | 122 +- ...essionReturnPromiseOfAny_es5.2.minified.js | 2 +- ...sDeclarationsClassAccessor_es5.1.normal.js | 18 +- ...eclarationsClassAccessor_es5.2.minified.js | 18 +- ...jsDeclarationsNestedParams_es5.1.normal.js | 34 +- ...DeclarationsNestedParams_es5.2.minified.js | 2 +- ...ngOperatorInAsyncGenerator_es5.1.normal.js | 44 +- ...OperatorInAsyncGenerator_es5.2.minified.js | 2 +- .../objectRest2_es5.1.normal.js | 36 +- .../objectRest2_es5.2.minified.js | 31 +- ...erArrowFunctionExpression7_es5.1.normal.js | 21 +- ...ArrowFunctionExpression7_es5.2.minified.js | 2 +- .../privateNameMethodAsync_es5.1.normal.js | 123 +- .../privateNameMethodAsync_es5.2.minified.js | 110 +- ...ameStaticsAndStaticMethods_es5.1.normal.js | 37 +- ...eStaticsAndStaticMethods_es5.2.minified.js | 18 +- .../privateNamesAndMethods_es5.1.normal.js | 37 +- .../privateNamesAndMethods_es5.2.minified.js | 2 +- ...ivateNamesAndStaticMethods_es5.1.normal.js | 37 +- ...ateNamesAndStaticMethods_es5.2.minified.js | 18 +- ...ameterInDownlevelGenerator_es5.1.normal.js | 78 +- ...eterInDownlevelGenerator_es5.2.minified.js | 2 +- .../superMethodCall_es5.1.normal.js | 22 +- .../superMethodCall_es5.2.minified.js | 2 +- ...mplateStringInYieldKeyword_es5.1.normal.js | 25 +- ...lateStringInYieldKeyword_es5.2.minified.js | 2 +- ...ithEmbeddedYieldKeywordES6_es5.1.normal.js | 31 +- ...hEmbeddedYieldKeywordES6_es5.2.minified.js | 2 +- ...s.asyncGenerators.es2018.1_es5.1.normal.js | 1203 +++--- ...asyncGenerators.es2018.1_es5.2.minified.js | 3 +- ...s.asyncGenerators.es2018.2_es5.1.normal.js | 757 ++-- ...asyncGenerators.es2018.2_es5.2.minified.js | 19 +- .../types.forAwait.es2018.1_es5.1.normal.js | 1568 ++++---- .../types.forAwait.es2018.1_es5.2.minified.js | 2 +- .../types.forAwait.es2018.2_es5.1.normal.js | 650 ++- .../types.forAwait.es2018.2_es5.2.minified.js | 2 +- .../types.forAwait.es2018.3_es5.1.normal.js | 564 ++- .../types.forAwait.es2018.3_es5.2.minified.js | 2 +- ...nAndIntersectionInference3_es5.1.normal.js | 18 +- ...ndIntersectionInference3_es5.2.minified.js | 2 +- .../unionTypeInference_es5.1.normal.js | 140 +- .../unionTypeInference_es5.2.minified.js | 64 +- .../uniqueSymbolsDeclarations_es5.1.normal.js | 416 +- ...niqueSymbolsDeclarations_es5.2.minified.js | 65 +- .../uniqueSymbols_es5.1.normal.js | 416 +- .../uniqueSymbols_es5.2.minified.js | 65 +- ...eldExpressionInControlFlow_es5.1.normal.js | 79 +- ...dExpressionInControlFlow_es5.2.minified.js | 5 +- .../vercel/full/next-31419/1/output/index.js | 83 +- .../vercel/full/next-33088/output/index.js | 57 +- .../tests/vercel/full/utf8-1/output/index.js | 101 +- .../regressions/1/full/output/index.js | 21 +- .../regressions/1/simplified/output/index.js | 21 +- crates/swc_ecma_ast/src/expr.rs | 60 +- crates/swc_ecma_ast/src/ident.rs | 4 +- crates/swc_ecma_ast/src/pat.rs | 3 +- crates/swc_ecma_ast/src/prop.rs | 22 - crates/swc_ecma_ast/src/source_map.rs | 4 + crates/swc_ecma_preset_env/src/lib.rs | 11 +- .../src/helpers/_ts_generator.js | 27 - .../src/helpers/_ts_values.js | 11 - .../src/helpers/mod.rs | 2 - .../src/es2015/generator.rs | 3499 ----------------- .../src/es2015/mod.rs | 8 +- .../src/es2015/regenerator/case.rs | 1619 ++++++++ .../src/es2015/regenerator/hoist.rs | 191 + .../src/es2015/regenerator/leap.rs | 137 + .../src/es2015/regenerator/mod.rs | 554 ++- .../tests/es2015_block_scoping.rs | 78 +- ...015_generator.rs => es2015_regenerator.rs} | 997 ++--- .../tests/es2017_async_to_generator.rs | 360 +- .../src/function/fn_env_hoister.rs | 213 +- crates/swc_html_codegen/src/lib.rs | 1 + .../pass/issue-1328/case1/output/entry.js | 710 +++- .../tests/pass/regenerator/1/output/entry.js | 734 +++- crates/swc_plugin_runner/benches/invoke.rs | 6 +- crates/swc_plugin_runner/tests/integration.rs | 7 +- packages/swc-helpers/src/_ts_generator.mjs | 1 - packages/swc-helpers/src/_ts_values.mjs | 1 - packages/swc-helpers/src/index.mjs | 2 +- 630 files changed, 20662 insertions(+), 22060 deletions(-) delete mode 100644 crates/swc/tests/exec/generator/1-object/exec.js delete mode 100644 crates/swc/tests/exec/generator/2-array/exec.js delete mode 100644 crates/swc/tests/exec/generator/3-object-accessor/exec.js delete mode 100644 crates/swc_ecma_transforms_base/src/helpers/_ts_generator.js delete mode 100644 crates/swc_ecma_transforms_base/src/helpers/_ts_values.js delete mode 100644 crates/swc_ecma_transforms_compat/src/es2015/generator.rs create mode 100644 crates/swc_ecma_transforms_compat/src/es2015/regenerator/case.rs create mode 100644 crates/swc_ecma_transforms_compat/src/es2015/regenerator/hoist.rs create mode 100644 crates/swc_ecma_transforms_compat/src/es2015/regenerator/leap.rs rename crates/swc_ecma_transforms_compat/tests/{es2015_generator.rs => es2015_regenerator.rs} (62%) delete mode 100644 packages/swc-helpers/src/_ts_generator.mjs delete mode 100644 packages/swc-helpers/src/_ts_values.mjs diff --git a/crates/swc/tests/exec/generator/1-object/exec.js b/crates/swc/tests/exec/generator/1-object/exec.js deleted file mode 100644 index 067c070e58c..00000000000 --- a/crates/swc/tests/exec/generator/1-object/exec.js +++ /dev/null @@ -1,29 +0,0 @@ - - -function* foo() { - const obj = { - a: 1, - b: yield true, - c: 2, - }; - - expect(obj.b).toEqual(1); - - yield 2; - - return obj.c; -} - -const g = foo(); -expect(g.next(0)).toEqual({ - value: true, - done: false, -}) -expect(g.next(1)).toEqual({ - value: 2, - done: false, -}) -expect(g.next()).toEqual({ - done: true, - value: 2 -}) \ No newline at end of file diff --git a/crates/swc/tests/exec/generator/2-array/exec.js b/crates/swc/tests/exec/generator/2-array/exec.js deleted file mode 100644 index 6065452ac17..00000000000 --- a/crates/swc/tests/exec/generator/2-array/exec.js +++ /dev/null @@ -1,29 +0,0 @@ - - -function* foo() { - const arr = [ - 1, - yield true, - 2, - ]; - - expect(arr[1]).toEqual(1); - - yield 2; - - return arr[2]; -} - -const g = foo(); -expect(g.next(0)).toEqual({ - value: true, - done: false, -}) -expect(g.next(1)).toEqual({ - value: 2, - done: false, -}) -expect(g.next()).toEqual({ - done: true, - value: 2 -}) \ No newline at end of file diff --git a/crates/swc/tests/exec/generator/3-object-accessor/exec.js b/crates/swc/tests/exec/generator/3-object-accessor/exec.js deleted file mode 100644 index 28c43bc3db8..00000000000 --- a/crates/swc/tests/exec/generator/3-object-accessor/exec.js +++ /dev/null @@ -1,31 +0,0 @@ - - -function* foo() { - const obj = { - a: 1, - get foo() { }, - b: yield true, - set foo(v) { }, - c: 2, - }; - - expect(obj.b).toEqual(1); - - yield 2; - - return obj.c; -} - -const g = foo(); -expect(g.next(0)).toEqual({ - value: true, - done: false, -}) -expect(g.next(1)).toEqual({ - value: 2, - done: false, -}) -expect(g.next()).toEqual({ - done: true, - value: 2 -}) \ No newline at end of file diff --git a/crates/swc/tests/fixture/config/regenerator/import-path/1/output/index.js b/crates/swc/tests/fixture/config/regenerator/import-path/1/output/index.js index 12b3a24cba2..bb756e799f7 100644 --- a/crates/swc/tests/fixture/config/regenerator/import-path/1/output/index.js +++ b/crates/swc/tests/fixture/config/regenerator/import-path/1/output/index.js @@ -1,29 +1,20 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "custom"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(gen); function gen() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function gen$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 4, - 2 - ]; + _ctx.next = 2; + return 1; case 2: - _state.sent(); - return [ - 4, - 3 - ]; - case 3: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return 2; + case 4: + _ctx.next = 6; + return 3; + case 6: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/fixture/issues-1xxx/1216/case-1/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1216/case-1/output/index.js index b1f9dcf3b6c..f3851a2fa9b 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1216/case-1/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1216/case-1/output/index.js @@ -1,5 +1,5 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var source = Math.random() < 2 ? "matilda" : "fred"; var details = { _id: "1" @@ -8,45 +8,44 @@ function request(path) { return _request.apply(this, arguments); } function _request() { - _request = _async_to_generator(function(path) { - return _ts_generator(this, function(_state) { - return [ - 2, - "success:".concat(path) - ]; - }); - }); + _request = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(path) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", "success:".concat(path)); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _request.apply(this, arguments); } -_async_to_generator(function() { - var obj, _tmp, _tmp1; - return _ts_generator(this, function(_state) { - switch(_state.label){ +_async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var obj; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - if (!(source === "matilda")) return [ - 3, - 1 - ]; - _tmp = details; - return [ - 3, - 3 - ]; - case 1: - return [ - 4, - request("/".concat(details._id, "?source=").concat(source)) - ]; - case 2: - _tmp = _state.sent(); - _state.label = 3; - case 3: - obj = _tmp; - _tmp1 = {}; - console.log((_tmp1.obj = obj, _tmp1)); - return [ - 2 - ]; + if (!(source === "matilda")) { + _ctx.next = 4; + break; + } + _ctx.t0 = details; + _ctx.next = 7; + break; + case 4: + _ctx.next = 6; + return request("/".concat(details._id, "?source=").concat(source)); + case 6: + _ctx.t0 = _ctx.sent; + case 7: + obj = _ctx.t0; + console.log({ + obj: obj + }); + case 9: + case "end": + return _ctx.stop(); } - }); -})(); + }, _callee); +}))(); diff --git a/crates/swc/tests/fixture/issues-1xxx/1216/case-2/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1216/case-2/output/index.js index b1f9dcf3b6c..f3851a2fa9b 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1216/case-2/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1216/case-2/output/index.js @@ -1,5 +1,5 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var source = Math.random() < 2 ? "matilda" : "fred"; var details = { _id: "1" @@ -8,45 +8,44 @@ function request(path) { return _request.apply(this, arguments); } function _request() { - _request = _async_to_generator(function(path) { - return _ts_generator(this, function(_state) { - return [ - 2, - "success:".concat(path) - ]; - }); - }); + _request = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(path) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", "success:".concat(path)); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _request.apply(this, arguments); } -_async_to_generator(function() { - var obj, _tmp, _tmp1; - return _ts_generator(this, function(_state) { - switch(_state.label){ +_async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var obj; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - if (!(source === "matilda")) return [ - 3, - 1 - ]; - _tmp = details; - return [ - 3, - 3 - ]; - case 1: - return [ - 4, - request("/".concat(details._id, "?source=").concat(source)) - ]; - case 2: - _tmp = _state.sent(); - _state.label = 3; - case 3: - obj = _tmp; - _tmp1 = {}; - console.log((_tmp1.obj = obj, _tmp1)); - return [ - 2 - ]; + if (!(source === "matilda")) { + _ctx.next = 4; + break; + } + _ctx.t0 = details; + _ctx.next = 7; + break; + case 4: + _ctx.next = 6; + return request("/".concat(details._id, "?source=").concat(source)); + case 6: + _ctx.t0 = _ctx.sent; + case 7: + obj = _ctx.t0; + console.log({ + obj: obj + }); + case 9: + case "end": + return _ctx.stop(); } - }); -})(); + }, _callee); +}))(); diff --git a/crates/swc/tests/fixture/issues-1xxx/1216/case-3/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1216/case-3/output/index.js index 5b64e4ccb63..2b5e6a908ab 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1216/case-3/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1216/case-3/output/index.js @@ -1,35 +1,32 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(foo); function foo() { - var val, _tmp, _tmp1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + var val; + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - if (!true) return [ - 3, - 1 - ]; - _tmp = 1; - return [ - 3, - 3 - ]; - case 1: - return [ - 4, - 0 - ]; - case 2: - _tmp = _state.sent(); - _state.label = 3; - case 3: - val = _tmp; - _tmp1 = {}; - console.log((_tmp1.val = val, _tmp1)); - return [ - 2 - ]; + if (!true) { + _ctx.next = 4; + break; + } + _ctx.t0 = 1; + _ctx.next = 7; + break; + case 4: + _ctx.next = 6; + return 0; + case 6: + _ctx.t0 = _ctx.sent; + case 7: + val = _ctx.t0; + console.log({ + val: val + }); + case 9: + case "end": + return _ctx.stop(); } - }); + }, _marked); } var v = foo(); console.log(v.next()); diff --git a/crates/swc/tests/fixture/issues-1xxx/1449/case1/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1449/case1/output/index.js index b0120026d15..18aaeb778da 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1449/case1/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1449/case1/output/index.js @@ -1,19 +1,21 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _throw from "@swc/helpers/src/_throw.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - var tmp, ref, ref, _tmp; - return _ts_generator(this, function(_state) { - _tmp = {}; - tmp = baz.bar, ref = tmp === void 0 ? _tmp : tmp, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")); - return [ - 2 - ]; - }); - }); + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var tmp, ref, ref; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + tmp = baz.bar, ref = tmp === void 0 ? {} : tmp, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/fixture/issues-1xxx/1455/case2/output/index.ts b/crates/swc/tests/fixture/issues-1xxx/1455/case2/output/index.ts index 2a22dfb1e98..966966438ed 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1455/case2/output/index.ts +++ b/crates/swc/tests/fixture/issues-1xxx/1455/case2/output/index.ts @@ -1,5 +1,5 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var obj = { find: function find(param) { var platform = param.platform; @@ -8,27 +8,26 @@ var obj = { }; }, byPlatform: function() { - var _ref = _async_to_generator(function(platform) { - var result, _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(platform) { + var result; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp = {}; - return [ - 4, - this.find((_tmp.platform = { + _ctx.next = 2; + return this.find({ + platform: { $eq: platform - }, _tmp)) - ]; - case 1: - result = _state.sent(); - return [ - 2, - result - ]; + } + }); + case 2: + result = _ctx.sent; + return _ctx.abrupt("return", result); + case 4: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, this); + })); return function(platform) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/fixture/issues-1xxx/1477/case1/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1477/case1/output/index.js index 912c4129469..cd0bb1ee5b2 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1477/case1/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1477/case1/output/index.js @@ -1,18 +1,21 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f(a, b) { return _f.apply(this, arguments); } function _f() { - _f = _async_to_generator(function(a, b) { + _f = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(a, b) { var ref, ref1, tmp, a_; - return _ts_generator(this, function(_state) { - ref = _sliced_to_array(JSON.parse(b), 1), ref1 = ref[0], tmp = ref1.a, a_ = tmp === void 0 ? 1 : tmp; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ref = _sliced_to_array(JSON.parse(b), 1), ref1 = ref[0], tmp = ref1.a, a_ = tmp === void 0 ? 1 : tmp; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f.apply(this, arguments); } diff --git a/crates/swc/tests/fixture/issues-1xxx/1575/case1/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1575/case1/output/index.js index 1975782a220..cbfa25d968d 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1575/case1/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1575/case1/output/index.js @@ -1,16 +1,19 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; Vue.component("test", { methods: { onSend: function onSend() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - if (this.msg === "") {} - return [ - 2 - ]; - }); - }).apply(this); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + if (this.msg === "") {} + case 1: + case "end": + return _ctx.stop(); + } + }, _callee, this); + })).apply(this); } } }); diff --git a/crates/swc/tests/fixture/issues-1xxx/1575/case2/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1575/case2/output/index.js index 7b0a9a4eea2..ab641b22fe1 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1575/case2/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1575/case2/output/index.js @@ -1,16 +1,19 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var obj = { foo: 5, method: function method() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - this.foo - ]; - }); - }).apply(this); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", this.foo); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee, this); + })).apply(this); } }; obj.method().then(function(v) { diff --git a/crates/swc/tests/fixture/issues-1xxx/1687/output/input.tsx b/crates/swc/tests/fixture/issues-1xxx/1687/output/input.tsx index 7ae4c7a16dc..ff357ee5190 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1687/output/input.tsx +++ b/crates/swc/tests/fixture/issues-1xxx/1687/output/input.tsx @@ -1,8 +1,8 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; import "core-js/modules/es.object.to-string.js"; import "core-js/modules/es.promise.js"; +import regeneratorRuntime from "regenerator-runtime"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useEffect, useState } from "react"; import { render } from "react-dom"; @@ -11,24 +11,22 @@ import { Button, ConfigProvider } from "antd"; function App() { var ref = _sliced_to_array(useState({}), 2), state = ref[0], setState = ref[1]; useEffect(function() { - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - fetch("/api/user") - ]; - case 1: - setState.apply(void 0, [ - _state.sent() - ]); - return [ - 2 - ]; + _ctx.t0 = setState; + _ctx.next = 3; + return fetch("/api/user"); + case 3: + _ctx.t1 = _ctx.sent; + (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, []); return /*#__PURE__*/ _jsxs(ConfigProvider, { locale: zhCN, diff --git a/crates/swc/tests/fixture/issues-1xxx/1718/case1/output/index.ts b/crates/swc/tests/fixture/issues-1xxx/1718/case1/output/index.ts index 31f278a1587..42eb4702d84 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1718/case1/output/index.ts +++ b/crates/swc/tests/fixture/issues-1xxx/1718/case1/output/index.ts @@ -1,101 +1,93 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function scanUser(groups) { return _scanUser.apply(this, arguments); } function _scanUser() { - _scanUser = _async_to_generator(function(groups) { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _scanUser = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(groups) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - Promise.all(groups.map(function() { - var _ref = _async_to_generator(function(param) { - var users, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, user, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - users = param.users; - _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 8 - ]); - _iterator = users[Symbol.iterator](); - _state.label = 2; - case 2: - if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [ - 3, - 5 - ]; - user = _step.value; - console.log("user", user); - return [ - 4, - new Promise(function(resolve) { - return setTimeout(resolve, 30); - }) - ]; - case 3: - _state.sent(); - _state.label = 4; - case 4: - _iteratorNormalCompletion = true; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 8 - ]; - case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 8 - ]; - case 7: - try { - if (!_iteratorNormalCompletion && _iterator.return != null) { - _iterator.return(); - } - } finally{ - if (_didIteratorError) { - throw _iteratorError; - } - } - return [ - 7 - ]; - case 8: - return [ - 2 - ]; - } - }); - }); - return function(_) { - return _ref.apply(this, arguments); - }; - }())) - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return Promise.all(groups.map(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(param) { + var users, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, user; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + users = param.users; + _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; + _ctx.prev = 2; + _iterator = users[Symbol.iterator](); + case 4: + if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { + _ctx.next = 12; + break; + } + user = _step.value; + console.log("user", user); + _ctx.next = 9; + return new Promise(function(resolve) { + return setTimeout(resolve, 30); + }); + case 9: + _iteratorNormalCompletion = true; + _ctx.next = 4; + break; + case 12: + _ctx.next = 18; + break; + case 14: + _ctx.prev = 14; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 18: + _ctx.prev = 18; + _ctx.prev = 19; + if (!_iteratorNormalCompletion && _iterator.return != null) { + _iterator.return(); + } + case 21: + _ctx.prev = 21; + if (!_didIteratorError) { + _ctx.next = 24; + break; + } + throw _iteratorError; + case 24: + return _ctx.finish(21); + case 25: + return _ctx.finish(18); + case 26: + case "end": + return _ctx.stop(); + } + }, _callee, null, [ + [ + 2, + 14, + 18, + 26 + ], + [ + 19, + , + 21, + 25 + ] + ]); + })); + return function(_) { + return _ref.apply(this, arguments); + }; + }())); + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _scanUser.apply(this, arguments); } scanUser([ diff --git a/crates/swc/tests/fixture/issues-1xxx/1721/case1/async-generator/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1721/case1/async-generator/output/index.js index fdf41c8f4f7..5290e69b4ef 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1721/case1/async-generator/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1721/case1/async-generator/output/index.js @@ -1,30 +1,23 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function lol() { return _lol.apply(this, arguments); } function _lol() { - _lol = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _lol = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 4, - 2 - ]; + _ctx.next = 2; + return 1; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return 2; + case 4: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _lol.apply(this, arguments); } diff --git a/crates/swc/tests/fixture/issues-1xxx/1721/case1/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1721/case1/output/index.js index 4818a3b6569..1285e095d26 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1721/case1/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1721/case1/output/index.js @@ -1,129 +1,104 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function lol() { return _lol.apply(this, arguments); } function _lol() { - _lol = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _lol = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 4, - 2 - ]; + _ctx.next = 2; + return 1; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return 2; + case 4: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _lol.apply(this, arguments); } function main() { return _main.apply(this, arguments); } function _main() { - _main = _async_to_generator(function() { - var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _main = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 1; _iterator = _async_iterator(lol()); - _state.label = 2; - case 2: - return [ - 4, - _iterator.next() - ]; case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - x = _value; - console.log(x); - _state.label = 4; - case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; + _ctx.next = 5; + return _iterator.next(); case 5: - return [ - 3, - 12 - ]; - case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; - case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; - case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; - case 10: - if (_didIteratorError) { - throw _iteratorError; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 10; + break; } - return [ - 7 - ]; - case 11: - return [ - 7 - ]; + { + _value = _step.value; + x = _value; + console.log(x); + } + case 7: + _iteratorAbruptCompletion = false; + _ctx.next = 3; + break; + case 10: + _ctx.next = 16; + break; case 12: - return [ - 2 - ]; + _ctx.prev = 12; + _ctx.t0 = _ctx["catch"](1); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 16: + _ctx.prev = 16; + _ctx.prev = 17; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 21; + break; + } + _ctx.next = 21; + return _iterator.return(); + case 21: + _ctx.prev = 21; + if (!_didIteratorError) { + _ctx.next = 24; + break; + } + throw _iteratorError; + case 24: + return _ctx.finish(21); + case 25: + return _ctx.finish(16); + case 26: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 1, + 12, + 16, + 26 + ], + [ + 17, + , + 21, + 25 + ] + ]); + })); return _main.apply(this, arguments); } main(); diff --git a/crates/swc/tests/fixture/issues-1xxx/1722/case1/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1722/case1/output/index.js index f97ff32dfe9..b3ed32f9d5b 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1722/case1/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1722/case1/output/index.js @@ -1,14 +1,17 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; (function() { - var _main = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - console.log(1); - return [ - 2 - ]; - }); - }); + var _main = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + console.log(1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); function main() { return _main.apply(this, arguments); } diff --git a/crates/swc/tests/fixture/issues-1xxx/1799/case1/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1799/case1/output/index.js index 58bada892db..87066e60150 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1799/case1/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1799/case1/output/index.js @@ -10,26 +10,22 @@ Object.defineProperty(exports, "default", { }); var _asyncToGenerator = require("@swc/helpers/lib/_async_to_generator.js").default; var _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default; -var _tsGenerator = require("@swc/helpers/lib/_ts_generator.js").default; +var _regeneratorRuntime = /*#__PURE__*/ _interopRequireDefault(require("regenerator-runtime")); var _react = /*#__PURE__*/ _interopRequireDefault(require("react")); function Foo() { return /*#__PURE__*/ _react.default.createElement("div", { - onClick: /*#__PURE__*/ _asyncToGenerator(function(e) { - return _tsGenerator(this, function(_state) { - switch(_state.label){ + onClick: /*#__PURE__*/ _asyncToGenerator(/*#__PURE__*/ _regeneratorRuntime.default.mark(function _callee(e) { + return _regeneratorRuntime.default.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - doSomething() - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return doSomething(); + case 2: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }); } Foo.displayName = "Foo"; diff --git a/crates/swc/tests/fixture/issues-1xxx/1799/case6-no-jsx/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1799/case6-no-jsx/output/index.js index 1c22673901c..a957c1c6ca4 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1799/case6-no-jsx/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1799/case6-no-jsx/output/index.js @@ -10,24 +10,20 @@ Object.defineProperty(exports, "default", { }); var _asyncToGenerator = require("@swc/helpers/lib/_async_to_generator.js").default; var _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default; -var _tsGenerator = require("@swc/helpers/lib/_ts_generator.js").default; +var _regeneratorRuntime = /*#__PURE__*/ _interopRequireDefault(require("regenerator-runtime")); var _react = /*#__PURE__*/ _interopRequireDefault(require("react")); function Foo() { - return call(/*#__PURE__*/ _asyncToGenerator(function(e) { - return _tsGenerator(this, function(_state) { - switch(_state.label){ + return call(/*#__PURE__*/ _asyncToGenerator(/*#__PURE__*/ _regeneratorRuntime.default.mark(function _callee(e) { + return _regeneratorRuntime.default.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - doSomething() - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return doSomething(); + case 2: + case "end": + return _ctx.stop(); } - }); - })); + }, _callee); + }))); } Foo.displayName = "Foo"; diff --git a/crates/swc/tests/fixture/issues-1xxx/1918/es5-after-other/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1918/es5-after-other/output/index.js index e24c9809801..4773c5b0a52 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1918/es5-after-other/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1918/es5-after-other/output/index.js @@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); var _defineProperty = require("@swc/helpers/lib/_define_property.js").default; -var _tsGenerator = require("@swc/helpers/lib/_ts_generator.js").default; +var _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default; +var _regeneratorRuntime = /*#__PURE__*/ _interopRequireDefault(require("regenerator-runtime")); function _asyncIterator(iterable) { var method; if (typeof Symbol === "function") { @@ -47,159 +48,137 @@ function _asyncToGenerator(fn) { }); }; } -_asyncToGenerator(function() { - var counter, resolve, promise, iterable, _tmp, res, _i, _iter, v, oldresolve, _tmp1, _tmp2; - return _tsGenerator(this, function(_state) { - switch(_state.label){ +_asyncToGenerator(/*#__PURE__*/ _regeneratorRuntime.default.mark(function _callee() { + var counter, resolve, promise, iterable, res, _i, _iter, v, oldresolve; + return _regeneratorRuntime.default.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: counter = 0; + ; promise = new Promise(function(r) { return resolve = r; }); - _tmp = {}; - iterable = _defineProperty(_tmp, Symbol.asyncIterator, function() { + iterable = _defineProperty({}, Symbol.asyncIterator, function() { return { next: function next() { return promise; } }; }); - res = _asyncToGenerator(function() { - var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value, err; - return _tsGenerator(this, function(_state) { - switch(_state.label){ + res = _asyncToGenerator(/*#__PURE__*/ _regeneratorRuntime.default.mark(function _callee() { + var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value; + return _regeneratorRuntime.default.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 1; _iterator = _asyncIterator(iterable); - _state.label = 2; - case 2: - return [ - 4, - _iterator.next() - ]; case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - value = _value; - counter++; - console.log(value); - _state.label = 4; - case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; + _ctx.next = 5; + return _iterator.next(); case 5: - return [ - 3, - 12 - ]; - case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 10; + break; + } + { + _value = _step.value; + value = _value; + counter++; + console.log(value); + } case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iteratorError.return() - ]; - case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; + _iteratorAbruptCompletion = false; + _ctx.next = 3; + break; case 10: - if (_didIteratorError) { - throw _iteratorError; - } - return [ - 7 - ]; - case 11: - return [ - 7 - ]; + _ctx.next = 16; + break; case 12: - if (counter !== 2) { - throw new Error(""); + _ctx.prev = 12; + _ctx.t0 = _ctx["catch"](1); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 16: + _ctx.prev = 16; + _ctx.prev = 17; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 21; + break; } - return [ - 2 - ]; + _ctx.next = 21; + return _iteratorError.return(); + case 21: + _ctx.prev = 21; + if (!_didIteratorError) { + _ctx.next = 24; + break; + } + throw _iteratorError; + case 24: + return _ctx.finish(21); + case 25: + return _ctx.finish(16); + case 26: + if (!(counter !== 2)) { + _ctx.next = 28; + break; + } + throw new Error(""); + case 28: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee, null, [ + [ + 1, + 12, + 16, + 26 + ], + [ + 17, + , + 21, + 25 + ] + ]); + }))(); _i = 0, _iter = [ 0, 1 ]; - _state.label = 1; - case 1: - if (!(_i < _iter.length)) return [ - 3, - 4 - ]; + case 6: + if (!(_i < _iter.length)) { + _ctx.next = 16; + break; + } v = _iter[_i]; - return [ - 4, - null - ]; - case 2: - _state.sent(); + _ctx.next = 10; + return null; + case 10: oldresolve = resolve; promise = new Promise(function(r) { return resolve = r; }); - _tmp1 = {}; - oldresolve((_tmp1.value = v, _tmp1.done = false, _tmp1)); - _state.label = 3; - case 3: + oldresolve({ + value: v, + done: false + }); + case 13: _i++; - return [ - 3, - 1 - ]; - case 4: - _tmp2 = {}; - resolve((_tmp2.value = undefined, _tmp2.done = true, _tmp2)); - return [ - 4, - res - ]; - case 5: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 6; + break; + case 16: + resolve({ + value: undefined, + done: true + }); + _ctx.next = 19; + return res; + case 19: + case "end": + return _ctx.stop(); } - }); -})(); + }, _callee); +}))(); diff --git a/crates/swc/tests/fixture/issues-1xxx/1918/es5/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1918/es5/output/index.js index 605622ddc7d..84fe8b88a56 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1918/es5/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1918/es5/output/index.js @@ -5,160 +5,139 @@ Object.defineProperty(exports, "__esModule", { var _asyncIterator = require("@swc/helpers/lib/_async_iterator.js").default; var _asyncToGenerator = require("@swc/helpers/lib/_async_to_generator.js").default; var _defineProperty = require("@swc/helpers/lib/_define_property.js").default; -var _tsGenerator = require("@swc/helpers/lib/_ts_generator.js").default; -_asyncToGenerator(function() { - var counter, resolve, promise, iterable, _tmp, res, _i, _iter, v, oldresolve, _tmp1, _tmp2; - return _tsGenerator(this, function(_state) { - switch(_state.label){ +var _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default; +var _regeneratorRuntime = /*#__PURE__*/ _interopRequireDefault(require("regenerator-runtime")); +_asyncToGenerator(/*#__PURE__*/ _regeneratorRuntime.default.mark(function _callee() { + var counter, resolve, promise, iterable, res, _i, _iter, v, oldresolve; + return _regeneratorRuntime.default.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: counter = 0; + ; promise = new Promise(function(r) { return resolve = r; }); - _tmp = {}; - iterable = _defineProperty(_tmp, Symbol.asyncIterator, function() { + iterable = _defineProperty({}, Symbol.asyncIterator, function() { return { next: function next() { return promise; } }; }); - res = _asyncToGenerator(function() { - var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value, err; - return _tsGenerator(this, function(_state) { - switch(_state.label){ + res = _asyncToGenerator(/*#__PURE__*/ _regeneratorRuntime.default.mark(function _callee() { + var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value; + return _regeneratorRuntime.default.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 1; _iterator = _asyncIterator(iterable); - _state.label = 2; - case 2: - return [ - 4, - _iterator.next() - ]; case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - value = _value; - counter++; - console.log(value); - _state.label = 4; - case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; + _ctx.next = 5; + return _iterator.next(); case 5: - return [ - 3, - 12 - ]; - case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 10; + break; + } + { + _value = _step.value; + value = _value; + counter++; + console.log(value); + } case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; - case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; + _iteratorAbruptCompletion = false; + _ctx.next = 3; + break; case 10: - if (_didIteratorError) { - throw _iteratorError; - } - return [ - 7 - ]; - case 11: - return [ - 7 - ]; + _ctx.next = 16; + break; case 12: - if (counter !== 2) { - throw new Error(""); + _ctx.prev = 12; + _ctx.t0 = _ctx["catch"](1); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 16: + _ctx.prev = 16; + _ctx.prev = 17; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 21; + break; } - return [ - 2 - ]; + _ctx.next = 21; + return _iterator.return(); + case 21: + _ctx.prev = 21; + if (!_didIteratorError) { + _ctx.next = 24; + break; + } + throw _iteratorError; + case 24: + return _ctx.finish(21); + case 25: + return _ctx.finish(16); + case 26: + if (!(counter !== 2)) { + _ctx.next = 28; + break; + } + throw new Error(""); + case 28: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee, null, [ + [ + 1, + 12, + 16, + 26 + ], + [ + 17, + , + 21, + 25 + ] + ]); + }))(); _i = 0, _iter = [ 0, 1 ]; - _state.label = 1; - case 1: - if (!(_i < _iter.length)) return [ - 3, - 4 - ]; + case 6: + if (!(_i < _iter.length)) { + _ctx.next = 16; + break; + } v = _iter[_i]; - return [ - 4, - null - ]; - case 2: - _state.sent(); + _ctx.next = 10; + return null; + case 10: oldresolve = resolve; promise = new Promise(function(r) { return resolve = r; }); - _tmp1 = {}; - oldresolve((_tmp1.value = v, _tmp1.done = false, _tmp1)); - _state.label = 3; - case 3: + oldresolve({ + value: v, + done: false + }); + case 13: _i++; - return [ - 3, - 1 - ]; - case 4: - _tmp2 = {}; - resolve((_tmp2.value = undefined, _tmp2.done = true, _tmp2)); - return [ - 4, - res - ]; - case 5: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 6; + break; + case 16: + resolve({ + value: undefined, + done: true + }); + _ctx.next = 19; + return res; + case 19: + case "end": + return _ctx.stop(); } - }); -})(); + }, _callee); +}))(); diff --git a/crates/swc/tests/fixture/issues-1xxx/1924/case1/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1924/case1/output/index.js index 251aa6a94c6..a617e8b3ebc 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1924/case1/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1924/case1/output/index.js @@ -2,11 +2,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _tsGenerator = require("@swc/helpers/lib/_ts_generator.js").default; +var _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default; +var _regeneratorRuntime = /*#__PURE__*/ _interopRequireDefault(require("regenerator-runtime")); +var _marked = /*#__PURE__*/ _regeneratorRuntime.default.mark(foo); function foo() { - return _tsGenerator(this, function(_state) { - return [ - 2 - ]; - }); + return _regeneratorRuntime.default.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/fixture/issues-2xxx/2024/full/output/index.js b/crates/swc/tests/fixture/issues-2xxx/2024/full/output/index.js index 3b4a8b871dd..cdff570579b 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2024/full/output/index.js +++ b/crates/swc/tests/fixture/issues-2xxx/2024/full/output/index.js @@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); var _asyncToGenerator = require("@swc/helpers/lib/_async_to_generator.js").default; -var _tsGenerator = require("@swc/helpers/lib/_ts_generator.js").default; -_asyncToGenerator(function() { +var _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default; +var _regeneratorRuntime = /*#__PURE__*/ _interopRequireDefault(require("regenerator-runtime")); +_asyncToGenerator(/*#__PURE__*/ _regeneratorRuntime.default.mark(function _callee() { var sleep, result; - return _tsGenerator(this, function(_state) { - switch(_state.label){ + return _regeneratorRuntime.default.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: sleep = function() { return new Promise(function(resolve) { @@ -16,16 +17,21 @@ _asyncToGenerator(function() { }, 500); }); }; - return [ - 4, - sleep() - ]; - case 1: - result = _state.sent() || "fallback"; + _ctx.next = 3; + return sleep(); + case 3: + _ctx.t0 = _ctx.sent; + if (_ctx.t0) { + _ctx.next = 6; + break; + } + _ctx.t0 = "fallback"; + case 6: + result = _ctx.t0; console.log(result); - return [ - 2 - ]; + case 8: + case "end": + return _ctx.stop(); } - }); -})(); + }, _callee); +}))(); diff --git a/crates/swc/tests/fixture/issues-2xxx/2024/no-module/output/index.js b/crates/swc/tests/fixture/issues-2xxx/2024/no-module/output/index.js index 10ff471375a..537484e772d 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2024/no-module/output/index.js +++ b/crates/swc/tests/fixture/issues-2xxx/2024/no-module/output/index.js @@ -1,9 +1,9 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -_async_to_generator(function() { +import regeneratorRuntime from "regenerator-runtime"; +_async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var sleep, result; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: sleep = function() { return new Promise(function(resolve) { @@ -12,16 +12,21 @@ _async_to_generator(function() { }, 500); }); }; - return [ - 4, - sleep() - ]; - case 1: - result = _state.sent() || "fallback"; + _ctx.next = 3; + return sleep(); + case 3: + _ctx.t0 = _ctx.sent; + if (_ctx.t0) { + _ctx.next = 6; + break; + } + _ctx.t0 = "fallback"; + case 6: + result = _ctx.t0; console.log(result); - return [ - 2 - ]; + case 8: + case "end": + return _ctx.stop(); } - }); -})(); + }, _callee); +}))(); diff --git a/crates/swc/tests/fixture/issues-2xxx/2164/es5/output/index.js b/crates/swc/tests/fixture/issues-2xxx/2164/es5/output/index.js index c1734d7c47a..1521221edf6 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2164/es5/output/index.js +++ b/crates/swc/tests/fixture/issues-2xxx/2164/es5/output/index.js @@ -1,18 +1,20 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { - var key, _tmp; - return _ts_generator(this, function(_state) { - _tmp = {}; - for(var key in _tmp); - return [ - 2 - ]; - }); - }); + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var key; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + for(key in {}); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn.apply(this, arguments); } diff --git a/crates/swc/tests/fixture/issues-2xxx/2232/case1/output/index.js b/crates/swc/tests/fixture/issues-2xxx/2232/case1/output/index.js index 617c6a218af..655334f061f 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2232/case1/output/index.js +++ b/crates/swc/tests/fixture/issues-2xxx/2232/case1/output/index.js @@ -2,7 +2,7 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _create_class from "@swc/helpers/src/_create_class.mjs"; import _object_without_properties from "@swc/helpers/src/_object_without_properties.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var Foo = /*#__PURE__*/ function() { "use strict"; function Foo() { @@ -12,18 +12,21 @@ var Foo = /*#__PURE__*/ function() { { key: "sendSomeMessage", value: function sendSomeMessage(_parent, _param, _param1) { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var _input, toNumber, messageBody, all, dataSources; - return _ts_generator(this, function(_state) { - _input = _param.input, toNumber = _input.toNumber, messageBody = _input.messageBody, all = _object_without_properties(_param.input, [ - "toNumber", - "messageBody" - ]), dataSources = _param1.dataSources; - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _input = _param.input, toNumber = _input.toNumber, messageBody = _input.messageBody, all = _object_without_properties(_param.input, [ + "toNumber", + "messageBody" + ]), dataSources = _param1.dataSources; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } } ]); diff --git a/crates/swc/tests/fixture/issues-2xxx/2232/case2/output/index.ts b/crates/swc/tests/fixture/issues-2xxx/2232/case2/output/index.ts index f4241398b4c..7a0345e20c2 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2232/case2/output/index.ts +++ b/crates/swc/tests/fixture/issues-2xxx/2232/case2/output/index.ts @@ -1,20 +1,23 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _object_without_properties from "@swc/helpers/src/_object_without_properties.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var resolver = { sendSomeMessage: function sendSomeMessage(_parent, _param, _param1) { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var _input, toNumber, messageBody, all, dataSources; - return _ts_generator(this, function(_state) { - _input = _param.input, toNumber = _input.toNumber, messageBody = _input.messageBody, all = _object_without_properties(_param.input, [ - "toNumber", - "messageBody" - ]), dataSources = _param1.dataSources; - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _input = _param.input, toNumber = _input.toNumber, messageBody = _input.messageBody, all = _object_without_properties(_param.input, [ + "toNumber", + "messageBody" + ]), dataSources = _param1.dataSources; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; export default resolver; diff --git a/crates/swc/tests/fixture/issues-2xxx/2248/es5/output/index.js b/crates/swc/tests/fixture/issues-2xxx/2248/es5/output/index.js index 8feb2306fe7..d88217e93d1 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2248/es5/output/index.js +++ b/crates/swc/tests/fixture/issues-2xxx/2248/es5/output/index.js @@ -1,18 +1,21 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export var foo = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - try { - console.log(1); - } catch (err) { - console.log(err.message); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + try { + console.log(1); + } catch (err) { + console.log(err.message); + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return function foo() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/fixture/issues-2xxx/2413/1/output/index.js b/crates/swc/tests/fixture/issues-2xxx/2413/1/output/index.js index 1b4d87dc1f5..4ba66269c4c 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2413/1/output/index.js +++ b/crates/swc/tests/fixture/issues-2xxx/2413/1/output/index.js @@ -1,43 +1,36 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -var handleSubmit = useMutation(/*#__PURE__*/ _async_to_generator(function() { - var res, _tmp, param, errors; - return _ts_generator(this, function(_state) { - switch(_state.label){ +import regeneratorRuntime from "regenerator-runtime"; +var handleSubmit = useMutation(/*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var res, errors; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _state.trys.push([ - 0, - 2, - , - 3 - ]); - _tmp = {}; - return [ - 4, - gate.register((_tmp.username = phoneNumber, _tmp)) - ]; - case 1: - res = _state.sent(); + _ctx.prev = 0; + _ctx.next = 3; + return gate.register({ + username: phoneNumber + }); + case 3: + res = _ctx.sent; setstep(function(prev) { return prev + 1; }); toast.success(res.message); - return [ - 3, - 3 - ]; - case 2: - param = _state.sent(); - errors = param.data.errors; + _ctx.next = 12; + break; + case 8: + _ctx.prev = 8; + _ctx.t0 = _ctx["catch"](0); + errors = _ctx.t0.data.errors; showErrorMessage(errors); - return [ - 3, - 3 - ]; - case 3: - return [ - 2 - ]; + case 12: + case "end": + return _ctx.stop(); } - }); -})); + }, _callee, null, [ + [ + 0, + 8 + ] + ]); +}))); diff --git a/crates/swc/tests/fixture/issues-2xxx/2717/output/index.ts b/crates/swc/tests/fixture/issues-2xxx/2717/output/index.ts index 2d1dd2fc74d..a1bd8a2434f 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2717/output/index.ts +++ b/crates/swc/tests/fixture/issues-2xxx/2717/output/index.ts @@ -1,41 +1,40 @@ -import e from "@swc/helpers/src/_ts_generator.mjs"; -import { takeLatest as t, select as r } from "redux-saga/effects"; -import { CHANGE_THEME as o, CHANGE_THEME_CUSTOM_PALETTE as s, CHANGE_THEME_SWITCH_MODE as n } from "core/actions/changeTheme"; +import e from "regenerator-runtime"; +var t = e.mark(saveTheme); +import { takeLatest as r, select as o } from "redux-saga/effects"; +import { CHANGE_THEME as s, CHANGE_THEME_CUSTOM_PALETTE as a, CHANGE_THEME_SWITCH_MODE as n } from "core/actions/changeTheme"; export var selectThemeObject = function(e) { return e.theme; }; -export function saveTheme(t) { - var o, s, c, m; - return e(this, function(e) { - switch(e.label){ +export function saveTheme(r) { + var s, a, c; + return e.wrap(function(e) { + for(;;)switch(e.prev = e.next){ case 0: - return o = t.type, [ - 4, - r(selectThemeObject) - ]; - case 1: - return s = e.sent(), c = {}, window.localStorage.setItem("theme", JSON.stringify((c.theme = s.theme, c.mode = s.mode, c.palette = s.palette, c))), o === n && (m = window.document.querySelector("body")) && (m.classList.add("light" === s.mode ? "light" : "dark"), m.classList.remove("light" === s.mode ? "dark" : "light")), [ - 2 - ]; + return s = r.type, e.next = 3, o(selectThemeObject); + case 3: + a = e.sent, window.localStorage.setItem("theme", JSON.stringify({ + theme: a.theme, + mode: a.mode, + palette: a.palette + })), s === n && (c = window.document.querySelector("body")) && (c.classList.add("light" === a.mode ? "light" : "dark"), c.classList.remove("light" === a.mode ? "dark" : "light")); + case 6: + case "end": + return e.stop(); } - }); + }, t); } export default function c() { - return e(this, function(e) { - switch(e.label){ + return e.wrap(function(e) { + for(;;)switch(e.prev = e.next){ case 0: - return [ - 4, - t([ - o, - s, - n - ], saveTheme) - ]; - case 1: - return e.sent(), [ - 2 - ]; + return e.next = 2, r([ + s, + a, + n + ], saveTheme); + case 2: + case "end": + return e.stop(); } - }); + }, c); }; diff --git a/crates/swc/tests/fixture/issues-4xxx/4108/1/output/index.ts b/crates/swc/tests/fixture/issues-4xxx/4108/1/output/index.ts index 1c4319fe766..7711a6ce863 100644 --- a/crates/swc/tests/fixture/issues-4xxx/4108/1/output/index.ts +++ b/crates/swc/tests/fixture/issues-4xxx/4108/1/output/index.ts @@ -1,28 +1,22 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _instanceof from "@swc/helpers/src/_instanceof.mjs"; import _to_consumable_array from "@swc/helpers/src/_to_consumable_array.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import { Transaction } from "@solana/web3.js"; import { WalletNotConnectedError } from "@solana/wallet-adapter-base"; export var getErrorForTransaction = function() { - var _ref = _async_to_generator(function(connection, txid) { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(connection, txid) { var tx, errors; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - // wait for all confirmation before geting transaction - return [ - 4, - connection.confirmTransaction(txid, "max") - ]; - case 1: - _state.sent(); - return [ - 4, - connection.getParsedConfirmedTransaction(txid) - ]; + _ctx.next = 2; + return connection.confirmTransaction(txid, "max"); case 2: - tx = _state.sent(); + _ctx.next = 4; + return connection.getParsedConfirmedTransaction(txid); + case 4: + tx = _ctx.sent; errors = []; if ((tx === null || tx === void 0 ? void 0 : tx.meta) && tx.meta.logMessages) { tx.meta.logMessages.forEach(function(log) { @@ -39,13 +33,13 @@ export var getErrorForTransaction = function() { } }); } - return [ - 2, - errors - ]; + return _ctx.abrupt("return", errors); + case 8: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function getErrorForTransaction(connection, txid) { return _ref.apply(this, arguments); }; @@ -60,16 +54,15 @@ export function sendTransactionsWithManualRetry(connection, wallet, instructions return _sendTransactionsWithManualRetry.apply(this, arguments); } function _sendTransactionsWithManualRetry() { - _sendTransactionsWithManualRetry = _async_to_generator(function(connection, wallet, instructions, signers) { - var stopPoint, tries, lastInstructionsLength, toRemoveSigners, _tmp, ids, filteredSigners, id, txs, e; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _sendTransactionsWithManualRetry = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(connection, wallet, instructions, signers) { + var stopPoint, tries, lastInstructionsLength, toRemoveSigners, ids, filteredSigners, id, txs; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: stopPoint = 0; tries = 0; lastInstructionsLength = null; - _tmp = {}; - toRemoveSigners = _tmp; + toRemoveSigners = {}; instructions = instructions.filter(function(instr, i) { if (instr.length > 0) { return true; @@ -82,86 +75,68 @@ function _sendTransactionsWithManualRetry() { filteredSigners = signers.filter(function(_, i) { return !toRemoveSigners[i]; }); - _state.label = 1; - case 1: - if (!(stopPoint < instructions.length && tries < 3)) return [ - 3, - 9 - ]; + case 7: + if (!(stopPoint < instructions.length && tries < 3)) { + _ctx.next = 33; + break; + } instructions = instructions.slice(stopPoint, instructions.length); filteredSigners = filteredSigners.slice(stopPoint, filteredSigners.length); if (instructions.length === lastInstructionsLength) tries = tries + 1; else tries = 0; - _state.label = 2; - case 2: - _state.trys.push([ - 2, - 7, - , - 8 - ]); - if (!(instructions.length === 1)) return [ - 3, - 4 - ]; - return [ - 4, - sendTransactionWithRetry(connection, wallet, instructions[0], filteredSigners[0], "single") - ]; - case 3: - id = _state.sent(); + _ctx.prev = 11; + if (!(instructions.length === 1)) { + _ctx.next = 20; + break; + } + _ctx.next = 15; + return sendTransactionWithRetry(connection, wallet, instructions[0], filteredSigners[0], "single"); + case 15: + id = _ctx.sent; ids.push(id.txid); stopPoint = 1; - return [ - 3, - 6 - ]; - case 4: - return [ - 4, - sendTransactions(connection, wallet, instructions, filteredSigners, SequenceType.StopOnFailure, "single") - ]; - case 5: - txs = _state.sent().txs; + _ctx.next = 24; + break; + case 20: + _ctx.next = 22; + return sendTransactions(connection, wallet, instructions, filteredSigners, SequenceType.StopOnFailure, "single"); + case 22: + txs = _ctx.sent.txs; ids = ids.concat(txs.map(function(t) { return t.txid; })); - _state.label = 6; - case 6: - return [ - 3, - 8 - ]; - case 7: - e = _state.sent(); - console.error(e); - return [ - 3, - 8 - ]; - case 8: + case 24: + _ctx.next = 29; + break; + case 26: + _ctx.prev = 26; + _ctx.t0 = _ctx["catch"](11); + console.error(_ctx.t0); + case 29: console.log("Died on ", stopPoint, "retrying from instruction", instructions[stopPoint], "instructions length is", instructions.length); lastInstructionsLength = instructions.length; - return [ - 3, - 1 - ]; - case 9: - return [ - 2, - ids - ]; + _ctx.next = 7; + break; + case 33: + return _ctx.abrupt("return", ids); + case 34: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 11, + 26 + ] + ]); + })); return _sendTransactionsWithManualRetry.apply(this, arguments); } export var sendTransactions = function() { - var _ref = _async_to_generator(function(connection, wallet, instructionSet, signersSet) { - var _loop, sequenceType, commitment, successCallback, failCallback, block, beforeTransactions, afterTransactions, _unsignedTxns, unsignedTxns, i, partiallySignedTransactions, fullySignedTransactions, signedTxns, pendingTxns, i1, signedTxnPromise, _tmp, e, _tmp1, result, _tmp2, _tmp3; - var _arguments = arguments; - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(connection, wallet, instructionSet, signersSet) { + var _loop, sequenceType, commitment, successCallback, failCallback, block, beforeTransactions, afterTransactions, _unsignedTxns, unsignedTxns, i, partiallySignedTransactions, fullySignedTransactions, signedTxns, pendingTxns, i1, signedTxnPromise, result, _args = arguments; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: _loop = function(i) { var _transaction; @@ -187,23 +162,26 @@ export var sendTransactions = function() { } unsignedTxns.push(transaction); }; - sequenceType = _arguments.length > 4 && _arguments[4] !== void 0 ? _arguments[4] : SequenceType.Parallel, commitment = _arguments.length > 5 && _arguments[5] !== void 0 ? _arguments[5] : "singleGossip", successCallback = _arguments.length > 6 && _arguments[6] !== void 0 ? _arguments[6] : function(txid, ind) {}, failCallback = _arguments.length > 7 && _arguments[7] !== void 0 ? _arguments[7] : function(txid, ind) { + sequenceType = _args.length > 4 && _args[4] !== void 0 ? _args[4] : SequenceType.Parallel, commitment = _args.length > 5 && _args[5] !== void 0 ? _args[5] : "singleGossip", successCallback = _args.length > 6 && _args[6] !== void 0 ? _args[6] : function(txid, ind) {}, failCallback = _args.length > 7 && _args[7] !== void 0 ? _args[7] : function(txid, ind) { return false; - }, block = _arguments.length > 8 ? _arguments[8] : void 0, beforeTransactions = _arguments.length > 9 && _arguments[9] !== void 0 ? _arguments[9] : [], afterTransactions = _arguments.length > 10 && _arguments[10] !== void 0 ? _arguments[10] : []; - if (!wallet.publicKey) throw new WalletNotConnectedError(); + }, block = _args.length > 8 ? _args[8] : void 0, beforeTransactions = _args.length > 9 && _args[9] !== void 0 ? _args[9] : [], afterTransactions = _args.length > 10 && _args[10] !== void 0 ? _args[10] : []; + ; + if (wallet.publicKey) { + _ctx.next = 5; + break; + } + throw new WalletNotConnectedError(); + case 5: unsignedTxns = beforeTransactions; - if (!!block) return [ - 3, - 2 - ]; - return [ - 4, - connection.getRecentBlockhash(commitment) - ]; - case 1: - block = _state.sent(); - _state.label = 2; - case 2: + if (block) { + _ctx.next = 10; + break; + } + _ctx.next = 9; + return connection.getRecentBlockhash(commitment); + case 9: + block = _ctx.sent; + case 10: for(i = 0; i < instructionSet.length; i++)_loop(i); (_unsignedTxns = unsignedTxns).push.apply(_unsignedTxns, _to_consumable_array(afterTransactions)); partiallySignedTransactions = unsignedTxns.filter(function(t) { @@ -216,163 +194,144 @@ export var sendTransactions = function() { return sig.publicKey.equals(wallet.publicKey); }); }); - return [ - 4, - wallet.signAllTransactions(partiallySignedTransactions) - ]; - case 3: - signedTxns = _state.sent(); + _ctx.next = 16; + return wallet.signAllTransactions(partiallySignedTransactions); + case 16: + signedTxns = _ctx.sent; signedTxns = fullySignedTransactions.concat(signedTxns); pendingTxns = []; console.log("Signed txns length", signedTxns.length, "vs handed in length", instructionSet.length); i1 = 0; - _state.label = 4; - case 4: - if (!(i1 < signedTxns.length)) return [ - 3, - 13 - ]; - _tmp = {}; - signedTxnPromise = sendSignedTransaction((_tmp.connection = connection, _tmp.signedTransaction = signedTxns[i1], _tmp)); - if (!(sequenceType !== SequenceType.Parallel)) return [ - 3, - 11 - ]; - _state.label = 5; - case 5: - _state.trys.push([ - 5, - 7, - , - 10 - ]); - return [ - 4, - signedTxnPromise.then(function(param) { - var txid = param.txid, slot = param.slot; - return successCallback(txid, i1); - }) - ]; - case 6: - _state.sent(); + case 21: + if (!(i1 < signedTxns.length)) { + _ctx.next = 47; + break; + } + signedTxnPromise = sendSignedTransaction({ + connection: connection, + signedTransaction: signedTxns[i1] + }); + if (!(sequenceType !== SequenceType.Parallel)) { + _ctx.next = 43; + break; + } + _ctx.prev = 24; + _ctx.next = 27; + return signedTxnPromise.then(function(param) { + var txid = param.txid, slot = param.slot; + return successCallback(txid, i1); + }); + case 27: pendingTxns.push(signedTxnPromise); - return [ - 3, - 10 - ]; - case 7: - e = _state.sent(); + _ctx.next = 41; + break; + case 30: + _ctx.prev = 30; + _ctx.t0 = _ctx["catch"](24); console.log("Failed at txn index:", i1); - console.log("Caught failure:", e); + console.log("Caught failure:", _ctx.t0); failCallback(signedTxns[i1], i1); - if (!(sequenceType === SequenceType.StopOnFailure)) return [ - 3, - 9 - ]; - _tmp1 = { - number: i1 - }; - return [ - 4, - Promise.all(pendingTxns) - ]; - case 8: - return [ - 2, - (_tmp1.txs = _state.sent(), _tmp1) - ]; - case 9: - return [ - 3, - 10 - ]; - case 10: - return [ - 3, - 12 - ]; - case 11: - pendingTxns.push(signedTxnPromise); - _state.label = 12; - case 12: + if (!(sequenceType === SequenceType.StopOnFailure)) { + _ctx.next = 41; + break; + } + _ctx.t1 = i1; + _ctx.next = 39; + return Promise.all(pendingTxns); + case 39: + _ctx.t2 = _ctx.sent; + return _ctx.abrupt("return", { + number: _ctx.t1, + txs: _ctx.t2 + }); + case 41: + _ctx.next = 44; + break; + case 43: + { + pendingTxns.push(signedTxnPromise); + } + case 44: i1++; - return [ - 3, - 4 - ]; - case 13: - if (!(sequenceType !== SequenceType.Parallel)) return [ - 3, - 15 - ]; - return [ - 4, - Promise.all(pendingTxns) - ]; - case 14: - result = _state.sent(); - _tmp2 = {}; - return [ - 2, - (_tmp2.number = signedTxns.length, _tmp2.txs = result, _tmp2) - ]; - case 15: - _tmp3 = { - number: signedTxns.length - }; - return [ - 4, - Promise.all(pendingTxns) - ]; - case 16: - return [ - 2, - (_tmp3.txs = _state.sent(), _tmp3) - ]; + _ctx.next = 21; + break; + case 47: + if (!(sequenceType !== SequenceType.Parallel)) { + _ctx.next = 52; + break; + } + _ctx.next = 50; + return Promise.all(pendingTxns); + case 50: + result = _ctx.sent; + return _ctx.abrupt("return", { + number: signedTxns.length, + txs: result + }); + case 52: + _ctx.t3 = signedTxns.length; + _ctx.next = 55; + return Promise.all(pendingTxns); + case 55: + _ctx.t4 = _ctx.sent; + return _ctx.abrupt("return", { + number: _ctx.t3, + txs: _ctx.t4 + }); + case 57: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 24, + 30 + ] + ]); + })); return function sendTransactions(connection, wallet, instructionSet, signersSet) { return _ref.apply(this, arguments); }; }(); export var sendTransaction = function() { - var _ref = _async_to_generator(function(connection, wallet, instructions, signers) { - var awaitConfirmation, commitment, includesFeePayer, block, transaction, _tmp, _transaction, _transaction1, _transaction2, rawTransaction, options, _tmp1, txid, slot, confirmation, errors, _tmp2; - var _arguments = arguments; - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(connection, wallet, instructions, signers) { + var awaitConfirmation, commitment, includesFeePayer, block, transaction, _transaction, _transaction1, _transaction2, rawTransaction, options, txid, slot, confirmation, errors, _args = arguments; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - awaitConfirmation = _arguments.length > 4 && _arguments[4] !== void 0 ? _arguments[4] : true, commitment = _arguments.length > 5 && _arguments[5] !== void 0 ? _arguments[5] : "singleGossip", includesFeePayer = _arguments.length > 6 && _arguments[6] !== void 0 ? _arguments[6] : false, block = _arguments.length > 7 ? _arguments[7] : void 0; - if (!wallet.publicKey) throw new WalletNotConnectedError(); - if (!_instanceof(instructions, Transaction)) return [ - 3, - 1 - ]; - transaction = instructions; - return [ - 3, - 5 - ]; - case 1: + awaitConfirmation = _args.length > 4 && _args[4] !== void 0 ? _args[4] : true, commitment = _args.length > 5 && _args[5] !== void 0 ? _args[5] : "singleGossip", includesFeePayer = _args.length > 6 && _args[6] !== void 0 ? _args[6] : false, block = _args.length > 7 ? _args[7] : void 0; + if (wallet.publicKey) { + _ctx.next = 3; + break; + } + throw new WalletNotConnectedError(); + case 3: + ; + if (!_instanceof(instructions, Transaction)) { + _ctx.next = 8; + break; + } + { + transaction = instructions; + } + _ctx.next = 22; + break; + case 8: transaction = new Transaction(); instructions.forEach(function(instruction) { return transaction.add(instruction); }); - _tmp = block; - if (_tmp) return [ - 3, - 3 - ]; - return [ - 4, - connection.getRecentBlockhash(commitment) - ]; - case 2: - _tmp = _state.sent(); - _state.label = 3; - case 3: - transaction.recentBlockhash = _tmp.blockhash; + _ctx.t0 = block; + if (_ctx.t0) { + _ctx.next = 15; + break; + } + _ctx.next = 14; + return connection.getRecentBlockhash(commitment); + case 14: + _ctx.t0 = _ctx.sent; + case 15: + transaction.recentBlockhash = _ctx.t0.blockhash; if (includesFeePayer) { ; (_transaction = transaction).setSigners.apply(_transaction, _to_consumable_array(signers.map(function(s) { @@ -391,92 +350,93 @@ export var sendTransaction = function() { ; (_transaction2 = transaction).partialSign.apply(_transaction2, _to_consumable_array(signers)); } - if (!!includesFeePayer) return [ - 3, - 5 - ]; - return [ - 4, - wallet.signTransaction(transaction) - ]; - case 4: - transaction = _state.sent(); - _state.label = 5; - case 5: + if (includesFeePayer) { + _ctx.next = 22; + break; + } + _ctx.next = 21; + return wallet.signTransaction(transaction); + case 21: + transaction = _ctx.sent; + case 22: rawTransaction = transaction.serialize(); - _tmp1 = {}; - options = (_tmp1.skipPreflight = true, _tmp1.commitment = commitment, _tmp1); - return [ - 4, - connection.sendRawTransaction(rawTransaction, options) - ]; - case 6: - txid = _state.sent(); + options = { + skipPreflight: true, + commitment: commitment + }; + _ctx.next = 26; + return connection.sendRawTransaction(rawTransaction, options); + case 26: + txid = _ctx.sent; slot = 0; - if (!awaitConfirmation) return [ - 3, - 9 - ]; - return [ - 4, - awaitTransactionSignatureConfirmation(txid, DEFAULT_TIMEOUT, connection, commitment) - ]; - case 7: - confirmation = _state.sent(); - if (!confirmation) throw new Error("Timed out awaiting confirmation on transaction"); + if (!awaitConfirmation) { + _ctx.next = 41; + break; + } + _ctx.next = 31; + return awaitTransactionSignatureConfirmation(txid, DEFAULT_TIMEOUT, connection, commitment); + case 31: + confirmation = _ctx.sent; + if (confirmation) { + _ctx.next = 34; + break; + } + throw new Error("Timed out awaiting confirmation on transaction"); + case 34: slot = (confirmation === null || confirmation === void 0 ? void 0 : confirmation.slot) || 0; - if (!(confirmation === null || confirmation === void 0 ? void 0 : confirmation.err)) return [ - 3, - 9 - ]; - return [ - 4, - getErrorForTransaction(connection, txid) - ]; - case 8: - errors = _state.sent(); + if (!(confirmation === null || confirmation === void 0 ? void 0 : confirmation.err)) { + _ctx.next = 41; + break; + } + _ctx.next = 38; + return getErrorForTransaction(connection, txid); + case 38: + errors = _ctx.sent; console.log(errors); throw new Error("Raw transaction ".concat(txid, " failed")); - case 9: - _tmp2 = {}; - return [ - 2, - (_tmp2.txid = txid, _tmp2.slot = slot, _tmp2) - ]; + case 41: + return _ctx.abrupt("return", { + txid: txid, + slot: slot + }); + case 42: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function sendTransaction(connection, wallet, instructions, signers) { return _ref.apply(this, arguments); }; }(); export var sendTransactionWithRetry = function() { - var _ref = _async_to_generator(function(connection, wallet, instructions, signers) { - var commitment, includesFeePayer, block, beforeSend, transaction, _tmp, _transaction, _transaction1, _transaction2, ref, txid, slot, _tmp1, _tmp2; - var _arguments = arguments; - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(connection, wallet, instructions, signers) { + var commitment, includesFeePayer, block, beforeSend, transaction, _transaction, _transaction1, _transaction2, ref, txid, slot, _args = arguments; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - commitment = _arguments.length > 4 && _arguments[4] !== void 0 ? _arguments[4] : "singleGossip", includesFeePayer = _arguments.length > 5 && _arguments[5] !== void 0 ? _arguments[5] : false, block = _arguments.length > 6 ? _arguments[6] : void 0, beforeSend = _arguments.length > 7 ? _arguments[7] : void 0; - if (!wallet.publicKey) throw new WalletNotConnectedError(); + commitment = _args.length > 4 && _args[4] !== void 0 ? _args[4] : "singleGossip", includesFeePayer = _args.length > 5 && _args[5] !== void 0 ? _args[5] : false, block = _args.length > 6 ? _args[6] : void 0, beforeSend = _args.length > 7 ? _args[7] : void 0; + if (wallet.publicKey) { + _ctx.next = 3; + break; + } + throw new WalletNotConnectedError(); + case 3: transaction = new Transaction(); instructions.forEach(function(instruction) { return transaction.add(instruction); }); - _tmp = block; - if (_tmp) return [ - 3, - 2 - ]; - return [ - 4, - connection.getRecentBlockhash(commitment) - ]; - case 1: - _tmp = _state.sent(); - _state.label = 2; - case 2: - transaction.recentBlockhash = _tmp.blockhash; + _ctx.t0 = block; + if (_ctx.t0) { + _ctx.next = 10; + break; + } + _ctx.next = 9; + return connection.getRecentBlockhash(commitment); + case 9: + _ctx.t0 = _ctx.sent; + case 10: + transaction.recentBlockhash = _ctx.t0.blockhash; if (includesFeePayer) { ; (_transaction = transaction).setSigners.apply(_transaction, _to_consumable_array(signers.map(function(s) { @@ -495,36 +455,37 @@ export var sendTransactionWithRetry = function() { ; (_transaction2 = transaction).partialSign.apply(_transaction2, _to_consumable_array(signers)); } - if (!!includesFeePayer) return [ - 3, - 4 - ]; - return [ - 4, - wallet.signTransaction(transaction) - ]; - case 3: - transaction = _state.sent(); - _state.label = 4; - case 4: + if (includesFeePayer) { + _ctx.next = 17; + break; + } + _ctx.next = 16; + return wallet.signTransaction(transaction); + case 16: + transaction = _ctx.sent; + case 17: if (beforeSend) { beforeSend(); } - _tmp1 = {}; - return [ - 4, - sendSignedTransaction((_tmp1.connection = connection, _tmp1.signedTransaction = transaction, _tmp1)) - ]; - case 5: - ref = _state.sent(), txid = ref.txid, slot = ref.slot; - _tmp2 = {}; - return [ - 2, - (_tmp2.txid = txid, _tmp2.slot = slot, _tmp2) - ]; + _ctx.next = 20; + return sendSignedTransaction({ + connection: connection, + signedTransaction: transaction + }); + case 20: + ref = _ctx.sent; + txid = ref.txid; + slot = ref.slot; + return _ctx.abrupt("return", { + txid: txid, + slot: slot + }); + case 24: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function sendTransactionWithRetry(connection, wallet, instructions, signers) { return _ref.apply(this, arguments); }; @@ -537,333 +498,322 @@ export function sendSignedTransaction(_) { return _sendSignedTransaction.apply(this, arguments); } function _sendSignedTransaction() { - _sendSignedTransaction = _async_to_generator(function(param) { - var signedTransaction, connection, _timeout, timeout, rawTransaction, startTime, slot, txid, _tmp, done, confirmation, err, simulateResult, e, i, line, _tmp1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _sendSignedTransaction = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(param) { + var signedTransaction, connection, _timeout, timeout, rawTransaction, startTime, slot, txid, done, confirmation, simulateResult, i, line; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: signedTransaction = param.signedTransaction, connection = param.connection, _timeout = param.timeout, timeout = _timeout === void 0 ? DEFAULT_TIMEOUT : _timeout; rawTransaction = signedTransaction.serialize(); startTime = getUnixTs(); slot = 0; - _tmp = {}; - return [ - 4, - connection.sendRawTransaction(rawTransaction, (_tmp.skipPreflight = true, _tmp)) - ]; - case 1: - txid = _state.sent(); + _ctx.next = 6; + return connection.sendRawTransaction(rawTransaction, { + skipPreflight: true + }); + case 6: + txid = _ctx.sent; console.log("Started awaiting confirmation for", txid); done = false; - _async_to_generator(function() { - var _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - if (!(!done && getUnixTs() - startTime < timeout)) return [ - 3, - 2 - ]; - _tmp = {}; - connection.sendRawTransaction(rawTransaction, (_tmp.skipPreflight = true, _tmp)); - return [ - 4, - sleep(500) - ]; - case 1: - _state.sent(); - return [ - 3, - 0 - ]; - case 2: - return [ - 2 - ]; + if (!(!done && getUnixTs() - startTime < timeout)) { + _ctx.next = 6; + break; + } + connection.sendRawTransaction(rawTransaction, { + skipPreflight: true + }); + _ctx.next = 4; + return sleep(500); + case 4: + _ctx.next = 0; + break; + case 6: + case "end": + return _ctx.stop(); } - }); - })(); - _state.label = 2; - case 2: - _state.trys.push([ - 2, - 4, - 9, - 10 - ]); - return [ - 4, - awaitTransactionSignatureConfirmation(txid, timeout, connection, "recent", true) - ]; - case 3: - confirmation = _state.sent(); - if (!confirmation) throw new Error("Timed out awaiting confirmation on transaction"); - if (confirmation.err) { - console.error(confirmation.err); - throw new Error("Transaction failed: Custom instruction error"); + }, _callee); + }))(); + _ctx.prev = 10; + _ctx.next = 13; + return awaitTransactionSignatureConfirmation(txid, timeout, connection, "recent", true); + case 13: + confirmation = _ctx.sent; + if (confirmation) { + _ctx.next = 16; + break; } + throw new Error("Timed out awaiting confirmation on transaction"); + case 16: + if (!confirmation.err) { + _ctx.next = 19; + break; + } + console.error(confirmation.err); + throw new Error("Transaction failed: Custom instruction error"); + case 19: slot = (confirmation === null || confirmation === void 0 ? void 0 : confirmation.slot) || 0; - return [ - 3, - 10 - ]; - case 4: - err = _state.sent(); - console.error("Timeout Error caught", err); - if (err.timeout) { - throw new Error("Timed out awaiting confirmation on transaction"); + _ctx.next = 47; + break; + case 22: + _ctx.prev = 22; + _ctx.t0 = _ctx["catch"](10); + console.error("Timeout Error caught", _ctx.t0); + if (!_ctx.t0.timeout) { + _ctx.next = 27; + break; } + throw new Error("Timed out awaiting confirmation on transaction"); + case 27: simulateResult = null; - _state.label = 5; - case 5: - _state.trys.push([ - 5, - 7, - , - 8 - ]); - return [ - 4, - simulateTransaction(connection, signedTransaction, "single") - ]; - case 6: - simulateResult = _state.sent().value; - return [ - 3, - 8 - ]; - case 7: - e = _state.sent(); - return [ - 3, - 8 - ]; - case 8: - if (simulateResult && simulateResult.err) { - if (simulateResult.logs) { - for(i = simulateResult.logs.length - 1; i >= 0; --i){ - line = simulateResult.logs[i]; - if (line.startsWith("Program log: ")) { - throw new Error("Transaction failed: " + line.slice("Program log: ".length)); - } - } - } - throw new Error(JSON.stringify(simulateResult.err)); + _ctx.prev = 28; + _ctx.next = 31; + return simulateTransaction(connection, signedTransaction, "single"); + case 31: + simulateResult = _ctx.sent.value; + _ctx.next = 36; + break; + case 34: + _ctx.prev = 34; + _ctx.t1 = _ctx["catch"](28); + case 36: + if (!(simulateResult && simulateResult.err)) { + _ctx.next = 47; + break; } - return [ - 3, - 10 - ]; - case 9: + if (!simulateResult.logs) { + _ctx.next = 46; + break; + } + i = simulateResult.logs.length - 1; + case 39: + if (!(i >= 0)) { + _ctx.next = 46; + break; + } + line = simulateResult.logs[i]; + if (!line.startsWith("Program log: ")) { + _ctx.next = 43; + break; + } + throw new Error("Transaction failed: " + line.slice("Program log: ".length)); + case 43: + --i; + _ctx.next = 39; + break; + case 46: + throw new Error(JSON.stringify(simulateResult.err)); + case 47: + _ctx.prev = 47; done = true; - return [ - 7 - ]; - case 10: + return _ctx.finish(47); + case 50: console.log("Latency", txid, getUnixTs() - startTime); - _tmp1 = {}; - return [ - 2, - (_tmp1.txid = txid, _tmp1.slot = slot, _tmp1) - ]; + return _ctx.abrupt("return", { + txid: txid, + slot: slot + }); + case 52: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 10, + 22, + 47, + 50 + ], + [ + 28, + 34 + ] + ]); + })); return _sendSignedTransaction.apply(this, arguments); } function simulateTransaction(connection, transaction, commitment) { return _simulateTransaction.apply(this, arguments); } function _simulateTransaction() { - _simulateTransaction = _async_to_generator(function(connection, transaction, commitment) { - var signData, wireTransaction, encodedTransaction, config, _tmp, args, res; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _simulateTransaction = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(connection, transaction, commitment) { + var signData, wireTransaction, encodedTransaction, config, args, res; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - connection._recentBlockhash(// @ts-ignore - connection._disableBlockhashCaching) - ]; - case 1: + _ctx.next = 2; + return connection._recentBlockhash(// @ts-ignore + connection._disableBlockhashCaching); + case 2: // @ts-ignore - transaction.recentBlockhash = _state.sent(); + transaction.recentBlockhash = _ctx.sent; signData = transaction.serializeMessage(); wireTransaction = transaction._serialize(signData); encodedTransaction = wireTransaction.toString("base64"); - _tmp = {}; - config = (_tmp.encoding = "base64", _tmp.commitment = commitment, _tmp); + config = { + encoding: "base64", + commitment: commitment + }; args = [ encodedTransaction, config ]; - return [ - 4, - connection._rpcRequest("simulateTransaction", args) - ]; - case 2: - res = _state.sent(); - if (res.error) { - throw new Error("failed to simulate transaction: " + res.error.message); + _ctx.next = 10; + return connection._rpcRequest("simulateTransaction", args); + case 10: + res = _ctx.sent; + if (!res.error) { + _ctx.next = 13; + break; } - return [ - 2, - res.result - ]; + throw new Error("failed to simulate transaction: " + res.error.message); + case 13: + return _ctx.abrupt("return", res.result); + case 14: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _simulateTransaction.apply(this, arguments); } function awaitTransactionSignatureConfirmation(txid, timeout, connection) { return _awaitTransactionSignatureConfirmation.apply(this, arguments); } function _awaitTransactionSignatureConfirmation() { - _awaitTransactionSignatureConfirmation = _async_to_generator(function(txid, timeout, connection) { - var commitment, queryStatus, done, status, _tmp, subId; - var _arguments = arguments; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _awaitTransactionSignatureConfirmation = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(txid, timeout, connection) { + var commitment, queryStatus, done, status, subId, _args = arguments; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - commitment = _arguments.length > 3 && _arguments[3] !== void 0 ? _arguments[3] : "recent", queryStatus = _arguments.length > 4 && _arguments[4] !== void 0 ? _arguments[4] : false; + commitment = _args.length > 3 && _args[3] !== void 0 ? _args[3] : "recent", queryStatus = _args.length > 4 && _args[4] !== void 0 ? _args[4] : false; done = false; - _tmp = {}; - status = (_tmp.slot = 0, _tmp.confirmations = 0, _tmp.err = null, _tmp); + status = { + slot: 0, + confirmations: 0, + err: null + }; subId = 0; - return [ - 4, - new Promise(function() { - var _ref = _async_to_generator(function(resolve, reject) { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - setTimeout(function() { - if (done) { - return; - } - done = true; - console.log("Rejecting for timeout..."); - reject({ - timeout: true - }); - }, timeout); - try { - subId = connection.onSignature(txid, function(result, context) { - done = true; - status = { - err: result.err, - slot: context.slot, - confirmations: 0 - }; - if (result.err) { - console.log("Rejected via websocket", result.err); - reject(status); - } else { - console.log("Resolved via websocket", result); - resolve(status); - } - }, commitment); - } catch (e) { - done = true; - console.error("WS error in setup", txid, e); + _ctx.next = 6; + return new Promise(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(resolve, reject) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + setTimeout(function() { + if (done) { + return; } - _state.label = 1; - case 1: - if (!(!done && queryStatus)) return [ - 3, - 3 - ]; - // eslint-disable-next-line no-loop-func - _async_to_generator(function() { - var signatureStatuses, e; - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - _state.trys.push([ - 0, - 2, - , - 3 - ]); - return [ - 4, - connection.getSignatureStatuses([ - txid - ]) - ]; - case 1: - signatureStatuses = _state.sent(); - status = signatureStatuses && signatureStatuses.value[0]; - if (!done) { - if (!status) { - console.log("REST null result for", txid, status); - } else if (status.err) { - console.log("REST error for", txid, status); - done = true; - reject(status.err); - } else if (!status.confirmations) { - console.log("REST no confirmations for", txid, status); - } else { - console.log("REST confirmation for", txid, status); - done = true; - resolve(status); - } + done = true; + console.log("Rejecting for timeout..."); + reject({ + timeout: true + }); + }, timeout); + try { + subId = connection.onSignature(txid, function(result, context) { + done = true; + status = { + err: result.err, + slot: context.slot, + confirmations: 0 + }; + if (result.err) { + console.log("Rejected via websocket", result.err); + reject(status); + } else { + console.log("Resolved via websocket", result); + resolve(status); + } + }, commitment); + } catch (e) { + done = true; + console.error("WS error in setup", txid, e); + } + case 2: + if (!(!done && queryStatus)) { + _ctx.next = 8; + break; + } + // eslint-disable-next-line no-loop-func + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var signatureStatuses; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.prev = 0; + _ctx.next = 3; + return connection.getSignatureStatuses([ + txid + ]); + case 3: + signatureStatuses = _ctx.sent; + status = signatureStatuses && signatureStatuses.value[0]; + if (!done) { + if (!status) { + console.log("REST null result for", txid, status); + } else if (status.err) { + console.log("REST error for", txid, status); + done = true; + reject(status.err); + } else if (!status.confirmations) { + console.log("REST no confirmations for", txid, status); + } else { + console.log("REST confirmation for", txid, status); + done = true; + resolve(status); } - return [ - 3, - 3 - ]; - case 2: - e = _state.sent(); - if (!done) { - console.log("REST connection error: txid", txid, e); - } - return [ - 3, - 3 - ]; - case 3: - return [ - 2 - ]; - } - }); - })(); - return [ - 4, - sleep(2000) - ]; - case 2: - _state.sent(); - return [ - 3, - 1 - ]; - case 3: - return [ - 2 - ]; - } - }); - }); - return function(resolve, reject) { - return _ref.apply(this, arguments); - }; - }()) - ]; - case 1: - status = _state.sent(); + } + _ctx.next = 11; + break; + case 8: + _ctx.prev = 8; + _ctx.t0 = _ctx["catch"](0); + if (!done) { + console.log("REST connection error: txid", txid, _ctx.t0); + } + case 11: + case "end": + return _ctx.stop(); + } + }, _callee, null, [ + [ + 0, + 8 + ] + ]); + }))(); + _ctx.next = 6; + return sleep(2000); + case 6: + _ctx.next = 2; + break; + case 8: + case "end": + return _ctx.stop(); + } + }, _callee); + })); + return function(resolve, reject) { + return _ref.apply(this, arguments); + }; + }()); + case 6: + status = _ctx.sent; //@ts-ignore if (connection._signatureSubscriptions[subId]) connection.removeSignatureListener(subId); done = true; console.log("Returning status", status); - return [ - 2, - status - ]; + return _ctx.abrupt("return", status); + case 11: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _awaitTransactionSignatureConfirmation.apply(this, arguments); } export function sleep(ms) { diff --git a/crates/swc/tests/fixture/issues-4xxx/4208/1/output/index.ts b/crates/swc/tests/fixture/issues-4xxx/4208/1/output/index.ts index b819dc3bec7..18fc479f0b0 100644 --- a/crates/swc/tests/fixture/issues-4xxx/4208/1/output/index.ts +++ b/crates/swc/tests/fixture/issues-4xxx/4208/1/output/index.ts @@ -1,20 +1,22 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export var CompanyBgStore = function CompanyBgStore() { "use strict"; _class_call_check(this, CompanyBgStore); this.corpName = 123; var _this = this; - this.getBusinessInfo = _async_to_generator(function() { - var corpName; - var _arguments = arguments; - return _ts_generator(this, function(_state) { - corpName = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : _this.corpName; - console.log(corpName); - return [ - 2 - ]; - }); - }); + this.getBusinessInfo = _async_to_generator(regeneratorRuntime.mark(function _callee() { + var corpName, _args = arguments; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + corpName = _args.length > 0 && _args[0] !== void 0 ? _args[0] : _this.corpName; + console.log(corpName); + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + })); }; diff --git a/crates/swc/tests/fixture/issues-4xxx/4224/1/output/index.js b/crates/swc/tests/fixture/issues-4xxx/4224/1/output/index.js index 48380672424..c146e355b9b 100644 --- a/crates/swc/tests/fixture/issues-4xxx/4224/1/output/index.js +++ b/crates/swc/tests/fixture/issues-4xxx/4224/1/output/index.js @@ -1,26 +1,32 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var A = function A() { "use strict"; _class_call_check(this, A); var _this = this; - this.foo = /*#__PURE__*/ _async_to_generator(function() { - return _ts_generator(this, function(_state) { - _this.x(); - return [ - 2 - ]; - }); - }); + this.foo = /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _this.x(); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); var _this1 = this; - this.bar = /*#__PURE__*/ _async_to_generator(function() { - return _ts_generator(this, function(_state) { - _this1.x(); - return [ - 2 - ]; - }); - }); + this.bar = /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _this1.x(); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); }; console.log(A); diff --git a/crates/swc/tests/fixture/issues-4xxx/4224/3/output/index.js b/crates/swc/tests/fixture/issues-4xxx/4224/3/output/index.js index f8ab63d31da..d3e773bcf60 100644 --- a/crates/swc/tests/fixture/issues-4xxx/4224/3/output/index.js +++ b/crates/swc/tests/fixture/issues-4xxx/4224/3/output/index.js @@ -1,7 +1,7 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _create_class from "@swc/helpers/src/_create_class.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var A = /*#__PURE__*/ function() { "use strict"; function A() { @@ -12,23 +12,29 @@ var A = /*#__PURE__*/ function() { key: "method", value: function method() { var _this = this; - this.foo = /*#__PURE__*/ _async_to_generator(function() { - return _ts_generator(this, function(_state) { - _this.x(); - return [ - 2 - ]; - }); - }); + this.foo = /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _this.x(); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); var _this1 = this; - this.bar = /*#__PURE__*/ _async_to_generator(function() { - return _ts_generator(this, function(_state) { - _this1.x(); - return [ - 2 - ]; - }); - }); + this.bar = /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _this1.x(); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); } } ]); diff --git a/crates/swc/tests/fixture/issues-4xxx/4226/1/output/exec.js b/crates/swc/tests/fixture/issues-4xxx/4226/1/output/exec.js index 83294b765c7..62edace5a79 100644 --- a/crates/swc/tests/fixture/issues-4xxx/4226/1/output/exec.js +++ b/crates/swc/tests/fixture/issues-4xxx/4226/1/output/exec.js @@ -1,15 +1,18 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import "reflect-metadata"; var v0 = function() { - var _ref = _async_to_generator(function(v1) { - return _ts_generator(this, function(_state) { - return [ - 2, - v1 - ]; - }); - }); + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee(v1) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", v1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function(v1) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/fixture/issues-4xxx/4226/3/output/exec.js b/crates/swc/tests/fixture/issues-4xxx/4226/3/output/exec.js index 36e5e102c49..c3fbe259ebe 100644 --- a/crates/swc/tests/fixture/issues-4xxx/4226/3/output/exec.js +++ b/crates/swc/tests/fixture/issues-4xxx/4226/3/output/exec.js @@ -3,17 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true }); var _asyncToGenerator = require("@swc/helpers/lib/_async_to_generator.js").default; -var _tsGenerator = require("@swc/helpers/lib/_ts_generator.js").default; +var _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default; +var _regeneratorRuntime = _interopRequireDefault(require("regenerator-runtime")); require("reflect-metadata"); var v0 = function() { - var _ref = _asyncToGenerator(function(v1) { - return _tsGenerator(this, function(_state) { - return [ - 2, - v1 - ]; - }); - }); + var _ref = _asyncToGenerator(_regeneratorRuntime.default.mark(function _callee(v1) { + return _regeneratorRuntime.default.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", v1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function(v1) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/fixture/issues-5xxx/5556/output/index.js b/crates/swc/tests/fixture/issues-5xxx/5556/output/index.js index 939563d33bf..65cb05cf7f2 100644 --- a/crates/swc/tests/fixture/issues-5xxx/5556/output/index.js +++ b/crates/swc/tests/fixture/issues-5xxx/5556/output/index.js @@ -1,4 +1,4 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var app; var ctx; x = function x() { @@ -9,25 +9,24 @@ x = function x() { type: "all", disable: app.config.env === "local" }, - task: function task(ctx) { - var res, _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + task: regeneratorRuntime.mark(function task(ctx) { + var res; + return regeneratorRuntime.wrap(function task$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp = {}; - return [ - 4, - ctx.curl("http://www.api.com/cache", (_tmp.contentType = "json", _tmp)) - ]; - case 1: - res = _state.sent(); + _ctx.next = 2; + return ctx.curl("http://www.api.com/cache", { + contentType: "json" + }); + case 2: + res = _ctx.sent; ctx.app.cache = res.data; - return [ - 2 - ]; + case 4: + case "end": + return _ctx.stop(); } - }); - } + }, task); + }) }; }; }; diff --git a/crates/swc/tests/fixture/issues-5xxx/5558/2/output/index.js b/crates/swc/tests/fixture/issues-5xxx/5558/2/output/index.js index 068468343d1..426055b12e3 100644 --- a/crates/swc/tests/fixture/issues-5xxx/5558/2/output/index.js +++ b/crates/swc/tests/fixture/issues-5xxx/5558/2/output/index.js @@ -1,7 +1,7 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _create_class from "@swc/helpers/src/_create_class.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var Foo = function() { "use strict"; function Foo() { @@ -11,22 +11,20 @@ var Foo = function() { { key: "bar", value: function bar() { - var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _async_to_generator(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return 1; + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); } } ]); diff --git a/crates/swc/tests/fixture/next.js/shared/lib/router/1/output/index.ts b/crates/swc/tests/fixture/next.js/shared/lib/router/1/output/index.ts index 30e3d32c3cd..9581782c765 100644 --- a/crates/swc/tests/fixture/next.js/shared/lib/router/1/output/index.ts +++ b/crates/swc/tests/fixture/next.js/shared/lib/router/1/output/index.ts @@ -1,6 +1,6 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var Router = /*#__PURE__*/ function() { "use strict"; function Router() { @@ -9,18 +9,18 @@ var Router = /*#__PURE__*/ function() { var _proto = Router.prototype; _proto.change = function change(method, url, as, options, forcedScroll) { var _this = this; - return _async_to_generator(function() { - var shouldResolveHref, prevLocale, parsedAs, localePathResult, didNavigate, ref, detectedDomain, asNoBasePath, _shallow, shallow, routeProps, _tmp, cleanedAs, localeChange, parsed, pathname, query, pages, rewrites, ref1, err, resolvedAs, rewritesResult, route, parsedAs1, asPathname, routeRegex, routeMatch, shouldInterpolate, interpolatedAs, _tmp1, missingParams, ref2, ref3, routeInfo, error, props, __N_SSG, __N_SSP, destination, parsedHref, ref4, newUrl, newAs, notFoundRoute, _, _tmp2, isValidShallowRoute, _scroll, shouldScroll, resetScroll, _tmp3, err1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var shouldResolveHref, prevLocale, parsedAs, localePathResult, didNavigate, ref, detectedDomain, asNoBasePath, _shallow, shallow, routeProps, cleanedAs, localeChange, parsed, pathname, query, pages, rewrites, ref1, resolvedAs, rewritesResult, route, parsedAs1, asPathname, routeRegex, routeMatch, shouldInterpolate, interpolatedAs, missingParams, ref2, ref3, routeInfo, error, props, __N_SSG, __N_SSP, destination, parsedHref, ref4, newUrl, newAs, notFoundRoute, isValidShallowRoute, _scroll, shouldScroll, resetScroll; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - if (!isLocalURL(url)) { - window.location.href = url; - return [ - 2, - false - ]; + if (isLocalURL(url)) { + _ctx.next = 3; + break; } + window.location.href = url; + return _ctx.abrupt("return", false); + case 3: shouldResolveHref = options._h || options._shouldResolveHref || pathNoQueryHash(url) === pathNoQueryHash(as); // for static pages with query params in the URL we delay // marking the router ready until after the query is updated @@ -28,54 +28,56 @@ var Router = /*#__PURE__*/ function() { _this.isReady = true; } prevLocale = _this.locale; + if (!process.env.__NEXT_I18N_SUPPORT) { + _ctx.next = 18; + break; + } + _this.locale = options.locale === false ? _this.defaultLocale : options.locale || _this.locale; + if (typeof options.locale === "undefined") { + options.locale = _this.locale; + } + parsedAs = parseRelativeUrl(hasBasePath(as) ? delBasePath(as) : as); + localePathResult = normalizeLocalePath(parsedAs.pathname, _this.locales); + if (localePathResult.detectedLocale) { + _this.locale = localePathResult.detectedLocale; + parsedAs.pathname = addBasePath(parsedAs.pathname); + as = formatWithValidation(parsedAs); + url = addBasePath(normalizeLocalePath(hasBasePath(url) ? delBasePath(url) : url, _this.locales).pathname); + } + didNavigate = false; + // we need to wrap this in the env check again since regenerator runtime + // moves this on its own due to the return if (process.env.__NEXT_I18N_SUPPORT) { - _this.locale = options.locale === false ? _this.defaultLocale : options.locale || _this.locale; - if (typeof options.locale === "undefined") { - options.locale = _this.locale; - } - parsedAs = parseRelativeUrl(hasBasePath(as) ? delBasePath(as) : as); - localePathResult = normalizeLocalePath(parsedAs.pathname, _this.locales); - if (localePathResult.detectedLocale) { - _this.locale = localePathResult.detectedLocale; - parsedAs.pathname = addBasePath(parsedAs.pathname); - as = formatWithValidation(parsedAs); - url = addBasePath(normalizeLocalePath(hasBasePath(url) ? delBasePath(url) : url, _this.locales).pathname); - } - didNavigate = false; - // we need to wrap this in the env check again since regenerator runtime - // moves this on its own due to the return - if (process.env.__NEXT_I18N_SUPPORT) { - ; - // if the locale isn't configured hard navigate to show 404 page - if (!((ref = _this.locales) === null || ref === void 0 ? void 0 : ref.includes(_this.locale))) { - parsedAs.pathname = addLocale(parsedAs.pathname, _this.locale); - window.location.href = formatWithValidation(parsedAs); - // this was previously a return but was removed in favor - // of better dead code elimination with regenerator runtime - didNavigate = true; - } - } - detectedDomain = detectDomainLocale(_this.domainLocales, undefined, _this.locale); - // we need to wrap this in the env check again since regenerator runtime - // moves this on its own due to the return - if (process.env.__NEXT_I18N_SUPPORT) { - // if we are navigating to a domain locale ensure we redirect to the - // correct domain - if (!didNavigate && detectedDomain && _this.isLocaleDomain && self.location.hostname !== detectedDomain.domain) { - asNoBasePath = delBasePath(as); - window.location.href = "http".concat(detectedDomain.http ? "" : "s", "://").concat(detectedDomain.domain).concat(addBasePath("".concat(_this.locale === detectedDomain.defaultLocale ? "" : "/".concat(_this.locale)).concat(asNoBasePath === "/" ? "" : asNoBasePath) || "/")); - // this was previously a return but was removed in favor - // of better dead code elimination with regenerator runtime - didNavigate = true; - } - } - if (didNavigate) { - return [ - 2, - new Promise(function() {}) - ]; + ; + // if the locale isn't configured hard navigate to show 404 page + if (!((ref = _this.locales) === null || ref === void 0 ? void 0 : ref.includes(_this.locale))) { + parsedAs.pathname = addLocale(parsedAs.pathname, _this.locale); + window.location.href = formatWithValidation(parsedAs); + // this was previously a return but was removed in favor + // of better dead code elimination with regenerator runtime + didNavigate = true; } } + detectedDomain = detectDomainLocale(_this.domainLocales, undefined, _this.locale); + // we need to wrap this in the env check again since regenerator runtime + // moves this on its own due to the return + if (process.env.__NEXT_I18N_SUPPORT) { + // if we are navigating to a domain locale ensure we redirect to the + // correct domain + if (!didNavigate && detectedDomain && _this.isLocaleDomain && self.location.hostname !== detectedDomain.domain) { + asNoBasePath = delBasePath(as); + window.location.href = "http".concat(detectedDomain.http ? "" : "s", "://").concat(detectedDomain.domain).concat(addBasePath("".concat(_this.locale === detectedDomain.defaultLocale ? "" : "/".concat(_this.locale)).concat(asNoBasePath === "/" ? "" : asNoBasePath) || "/")); + // this was previously a return but was removed in favor + // of better dead code elimination with regenerator runtime + didNavigate = true; + } + } + if (!didNavigate) { + _ctx.next = 18; + break; + } + return _ctx.abrupt("return", new Promise(function() {})); + case 18: if (!options._h) { _this.isSsr = false; } @@ -84,8 +86,9 @@ var Router = /*#__PURE__*/ function() { performance.mark("routeChange"); } _shallow = options.shallow, shallow = _shallow === void 0 ? false : _shallow; - _tmp = {}; - routeProps = (_tmp.shallow = shallow, _tmp); + routeProps = { + shallow: shallow + }; if (_this._inFlightRoute) { _this.abortComponentLoad(_this._inFlightRoute, routeProps); } @@ -93,60 +96,44 @@ var Router = /*#__PURE__*/ function() { cleanedAs = delLocale(hasBasePath(as) ? delBasePath(as) : as, _this.locale); _this._inFlightRoute = as; localeChange = prevLocale !== _this.locale; - // If the url change is only related to a hash change - // We should not proceed. We should only change the state. - // WARNING: `_h` is an internal option for handing Next.js client-side - // hydration. Your app should _never_ use this property. It may change at - // any time without notice. - if (!options._h && _this.onlyAHashChange(cleanedAs) && !localeChange) { - _this.asPath = cleanedAs; - Router.events.emit("hashChangeStart", as, routeProps); - // TODO: do we need the resolved href when only a hash change? - _this.changeState(method, url, as, options); - _this.scrollToHash(cleanedAs); - _this.notify(_this.components[_this.route], null); - Router.events.emit("hashChangeComplete", as, routeProps); - return [ - 2, - true - ]; + if (!(!options._h && _this.onlyAHashChange(cleanedAs) && !localeChange)) { + _ctx.next = 35; + break; } + _this.asPath = cleanedAs; + Router.events.emit("hashChangeStart", as, routeProps); + // TODO: do we need the resolved href when only a hash change? + _this.changeState(method, url, as, options); + _this.scrollToHash(cleanedAs); + _this.notify(_this.components[_this.route], null); + Router.events.emit("hashChangeComplete", as, routeProps); + return _ctx.abrupt("return", true); + case 35: parsed = parseRelativeUrl(url); pathname = parsed.pathname, query = parsed.query; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 4, - , - 5 - ]); - return [ - 4, - _this.pageLoader.getPageList() - ]; - case 2: - pages = _state.sent(); - return [ - 4, - getClientBuildManifest() - ]; - case 3: - ref1 = _state.sent(), rewrites = ref1.__rewrites, ref1; - return [ - 3, - 5 - ]; - case 4: - err = _state.sent(); + ; + _ctx.prev = 38; + _ctx.next = 41; + return _this.pageLoader.getPageList(); + case 41: + pages = _ctx.sent; + ; + _ctx.next = 45; + return getClientBuildManifest(); + case 45: + ref1 = _ctx.sent; + rewrites = ref1.__rewrites; + ref1; + _ctx.next = 54; + break; + case 50: + _ctx.prev = 50; + _ctx.t0 = _ctx["catch"](38); // If we fail to resolve the page list or client-build manifest, we must // do a server-side transition: window.location.href = as; - return [ - 2, - false - ]; - case 5: + return _ctx.abrupt("return", false); + case 54: // If asked to change the current URL we should reload the current page // (not location.reload() but reload getInitialProps and other Next.js stuffs) // We also need to set the method = replaceState always @@ -184,126 +171,113 @@ var Router = /*#__PURE__*/ function() { } } route = removePathTrailingSlash(pathname); - if (!isLocalURL(as)) { - if (process.env.NODE_ENV !== "production") { - throw new Error('Invalid href: "'.concat(url, '" and as: "').concat(as, '", received relative href and external as') + "\nSee more info: https://nextjs.org/docs/messages/invalid-relative-url-external-as"); - } - window.location.href = as; - return [ - 2, - false - ]; + if (isLocalURL(as)) { + _ctx.next = 64; + break; } + if (!(process.env.NODE_ENV !== "production")) { + _ctx.next = 62; + break; + } + throw new Error('Invalid href: "'.concat(url, '" and as: "').concat(as, '", received relative href and external as') + "\nSee more info: https://nextjs.org/docs/messages/invalid-relative-url-external-as"); + case 62: + window.location.href = as; + return _ctx.abrupt("return", false); + case 64: resolvedAs = delLocale(delBasePath(resolvedAs), _this.locale); - _tmp1 = {}; - if (isDynamicRoute(route)) { - parsedAs1 = parseRelativeUrl(resolvedAs); - asPathname = parsedAs1.pathname; - routeRegex = getRouteRegex(route); - routeMatch = getRouteMatcher(routeRegex)(asPathname); - shouldInterpolate = route === asPathname; - interpolatedAs = shouldInterpolate ? interpolateAs(route, asPathname, query) : _tmp1; - if (!routeMatch || shouldInterpolate && !interpolatedAs.result) { - missingParams = Object.keys(routeRegex.groups).filter(function(param) { - return !query[param]; - }); - if (missingParams.length > 0) { - if (process.env.NODE_ENV !== "production") { - console.warn("".concat(shouldInterpolate ? "Interpolating href" : "Mismatching `as` and `href`", " failed to manually provide ") + "the params: ".concat(missingParams.join(", "), " in the `href`'s `query`")); - } - throw new Error((shouldInterpolate ? "The provided `href` (".concat(url, ") value is missing query values (").concat(missingParams.join(", "), ") to be interpolated properly. ") : "The provided `as` value (".concat(asPathname, ") is incompatible with the `href` value (").concat(route, "). ")) + "Read more: https://nextjs.org/docs/messages/".concat(shouldInterpolate ? "href-interpolation-failed" : "incompatible-href-as")); - } - } else if (shouldInterpolate) { - as = formatWithValidation(Object.assign({}, parsedAs1, { - pathname: interpolatedAs.result, - query: omitParmsFromQuery(query, interpolatedAs.params) - })); - } else { - // Merge params into `query`, overwriting any specified in search - Object.assign(query, routeMatch); - } + if (!isDynamicRoute(route)) { + _ctx.next = 80; + break; } + parsedAs1 = parseRelativeUrl(resolvedAs); + asPathname = parsedAs1.pathname; + routeRegex = getRouteRegex(route); + routeMatch = getRouteMatcher(routeRegex)(asPathname); + shouldInterpolate = route === asPathname; + interpolatedAs = shouldInterpolate ? interpolateAs(route, asPathname, query) : {}; + if (!(!routeMatch || shouldInterpolate && !interpolatedAs.result)) { + _ctx.next = 79; + break; + } + missingParams = Object.keys(routeRegex.groups).filter(function(param) { + return !query[param]; + }); + if (!(missingParams.length > 0)) { + _ctx.next = 77; + break; + } + if (process.env.NODE_ENV !== "production") { + console.warn("".concat(shouldInterpolate ? "Interpolating href" : "Mismatching `as` and `href`", " failed to manually provide ") + "the params: ".concat(missingParams.join(", "), " in the `href`'s `query`")); + } + throw new Error((shouldInterpolate ? "The provided `href` (".concat(url, ") value is missing query values (").concat(missingParams.join(", "), ") to be interpolated properly. ") : "The provided `as` value (".concat(asPathname, ") is incompatible with the `href` value (").concat(route, "). ")) + "Read more: https://nextjs.org/docs/messages/".concat(shouldInterpolate ? "href-interpolation-failed" : "incompatible-href-as")); + case 77: + _ctx.next = 80; + break; + case 79: + if (shouldInterpolate) { + as = formatWithValidation(Object.assign({}, parsedAs1, { + pathname: interpolatedAs.result, + query: omitParmsFromQuery(query, interpolatedAs.params) + })); + } else { + // Merge params into `query`, overwriting any specified in search + Object.assign(query, routeMatch); + } + case 80: Router.events.emit("routeChangeStart", as, routeProps); - _state.label = 6; - case 6: - _state.trys.push([ - 6, - 15, - , - 16 - ]); - return [ - 4, - _this.getRouteInfo(route, pathname, query, as, resolvedAs, routeProps) - ]; - case 7: - routeInfo = _state.sent(); + _ctx.prev = 81; + ; + _ctx.next = 85; + return _this.getRouteInfo(route, pathname, query, as, resolvedAs, routeProps); + case 85: + routeInfo = _ctx.sent; error = routeInfo.error, props = routeInfo.props, __N_SSG = routeInfo.__N_SSG, __N_SSP = routeInfo.__N_SSP; - if (!((__N_SSG || __N_SSP) && props)) return [ - 3, - 13 - ]; - if (props.pageProps && props.pageProps.__N_REDIRECT) { - destination = props.pageProps.__N_REDIRECT; - // check if destination is internal (resolves to a page) and attempt - // client-navigation if it is falling back to hard navigation if - // it's not - if (destination.startsWith("/") && props.pageProps.__N_REDIRECT_BASE_PATH !== false) { - parsedHref = parseRelativeUrl(destination); - parsedHref.pathname = resolveDynamicRoute(parsedHref.pathname, pages); - ref4 = prepareUrlAs(_this, destination, destination), newUrl = ref4.url, newAs = ref4.as; - return [ - 2, - _this.change(method, newUrl, newAs, options) - ]; - } - window.location.href = destination; - return [ - 2, - new Promise(function() {}) - ]; + if (!((__N_SSG || __N_SSP) && props)) { + _ctx.next = 112; + break; } + if (!(props.pageProps && props.pageProps.__N_REDIRECT)) { + _ctx.next = 97; + break; + } + destination = props.pageProps.__N_REDIRECT; + if (!(destination.startsWith("/") && props.pageProps.__N_REDIRECT_BASE_PATH !== false)) { + _ctx.next = 95; + break; + } + parsedHref = parseRelativeUrl(destination); + parsedHref.pathname = resolveDynamicRoute(parsedHref.pathname, pages); + ref4 = prepareUrlAs(_this, destination, destination), newUrl = ref4.url, newAs = ref4.as; + return _ctx.abrupt("return", _this.change(method, newUrl, newAs, options)); + case 95: + window.location.href = destination; + return _ctx.abrupt("return", new Promise(function() {})); + case 97: _this.isPreview = !!props.__N_PREVIEW; - if (!(props.notFound === SSG_DATA_NOT_FOUND)) return [ - 3, - 13 - ]; - _state.label = 8; - case 8: - _state.trys.push([ - 8, - 10, - , - 11 - ]); - return [ - 4, - _this.fetchComponent("/404") - ]; - case 9: - _state.sent(); + if (!(props.notFound === SSG_DATA_NOT_FOUND)) { + _ctx.next = 112; + break; + } + ; + _ctx.prev = 100; + _ctx.next = 103; + return _this.fetchComponent("/404"); + case 103: notFoundRoute = "/404"; - return [ - 3, - 11 - ]; - case 10: - _ = _state.sent(); + _ctx.next = 109; + break; + case 106: + _ctx.prev = 106; + _ctx.t1 = _ctx["catch"](100); notFoundRoute = "/_error"; - return [ - 3, - 11 - ]; - case 11: - _tmp2 = {}; - return [ - 4, - _this.getRouteInfo(notFoundRoute, notFoundRoute, query, as, resolvedAs, (_tmp2.shallow = false, _tmp2)) - ]; - case 12: - routeInfo = _state.sent(); - _state.label = 13; - case 13: + case 109: + _ctx.next = 111; + return _this.getRouteInfo(notFoundRoute, notFoundRoute, query, as, resolvedAs, { + shallow: false + }); + case 111: + routeInfo = _ctx.sent; + case 112: Router.events.emit("beforeHistoryChange", as, routeProps); _this.changeState(method, url, as, options); if (options._h && pathname === "/_error" && ((ref2 = self.__NEXT_DATA__.props) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.pageProps) === null || ref3 === void 0 ? void 0 : ref3.statusCode) === 500 && (props === null || props === void 0 ? void 0 : props.pageProps)) { @@ -312,48 +286,61 @@ var Router = /*#__PURE__*/ function() { props.pageProps.statusCode = 500; } isValidShallowRoute = options.shallow && _this.route === route; + ; shouldScroll = (_scroll = options.scroll) !== null && _scroll !== void 0 ? _scroll : !isValidShallowRoute; - _tmp3 = {}; - resetScroll = shouldScroll ? (_tmp3.x = 0, _tmp3.y = 0, _tmp3) : null; - return [ - 4, - _this.set(route, pathname, query, cleanedAs, routeInfo, forcedScroll !== null && forcedScroll !== void 0 ? forcedScroll : resetScroll).catch(function(e) { - if (e.cancelled) error = error || e; - else throw e; - }) - ]; - case 14: - _state.sent(); - if (error) { - Router.events.emit("routeChangeError", error, cleanedAs, routeProps); - throw error; + resetScroll = shouldScroll ? { + x: 0, + y: 0 + } : null; + _ctx.next = 121; + return _this.set(route, pathname, query, cleanedAs, routeInfo, forcedScroll !== null && forcedScroll !== void 0 ? forcedScroll : resetScroll).catch(function(e) { + if (e.cancelled) error = error || e; + else throw e; + }); + case 121: + if (!error) { + _ctx.next = 124; + break; } + Router.events.emit("routeChangeError", error, cleanedAs, routeProps); + throw error; + case 124: if (process.env.__NEXT_I18N_SUPPORT) { if (_this.locale) { document.documentElement.lang = _this.locale; } } Router.events.emit("routeChangeComplete", as, routeProps); - return [ - 2, - true - ]; - case 15: - err1 = _state.sent(); - if (isError(err1) && err1.cancelled) { - return [ - 2, - false - ]; + return _ctx.abrupt("return", true); + case 129: + _ctx.prev = 129; + _ctx.t2 = _ctx["catch"](81); + if (!(isError(_ctx.t2) && _ctx.t2.cancelled)) { + _ctx.next = 133; + break; } - throw err1; - case 16: - return [ - 2 - ]; + return _ctx.abrupt("return", false); + case 133: + throw _ctx.t2; + case 134: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee, null, [ + [ + 38, + 50 + ], + [ + 81, + 129 + ], + [ + 100, + 106 + ] + ]); + }))(); }; return Router; }(); diff --git a/crates/swc/tests/fixture/sourcemap/002/output/index.js b/crates/swc/tests/fixture/sourcemap/002/output/index.js index 918026e8763..ee6ac248061 100644 --- a/crates/swc/tests/fixture/sourcemap/002/output/index.js +++ b/crates/swc/tests/fixture/sourcemap/002/output/index.js @@ -1,5 +1,5 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export default function StaticPage(param) { var data = param.data; return /*#__PURE__*/ React.createElement("div", null, data.foo); @@ -8,19 +8,22 @@ export function getStaticProps() { return _getStaticProps.apply(this, arguments); } function _getStaticProps() { - _getStaticProps = _async_to_generator(function() { - var _tmp; - return _ts_generator(this, function(_state) { - _tmp = {}; - return [ - 2, - (_tmp.props = { - data: { - foo: "bar" - } - }, _tmp) - ]; - }); - }); + _getStaticProps = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", { + props: { + data: { + foo: "bar" + } + } + }); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _getStaticProps.apply(this, arguments); } diff --git a/crates/swc/tests/fixture/sourcemap/002/output/index.map b/crates/swc/tests/fixture/sourcemap/002/output/index.map index 4d0d8ce4451..8cff5253f07 100644 --- a/crates/swc/tests/fixture/sourcemap/002/output/index.map +++ b/crates/swc/tests/fixture/sourcemap/002/output/index.map @@ -1,5 +1,5 @@ { - "mappings": "AAAA;;AAAA,eAAe,SAASA,UAAU,CAAC,KAAQ,EAAE;QAAV,AAAEC,IAAI,GAAN,KAAQ,CAANA,IAAI,AAAE;IACvC,qBAAO,oBAACC,KAAG,QAAED,IAAI,CAACE,GAAG,CAAO,CAAC;AACjC,CAAC,CAAA;AAED,gBAAsBC,cAAc;WAAdA,eAAc;CAQnC;SARqBA,eAAc;IAAdA,eAAc,GAA7B,oBAAA,WAAgC;;;;YACnC;;sBACIC,KAAK,GAAE;oBACHJ,IAAI,EAAE;wBACFE,GAAG,EAAE,KAAK;qBACb;iBACJ;cACH;;IACN,CAAC,CAAA;WARqBC,eAAc", + "mappings": "AAAA;;AAAA,eAAe,SAASA,UAAU,CAAC,KAAQ,EAAE;QAAV,AAAEC,IAAI,GAAN,KAAQ,CAANA,IAAI,AAAE;IACvC,qBAAO,oBAACC,KAAG,QAAED,IAAI,CAACE,GAAG,CAAO,CAAC;AACjC,CAAC,CAAA;AAED,gBAAsBC,cAAc;WAAdA,eAAc;CAQnC;SARqBA,eAAc;IAAdA,eAAc,GAA7B,0DAAA,mBAAgC;;;;iDAC5B;wBACHC,KAAK,EAAE;4BACHJ,IAAI,EAAE;gCACFE,GAAG,EAAE,KAAK;6BACb;yBACJ;qBACJ;;;;;;IACL,CAAC,EAAA;WARqBC,eAAc", "names": [ "StaticPage", "data", diff --git a/crates/swc/tests/fixture/sourcemap/003/output/index.js b/crates/swc/tests/fixture/sourcemap/003/output/index.js index 4f2fdcd057e..f29c4fb95d1 100644 --- a/crates/swc/tests/fixture/sourcemap/003/output/index.js +++ b/crates/swc/tests/fixture/sourcemap/003/output/index.js @@ -1 +1 @@ -import t from"@swc/helpers/src/_async_to_generator.mjs";import r from"@swc/helpers/src/_ts_generator.mjs";export default function n(t){var r=t.data;return React.createElement("div",null,r.foo)};export function getStaticProps(){return o.apply(this,arguments)}function o(){return(o=t(function(){var t;return r(this,function(r){return[2,((t={}).props={data:{foo:"bar"}},t)]})})).apply(this,arguments)} +import t from"@swc/helpers/src/_async_to_generator.mjs";import r from"regenerator-runtime";export default function e(t){var r=t.data;return React.createElement("div",null,r.foo)};export function getStaticProps(){return n.apply(this,arguments)}function n(){return(n=t(r.mark(function t(){return r.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",{props:{data:{foo:"bar"}}});case 1:case"end":return t.stop()}},t)}))).apply(this,arguments)} diff --git a/crates/swc/tests/fixture/sourcemap/003/output/index.map b/crates/swc/tests/fixture/sourcemap/003/output/index.map index 0eb8d3534b5..9636d6201ce 100644 --- a/crates/swc/tests/fixture/sourcemap/003/output/index.map +++ b/crates/swc/tests/fixture/sourcemap/003/output/index.map @@ -1,5 +1,5 @@ { - "mappings": "AAAA,yGAAA,gBAAe,SAASA,CAAU,CAAC,CAAQ,CAAE,KAAV,AAAEC,CAAI,CAAN,CAAQ,CAANA,IAAI,AAAE,AACvC,QAAO,oBAACC,KAAG,MAAED,CAAI,CAACE,GAAG,CAAO,AAAC,AACjC,CAAC,AAED,iBAAsBC,cAAc,UAAdA,CAAc,uBAQnC,SARqBA,CAAc,UAAdA,CAAc,CAA7B,EAAA,UAAgC,iCACnC,iBACIC,KAAK,CAAE,CACHJ,IAAI,CAAE,CACFE,GAAG,CAAE,KAAK,CACb,CACJ,IACH,EACN,CAAC,CAAA,wBAAA", + "mappings": "AAAA,0FAAA,gBAAe,SAASA,CAAU,CAAC,CAAQ,CAAE,KAAV,AAAEC,CAAI,CAAN,CAAQ,CAANA,IAAI,AAAE,AACvC,QAAO,oBAACC,KAAG,MAAED,CAAI,CAACE,GAAG,CAAO,AAAC,AACjC,CAAC,AAED,iBAAsBC,cAAc,UAAdA,CAAc,uBAQnC,SARqBA,CAAc,UAAdA,CAAc,CAA7B,SAAA,YAAgC,wFAC5B,CACHC,KAAK,CAAE,CACHJ,IAAI,CAAE,CACFE,GAAG,CAAE,KAAK,CACb,CACJ,CACJ,uCACL,CAAC,EAAA,wBAAA", "names": [ "StaticPage", "data", diff --git a/crates/swc/tests/fixture/sourcemap/005/output/index.js b/crates/swc/tests/fixture/sourcemap/005/output/index.js index 01c4b2b6fe0..293e6eb01c9 100644 --- a/crates/swc/tests/fixture/sourcemap/005/output/index.js +++ b/crates/swc/tests/fixture/sourcemap/005/output/index.js @@ -1,70 +1,69 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -it("should compress avif smaller than webp and smaller than jpg", /*#__PURE__*/ _async_to_generator(function() { - var query, _tmp, res1, _tmp1, res2, _tmp2, res3, _tmp3, avif, webp, jpeg, _tmp4; - return _ts_generator(this, function(_state) { - switch(_state.label){ +import regeneratorRuntime from "regenerator-runtime"; +it("should compress avif smaller than webp and smaller than jpg", /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var query, res1, res2, res3, avif, webp, jpeg; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp = {}; - query = (_tmp.url = "/test.jpg", _tmp.w = w, _tmp.q = 75, _tmp); - _tmp1 = {}; - return [ - 4, - fetchViaHTTP(appPort, "/_next/image", query, (_tmp1.headers = { + query = { + url: "/test.jpg", + w: w, + q: 75 + }; + _ctx.next = 3; + return fetchViaHTTP(appPort, "/_next/image", query, { + headers: { accept: "image/avif" - }, _tmp1)) - ]; - case 1: - res1 = _state.sent(); + } + }); + case 3: + res1 = _ctx.sent; expect(res1.status).toBe(200); expect(res1.headers.get("Content-Type")).toBe("image/avif"); - _tmp2 = {}; - return [ - 4, - fetchViaHTTP(appPort, "/_next/image", query, (_tmp2.headers = { + _ctx.next = 8; + return fetchViaHTTP(appPort, "/_next/image", query, { + headers: { accept: "image/webp" - }, _tmp2)) - ]; - case 2: - res2 = _state.sent(); + } + }); + case 8: + res2 = _ctx.sent; expect(res2.status).toBe(200); expect(res2.headers.get("Content-Type")).toBe("image/webp"); - _tmp3 = {}; - return [ - 4, - fetchViaHTTP(appPort, "/_next/image", query, (_tmp3.headers = { + _ctx.next = 13; + return fetchViaHTTP(appPort, "/_next/image", query, { + headers: { accept: "image/jpeg" - }, _tmp3)) - ]; - case 3: - res3 = _state.sent(); + } + }); + case 13: + res3 = _ctx.sent; expect(res3.status).toBe(200); expect(res3.headers.get("Content-Type")).toBe("image/jpeg"); - return [ - 4, - res1.buffer() - ]; - case 4: - avif = _state.sent().byteLength; - return [ - 4, - res2.buffer() - ]; - case 5: - webp = _state.sent().byteLength; - return [ - 4, - res3.buffer() - ]; - case 6: - jpeg = _state.sent().byteLength; - _tmp4 = {}; - console.log((_tmp4.isSharp = isSharp, _tmp4.w = w, _tmp4.avif = avif, _tmp4.webp = webp, _tmp4.jpeg = jpeg, _tmp4)); + _ctx.next = 18; + return res1.buffer(); + case 18: + avif = _ctx.sent.byteLength; + _ctx.next = 21; + return res2.buffer(); + case 21: + webp = _ctx.sent.byteLength; + _ctx.next = 24; + return res3.buffer(); + case 24: + jpeg = _ctx.sent.byteLength; + console.log({ + isSharp: isSharp, + w: w, + avif: avif, + webp: webp, + jpeg: jpeg + }); expect(webp).toBeLessThan(jpeg); expect(avif).toBeLessThan(webp); - return [ - 2 - ]; + case 28: + case "end": + return _ctx.stop(); } - }); -})); + }, _callee); +}))); diff --git a/crates/swc/tests/fixture/sourcemap/005/output/index.map b/crates/swc/tests/fixture/sourcemap/005/output/index.map index b9cbc8f36a3..3e25a683984 100644 --- a/crates/swc/tests/fixture/sourcemap/005/output/index.map +++ b/crates/swc/tests/fixture/sourcemap/005/output/index.map @@ -1,5 +1,5 @@ { - "mappings": "AAAAA;;AAAAA,EAAE,CAAC,6DAA6D,gBAAE,oBAAA,WAAY;QACpEC,KAAK,QACLC,IAAI,SAQJC,IAAI,SAQJC,IAAI,SAQJC,IAAI,EACJC,IAAI,EACJC,IAAI;;;;;gBA3BJN,KAAK,SAAKO,GAAG,GAAE,WAAW,OAAEC,CAAC,GAADA,CAAC,OAAEC,CAAC,GAAE,EAAE,OAAE,CAAC;;gBAChC;;oBAAMC,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,SAC1DY,OAAO,GAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB,SACH;kBAAA;;gBAJIZ,IAAI,GAAG,aAIX,CAAA;gBACFa,MAAM,CAACb,IAAI,CAACc,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACb,IAAI,CAACW,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;;gBAE/C;;oBAAMN,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,SAC1DY,OAAO,GAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB,SACH;kBAAA;;gBAJIX,IAAI,GAAG,aAIX,CAAA;gBACFY,MAAM,CAACZ,IAAI,CAACa,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACZ,IAAI,CAACU,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;;gBAE/C;;oBAAMN,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,SAC1DY,OAAO,GAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB,SACH;kBAAA;;gBAJIV,IAAI,GAAG,aAIX,CAAA;gBACFW,MAAM,CAACX,IAAI,CAACY,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACX,IAAI,CAACS,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;gBAE9C;;oBAAMf,IAAI,CAACiB,MAAM,EAAE;kBAAA;;gBAA3Bd,IAAI,GAAG,AAAC,aAAmB,CAAEe,UAAU,CAAA;gBAC/B;;oBAAMjB,IAAI,CAACgB,MAAM,EAAE;kBAAA;;gBAA3Bb,IAAI,GAAG,AAAC,aAAmB,CAAEc,UAAU,CAAA;gBAC/B;;oBAAMhB,IAAI,CAACe,MAAM,EAAE;kBAAA;;gBAA3BZ,IAAI,GAAG,AAAC,aAAmB,CAAEa,UAAU,CAAA;;gBAE7CC,OAAO,CAACC,GAAG,QAAGC,OAAO,GAAPA,OAAO,QAAEd,CAAC,GAADA,CAAC,QAAEJ,IAAI,GAAJA,IAAI,QAAEC,IAAI,GAAJA,IAAI,QAAEC,IAAI,GAAJA,IAAI,SAAG,CAAC;gBAE9CQ,MAAM,CAACT,IAAI,CAAC,CAACkB,YAAY,CAACjB,IAAI,CAAC,CAAC;gBAChCQ,MAAM,CAACV,IAAI,CAAC,CAACmB,YAAY,CAAClB,IAAI,CAAC,CAAC;;;;;;AACpC,CAAC,CAAA,CAAC,CAAC", + "mappings": "AAAAA;;AAAAA,EAAE,CAAC,6DAA6D,gBAAE,0DAAA,mBAAY;QACpEC,KAAK,EACLC,IAAI,EAQJC,IAAI,EAQJC,IAAI,EAQJC,IAAI,EACJC,IAAI,EACJC,IAAI;;;;gBA3BJN,KAAK,GAAG;oBAAEO,GAAG,EAAE,WAAW;oBAAEC,CAAC,EAADA,CAAC;oBAAEC,CAAC,EAAE,EAAE;iBAAE,CAAC;;uBAC1BC,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,EAAE;oBAC5DY,OAAO,EAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB;iBACJ,CAAC;;gBAJIZ,IAAI,YAIR,CAAA;gBACFa,MAAM,CAACb,IAAI,CAACc,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACb,IAAI,CAACW,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;;uBAEzCN,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,EAAE;oBAC5DY,OAAO,EAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB;iBACJ,CAAC;;gBAJIX,IAAI,YAIR,CAAA;gBACFY,MAAM,CAACZ,IAAI,CAACa,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACZ,IAAI,CAACU,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;;uBAEzCN,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,EAAE;oBAC5DY,OAAO,EAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB;iBACJ,CAAC;;gBAJIV,IAAI,YAIR,CAAA;gBACFW,MAAM,CAACX,IAAI,CAACY,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACX,IAAI,CAACS,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;;uBAExCf,IAAI,CAACiB,MAAM,EAAE;;gBAA3Bd,IAAI,GAAG,UAAsBe,UAAU,CAAA;;uBACzBjB,IAAI,CAACgB,MAAM,EAAE;;gBAA3Bb,IAAI,GAAG,UAAsBc,UAAU,CAAA;;uBACzBhB,IAAI,CAACe,MAAM,EAAE;;gBAA3BZ,IAAI,GAAG,UAAsBa,UAAU,CAAA;gBAE7CC,OAAO,CAACC,GAAG,CAAC;oBAAEC,OAAO,EAAPA,OAAO;oBAAEd,CAAC,EAADA,CAAC;oBAAEJ,IAAI,EAAJA,IAAI;oBAAEC,IAAI,EAAJA,IAAI;oBAAEC,IAAI,EAAJA,IAAI;iBAAE,CAAC,CAAC;gBAE9CQ,MAAM,CAACT,IAAI,CAAC,CAACkB,YAAY,CAACjB,IAAI,CAAC,CAAC;gBAChCQ,MAAM,CAACV,IAAI,CAAC,CAACmB,YAAY,CAAClB,IAAI,CAAC,CAAC;;;;;;AACpC,CAAC,EAAA,CAAC,CAAC", "names": [ "it", "query", diff --git a/crates/swc/tests/fixture/sourcemap/006/output/index.js b/crates/swc/tests/fixture/sourcemap/006/output/index.js index 01c4b2b6fe0..293e6eb01c9 100644 --- a/crates/swc/tests/fixture/sourcemap/006/output/index.js +++ b/crates/swc/tests/fixture/sourcemap/006/output/index.js @@ -1,70 +1,69 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -it("should compress avif smaller than webp and smaller than jpg", /*#__PURE__*/ _async_to_generator(function() { - var query, _tmp, res1, _tmp1, res2, _tmp2, res3, _tmp3, avif, webp, jpeg, _tmp4; - return _ts_generator(this, function(_state) { - switch(_state.label){ +import regeneratorRuntime from "regenerator-runtime"; +it("should compress avif smaller than webp and smaller than jpg", /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var query, res1, res2, res3, avif, webp, jpeg; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp = {}; - query = (_tmp.url = "/test.jpg", _tmp.w = w, _tmp.q = 75, _tmp); - _tmp1 = {}; - return [ - 4, - fetchViaHTTP(appPort, "/_next/image", query, (_tmp1.headers = { + query = { + url: "/test.jpg", + w: w, + q: 75 + }; + _ctx.next = 3; + return fetchViaHTTP(appPort, "/_next/image", query, { + headers: { accept: "image/avif" - }, _tmp1)) - ]; - case 1: - res1 = _state.sent(); + } + }); + case 3: + res1 = _ctx.sent; expect(res1.status).toBe(200); expect(res1.headers.get("Content-Type")).toBe("image/avif"); - _tmp2 = {}; - return [ - 4, - fetchViaHTTP(appPort, "/_next/image", query, (_tmp2.headers = { + _ctx.next = 8; + return fetchViaHTTP(appPort, "/_next/image", query, { + headers: { accept: "image/webp" - }, _tmp2)) - ]; - case 2: - res2 = _state.sent(); + } + }); + case 8: + res2 = _ctx.sent; expect(res2.status).toBe(200); expect(res2.headers.get("Content-Type")).toBe("image/webp"); - _tmp3 = {}; - return [ - 4, - fetchViaHTTP(appPort, "/_next/image", query, (_tmp3.headers = { + _ctx.next = 13; + return fetchViaHTTP(appPort, "/_next/image", query, { + headers: { accept: "image/jpeg" - }, _tmp3)) - ]; - case 3: - res3 = _state.sent(); + } + }); + case 13: + res3 = _ctx.sent; expect(res3.status).toBe(200); expect(res3.headers.get("Content-Type")).toBe("image/jpeg"); - return [ - 4, - res1.buffer() - ]; - case 4: - avif = _state.sent().byteLength; - return [ - 4, - res2.buffer() - ]; - case 5: - webp = _state.sent().byteLength; - return [ - 4, - res3.buffer() - ]; - case 6: - jpeg = _state.sent().byteLength; - _tmp4 = {}; - console.log((_tmp4.isSharp = isSharp, _tmp4.w = w, _tmp4.avif = avif, _tmp4.webp = webp, _tmp4.jpeg = jpeg, _tmp4)); + _ctx.next = 18; + return res1.buffer(); + case 18: + avif = _ctx.sent.byteLength; + _ctx.next = 21; + return res2.buffer(); + case 21: + webp = _ctx.sent.byteLength; + _ctx.next = 24; + return res3.buffer(); + case 24: + jpeg = _ctx.sent.byteLength; + console.log({ + isSharp: isSharp, + w: w, + avif: avif, + webp: webp, + jpeg: jpeg + }); expect(webp).toBeLessThan(jpeg); expect(avif).toBeLessThan(webp); - return [ - 2 - ]; + case 28: + case "end": + return _ctx.stop(); } - }); -})); + }, _callee); +}))); diff --git a/crates/swc/tests/fixture/sourcemap/006/output/index.map b/crates/swc/tests/fixture/sourcemap/006/output/index.map index 4c4dccdf7c8..3ae9de99bcc 100644 --- a/crates/swc/tests/fixture/sourcemap/006/output/index.map +++ b/crates/swc/tests/fixture/sourcemap/006/output/index.map @@ -1,5 +1,5 @@ { - "mappings": "AAAAA;;AAAAA,EAAE,CAAC,6DAA6D,gBAAE,oBAAA,WAAY;QAOpEC,KAAK,QACLC,IAAI,SAQJC,IAAI,SAQJC,IAAI,SAQJC,IAAI,EACJC,IAAI,EACJC,IAAI;;;;;gBA3BJN,KAAK,SAAKO,GAAG,GAAE,WAAW,OAAEC,CAAC,GAADA,CAAC,OAAEC,CAAC,GAAE,EAAE,OAAE,CAAC;;gBAChC;;oBAAMC,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,SAC1DY,OAAO,GAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB,SACH;kBAAA;;gBAJIZ,IAAI,GAAG,aAIX,CAAA;gBACFa,MAAM,CAACb,IAAI,CAACc,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACb,IAAI,CAACW,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;;gBAE/C;;oBAAMN,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,SAC1DY,OAAO,GAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB,SACH;kBAAA;;gBAJIX,IAAI,GAAG,aAIX,CAAA;gBACFY,MAAM,CAACZ,IAAI,CAACa,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACZ,IAAI,CAACU,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;;gBAE/C;;oBAAMN,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,SAC1DY,OAAO,GAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB,SACH;kBAAA;;gBAJIV,IAAI,GAAG,aAIX,CAAA;gBACFW,MAAM,CAACX,IAAI,CAACY,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACX,IAAI,CAACS,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;gBAE9C;;oBAAMf,IAAI,CAACiB,MAAM,EAAE;kBAAA;;gBAA3Bd,IAAI,GAAG,AAAC,aAAmB,CAAEe,UAAU,CAAA;gBAC/B;;oBAAMjB,IAAI,CAACgB,MAAM,EAAE;kBAAA;;gBAA3Bb,IAAI,GAAG,AAAC,aAAmB,CAAEc,UAAU,CAAA;gBAC/B;;oBAAMhB,IAAI,CAACe,MAAM,EAAE;kBAAA;;gBAA3BZ,IAAI,GAAG,AAAC,aAAmB,CAAEa,UAAU,CAAA;;gBAE7CC,OAAO,CAACC,GAAG,QAAGC,OAAO,GAAPA,OAAO,QAAEd,CAAC,GAADA,CAAC,QAAEJ,IAAI,GAAJA,IAAI,QAAEC,IAAI,GAAJA,IAAI,QAAEC,IAAI,GAAJA,IAAI,SAAG,CAAC;gBAE9CQ,MAAM,CAACT,IAAI,CAAC,CAACkB,YAAY,CAACjB,IAAI,CAAC,CAAC;gBAChCQ,MAAM,CAACV,IAAI,CAAC,CAACmB,YAAY,CAAClB,IAAI,CAAC,CAAC;;;;;;AACpC,CAAC,CAAA,CAAC,CAAC", + "mappings": "AAAAA;;AAAAA,EAAE,CAAC,6DAA6D,gBAAE,0DAAA,mBAAY;QAOpEC,KAAK,EACLC,IAAI,EAQJC,IAAI,EAQJC,IAAI,EAQJC,IAAI,EACJC,IAAI,EACJC,IAAI;;;;gBA3BJN,KAAK,GAAG;oBAAEO,GAAG,EAAE,WAAW;oBAAEC,CAAC,EAADA,CAAC;oBAAEC,CAAC,EAAE,EAAE;iBAAE,CAAC;;uBAC1BC,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,EAAE;oBAC5DY,OAAO,EAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB;iBACJ,CAAC;;gBAJIZ,IAAI,YAIR,CAAA;gBACFa,MAAM,CAACb,IAAI,CAACc,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACb,IAAI,CAACW,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;;uBAEzCN,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,EAAE;oBAC5DY,OAAO,EAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB;iBACJ,CAAC;;gBAJIX,IAAI,YAIR,CAAA;gBACFY,MAAM,CAACZ,IAAI,CAACa,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACZ,IAAI,CAACU,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;;uBAEzCN,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,EAAE;oBAC5DY,OAAO,EAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB;iBACJ,CAAC;;gBAJIV,IAAI,YAIR,CAAA;gBACFW,MAAM,CAACX,IAAI,CAACY,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACX,IAAI,CAACS,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;;uBAExCf,IAAI,CAACiB,MAAM,EAAE;;gBAA3Bd,IAAI,GAAG,UAAsBe,UAAU,CAAA;;uBACzBjB,IAAI,CAACgB,MAAM,EAAE;;gBAA3Bb,IAAI,GAAG,UAAsBc,UAAU,CAAA;;uBACzBhB,IAAI,CAACe,MAAM,EAAE;;gBAA3BZ,IAAI,GAAG,UAAsBa,UAAU,CAAA;gBAE7CC,OAAO,CAACC,GAAG,CAAC;oBAAEC,OAAO,EAAPA,OAAO;oBAAEd,CAAC,EAADA,CAAC;oBAAEJ,IAAI,EAAJA,IAAI;oBAAEC,IAAI,EAAJA,IAAI;oBAAEC,IAAI,EAAJA,IAAI;iBAAE,CAAC,CAAC;gBAE9CQ,MAAM,CAACT,IAAI,CAAC,CAACkB,YAAY,CAACjB,IAAI,CAAC,CAAC;gBAChCQ,MAAM,CAACV,IAAI,CAAC,CAACmB,YAAY,CAAClB,IAAI,CAAC,CAAC;;;;;;AACpC,CAAC,EAAA,CAAC,CAAC", "names": [ "it", "query", diff --git a/crates/swc/tests/stacktrace/issue-622/output/stacks.txt b/crates/swc/tests/stacktrace/issue-622/output/stacks.txt index 43681402f33..e3e53104b40 100644 --- a/crates/swc/tests/stacktrace/issue-622/output/stacks.txt +++ b/crates/swc/tests/stacktrace/issue-622/output/stacks.txt @@ -3,13 +3,10 @@ $DIR/tests/stacktrace/issue-622/input/index.js:3 ^ ReferenceError: call is not defined - at null. ($DIR/tests/stacktrace/issue-622/input/index.js:3:9) - at null.step ($DIR/tests/stacktrace/issue-622/input/index.js:1:1) - at Object.next ($DIR/tests/stacktrace/issue-622/input/index.js:1:1) + at null._callee$ ($DIR/tests/stacktrace/issue-622/input/index.js:3:9) at null.asyncGeneratorStep ($DIR/tests/stacktrace/issue-622/input/index.js:1:1) at null._next ($DIR/tests/stacktrace/issue-622/input/index.js:1:1) at null. ($DIR/tests/stacktrace/issue-622/input/index.js:1:1) at new Promise () at null. ($DIR/tests/stacktrace/issue-622/input/index.js:1:1) at null._foo ($DIR/tests/stacktrace/issue-622/input/index.js:1:19) - at null.foo ($DIR/tests/stacktrace/issue-622/input/index.js:1:19) diff --git a/crates/swc/tests/tsc-references/FunctionDeclaration13_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/FunctionDeclaration13_es6_es5.1.normal.js index da8bb01b1f8..46bafa5d272 100644 --- a/crates/swc/tests/tsc-references/FunctionDeclaration13_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/FunctionDeclaration13_es6_es5.1.normal.js @@ -1,10 +1,15 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(foo); function foo() { var v; - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ; + case 1: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/FunctionDeclaration13_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/FunctionDeclaration13_es6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/FunctionDeclaration13_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/FunctionDeclaration13_es6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/FunctionDeclaration1_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/FunctionDeclaration1_es6_es5.1.normal.js index a2b970c10a0..617d437c222 100644 --- a/crates/swc/tests/tsc-references/FunctionDeclaration1_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/FunctionDeclaration1_es6_es5.1.normal.js @@ -1,9 +1,12 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(foo); function foo() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/FunctionDeclaration1_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/FunctionDeclaration1_es6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/FunctionDeclaration1_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/FunctionDeclaration1_es6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/FunctionDeclaration9_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/FunctionDeclaration9_es6_es5.1.normal.js index 2a2a76ba502..b9388217a18 100644 --- a/crates/swc/tests/tsc-references/FunctionDeclaration9_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/FunctionDeclaration9_es6_es5.1.normal.js @@ -1,23 +1,23 @@ // @target: es6 import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(foo); function foo() { - var v, _tmp, _tmp1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + var v; + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp1 = {}; - _tmp = [ - _tmp1 - ]; - return [ - 4 - ]; - case 1: - v = _define_property.apply(void 0, _tmp.concat(_state.sent(), foo)); - return [ - 2 - ]; + _ctx.t0 = _define_property; + _ctx.t1 = {}; + _ctx.next = 4; + return; + case 4: + _ctx.t2 = _ctx.sent; + _ctx.t3 = foo; + v = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); + case 7: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/FunctionDeclaration9_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/FunctionDeclaration9_es6_es5.2.minified.js index 5b0bb03ca6d..aac75dd6df5 100644 --- a/crates/swc/tests/tsc-references/FunctionDeclaration9_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/FunctionDeclaration9_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/FunctionExpression1_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/FunctionExpression1_es6_es5.1.normal.js index 944c2831a45..ea79c1c36bc 100644 --- a/crates/swc/tests/tsc-references/FunctionExpression1_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/FunctionExpression1_es6_es5.1.normal.js @@ -1,9 +1,11 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -var v = function v() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}; +import regeneratorRuntime from "regenerator-runtime"; +var v = /*#__PURE__*/ regeneratorRuntime.mark(function v() { + return regeneratorRuntime.wrap(function v$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, v); +}); diff --git a/crates/swc/tests/tsc-references/FunctionExpression1_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/FunctionExpression1_es6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/FunctionExpression1_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/FunctionExpression1_es6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/FunctionExpression2_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/FunctionExpression2_es6_es5.1.normal.js index 0a84f3bdd12..9ff0fbc807d 100644 --- a/crates/swc/tests/tsc-references/FunctionExpression2_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/FunctionExpression2_es6_es5.1.normal.js @@ -1,9 +1,11 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -var v = function foo() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}; +import regeneratorRuntime from "regenerator-runtime"; +var v = /*#__PURE__*/ regeneratorRuntime.mark(function foo() { + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, foo); +}); diff --git a/crates/swc/tests/tsc-references/FunctionExpression2_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/FunctionExpression2_es6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/FunctionExpression2_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/FunctionExpression2_es6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/FunctionPropertyAssignments1_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/FunctionPropertyAssignments1_es6_es5.1.normal.js index 383b0689734..67d598a527a 100644 --- a/crates/swc/tests/tsc-references/FunctionPropertyAssignments1_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/FunctionPropertyAssignments1_es6_es5.1.normal.js @@ -1,11 +1,13 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var v = { - foo: function foo() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - } + foo: /*#__PURE__*/ regeneratorRuntime.mark(function foo() { + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, foo); + }) }; diff --git a/crates/swc/tests/tsc-references/FunctionPropertyAssignments1_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/FunctionPropertyAssignments1_es6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/FunctionPropertyAssignments1_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/FunctionPropertyAssignments1_es6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/FunctionPropertyAssignments5_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/FunctionPropertyAssignments5_es6_es5.1.normal.js index cc5378d4b56..c8a90fb5e5b 100644 --- a/crates/swc/tests/tsc-references/FunctionPropertyAssignments5_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/FunctionPropertyAssignments5_es6_es5.1.normal.js @@ -1,10 +1,12 @@ // @target: es6 import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -var v = _define_property({}, foo(), function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}); +import regeneratorRuntime from "regenerator-runtime"; +var v = _define_property({}, foo(), /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); +})); diff --git a/crates/swc/tests/tsc-references/FunctionPropertyAssignments5_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/FunctionPropertyAssignments5_es6_es5.2.minified.js index 913c899f448..d29326bb7b5 100644 --- a/crates/swc/tests/tsc-references/FunctionPropertyAssignments5_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/FunctionPropertyAssignments5_es6_es5.2.minified.js @@ -1,9 +1,11 @@ import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -_define_property({}, foo(), function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}); +import regeneratorRuntime from "regenerator-runtime"; +_define_property({}, foo(), regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); +})); diff --git a/crates/swc/tests/tsc-references/MemberFunctionDeclaration1_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/MemberFunctionDeclaration1_es6_es5.1.normal.js index c2db1581505..e4eb6f78a4c 100644 --- a/crates/swc/tests/tsc-references/MemberFunctionDeclaration1_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/MemberFunctionDeclaration1_es6_es5.1.normal.js @@ -1,18 +1,20 @@ // @target: es6 import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { _class_call_check(this, C); } var _proto = C.prototype; - _proto.foo = function foo() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }; + _proto.foo = /*#__PURE__*/ regeneratorRuntime.mark(function foo() { + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, foo); + }); return C; }(); diff --git a/crates/swc/tests/tsc-references/MemberFunctionDeclaration1_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/MemberFunctionDeclaration1_es6_es5.2.minified.js index e1e1ce181c9..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/MemberFunctionDeclaration1_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/MemberFunctionDeclaration1_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/MemberFunctionDeclaration2_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/MemberFunctionDeclaration2_es6_es5.1.normal.js index c2db1581505..e4eb6f78a4c 100644 --- a/crates/swc/tests/tsc-references/MemberFunctionDeclaration2_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/MemberFunctionDeclaration2_es6_es5.1.normal.js @@ -1,18 +1,20 @@ // @target: es6 import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { _class_call_check(this, C); } var _proto = C.prototype; - _proto.foo = function foo() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }; + _proto.foo = /*#__PURE__*/ regeneratorRuntime.mark(function foo() { + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, foo); + }); return C; }(); diff --git a/crates/swc/tests/tsc-references/MemberFunctionDeclaration2_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/MemberFunctionDeclaration2_es6_es5.2.minified.js index e1e1ce181c9..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/MemberFunctionDeclaration2_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/MemberFunctionDeclaration2_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/MemberFunctionDeclaration3_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/MemberFunctionDeclaration3_es6_es5.1.normal.js index b44b6f0978c..af1e2ad1845 100644 --- a/crates/swc/tests/tsc-references/MemberFunctionDeclaration3_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/MemberFunctionDeclaration3_es6_es5.1.normal.js @@ -1,18 +1,20 @@ // @target: es6 import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { _class_call_check(this, C); } var _proto = C.prototype; - _proto[foo] = function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }; + _proto[foo] = /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }); return C; }(); diff --git a/crates/swc/tests/tsc-references/MemberFunctionDeclaration3_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/MemberFunctionDeclaration3_es6_es5.2.minified.js index e1e1ce181c9..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/MemberFunctionDeclaration3_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/MemberFunctionDeclaration3_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/MemberFunctionDeclaration7_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/MemberFunctionDeclaration7_es6_es5.1.normal.js index c2db1581505..e4eb6f78a4c 100644 --- a/crates/swc/tests/tsc-references/MemberFunctionDeclaration7_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/MemberFunctionDeclaration7_es6_es5.1.normal.js @@ -1,18 +1,20 @@ // @target: es6 import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { _class_call_check(this, C); } var _proto = C.prototype; - _proto.foo = function foo() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }; + _proto.foo = /*#__PURE__*/ regeneratorRuntime.mark(function foo() { + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, foo); + }); return C; }(); diff --git a/crates/swc/tests/tsc-references/MemberFunctionDeclaration7_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/MemberFunctionDeclaration7_es6_es5.2.minified.js index e1e1ce181c9..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/MemberFunctionDeclaration7_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/MemberFunctionDeclaration7_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/YieldExpression10_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/YieldExpression10_es6_es5.1.normal.js index 1fd079cac32..3b2b09bc98e 100644 --- a/crates/swc/tests/tsc-references/YieldExpression10_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/YieldExpression10_es6_es5.1.normal.js @@ -1,20 +1,16 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var v = { - foo: function foo1() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + foo: /*#__PURE__*/ regeneratorRuntime.mark(function foo1() { + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - foo - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return foo; + case 2: + case "end": + return _ctx.stop(); } - }); - } + }, foo1); + }) }; diff --git a/crates/swc/tests/tsc-references/YieldExpression10_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/YieldExpression10_es6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/YieldExpression10_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/YieldExpression10_es6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/YieldExpression11_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/YieldExpression11_es6_es5.1.normal.js index cfb2c2b45e5..2b8dbf8d728 100644 --- a/crates/swc/tests/tsc-references/YieldExpression11_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/YieldExpression11_es6_es5.1.normal.js @@ -1,27 +1,23 @@ // @target: es6 import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { _class_call_check(this, C); } var _proto = C.prototype; - _proto.foo = function foo1() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _proto.foo = /*#__PURE__*/ regeneratorRuntime.mark(function foo1() { + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - foo - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return foo; + case 2: + case "end": + return _ctx.stop(); } - }); - }; + }, foo1); + }); return C; }(); diff --git a/crates/swc/tests/tsc-references/YieldExpression11_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/YieldExpression11_es6_es5.2.minified.js index e1e1ce181c9..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/YieldExpression11_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/YieldExpression11_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/YieldExpression13_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/YieldExpression13_es6_es5.1.normal.js index 1b8dd0ddb50..c1f63e109dc 100644 --- a/crates/swc/tests/tsc-references/YieldExpression13_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/YieldExpression13_es6_es5.1.normal.js @@ -1,17 +1,15 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(foo); function foo() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/YieldExpression13_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/YieldExpression13_es6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/YieldExpression13_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/YieldExpression13_es6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/YieldExpression19_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/YieldExpression19_es6_es5.1.normal.js index e77c97523ce..cb76dcd9dbf 100644 --- a/crates/swc/tests/tsc-references/YieldExpression19_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/YieldExpression19_es6_es5.1.normal.js @@ -1,28 +1,29 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(foo); function foo() { var bar; - return _ts_generator(this, function(_state) { - bar = function bar() { - function quux() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - foo - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + bar = function bar() { + var _marked = /*#__PURE__*/ regeneratorRuntime.mark(quux); + function quux() { + return regeneratorRuntime.wrap(function quux$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return foo; + case 2: + case "end": + return _ctx.stop(); + } + }, _marked); } - }); - } - }; - return [ - 2 - ]; - }); + }; + case 1: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/YieldExpression19_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/YieldExpression19_es6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/YieldExpression19_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/YieldExpression19_es6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/YieldExpression3_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/YieldExpression3_es6_es5.1.normal.js index bc34dee12da..6f9371f50e0 100644 --- a/crates/swc/tests/tsc-references/YieldExpression3_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/YieldExpression3_es6_es5.1.normal.js @@ -1,22 +1,18 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(foo); function foo() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 4 - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return; + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/YieldExpression3_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/YieldExpression3_es6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/YieldExpression3_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/YieldExpression3_es6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/YieldExpression4_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/YieldExpression4_es6_es5.1.normal.js index bc34dee12da..6f9371f50e0 100644 --- a/crates/swc/tests/tsc-references/YieldExpression4_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/YieldExpression4_es6_es5.1.normal.js @@ -1,22 +1,18 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(foo); function foo() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 4 - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return; + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/YieldExpression4_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/YieldExpression4_es6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/YieldExpression4_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/YieldExpression4_es6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/YieldExpression6_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/YieldExpression6_es6_es5.1.normal.js index 15499dfe650..29b0051f1b2 100644 --- a/crates/swc/tests/tsc-references/YieldExpression6_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/YieldExpression6_es6_es5.1.normal.js @@ -1,19 +1,14 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(foo); function foo() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(foo) - ]; + return _ctx.delegateYield(foo, "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/YieldExpression6_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/YieldExpression6_es6_es5.2.minified.js index 488ea2b0d50..a79c39969f3 100644 --- a/crates/swc/tests/tsc-references/YieldExpression6_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/YieldExpression6_es6_es5.2.minified.js @@ -1,2 +1,13 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = regeneratorRuntime.mark(foo); +function foo() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.delegateYield(foo, "t0", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked); +} diff --git a/crates/swc/tests/tsc-references/YieldExpression7_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/YieldExpression7_es6_es5.1.normal.js index c9cc421df03..1b97724edcd 100644 --- a/crates/swc/tests/tsc-references/YieldExpression7_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/YieldExpression7_es6_es5.1.normal.js @@ -1,18 +1,15 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(foo); function foo() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function foo$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - foo - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return foo; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/YieldExpression7_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/YieldExpression7_es6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/YieldExpression7_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/YieldExpression7_es6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/YieldExpression9_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/YieldExpression9_es6_es5.1.normal.js index aacecc8c227..26d71b46d85 100644 --- a/crates/swc/tests/tsc-references/YieldExpression9_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/YieldExpression9_es6_es5.1.normal.js @@ -1,18 +1,14 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -var v = function v() { - return _ts_generator(this, function(_state) { - switch(_state.label){ +import regeneratorRuntime from "regenerator-runtime"; +var v = /*#__PURE__*/ regeneratorRuntime.mark(function v() { + return regeneratorRuntime.wrap(function v$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - foo - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return foo; + case 2: + case "end": + return _ctx.stop(); } - }); -}; + }, v); +}); diff --git a/crates/swc/tests/tsc-references/YieldExpression9_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/YieldExpression9_es6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/YieldExpression9_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/YieldExpression9_es6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/YieldStarExpression4_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/YieldStarExpression4_es6_es5.1.normal.js index 94cb0f69a36..76b03a3c45b 100644 --- a/crates/swc/tests/tsc-references/YieldStarExpression4_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/YieldStarExpression4_es6_es5.1.normal.js @@ -1,19 +1,14 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values([]) - ]; + return _ctx.delegateYield([], "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/YieldStarExpression4_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/YieldStarExpression4_es6_es5.2.minified.js index 488ea2b0d50..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/YieldStarExpression4_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/YieldStarExpression4_es6_es5.2.minified.js @@ -1,2 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncAliasReturnType_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAliasReturnType_es5_es5.1.normal.js index 250dec388fe..4c552cd2f36 100644 --- a/crates/swc/tests/tsc-references/asyncAliasReturnType_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAliasReturnType_es5_es5.1.normal.js @@ -2,17 +2,19 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f() { return _f.apply(this, arguments); } function _f() { - _f = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncAliasReturnType_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncAliasReturnType_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncAliasReturnType_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAliasReturnType_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncAliasReturnType_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAliasReturnType_es6_es5.1.normal.js index 052851a0f26..edad983f8cd 100644 --- a/crates/swc/tests/tsc-references/asyncAliasReturnType_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAliasReturnType_es6_es5.1.normal.js @@ -1,17 +1,19 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f() { return _f.apply(this, arguments); } function _f() { - _f = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncAliasReturnType_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncAliasReturnType_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncAliasReturnType_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAliasReturnType_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction10_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunction10_es2017_es5.1.normal.js index f90acb08d97..de4cf0f1c10 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction10_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction10_es2017_es5.1.normal.js @@ -1,16 +1,20 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var foo = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var v; - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function foo() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction10_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction10_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction10_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction10_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction10_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunction10_es5_es5.1.normal.js index 2ed9055b7d8..265626ae485 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction10_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction10_es5_es5.1.normal.js @@ -2,16 +2,20 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var foo = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var v; - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function foo() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction10_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction10_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction10_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction10_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction10_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunction10_es6_es5.1.normal.js index 9115af04637..6af2823b8b0 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction10_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction10_es6_es5.1.normal.js @@ -1,16 +1,20 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var foo = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var v; - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function foo() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction10_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction10_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction10_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction10_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction11_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunction11_es5_es5.1.normal.js index 2662463d6c9..dd0ff15f75c 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction11_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction11_es5_es5.1.normal.js @@ -5,34 +5,29 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var A = function A() { "use strict"; _class_call_check(this, A); var _this = this; - this.b = /*#__PURE__*/ _async_to_generator(function() { - var _len, args, _key, obj, _tmp; - var _arguments = arguments; - return _ts_generator(this, function(_state) { - switch(_state.label){ + this.b = /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var _len, args, _key, obj, _args = arguments; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - for(_len = _arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){ - args[_key] = _arguments[_key]; + for(_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++){ + args[_key] = _args[_key]; } - return [ - 4, - Promise.resolve() - ]; - case 1: - _state.sent(); - _tmp = {}; - obj = _define_property(_tmp, "a", function() { + _ctx.next = 3; + return Promise.resolve(); + case 3: + obj = _define_property({}, "a", function() { return _this; }); // computed property name after `await` triggers case - return [ - 2 - ]; + case 4: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction11_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction11_es5_es5.2.minified.js index 05a32126231..4456ada471b 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction11_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction11_es5_es5.2.minified.js @@ -1,4 +1,4 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction1_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunction1_es2017_es5.1.normal.js index 50f58b52a62..48ba0adffe9 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction1_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction1_es2017_es5.1.normal.js @@ -1,15 +1,17 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var foo = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function foo() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction1_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction1_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction1_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction1_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction1_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunction1_es5_es5.1.normal.js index f3066675bfb..3e306f5e3f3 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction1_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction1_es5_es5.1.normal.js @@ -2,15 +2,17 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var foo = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function foo() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction1_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction1_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction1_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction1_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction1_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunction1_es6_es5.1.normal.js index 7fbea6d7670..566d319f64a 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction1_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction1_es6_es5.1.normal.js @@ -1,15 +1,17 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var foo = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function foo() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction1_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction1_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction1_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction1_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es2017_es5.1.normal.js index c3f8527d6be..ab16c118ba0 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es2017_es5.1.normal.js @@ -2,7 +2,7 @@ // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -13,22 +13,20 @@ var C = /*#__PURE__*/ function() { var other = function other() {}; var _this = this, _arguments = arguments; var fn = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - other.apply(_this, _arguments) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return other.apply(_this, _arguments); + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function fn() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es2017_es5.2.minified.js index 8d9671bc20d..2514aa8cd1f 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es2017_es5.2.minified.js @@ -1,3 +1,3 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es5_es5.1.normal.js index 34dfa9cd539..a2f09870e1f 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es5_es5.1.normal.js @@ -3,7 +3,7 @@ // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -14,22 +14,20 @@ var C = /*#__PURE__*/ function() { var other = function other() {}; var _this = this, _arguments = arguments; var fn = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - other.apply(_this, _arguments) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return other.apply(_this, _arguments); + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function fn() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es5_es5.2.minified.js index 8d9671bc20d..2514aa8cd1f 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es5_es5.2.minified.js @@ -1,3 +1,3 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es6_es5.1.normal.js index 90cea527433..91c58eab116 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es6_es5.1.normal.js @@ -2,7 +2,7 @@ // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -13,22 +13,20 @@ var C = /*#__PURE__*/ function() { var other = function other() {}; var _this = this, _arguments = arguments; var fn = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - other.apply(_this, _arguments) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return other.apply(_this, _arguments); + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function fn() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es6_es5.2.minified.js index 8d9671bc20d..2514aa8cd1f 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es6_es5.2.minified.js @@ -1,3 +1,3 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es2017_es5.1.normal.js index c12673797f4..c43c0c921f1 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es2017_es5.1.normal.js @@ -2,7 +2,7 @@ // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -12,22 +12,20 @@ var C = /*#__PURE__*/ function() { _proto.method = function method() { var _this = this; var fn = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _this - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return _this; + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function fn() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es2017_es5.2.minified.js index 8d9671bc20d..2514aa8cd1f 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es2017_es5.2.minified.js @@ -1,3 +1,3 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es5_es5.1.normal.js index 6730e450475..bdddf828a67 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es5_es5.1.normal.js @@ -3,7 +3,7 @@ // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -13,22 +13,20 @@ var C = /*#__PURE__*/ function() { _proto.method = function method() { var _this = this; var fn = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _this - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return _this; + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function fn() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es5_es5.2.minified.js index 8d9671bc20d..2514aa8cd1f 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es5_es5.2.minified.js @@ -1,3 +1,3 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es6_es5.1.normal.js index 849e25c58b1..79492ffae54 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es6_es5.1.normal.js @@ -2,7 +2,7 @@ // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -12,22 +12,20 @@ var C = /*#__PURE__*/ function() { _proto.method = function method() { var _this = this; var fn = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _this - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return _this; + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function fn() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es6_es5.2.minified.js index 8d9671bc20d..2514aa8cd1f 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es6_es5.2.minified.js @@ -1,3 +1,3 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction_allowJs_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunction_allowJs_es5.1.normal.js index 4a36280daf8..4eef2abc32c 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction_allowJs_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction_allowJs_es5.1.normal.js @@ -5,45 +5,54 @@ // @filename: file.js // Error (good) /** @type {function(): string} */ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var a = function() { return 0; }; // Error (good) /** @type {function(): string} */ var b = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 0 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 0); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function b() { return _ref.apply(this, arguments); }; }(); // No error (bad) /** @type {function(): string} */ var c = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 0 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 0); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function c() { return _ref.apply(this, arguments); }; }(); /** @type {function(function(): string): void} */ var f = function(p) {}; // Error (good) -f(/*#__PURE__*/ _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 0 - ]; - }); -})); +f(/*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 0); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); +}))); diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction_allowJs_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction_allowJs_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction_allowJs_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction_allowJs_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es5.1.normal.js index 68f0238c522..6ad9eee03e7 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es5.1.normal.js @@ -2,197 +2,233 @@ // @isolatedModules: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f0() { return _f0.apply(this, arguments); } function _f0() { - _f0 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f0 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f0.apply(this, arguments); } function f1() { return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } function f3() { return _f3.apply(this, arguments); } function _f3() { - _f3 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f3 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f3.apply(this, arguments); } var f4 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f4() { return _ref.apply(this, arguments); }; }(); var f5 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f5() { return _ref.apply(this, arguments); }; }(); var f6 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f6() { return _ref.apply(this, arguments); }; }(); var f7 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f7() { return _ref.apply(this, arguments); }; }(); var f8 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f8() { return _ref.apply(this, arguments); }; }(); var f9 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f9() { return _ref.apply(this, arguments); }; }(); var f10 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", p); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f10() { return _ref.apply(this, arguments); }; }(); var f11 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", mp); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f11() { return _ref.apply(this, arguments); }; }(); var f12 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", mp); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f12() { return _ref.apply(this, arguments); }; }(); var f13 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", p); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f13() { return _ref.apply(this, arguments); }; }(); var o = { m1: function m1() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, m2: function m2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, m3: function m3() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; var C = /*#__PURE__*/ function() { @@ -202,58 +238,70 @@ var C = /*#__PURE__*/ function() { } var _proto = C.prototype; _proto.m1 = function m1() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.m2 = function m2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.m3 = function m3() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m4 = function m4() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m5 = function m5() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m6 = function m6() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C; }(); @@ -263,13 +311,15 @@ var M; return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } M.f1 = f1; diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es5.2.minified.js index 978cac56948..d86ee423d8c 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es5.2.minified.js @@ -1,5 +1,5 @@ var M; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; M || (M = {}); diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es5.1.normal.js index 65deee57b63..203cf62fa22 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es5.1.normal.js @@ -3,197 +3,233 @@ // @isolatedModules: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f0() { return _f0.apply(this, arguments); } function _f0() { - _f0 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f0 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f0.apply(this, arguments); } function f1() { return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } function f3() { return _f3.apply(this, arguments); } function _f3() { - _f3 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f3 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f3.apply(this, arguments); } var f4 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f4() { return _ref.apply(this, arguments); }; }(); var f5 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f5() { return _ref.apply(this, arguments); }; }(); var f6 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f6() { return _ref.apply(this, arguments); }; }(); var f7 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f7() { return _ref.apply(this, arguments); }; }(); var f8 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f8() { return _ref.apply(this, arguments); }; }(); var f9 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f9() { return _ref.apply(this, arguments); }; }(); var f10 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", p); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f10() { return _ref.apply(this, arguments); }; }(); var f11 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", mp); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f11() { return _ref.apply(this, arguments); }; }(); var f12 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", mp); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f12() { return _ref.apply(this, arguments); }; }(); var f13 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", p); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f13() { return _ref.apply(this, arguments); }; }(); var o = { m1: function m1() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, m2: function m2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, m3: function m3() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; var C = /*#__PURE__*/ function() { @@ -203,58 +239,70 @@ var C = /*#__PURE__*/ function() { } var _proto = C.prototype; _proto.m1 = function m1() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.m2 = function m2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.m3 = function m3() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m4 = function m4() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m5 = function m5() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m6 = function m6() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C; }(); @@ -264,13 +312,15 @@ var M; return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } M.f1 = f1; diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es5.2.minified.js index 978cac56948..d86ee423d8c 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es5.2.minified.js @@ -1,5 +1,5 @@ var M; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; M || (M = {}); diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es5.1.normal.js index d0c32e02b0f..8c2b60e83f4 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es5.1.normal.js @@ -2,197 +2,233 @@ // @isolatedModules: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f0() { return _f0.apply(this, arguments); } function _f0() { - _f0 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f0 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f0.apply(this, arguments); } function f1() { return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } function f3() { return _f3.apply(this, arguments); } function _f3() { - _f3 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f3 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f3.apply(this, arguments); } var f4 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f4() { return _ref.apply(this, arguments); }; }(); var f5 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f5() { return _ref.apply(this, arguments); }; }(); var f6 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f6() { return _ref.apply(this, arguments); }; }(); var f7 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f7() { return _ref.apply(this, arguments); }; }(); var f8 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f8() { return _ref.apply(this, arguments); }; }(); var f9 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f9() { return _ref.apply(this, arguments); }; }(); var f10 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", p); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f10() { return _ref.apply(this, arguments); }; }(); var f11 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", mp); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f11() { return _ref.apply(this, arguments); }; }(); var f12 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", mp); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f12() { return _ref.apply(this, arguments); }; }(); var f13 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", p); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f13() { return _ref.apply(this, arguments); }; }(); var o = { m1: function m1() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, m2: function m2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, m3: function m3() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; var C = /*#__PURE__*/ function() { @@ -202,58 +238,70 @@ var C = /*#__PURE__*/ function() { } var _proto = C.prototype; _proto.m1 = function m1() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.m2 = function m2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.m3 = function m3() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m4 = function m4() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m5 = function m5() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m6 = function m6() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C; }(); @@ -263,13 +311,15 @@ var M; return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } M.f1 = f1; diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es5.2.minified.js index 978cac56948..d86ee423d8c 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es5.2.minified.js @@ -1,5 +1,5 @@ var M; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; M || (M = {}); diff --git a/crates/swc/tests/tsc-references/asyncAwaitNestedClasses_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwaitNestedClasses_es5_es5.1.normal.js index 0cc28e234d4..a4e27fb9f77 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitNestedClasses_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwaitNestedClasses_es5_es5.1.normal.js @@ -4,7 +4,7 @@ // https://github.com/Microsoft/TypeScript/issues/20744 import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var _B; var A = function A() { "use strict"; @@ -27,22 +27,18 @@ A.B = (_B = /*#__PURE__*/ function() { _class_call_check(this, C); } C.func = function func() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _B.func2() - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _B.func2(); + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C; }(), _B); diff --git a/crates/swc/tests/tsc-references/asyncAwaitNestedClasses_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncAwaitNestedClasses_es5_es5.2.minified.js index f823227a338..c191f6c3a5a 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitNestedClasses_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAwaitNestedClasses_es5_es5.2.minified.js @@ -1,6 +1,6 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var _B, A = function A() { "use strict"; _class_call_check(this, A); @@ -21,20 +21,16 @@ A.B = ((_B = function() { _class_call_check(this, C); } return C.func = function() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return _async_to_generator(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _B.func2() - ]; - case 1: - return _state.sent(), [ - 2 - ]; + return _ctx.next = 2, _B.func2(); + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, C; }(), _B), A.B.C.func(); diff --git a/crates/swc/tests/tsc-references/asyncAwait_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwait_es2017_es5.1.normal.js index 2a69ac2f550..554cc0bedd1 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es2017_es5.1.normal.js @@ -1,197 +1,233 @@ // @target: es2017 import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f0() { return _f0.apply(this, arguments); } function _f0() { - _f0 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f0 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f0.apply(this, arguments); } function f1() { return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } function f3() { return _f3.apply(this, arguments); } function _f3() { - _f3 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f3 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f3.apply(this, arguments); } var f4 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f4() { return _ref.apply(this, arguments); }; }(); var f5 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f5() { return _ref.apply(this, arguments); }; }(); var f6 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f6() { return _ref.apply(this, arguments); }; }(); var f7 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f7() { return _ref.apply(this, arguments); }; }(); var f8 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f8() { return _ref.apply(this, arguments); }; }(); var f9 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f9() { return _ref.apply(this, arguments); }; }(); var f10 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", p); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f10() { return _ref.apply(this, arguments); }; }(); var f11 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", mp); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f11() { return _ref.apply(this, arguments); }; }(); var f12 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", mp); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f12() { return _ref.apply(this, arguments); }; }(); var f13 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", p); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f13() { return _ref.apply(this, arguments); }; }(); var o = { m1: function m1() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, m2: function m2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, m3: function m3() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; var C = /*#__PURE__*/ function() { @@ -201,58 +237,70 @@ var C = /*#__PURE__*/ function() { } var _proto = C.prototype; _proto.m1 = function m1() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.m2 = function m2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.m3 = function m3() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m4 = function m4() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m5 = function m5() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m6 = function m6() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C; }(); @@ -262,13 +310,15 @@ var M; return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } M.f1 = f1; @@ -277,26 +327,19 @@ function f14() { return _f14.apply(this, arguments); } function _f14() { - _f14 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f14 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 3, - 2 - ]; + _ctx.next = 2; + return 1; case 2: - return [ - 2 - ]; + return _ctx.abrupt("break", 3); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f14.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncAwait_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncAwait_es2017_es5.2.minified.js index 978cac56948..d86ee423d8c 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es2017_es5.2.minified.js @@ -1,5 +1,5 @@ var M; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; M || (M = {}); diff --git a/crates/swc/tests/tsc-references/asyncAwait_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwait_es5_es5.1.normal.js index 3eac4f56ce2..2cf1b73d2e6 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es5_es5.1.normal.js @@ -2,197 +2,233 @@ // @lib: es5,es2015.promise import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f0() { return _f0.apply(this, arguments); } function _f0() { - _f0 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f0 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f0.apply(this, arguments); } function f1() { return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } function f3() { return _f3.apply(this, arguments); } function _f3() { - _f3 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f3 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f3.apply(this, arguments); } var f4 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f4() { return _ref.apply(this, arguments); }; }(); var f5 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f5() { return _ref.apply(this, arguments); }; }(); var f6 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f6() { return _ref.apply(this, arguments); }; }(); var f7 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f7() { return _ref.apply(this, arguments); }; }(); var f8 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f8() { return _ref.apply(this, arguments); }; }(); var f9 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f9() { return _ref.apply(this, arguments); }; }(); var f10 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", p); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f10() { return _ref.apply(this, arguments); }; }(); var f11 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", mp); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f11() { return _ref.apply(this, arguments); }; }(); var f12 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", mp); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f12() { return _ref.apply(this, arguments); }; }(); var f13 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", p); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f13() { return _ref.apply(this, arguments); }; }(); var o = { m1: function m1() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, m2: function m2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, m3: function m3() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; var C = /*#__PURE__*/ function() { @@ -202,58 +238,70 @@ var C = /*#__PURE__*/ function() { } var _proto = C.prototype; _proto.m1 = function m1() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.m2 = function m2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.m3 = function m3() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m4 = function m4() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m5 = function m5() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m6 = function m6() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C; }(); @@ -263,13 +311,15 @@ var M; return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } M.f1 = f1; @@ -278,26 +328,19 @@ function f14() { return _f14.apply(this, arguments); } function _f14() { - _f14 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f14 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 3, - 2 - ]; + _ctx.next = 2; + return 1; case 2: - return [ - 2 - ]; + return _ctx.abrupt("break", 3); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f14.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncAwait_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncAwait_es5_es5.2.minified.js index 978cac56948..d86ee423d8c 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es5_es5.2.minified.js @@ -1,5 +1,5 @@ var M; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; M || (M = {}); diff --git a/crates/swc/tests/tsc-references/asyncAwait_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwait_es6_es5.1.normal.js index 09c97545968..e43ea20288d 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es6_es5.1.normal.js @@ -1,197 +1,233 @@ // @target: ES6 import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f0() { return _f0.apply(this, arguments); } function _f0() { - _f0 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f0 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f0.apply(this, arguments); } function f1() { return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } function f3() { return _f3.apply(this, arguments); } function _f3() { - _f3 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f3 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f3.apply(this, arguments); } var f4 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f4() { return _ref.apply(this, arguments); }; }(); var f5 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f5() { return _ref.apply(this, arguments); }; }(); var f6 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f6() { return _ref.apply(this, arguments); }; }(); var f7 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f7() { return _ref.apply(this, arguments); }; }(); var f8 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f8() { return _ref.apply(this, arguments); }; }(); var f9 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f9() { return _ref.apply(this, arguments); }; }(); var f10 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", p); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f10() { return _ref.apply(this, arguments); }; }(); var f11 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", mp); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f11() { return _ref.apply(this, arguments); }; }(); var f12 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", mp); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f12() { return _ref.apply(this, arguments); }; }(); var f13 = function() { - var _ref = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", p); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f13() { return _ref.apply(this, arguments); }; }(); var o = { m1: function m1() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, m2: function m2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, m3: function m3() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; var C = /*#__PURE__*/ function() { @@ -201,58 +237,70 @@ var C = /*#__PURE__*/ function() { } var _proto = C.prototype; _proto.m1 = function m1() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.m2 = function m2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.m3 = function m3() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m4 = function m4() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m5 = function m5() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; C.m6 = function m6() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C; }(); @@ -262,13 +310,15 @@ var M; return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } M.f1 = f1; @@ -277,26 +327,19 @@ function f14() { return _f14.apply(this, arguments); } function _f14() { - _f14 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f14 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 3, - 2 - ]; + _ctx.next = 2; + return 1; case 2: - return [ - 2 - ]; + return _ctx.abrupt("break", 3); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f14.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncAwait_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncAwait_es6_es5.2.minified.js index 978cac56948..d86ee423d8c 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es6_es5.2.minified.js @@ -1,5 +1,5 @@ var M; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; M || (M = {}); diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es2017_es5.1.normal.js index e5d3698e2cf..78f3528aadd 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es2017_es5.1.normal.js @@ -1,18 +1,22 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var v; - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es5_es5.1.normal.js index 294aeb8fec2..1faae05d49a 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es5_es5.1.normal.js @@ -2,18 +2,22 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var v; - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es6_es5.1.normal.js index 052681c3219..f90b08f20cf 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es6_es5.1.normal.js @@ -1,18 +1,22 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var v; - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration13_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es2017_es5.1.normal.js index 00b7bb0bdea..4dac6b9317d 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es2017_es5.1.normal.js @@ -1,17 +1,21 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return"); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es5_es5.1.normal.js index 2424f06c5bb..a8daddbe896 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es5_es5.1.normal.js @@ -2,17 +2,21 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return"); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es6_es5.1.normal.js index 0034ec865e5..039d46f483b 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es6_es5.1.normal.js @@ -1,17 +1,21 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return"); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration14_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es2017_es5.1.normal.js index 00b7bb0bdea..6f7db72324d 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es2017_es5.1.normal.js @@ -1,17 +1,19 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es5_es5.1.normal.js index 2424f06c5bb..526abcec384 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es5_es5.1.normal.js @@ -2,17 +2,19 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es6_es5.1.normal.js index 0034ec865e5..e5eec66c2e0 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es6_es5.1.normal.js @@ -1,17 +1,19 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration1_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclarationCapturesArguments_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncFunctionDeclarationCapturesArguments_es5_es5.1.normal.js index b0b623218b5..08a1f3752dd 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclarationCapturesArguments_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclarationCapturesArguments_es5_es5.1.normal.js @@ -3,7 +3,7 @@ // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -16,23 +16,19 @@ var C = /*#__PURE__*/ function() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { - var _arguments = arguments; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var _args = arguments; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - other.apply(this, _arguments) - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return other.apply(this, _args); + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, this); + })); return _fn.apply(this, arguments); } }; diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclarationCapturesArguments_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncFunctionDeclarationCapturesArguments_es5_es5.2.minified.js index 8d9671bc20d..2514aa8cd1f 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclarationCapturesArguments_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclarationCapturesArguments_es5_es5.2.minified.js @@ -1,3 +1,3 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncImportedPromise_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncImportedPromise_es5_es5.1.normal.js index 0c22fb5b1b7..4e317692d4b 100644 --- a/crates/swc/tests/tsc-references/asyncImportedPromise_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncImportedPromise_es5_es5.1.normal.js @@ -19,7 +19,7 @@ export var Task = /*#__PURE__*/ function(Promise1) { // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var Test = /*#__PURE__*/ function() { "use strict"; function Test() { @@ -27,13 +27,17 @@ var Test = /*#__PURE__*/ function() { } var _proto = Test.prototype; _proto.example = function example() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return"); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return Test; }(); diff --git a/crates/swc/tests/tsc-references/asyncImportedPromise_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncImportedPromise_es5_es5.2.minified.js index 7094dc339b7..a796b026219 100644 --- a/crates/swc/tests/tsc-references/asyncImportedPromise_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncImportedPromise_es5_es5.2.minified.js @@ -13,4 +13,4 @@ export var Task = function(Promise1) { }(_wrap_native_super(Promise)); import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncImportedPromise_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncImportedPromise_es6_es5.1.normal.js index 889d9c138b6..0da26a44a33 100644 --- a/crates/swc/tests/tsc-references/asyncImportedPromise_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncImportedPromise_es6_es5.1.normal.js @@ -18,7 +18,7 @@ export var Task = /*#__PURE__*/ function(Promise1) { // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var Test = /*#__PURE__*/ function() { "use strict"; function Test() { @@ -26,13 +26,17 @@ var Test = /*#__PURE__*/ function() { } var _proto = Test.prototype; _proto.example = function example() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return"); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return Test; }(); diff --git a/crates/swc/tests/tsc-references/asyncImportedPromise_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncImportedPromise_es6_es5.2.minified.js index 7094dc339b7..a796b026219 100644 --- a/crates/swc/tests/tsc-references/asyncImportedPromise_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncImportedPromise_es6_es5.2.minified.js @@ -13,4 +13,4 @@ export var Task = function(Promise1) { }(_wrap_native_super(Promise)); import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncMethodWithSuperConflict_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncMethodWithSuperConflict_es6_es5.1.normal.js index 1f55e107a13..a6f5efb373d 100644 --- a/crates/swc/tests/tsc-references/asyncMethodWithSuperConflict_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncMethodWithSuperConflict_es6_es5.1.normal.js @@ -6,7 +6,7 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _set from "@swc/helpers/src/_set.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var A = /*#__PURE__*/ function() { "use strict"; function A() { @@ -36,24 +36,27 @@ var B = /*#__PURE__*/ function(A) { }, _superprop_get = function(_prop) { return _get(_get_prototype_of(B.prototype), _prop, _this); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var _super, _superIndex, a, b; - return _ts_generator(this, function(_state) { - _super = null; - _superIndex = null; - // call with property access - _superprop_get_x().call(_this1); - // call additional property. - _superprop_get_y().call(_this1); - // call with element access - _superprop_get("x").call(_this1); - a = _superprop_get_x(); - b = _superprop_get("x"); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _super = null; + _superIndex = null; + // call with property access + _superprop_get_x().call(_this1); + // call additional property. + _superprop_get_y().call(_this1); + // call with element access + _superprop_get("x").call(_this1); + a = _superprop_get_x(); + b = _superprop_get("x"); + case 7: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; // async method with assignment/destructuring on 'super' requires a binding _proto.advanced = function advanced() { @@ -83,35 +86,40 @@ var B = /*#__PURE__*/ function(A) { }, _superprop_set = function(_prop, _value) { return _set(_get_prototype_of(B.prototype), _prop, _value, _this, true); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var _super, _superIndex, f, a, b, ref, ref1; - return _ts_generator(this, function(_state) { - _super = null; - _superIndex = null; - f = function() {}; - // call with property access - _superprop_get_x().call(_this1); - // call with element access - _superprop_get("x").call(_this1); - a = _superprop_get_x(); - b = _superprop_get("x"); - // property access (assign) - _superprop_set_x(f); - // element access (assign) - _superprop_set("x", f); - // destructuring assign with property access - (ref = { - f: f - }, _superprop_update_x._ = ref.f, ref); - // destructuring assign with element access - (ref1 = { - f: f - }, _superprop_update("x")._ = ref1.f, ref1); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _super = null; + _superIndex = null; + f = function() {}; + // call with property access + _superprop_get_x().call(_this1); + // call with element access + _superprop_get("x").call(_this1); + a = _superprop_get_x(); + b = _superprop_get("x"); + // property access (assign) + _superprop_set_x(f); + // element access (assign) + _superprop_set("x", f); + ; + // destructuring assign with property access + (ref = { + f: f + }, _superprop_update_x._ = ref.f, ref); + ; + // destructuring assign with element access + (ref1 = { + f: f + }, _superprop_update("x")._ = ref1.f, ref1); + case 13: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return B; }(A); diff --git a/crates/swc/tests/tsc-references/asyncMethodWithSuperConflict_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncMethodWithSuperConflict_es6_es5.2.minified.js index f60decaa1d2..3760c0ba1e7 100644 --- a/crates/swc/tests/tsc-references/asyncMethodWithSuperConflict_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncMethodWithSuperConflict_es6_es5.2.minified.js @@ -5,4 +5,4 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _set from "@swc/helpers/src/_set.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es2017_es5.1.normal.js index 69b4ad434a7..293d3155cf2 100644 --- a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es2017_es5.1.normal.js @@ -7,7 +7,7 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _set from "@swc/helpers/src/_set.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var A = /*#__PURE__*/ function() { "use strict"; function A() { @@ -37,22 +37,25 @@ var B = /*#__PURE__*/ function(A) { }, _superprop_get = function(_prop) { return _get(_get_prototype_of(B.prototype), _prop, _this); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var a, b; - return _ts_generator(this, function(_state) { - // call with property access - _superprop_get_x().call(_this1); - // call additional property. - _superprop_get_y().call(_this1); - // call with element access - _superprop_get("x").call(_this1); - a = _superprop_get_x(); - b = _superprop_get("x"); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + // call with property access + _superprop_get_x().call(_this1); + // call additional property. + _superprop_get_y().call(_this1); + // call with element access + _superprop_get("x").call(_this1); + a = _superprop_get_x(); + b = _superprop_get("x"); + case 5: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; // async method with assignment/destructuring on 'super' requires a binding _proto.advanced = function advanced() { @@ -82,33 +85,38 @@ var B = /*#__PURE__*/ function(A) { }, _superprop_set = function(_prop, _value) { return _set(_get_prototype_of(B.prototype), _prop, _value, _this, true); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var f, a, b, ref, ref1; - return _ts_generator(this, function(_state) { - f = function() {}; - // call with property access - _superprop_get_x().call(_this1); - // call with element access - _superprop_get("x").call(_this1); - a = _superprop_get_x(); - b = _superprop_get("x"); - // property access (assign) - _superprop_set_x(f); - // element access (assign) - _superprop_set("x", f); - // destructuring assign with property access - (ref = { - f: f - }, _superprop_update_x._ = ref.f, ref); - // destructuring assign with element access - (ref1 = { - f: f - }, _superprop_update("x")._ = ref1.f, ref1); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + f = function() {}; + // call with property access + _superprop_get_x().call(_this1); + // call with element access + _superprop_get("x").call(_this1); + a = _superprop_get_x(); + b = _superprop_get("x"); + // property access (assign) + _superprop_set_x(f); + // element access (assign) + _superprop_set("x", f); + ; + // destructuring assign with property access + (ref = { + f: f + }, _superprop_update_x._ = ref.f, ref); + ; + // destructuring assign with element access + (ref1 = { + f: f + }, _superprop_update("x")._ = ref1.f, ref1); + case 11: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return B; }(A); diff --git a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es2017_es5.2.minified.js index f60decaa1d2..3760c0ba1e7 100644 --- a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es2017_es5.2.minified.js @@ -5,4 +5,4 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _set from "@swc/helpers/src/_set.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es5_es5.1.normal.js index 1335e1ce7dd..4d3e1d71d35 100644 --- a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es5_es5.1.normal.js @@ -8,7 +8,7 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _set from "@swc/helpers/src/_set.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var A = /*#__PURE__*/ function() { "use strict"; function A() { @@ -38,22 +38,25 @@ var B = /*#__PURE__*/ function(A) { }, _superprop_get = function(_prop) { return _get(_get_prototype_of(B.prototype), _prop, _this); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var a, b; - return _ts_generator(this, function(_state) { - // call with property access - _superprop_get_x().call(_this1); - // call additional property. - _superprop_get_y().call(_this1); - // call with element access - _superprop_get("x").call(_this1); - a = _superprop_get_x(); - b = _superprop_get("x"); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + // call with property access + _superprop_get_x().call(_this1); + // call additional property. + _superprop_get_y().call(_this1); + // call with element access + _superprop_get("x").call(_this1); + a = _superprop_get_x(); + b = _superprop_get("x"); + case 5: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; // async method with assignment/destructuring on 'super' requires a binding _proto.advanced = function advanced() { @@ -83,33 +86,38 @@ var B = /*#__PURE__*/ function(A) { }, _superprop_set = function(_prop, _value) { return _set(_get_prototype_of(B.prototype), _prop, _value, _this, true); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var f, a, b, ref, ref1; - return _ts_generator(this, function(_state) { - f = function() {}; - // call with property access - _superprop_get_x().call(_this1); - // call with element access - _superprop_get("x").call(_this1); - a = _superprop_get_x(); - b = _superprop_get("x"); - // property access (assign) - _superprop_set_x(f); - // element access (assign) - _superprop_set("x", f); - // destructuring assign with property access - (ref = { - f: f - }, _superprop_update_x._ = ref.f, ref); - // destructuring assign with element access - (ref1 = { - f: f - }, _superprop_update("x")._ = ref1.f, ref1); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + f = function() {}; + // call with property access + _superprop_get_x().call(_this1); + // call with element access + _superprop_get("x").call(_this1); + a = _superprop_get_x(); + b = _superprop_get("x"); + // property access (assign) + _superprop_set_x(f); + // element access (assign) + _superprop_set("x", f); + ; + // destructuring assign with property access + (ref = { + f: f + }, _superprop_update_x._ = ref.f, ref); + ; + // destructuring assign with element access + (ref1 = { + f: f + }, _superprop_update("x")._ = ref1.f, ref1); + case 11: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return B; }(A); diff --git a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es5_es5.2.minified.js index f60decaa1d2..3760c0ba1e7 100644 --- a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es5_es5.2.minified.js @@ -5,4 +5,4 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _set from "@swc/helpers/src/_set.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es6_es5.1.normal.js index d00a1aa2e59..e2515a45978 100644 --- a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es6_es5.1.normal.js @@ -9,7 +9,7 @@ import _inherits from "@swc/helpers/src/_inherits.mjs"; import _set from "@swc/helpers/src/_set.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var A = /*#__PURE__*/ function() { "use strict"; function A() { @@ -39,22 +39,25 @@ var B = /*#__PURE__*/ function(A) { }, _superprop_get = function(_prop) { return _get(_get_prototype_of(B.prototype), _prop, _this); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var a, b; - return _ts_generator(this, function(_state) { - // call with property access - _superprop_get_x().call(_this1); - // call additional property. - _superprop_get_y().call(_this1); - // call with element access - _superprop_get("x").call(_this1); - a = _superprop_get_x(); - b = _superprop_get("x"); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + // call with property access + _superprop_get_x().call(_this1); + // call additional property. + _superprop_get_y().call(_this1); + // call with element access + _superprop_get("x").call(_this1); + a = _superprop_get_x(); + b = _superprop_get("x"); + case 5: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; // async method with assignment/destructuring on 'super' requires a binding _proto.advanced = function advanced() { @@ -84,89 +87,106 @@ var B = /*#__PURE__*/ function(A) { }, _superprop_set = function(_prop, _value) { return _set(_get_prototype_of(B.prototype), _prop, _value, _this, true); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var f, a, b, ref, ref1; - return _ts_generator(this, function(_state) { - f = function() {}; - // call with property access - _superprop_get_x().call(_this1); - // call with element access - _superprop_get("x").call(_this1); - a = _superprop_get_x(); - b = _superprop_get("x"); - // property access (assign) - _superprop_set_x(f); - // element access (assign) - _superprop_set("x", f); - // destructuring assign with property access - (ref = { - f: f - }, _superprop_update_x._ = ref.f, ref); - // destructuring assign with element access - (ref1 = { - f: f - }, _superprop_update("x")._ = ref1.f, ref1); - // property access in arrow - (function() { - return _superprop_get_x().call(_this1); - }); - // element access in arrow - (function() { - return _superprop_get("x").call(_this1); - }); - /*#__PURE__*/ // property access in async arrow - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - _superprop_get_x().call(_this1) - ]; - }); - }); - /*#__PURE__*/ // element access in async arrow - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - _superprop_get("x").call(_this1) - ]; - }); - }); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + f = function() {}; + // call with property access + _superprop_get_x().call(_this1); + // call with element access + _superprop_get("x").call(_this1); + a = _superprop_get_x(); + b = _superprop_get("x"); + // property access (assign) + _superprop_set_x(f); + // element access (assign) + _superprop_set("x", f); + ; + // destructuring assign with property access + (ref = { + f: f + }, _superprop_update_x._ = ref.f, ref); + ; + // destructuring assign with element access + (ref1 = { + f: f + }, _superprop_update("x")._ = ref1.f, ref1); + // property access in arrow + (function() { + return _superprop_get_x().call(_this1); + }); + // element access in arrow + (function() { + return _superprop_get("x").call(_this1); + }); + /*#__PURE__*/ // property access in async arrow + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", _superprop_get_x().call(_this1)); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); + /*#__PURE__*/ // element access in async arrow + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", _superprop_get("x").call(_this1)); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); + case 15: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.property_access_only_read_only = function property_access_only_read_only() { var _this = this; var _this1 = this, _superprop_get_x = function() { return _get(_get_prototype_of(B.prototype), "x", _this); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var a; - return _ts_generator(this, function(_state) { - // call with property access - _superprop_get_x().call(_this1); - a = _superprop_get_x(); - // property access in arrow - (function() { - return _superprop_get_x().call(_this1); - }); - /*#__PURE__*/ // property access in async arrow - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - _superprop_get_x().call(_this1) - ]; - }); - }); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + // call with property access + _superprop_get_x().call(_this1); + a = _superprop_get_x(); + // property access in arrow + (function() { + return _superprop_get_x().call(_this1); + }); + /*#__PURE__*/ // property access in async arrow + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", _superprop_get_x().call(_this1)); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); + case 4: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.property_access_only_write_only = function property_access_only_write_only() { var _this = this; @@ -182,64 +202,77 @@ var B = /*#__PURE__*/ function(A) { }, _superprop_set_x = function(_value) { return _set(_get_prototype_of(B.prototype), "x", _value, _this, true); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var f, ref; - return _ts_generator(this, function(_state) { - f = function() {}; - // property access (assign) - _superprop_set_x(f); - // destructuring assign with property access - (ref = { - f: f - }, _superprop_update_x._ = ref.f, ref); - // property access (assign) in arrow - (function() { - return _superprop_set_x(f); - }); - /*#__PURE__*/ // property access (assign) in async arrow - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - _superprop_set_x(f) - ]; - }); - }); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + f = function() {}; + // property access (assign) + _superprop_set_x(f); + ; + // destructuring assign with property access + (ref = { + f: f + }, _superprop_update_x._ = ref.f, ref); + // property access (assign) in arrow + (function() { + return _superprop_set_x(f); + }); + /*#__PURE__*/ // property access (assign) in async arrow + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", _superprop_set_x(f)); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); + case 6: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.element_access_only_read_only = function element_access_only_read_only() { var _this = this; var _this1 = this, _superprop_get = function(_prop) { return _get(_get_prototype_of(B.prototype), _prop, _this); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var a; - return _ts_generator(this, function(_state) { - // call with element access - _superprop_get("x").call(_this1); - a = _superprop_get("x"); - // element access in arrow - (function() { - return _superprop_get("x").call(_this1); - }); - /*#__PURE__*/ // element access in async arrow - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - _superprop_get("x").call(_this1) - ]; - }); - }); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + // call with element access + _superprop_get("x").call(_this1); + a = _superprop_get("x"); + // element access in arrow + (function() { + return _superprop_get("x").call(_this1); + }); + /*#__PURE__*/ // element access in async arrow + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", _superprop_get("x").call(_this1)); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); + case 4: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.element_access_only_write_only = function element_access_only_write_only() { var _this = this; @@ -257,64 +290,77 @@ var B = /*#__PURE__*/ function(A) { }, _superprop_set = function(_prop, _value) { return _set(_get_prototype_of(B.prototype), _prop, _value, _this, true); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var f, ref; - return _ts_generator(this, function(_state) { - f = function() {}; - // element access (assign) - _superprop_set("x", f); - // destructuring assign with element access - (ref = { - f: f - }, _superprop_update("x")._ = ref.f, ref); - // element access (assign) in arrow - (function() { - return _superprop_set("x", f); - }); - /*#__PURE__*/ // element access (assign) in async arrow - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - _superprop_set("x", f) - ]; - }); - }); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + f = function() {}; + // element access (assign) + _superprop_set("x", f); + ; + // destructuring assign with element access + (ref = { + f: f + }, _superprop_update("x")._ = ref.f, ref); + // element access (assign) in arrow + (function() { + return _superprop_set("x", f); + }); + /*#__PURE__*/ // element access (assign) in async arrow + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", _superprop_set("x", f)); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); + case 6: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.property_access_only_read_only_in_generator = function property_access_only_read_only_in_generator() { var _this = this; var _this1 = this, _superprop_get_x = function() { return _get(_get_prototype_of(B.prototype), "x", _this); }; - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var a; - return _ts_generator(this, function(_state) { - // call with property access - _superprop_get_x().call(_this1); - a = _superprop_get_x(); - // property access in arrow - (function() { - return _superprop_get_x().call(_this1); - }); - /*#__PURE__*/ // property access in async arrow - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - _superprop_get_x().call(_this1) - ]; - }); - }); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + // call with property access + _superprop_get_x().call(_this1); + a = _superprop_get_x(); + // property access in arrow + (function() { + return _superprop_get_x().call(_this1); + }); + /*#__PURE__*/ // property access in async arrow + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", _superprop_get_x().call(_this1)); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); + case 4: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.property_access_only_write_only_in_generator = function property_access_only_write_only_in_generator() { var _this = this; @@ -330,64 +376,77 @@ var B = /*#__PURE__*/ function(A) { }, _superprop_set_x = function(_value) { return _set(_get_prototype_of(B.prototype), "x", _value, _this, true); }; - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var f, ref; - return _ts_generator(this, function(_state) { - f = function() {}; - // property access (assign) - _superprop_set_x(f); - // destructuring assign with property access - (ref = { - f: f - }, _superprop_update_x._ = ref.f, ref); - // property access (assign) in arrow - (function() { - return _superprop_set_x(f); - }); - /*#__PURE__*/ // property access (assign) in async arrow - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - _superprop_set_x(f) - ]; - }); - }); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + f = function() {}; + // property access (assign) + _superprop_set_x(f); + ; + // destructuring assign with property access + (ref = { + f: f + }, _superprop_update_x._ = ref.f, ref); + // property access (assign) in arrow + (function() { + return _superprop_set_x(f); + }); + /*#__PURE__*/ // property access (assign) in async arrow + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", _superprop_set_x(f)); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); + case 6: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.element_access_only_read_only_in_generator = function element_access_only_read_only_in_generator() { var _this = this; var _this1 = this, _superprop_get = function(_prop) { return _get(_get_prototype_of(B.prototype), _prop, _this); }; - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var a; - return _ts_generator(this, function(_state) { - // call with element access - _superprop_get("x").call(_this1); - a = _superprop_get("x"); - // element access in arrow - (function() { - return _superprop_get("x").call(_this1); - }); - /*#__PURE__*/ // element access in async arrow - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - _superprop_get("x").call(_this1) - ]; - }); - }); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + // call with element access + _superprop_get("x").call(_this1); + a = _superprop_get("x"); + // element access in arrow + (function() { + return _superprop_get("x").call(_this1); + }); + /*#__PURE__*/ // element access in async arrow + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", _superprop_get("x").call(_this1)); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); + case 4: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.element_access_only_write_only_in_generator = function element_access_only_write_only_in_generator() { var _this = this; @@ -405,34 +464,41 @@ var B = /*#__PURE__*/ function(A) { }, _superprop_set = function(_prop, _value) { return _set(_get_prototype_of(B.prototype), _prop, _value, _this, true); }; - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var f, ref; - return _ts_generator(this, function(_state) { - f = function() {}; - // element access (assign) - _superprop_set("x", f); - // destructuring assign with element access - (ref = { - f: f - }, _superprop_update("x")._ = ref.f, ref); - // element access (assign) in arrow - (function() { - return _superprop_set("x", f); - }); - /*#__PURE__*/ // element access (assign) in async arrow - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - _superprop_set("x", f) - ]; - }); - }); - return [ - 2 - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + f = function() {}; + // element access (assign) + _superprop_set("x", f); + ; + // destructuring assign with element access + (ref = { + f: f + }, _superprop_update("x")._ = ref.f, ref); + // element access (assign) in arrow + (function() { + return _superprop_set("x", f); + }); + /*#__PURE__*/ // element access (assign) in async arrow + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", _superprop_set("x", f)); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); + case 6: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return B; }(A); diff --git a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es6_es5.2.minified.js index dc75ec0303a..5fbe289a9b9 100644 --- a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es6_es5.2.minified.js @@ -6,4 +6,4 @@ import _inherits from "@swc/helpers/src/_inherits.mjs"; import _set from "@swc/helpers/src/_set.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncMultiFile_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncMultiFile_es5_es5.1.normal.js index 1ea54a3db6a..4adc7b44fb2 100644 --- a/crates/swc/tests/tsc-references/asyncMultiFile_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncMultiFile_es5_es5.1.normal.js @@ -2,18 +2,20 @@ // @lib: es5,es2015.promise // @filename: a.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f() { return _f.apply(this, arguments); } function _f() { - _f = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f.apply(this, arguments); } // @filename: b.ts diff --git a/crates/swc/tests/tsc-references/asyncMultiFile_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncMultiFile_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncMultiFile_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncMultiFile_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncMultiFile_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncMultiFile_es6_es5.1.normal.js index 51e31e0ec4c..422fb9875a2 100644 --- a/crates/swc/tests/tsc-references/asyncMultiFile_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncMultiFile_es6_es5.1.normal.js @@ -1,18 +1,20 @@ // @target: es6 // @filename: a.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f() { return _f.apply(this, arguments); } function _f() { - _f = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f.apply(this, arguments); } // @filename: b.ts diff --git a/crates/swc/tests/tsc-references/asyncMultiFile_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncMultiFile_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncMultiFile_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncMultiFile_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es2017_es5.1.normal.js index 954f35b1d76..3e5565cb9e6 100644 --- a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es2017_es5.1.normal.js @@ -1,45 +1,41 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var x = function() { - var _ref = _async_to_generator(function(i) { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(i) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - someOtherFunction(i) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return someOtherFunction(i); + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function x(i) { return _ref.apply(this, arguments); }; }(); var x1 = function() { - var _ref = _async_to_generator(function(i) { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(i) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - someOtherFunction(i) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return someOtherFunction(i); + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function x1(i) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5_es5.1.normal.js index e02588858ef..3b7cdd786dc 100644 --- a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5_es5.1.normal.js @@ -2,45 +2,41 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var x = function() { - var _ref = _async_to_generator(function(i) { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(i) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - someOtherFunction(i) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return someOtherFunction(i); + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function x(i) { return _ref.apply(this, arguments); }; }(); var x1 = function() { - var _ref = _async_to_generator(function(i) { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(i) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - someOtherFunction(i) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return someOtherFunction(i); + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function x1(i) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6_es5.1.normal.js index 8877ae86cbf..20b9223f1d2 100644 --- a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6_es5.1.normal.js @@ -1,45 +1,41 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var x = function() { - var _ref = _async_to_generator(function(i) { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(i) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - someOtherFunction(i) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return someOtherFunction(i); + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function x(i) { return _ref.apply(this, arguments); }; }(); var x1 = function() { - var _ref = _async_to_generator(function(i) { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(i) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - someOtherFunction(i) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return someOtherFunction(i); + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function x1(i) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncUseStrict_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncUseStrict_es2017_es5.1.normal.js index f53d2544398..f726d7e0789 100644 --- a/crates/swc/tests/tsc-references/asyncUseStrict_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncUseStrict_es2017_es5.1.normal.js @@ -1,28 +1,33 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: "use strict"; - return [ - 4, - p - ]; - case 1: - b = _state.sent() || a; - return [ - 2 - ]; + _ctx.next = 3; + return p; + case 3: + _ctx.t0 = _ctx.sent; + if (_ctx.t0) { + _ctx.next = 6; + break; + } + _ctx.t0 = a; + case 6: + b = _ctx.t0; + case 7: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncUseStrict_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncUseStrict_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncUseStrict_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncUseStrict_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncUseStrict_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncUseStrict_es5_es5.1.normal.js index f7b5aebec5e..6d4e1fe3424 100644 --- a/crates/swc/tests/tsc-references/asyncUseStrict_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncUseStrict_es5_es5.1.normal.js @@ -2,28 +2,33 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: "use strict"; - return [ - 4, - p - ]; - case 1: - b = _state.sent() || a; - return [ - 2 - ]; + _ctx.next = 3; + return p; + case 3: + _ctx.t0 = _ctx.sent; + if (_ctx.t0) { + _ctx.next = 6; + break; + } + _ctx.t0 = a; + case 6: + b = _ctx.t0; + case 7: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncUseStrict_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncUseStrict_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncUseStrict_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncUseStrict_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncUseStrict_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncUseStrict_es6_es5.1.normal.js index 256fcb0e9eb..a673d83d7f1 100644 --- a/crates/swc/tests/tsc-references/asyncUseStrict_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncUseStrict_es6_es5.1.normal.js @@ -1,28 +1,33 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: "use strict"; - return [ - 4, - p - ]; - case 1: - b = _state.sent() || a; - return [ - 2 - ]; + _ctx.next = 3; + return p; + case 3: + _ctx.t0 = _ctx.sent; + if (_ctx.t0) { + _ctx.next = 6; + break; + } + _ctx.t0 = a; + case 6: + b = _ctx.t0; + case 7: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncUseStrict_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncUseStrict_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/asyncUseStrict_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncUseStrict_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/asyncWithVarShadowing_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncWithVarShadowing_es6_es5.1.normal.js index d917d82e340..01e3f636186 100644 --- a/crates/swc/tests/tsc-references/asyncWithVarShadowing_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncWithVarShadowing_es6_es5.1.normal.js @@ -5,689 +5,881 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _extends from "@swc/helpers/src/_extends.mjs"; import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs"; import _to_array from "@swc/helpers/src/_to_array.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function fn1(x) { return _fn1.apply(this, arguments); } function _fn1() { - _fn1 = _async_to_generator(function(x) { + _fn1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn1.apply(this, arguments); } function fn2(x) { return _fn2.apply(this, arguments); } function _fn2() { - _fn2 = _async_to_generator(function(x) { + _fn2 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x, z; - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn2.apply(this, arguments); } function fn3(x) { return _fn3.apply(this, arguments); } function _fn3() { - _fn3 = _async_to_generator(function(x) { + _fn3 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var z; - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn3.apply(this, arguments); } function fn4(x) { return _fn4.apply(this, arguments); } function _fn4() { - _fn4 = _async_to_generator(function(x) { + _fn4 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - x = y; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + x = y; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn4.apply(this, arguments); } function fn5(x) { return _fn5.apply(this, arguments); } function _fn5() { - _fn5 = _async_to_generator(function(x) { + _fn5 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - x = y.x; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + x = y.x; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn5.apply(this, arguments); } function fn6(x) { return _fn6.apply(this, arguments); } function _fn6() { - _fn6 = _async_to_generator(function(x) { + _fn6 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x, z; - return _ts_generator(this, function(_state) { - x = y.x, z = y.z; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + x = y.x, z = y.z; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn6.apply(this, arguments); } function fn7(x) { return _fn7.apply(this, arguments); } function _fn7() { - _fn7 = _async_to_generator(function(x) { + _fn7 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var _x, x; - return _ts_generator(this, function(_state) { - _x = y.x, x = _x === void 0 ? y : _x; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _x = y.x, x = _x === void 0 ? y : _x; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn7.apply(this, arguments); } function fn8(x) { return _fn8.apply(this, arguments); } function _fn8() { - _fn8 = _async_to_generator(function(x) { + _fn8 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - x = y.z; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + x = y.z; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn8.apply(this, arguments); } function fn9(x) { return _fn9.apply(this, arguments); } function _fn9() { - _fn9 = _async_to_generator(function(x) { + _fn9 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - x = y.z.x; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + x = y.z.x; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn9.apply(this, arguments); } function fn10(x) { return _fn10.apply(this, arguments); } function _fn10() { - _fn10 = _async_to_generator(function(x) { + _fn10 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var tmp, x; - return _ts_generator(this, function(_state) { - tmp = y.z, x = (tmp === void 0 ? y : tmp).x; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + tmp = y.z, x = (tmp === void 0 ? y : tmp).x; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn10.apply(this, arguments); } function fn11(x) { return _fn11.apply(this, arguments); } function _fn11() { - _fn11 = _async_to_generator(function(x) { - var x, _tmp; - return _ts_generator(this, function(_state) { - _tmp = {}; - x = _extends(_tmp, y); - return [ - 2 - ]; - }); - }); + _fn11 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { + var x; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + x = _extends({}, y); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn11.apply(this, arguments); } function fn12(x) { return _fn12.apply(this, arguments); } function _fn12() { - _fn12 = _async_to_generator(function(x) { + _fn12 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var _y, x; - return _ts_generator(this, function(_state) { - _y = _sliced_to_array(y, 1), x = _y[0]; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _y = _sliced_to_array(y, 1), x = _y[0]; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn12.apply(this, arguments); } function fn13(x) { return _fn13.apply(this, arguments); } function _fn13() { - _fn13 = _async_to_generator(function(x) { + _fn13 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var _y, tmp, x; - return _ts_generator(this, function(_state) { - _y = _sliced_to_array(y, 1), tmp = _y[0], x = tmp === void 0 ? y : tmp; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _y = _sliced_to_array(y, 1), tmp = _y[0], x = tmp === void 0 ? y : tmp; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn13.apply(this, arguments); } function fn14(x) { return _fn14.apply(this, arguments); } function _fn14() { - _fn14 = _async_to_generator(function(x) { + _fn14 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var _y, x; - return _ts_generator(this, function(_state) { - _y = _sliced_to_array(y, 2), x = _y[1]; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _y = _sliced_to_array(y, 2), x = _y[1]; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn14.apply(this, arguments); } function fn15(x) { return _fn15.apply(this, arguments); } function _fn15() { - _fn15 = _async_to_generator(function(x) { + _fn15 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var _y, x; - return _ts_generator(this, function(_state) { - _y = _to_array(y), x = _y.slice(0); - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _y = _to_array(y), x = _y.slice(0); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn15.apply(this, arguments); } function fn16(x) { return _fn16.apply(this, arguments); } function _fn16() { - _fn16 = _async_to_generator(function(x) { + _fn16 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var _y, ref, x; - return _ts_generator(this, function(_state) { - _y = _sliced_to_array(y, 1), ref = _sliced_to_array(_y[0], 1), x = ref[0]; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _y = _sliced_to_array(y, 1), ref = _sliced_to_array(_y[0], 1), x = ref[0]; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn16.apply(this, arguments); } function fn17(x) { return _fn17.apply(this, arguments); } function _fn17() { - _fn17 = _async_to_generator(function(x) { + _fn17 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var _y, tmp, ref, x; - return _ts_generator(this, function(_state) { - _y = _sliced_to_array(y, 1), tmp = _y[0], ref = _sliced_to_array(tmp === void 0 ? y : tmp, 1), x = ref[0]; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _y = _sliced_to_array(y, 1), tmp = _y[0], ref = _sliced_to_array(tmp === void 0 ? y : tmp, 1), x = ref[0]; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn17.apply(this, arguments); } function fn18(_) { return _fn18.apply(this, arguments); } function _fn18() { - _fn18 = _async_to_generator(function(param) { + _fn18 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(param) { var x, x; - return _ts_generator(this, function(_state) { - x = param.x; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + x = param.x; + ; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn18.apply(this, arguments); } function fn19(_) { return _fn19.apply(this, arguments); } function _fn19() { - _fn19 = _async_to_generator(function(param) { + _fn19 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(param) { var _param, x, x; - return _ts_generator(this, function(_state) { - _param = _sliced_to_array(param, 1), x = _param[0]; - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _param = _sliced_to_array(param, 1), x = _param[0]; + ; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn19.apply(this, arguments); } function fn20(x) { return _fn20.apply(this, arguments); } function _fn20() { - _fn20 = _async_to_generator(function(x) { + _fn20 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - { - ; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + { + ; + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn20.apply(this, arguments); } function fn21(x) { return _fn21.apply(this, arguments); } function _fn21() { - _fn21 = _async_to_generator(function(x) { + _fn21 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - if (y) { - ; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + if (y) { + ; + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn21.apply(this, arguments); } function fn22(x) { return _fn22.apply(this, arguments); } function _fn22() { - _fn22 = _async_to_generator(function(x) { + _fn22 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - if (y) {} else { - ; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + if (y) {} else { + ; + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn22.apply(this, arguments); } function fn23(x) { return _fn23.apply(this, arguments); } function _fn23() { - _fn23 = _async_to_generator(function(x) { + _fn23 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - try { - ; - } catch (e) {} - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + try { + ; + } catch (e) {} + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn23.apply(this, arguments); } function fn24(x) { return _fn24.apply(this, arguments); } function _fn24() { - _fn24 = _async_to_generator(function(x) { + _fn24 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - try {} catch (e) { - ; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + try {} catch (e) { + ; + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn24.apply(this, arguments); } function fn25(x) { return _fn25.apply(this, arguments); } function _fn25() { - _fn25 = _async_to_generator(function(x) { + _fn25 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x1; - return _ts_generator(this, function(_state) { - try {} catch (x1) { - ; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + try {} catch (x1) { + ; + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn25.apply(this, arguments); } function fn26(x) { return _fn26.apply(this, arguments); } function _fn26() { - _fn26 = _async_to_generator(function(x) { + _fn26 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x1, x1; - return _ts_generator(this, function(_state) { - try {} catch (param) { - x1 = param.x; - ; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + try {} catch (param) { + x1 = param.x; + ; + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn26.apply(this, arguments); } function fn27(x) { return _fn27.apply(this, arguments); } function _fn27() { - _fn27 = _async_to_generator(function(x) { + _fn27 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - try {} finally{ - ; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + try {} finally{ + ; + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn27.apply(this, arguments); } function fn28(x) { return _fn28.apply(this, arguments); } function _fn28() { - _fn28 = _async_to_generator(function(x) { - return _ts_generator(this, function(_state) { - while(y){ - var x; + _fn28 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { + var x; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + while(y){ + ; + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn28.apply(this, arguments); } function fn29(x) { return _fn29.apply(this, arguments); } function _fn29() { - _fn29 = _async_to_generator(function(x) { + _fn29 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - do { - ; - }while (y); - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + do { + ; + }while (y); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn29.apply(this, arguments); } function fn30(x) { return _fn30.apply(this, arguments); } function _fn30() { - _fn30 = _async_to_generator(function(x) { + _fn30 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - for(x = y;;){} - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + for(x = y;;){} + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn30.apply(this, arguments); } function fn31(x) { return _fn31.apply(this, arguments); } function _fn31() { - _fn31 = _async_to_generator(function(x) { + _fn31 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - for(x = y.x;;){} - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + for(x = y.x;;){} + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn31.apply(this, arguments); } function fn32(x) { return _fn32.apply(this, arguments); } function _fn32() { - _fn32 = _async_to_generator(function(x) { + _fn32 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - for(;;){ - ; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + for(;;){ + ; + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn32.apply(this, arguments); } function fn33(x) { return _fn33.apply(this, arguments); } function _fn33() { - _fn33 = _async_to_generator(function(x) { + _fn33 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - for(var x in y){} - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + for(x in y){} + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn33.apply(this, arguments); } function fn34(x) { return _fn34.apply(this, arguments); } function _fn34() { - _fn34 = _async_to_generator(function(x) { + _fn34 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var z, x; - return _ts_generator(this, function(_state) { - for(var z in y){ - ; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + for(z in y){ + ; + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn34.apply(this, arguments); } function fn35(x) { return _fn35.apply(this, arguments); } function _fn35() { - _fn35 = _async_to_generator(function(x) { + _fn35 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, x; - return _ts_generator(this, function(_state) { - _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - try { - for(_iterator = y[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ - x = _step.value; - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally{ - try { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; + _ctx.prev = 1; + for(_iterator = y[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ + x = _step.value; + } + _ctx.next = 9; + break; + case 5: + _ctx.prev = 5; + _ctx.t0 = _ctx["catch"](1); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 9: + _ctx.prev = 9; + _ctx.prev = 10; if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } - } finally{ - if (_didIteratorError) { - throw _iteratorError; + case 12: + _ctx.prev = 12; + if (!_didIteratorError) { + _ctx.next = 15; + break; } - } + throw _iteratorError; + case 15: + return _ctx.finish(12); + case 16: + return _ctx.finish(9); + case 17: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee, null, [ + [ + 1, + 5, + 9, + 17 + ], + [ + 10, + , + 12, + 16 + ] + ]); + })); return _fn35.apply(this, arguments); } function fn36(x) { return _fn36.apply(this, arguments); } function _fn36() { - _fn36 = _async_to_generator(function(x) { + _fn36 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, x; - return _ts_generator(this, function(_state) { - _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - try { - for(_iterator = y[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ - x = _step.value.x; - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally{ - try { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; + _ctx.prev = 1; + for(_iterator = y[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ + x = _step.value.x; + } + _ctx.next = 9; + break; + case 5: + _ctx.prev = 5; + _ctx.t0 = _ctx["catch"](1); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 9: + _ctx.prev = 9; + _ctx.prev = 10; if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } - } finally{ - if (_didIteratorError) { - throw _iteratorError; + case 12: + _ctx.prev = 12; + if (!_didIteratorError) { + _ctx.next = 15; + break; } - } + throw _iteratorError; + case 15: + return _ctx.finish(12); + case 16: + return _ctx.finish(9); + case 17: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee, null, [ + [ + 1, + 5, + 9, + 17 + ], + [ + 10, + , + 12, + 16 + ] + ]); + })); return _fn36.apply(this, arguments); } function fn37(x) { return _fn37.apply(this, arguments); } function _fn37() { - _fn37 = _async_to_generator(function(x) { + _fn37 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, z, x; - return _ts_generator(this, function(_state) { - _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - try { - for(_iterator = y[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ - z = _step.value; - ; - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally{ - try { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; + _ctx.prev = 1; + for(_iterator = y[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ + z = _step.value; + ; + } + _ctx.next = 9; + break; + case 5: + _ctx.prev = 5; + _ctx.t0 = _ctx["catch"](1); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 9: + _ctx.prev = 9; + _ctx.prev = 10; if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } - } finally{ - if (_didIteratorError) { - throw _iteratorError; + case 12: + _ctx.prev = 12; + if (!_didIteratorError) { + _ctx.next = 15; + break; } - } + throw _iteratorError; + case 15: + return _ctx.finish(12); + case 16: + return _ctx.finish(9); + case 17: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee, null, [ + [ + 1, + 5, + 9, + 17 + ], + [ + 10, + , + 12, + 16 + ] + ]); + })); return _fn37.apply(this, arguments); } function fn38(x) { return _fn38.apply(this, arguments); } function _fn38() { - _fn38 = _async_to_generator(function(x) { + _fn38 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - switch(y){ - case y: - ; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + switch(y){ + case y: + ; + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn38.apply(this, arguments); } function fn39(x) { return _fn39.apply(this, arguments); } function _fn39() { - _fn39 = _async_to_generator(function(x) { + _fn39 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - foo: { - ; - break foo; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ; + return _ctx.abrupt("break", 2); + case 2: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn39.apply(this, arguments); } function fn40(x) { return _fn40.apply(this, arguments); } function _fn40() { - _fn40 = _async_to_generator(function(x) { + _fn40 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { var x; - return _ts_generator(this, function(_state) { - try {} catch (e) { - ; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + try {} catch (e) { + ; + } + case 1: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); - }); + }, _callee); + })); return _fn40.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncWithVarShadowing_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncWithVarShadowing_es6_es5.2.minified.js index e69c5f644cd..5d2490c3d91 100644 --- a/crates/swc/tests/tsc-references/asyncWithVarShadowing_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncWithVarShadowing_es6_es5.2.minified.js @@ -2,4 +2,4 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _extends from "@swc/helpers/src/_extends.mjs"; import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs"; import _to_array from "@swc/helpers/src/_to_array.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression1_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression1_es2017_es5.1.normal.js index 4faed192200..81211828afe 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression1_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression1_es2017_es5.1.normal.js @@ -1,29 +1,34 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = _state.sent() || a; + _ctx.next = 3; + return p; + case 3: + _ctx.t0 = _ctx.sent; + if (_ctx.t0) { + _ctx.next = 6; + break; + } + _ctx.t0 = a; + case 6: + b = _ctx.t0; after(); - return [ - 2 - ]; + case 8: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression1_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression1_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression1_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression1_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression1_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression1_es5_es5.1.normal.js index c3a7761a2e3..5fbd3162f27 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression1_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression1_es5_es5.1.normal.js @@ -2,29 +2,34 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = _state.sent() || a; + _ctx.next = 3; + return p; + case 3: + _ctx.t0 = _ctx.sent; + if (_ctx.t0) { + _ctx.next = 6; + break; + } + _ctx.t0 = a; + case 6: + b = _ctx.t0; after(); - return [ - 2 - ]; + case 8: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression1_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression1_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression1_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression1_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression1_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression1_es6_es5.1.normal.js index 962c7d09793..79e246f8b5a 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression1_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression1_es6_es5.1.normal.js @@ -1,29 +1,34 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = _state.sent() || a; + _ctx.next = 3; + return p; + case 3: + _ctx.t0 = _ctx.sent; + if (_ctx.t0) { + _ctx.next = 6; + break; + } + _ctx.t0 = a; + case 6: + b = _ctx.t0; after(); - return [ - 2 - ]; + case 8: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression1_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression1_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression1_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression1_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression2_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression2_es2017_es5.1.normal.js index f6d562120cc..55d20e5e9fe 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression2_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression2_es2017_es5.1.normal.js @@ -1,29 +1,34 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = _state.sent() && a; + _ctx.next = 3; + return p; + case 3: + _ctx.t0 = _ctx.sent; + if (!_ctx.t0) { + _ctx.next = 6; + break; + } + _ctx.t0 = a; + case 6: + b = _ctx.t0; after(); - return [ - 2 - ]; + case 8: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression2_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression2_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression2_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression2_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression2_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression2_es5_es5.1.normal.js index 61cfe26b7c1..b99f6f54bc8 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression2_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression2_es5_es5.1.normal.js @@ -2,29 +2,34 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = _state.sent() && a; + _ctx.next = 3; + return p; + case 3: + _ctx.t0 = _ctx.sent; + if (!_ctx.t0) { + _ctx.next = 6; + break; + } + _ctx.t0 = a; + case 6: + b = _ctx.t0; after(); - return [ - 2 - ]; + case 8: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression2_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression2_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression2_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression2_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression2_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression2_es6_es5.1.normal.js index 791c88e7127..44bf2e9c6b2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression2_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression2_es6_es5.1.normal.js @@ -1,29 +1,34 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = _state.sent() && a; + _ctx.next = 3; + return p; + case 3: + _ctx.t0 = _ctx.sent; + if (!_ctx.t0) { + _ctx.next = 6; + break; + } + _ctx.t0 = a; + case 6: + b = _ctx.t0; after(); - return [ - 2 - ]; + case 8: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression2_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression2_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression2_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression2_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression3_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression3_es2017_es5.1.normal.js index 6aafa6da3ef..669ee120013 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression3_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression3_es2017_es5.1.normal.js @@ -1,29 +1,29 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = _state.sent() + a; + _ctx.next = 3; + return p; + case 3: + _ctx.t0 = _ctx.sent; + _ctx.t1 = a; + b = _ctx.t0 + _ctx.t1; after(); - return [ - 2 - ]; + case 7: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression3_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression3_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression3_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression3_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression3_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression3_es5_es5.1.normal.js index 90ab1877b9c..36c7d6ce578 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression3_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression3_es5_es5.1.normal.js @@ -2,29 +2,29 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = _state.sent() + a; + _ctx.next = 3; + return p; + case 3: + _ctx.t0 = _ctx.sent; + _ctx.t1 = a; + b = _ctx.t0 + _ctx.t1; after(); - return [ - 2 - ]; + case 7: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression3_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression3_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression3_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression3_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression3_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression3_es6_es5.1.normal.js index 4e68f507dfc..dd4e78c87a4 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression3_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression3_es6_es5.1.normal.js @@ -1,29 +1,29 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = _state.sent() + a; + _ctx.next = 3; + return p; + case 3: + _ctx.t0 = _ctx.sent; + _ctx.t1 = a; + b = _ctx.t0 + _ctx.t1; after(); - return [ - 2 - ]; + case 7: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression3_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression3_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression3_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression3_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression4_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression4_es2017_es5.1.normal.js index cdec4e17989..8928ac15ea1 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression4_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression4_es2017_es5.1.normal.js @@ -1,29 +1,27 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = (_state.sent(), a); + _ctx.next = 3; + return p; + case 3: + b = (_ctx.sent, a); after(); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression4_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression4_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression4_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression4_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression4_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression4_es5_es5.1.normal.js index b6f2fb929d5..37022c58e26 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression4_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression4_es5_es5.1.normal.js @@ -2,29 +2,27 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = (_state.sent(), a); + _ctx.next = 3; + return p; + case 3: + b = (_ctx.sent, a); after(); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression4_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression4_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression4_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression4_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression4_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression4_es6_es5.1.normal.js index 4486c512a05..517f8b86384 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression4_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression4_es6_es5.1.normal.js @@ -1,29 +1,27 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = (_state.sent(), a); + _ctx.next = 3; + return p; + case 3: + b = (_ctx.sent, a); after(); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression4_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression4_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression4_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression4_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression5_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression5_es2017_es5.1.normal.js index 89a5b7d6206..0850afcf4e3 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression5_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression5_es2017_es5.1.normal.js @@ -1,29 +1,28 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var o; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - o.a = _state.sent(); + ; + _ctx.next = 4; + return p; + case 4: + o.a = _ctx.sent; after(); - return [ - 2 - ]; + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression5_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression5_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression5_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression5_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression5_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression5_es5_es5.1.normal.js index 3d497da2052..f6976cf8838 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression5_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression5_es5_es5.1.normal.js @@ -2,29 +2,28 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var o; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - o.a = _state.sent(); + ; + _ctx.next = 4; + return p; + case 4: + o.a = _ctx.sent; after(); - return [ - 2 - ]; + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression5_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression5_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression5_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression5_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression5_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitBinaryExpression5_es6_es5.1.normal.js index 31e9a1a9979..c8009520de1 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression5_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression5_es6_es5.1.normal.js @@ -1,29 +1,28 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var o; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - o.a = _state.sent(); + ; + _ctx.next = 4; + return p; + case 4: + o.a = _ctx.sent; after(); - return [ - 2 - ]; + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitBinaryExpression5_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitBinaryExpression5_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitBinaryExpression5_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitBinaryExpression5_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression1_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression1_es2017_es5.1.normal.js index 04d8e4350b1..8e623c99ccc 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression1_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression1_es2017_es5.1.normal.js @@ -1,21 +1,24 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - before(); - b = fn(a, a, a); - after(); - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + before(); + b = fn(a, a, a); + after(); + case 3: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression1_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression1_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression1_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression1_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression1_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression1_es5_es5.1.normal.js index 4084c1a26d4..8c204724774 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression1_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression1_es5_es5.1.normal.js @@ -2,21 +2,24 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - before(); - b = fn(a, a, a); - after(); - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + before(); + b = fn(a, a, a); + after(); + case 3: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression1_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression1_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression1_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression1_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression1_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression1_es6_es5.1.normal.js index 96048c588c1..b882c24280f 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression1_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression1_es6_es5.1.normal.js @@ -1,21 +1,24 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - before(); - b = fn(a, a, a); - after(); - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + before(); + b = fn(a, a, a); + after(); + case 3: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression1_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression1_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression1_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression1_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression2_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression2_es2017_es5.1.normal.js index 70e11906a1e..d9af219b015 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression2_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression2_es2017_es5.1.normal.js @@ -1,33 +1,31 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = fn.apply(void 0, [ - _state.sent(), - a, - a - ]); + _ctx.t0 = fn; + _ctx.next = 4; + return p; + case 4: + _ctx.t1 = _ctx.sent; + _ctx.t2 = a; + _ctx.t3 = a; + b = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); after(); - return [ - 2 - ]; + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression2_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression2_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression2_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression2_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression2_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression2_es5_es5.1.normal.js index 6e9f56e490d..bcd92e714fa 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression2_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression2_es5_es5.1.normal.js @@ -2,33 +2,31 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = fn.apply(void 0, [ - _state.sent(), - a, - a - ]); + _ctx.t0 = fn; + _ctx.next = 4; + return p; + case 4: + _ctx.t1 = _ctx.sent; + _ctx.t2 = a; + _ctx.t3 = a; + b = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); after(); - return [ - 2 - ]; + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression2_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression2_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression2_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression2_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression2_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression2_es6_es5.1.normal.js index 5f448516f91..fef4cddc9c2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression2_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression2_es6_es5.1.normal.js @@ -1,33 +1,31 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - p - ]; - case 1: - b = fn.apply(void 0, [ - _state.sent(), - a, - a - ]); + _ctx.t0 = fn; + _ctx.next = 4; + return p; + case 4: + _ctx.t1 = _ctx.sent; + _ctx.t2 = a; + _ctx.t3 = a; + b = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); after(); - return [ - 2 - ]; + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression2_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression2_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression2_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression2_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression3_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression3_es2017_es5.1.normal.js index 1a3f8a4abec..8410697e58f 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression3_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression3_es2017_es5.1.normal.js @@ -1,32 +1,31 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { - var b, _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var b; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - _tmp = [ - a - ]; - return [ - 4, - p - ]; - case 1: - b = fn.apply(void 0, _tmp.concat(_state.sent(), a)); + _ctx.t0 = fn; + _ctx.t1 = a; + _ctx.next = 5; + return p; + case 5: + _ctx.t2 = _ctx.sent; + _ctx.t3 = a; + b = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); after(); - return [ - 2 - ]; + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression3_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression3_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression3_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression3_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression3_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression3_es5_es5.1.normal.js index a6e85fa783b..4598029276a 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression3_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression3_es5_es5.1.normal.js @@ -2,32 +2,31 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { - var b, _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var b; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - _tmp = [ - a - ]; - return [ - 4, - p - ]; - case 1: - b = fn.apply(void 0, _tmp.concat(_state.sent(), a)); + _ctx.t0 = fn; + _ctx.t1 = a; + _ctx.next = 5; + return p; + case 5: + _ctx.t2 = _ctx.sent; + _ctx.t3 = a; + b = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); after(); - return [ - 2 - ]; + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression3_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression3_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression3_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression3_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression3_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression3_es6_es5.1.normal.js index 2c3402aaaee..3cd1fd7051a 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression3_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression3_es6_es5.1.normal.js @@ -1,32 +1,31 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { - var b, _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var b; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - _tmp = [ - a - ]; - return [ - 4, - p - ]; - case 1: - b = fn.apply(void 0, _tmp.concat(_state.sent(), a)); + _ctx.t0 = fn; + _ctx.t1 = a; + _ctx.next = 5; + return p; + case 5: + _ctx.t2 = _ctx.sent; + _ctx.t3 = a; + b = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); after(); - return [ - 2 - ]; + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression3_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression3_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression3_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression3_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression4_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression4_es2017_es5.1.normal.js index ac13940cf64..913f401ef48 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression4_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression4_es2017_es5.1.normal.js @@ -1,29 +1,28 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - pfn - ]; - case 1: - b = _state.sent()(a, a, a); + _ctx.next = 3; + return pfn; + case 3: + _ctx.t0 = _ctx.sent; + b = (0, _ctx.t0)(a, a, a); after(); - return [ - 2 - ]; + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression4_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression4_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression4_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression4_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression4_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression4_es5_es5.1.normal.js index 11f2cba65e3..3f35eedae2b 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression4_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression4_es5_es5.1.normal.js @@ -2,29 +2,28 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - pfn - ]; - case 1: - b = _state.sent()(a, a, a); + _ctx.next = 3; + return pfn; + case 3: + _ctx.t0 = _ctx.sent; + b = (0, _ctx.t0)(a, a, a); after(); - return [ - 2 - ]; + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression4_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression4_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression4_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression4_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression4_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression4_es6_es5.1.normal.js index 880b07c6bbd..2a4eb1096cf 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression4_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression4_es6_es5.1.normal.js @@ -1,29 +1,28 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - pfn - ]; - case 1: - b = _state.sent()(a, a, a); + _ctx.next = 3; + return pfn; + case 3: + _ctx.t0 = _ctx.sent; + b = (0, _ctx.t0)(a, a, a); after(); - return [ - 2 - ]; + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression4_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression4_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression4_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression4_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression5_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression5_es2017_es5.1.normal.js index dfaa41d5dfe..05f31481ddf 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression5_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression5_es2017_es5.1.normal.js @@ -1,21 +1,24 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - before(); - b = o.fn(a, a, a); - after(); - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + before(); + b = o.fn(a, a, a); + after(); + case 3: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression5_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression5_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression5_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression5_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression5_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression5_es5_es5.1.normal.js index bf458251dc5..b49f67aa66b 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression5_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression5_es5_es5.1.normal.js @@ -2,21 +2,24 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - before(); - b = o.fn(a, a, a); - after(); - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + before(); + b = o.fn(a, a, a); + after(); + case 3: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression5_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression5_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression5_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression5_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression5_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression5_es6_es5.1.normal.js index 8827c53963c..bb7f387e3aa 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression5_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression5_es6_es5.1.normal.js @@ -1,21 +1,24 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - before(); - b = o.fn(a, a, a); - after(); - return [ - 2 - ]; - }); - }); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + before(); + b = o.fn(a, a, a); + after(); + case 3: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression5_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression5_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression5_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression5_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression6_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression6_es2017_es5.1.normal.js index a613f97ab3e..9143a498842 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression6_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression6_es2017_es5.1.normal.js @@ -1,34 +1,31 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - _ = o.fn; - return [ - 4, - p - ]; - case 1: - b = _.apply(void 0, [ - _state.sent(), - a, - a - ]); + _ctx.t0 = o; + _ctx.next = 4; + return p; + case 4: + _ctx.t1 = _ctx.sent; + _ctx.t2 = a; + _ctx.t3 = a; + b = _ctx.t0.fn.call(_ctx.t0, _ctx.t1, _ctx.t2, _ctx.t3); after(); - return [ - 2 - ]; + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression6_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression6_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression6_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression6_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression6_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression6_es5_es5.1.normal.js index e7ef297d378..31825b63caf 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression6_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression6_es5_es5.1.normal.js @@ -2,34 +2,31 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - _ = o.fn; - return [ - 4, - p - ]; - case 1: - b = _.apply(void 0, [ - _state.sent(), - a, - a - ]); + _ctx.t0 = o; + _ctx.next = 4; + return p; + case 4: + _ctx.t1 = _ctx.sent; + _ctx.t2 = a; + _ctx.t3 = a; + b = _ctx.t0.fn.call(_ctx.t0, _ctx.t1, _ctx.t2, _ctx.t3); after(); - return [ - 2 - ]; + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression6_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression6_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression6_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression6_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression6_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression6_es6_es5.1.normal.js index 1e9edec4d0d..760652bb38e 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression6_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression6_es6_es5.1.normal.js @@ -1,34 +1,31 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - _ = o.fn; - return [ - 4, - p - ]; - case 1: - b = _.apply(void 0, [ - _state.sent(), - a, - a - ]); + _ctx.t0 = o; + _ctx.next = 4; + return p; + case 4: + _ctx.t1 = _ctx.sent; + _ctx.t2 = a; + _ctx.t3 = a; + b = _ctx.t0.fn.call(_ctx.t0, _ctx.t1, _ctx.t2, _ctx.t3); after(); - return [ - 2 - ]; + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression6_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression6_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression6_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression6_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression7_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression7_es2017_es5.1.normal.js index 5cd1a5ef228..0ce8e631d3e 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression7_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression7_es2017_es5.1.normal.js @@ -1,33 +1,31 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { - var b, _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var b; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - _ = o.fn; - _tmp = [ - a - ]; - return [ - 4, - p - ]; - case 1: - b = _.apply(void 0, _tmp.concat(_state.sent(), a)); + _ctx.t0 = o; + _ctx.t1 = a; + _ctx.next = 5; + return p; + case 5: + _ctx.t2 = _ctx.sent; + _ctx.t3 = a; + b = _ctx.t0.fn.call(_ctx.t0, _ctx.t1, _ctx.t2, _ctx.t3); after(); - return [ - 2 - ]; + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression7_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression7_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression7_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression7_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression7_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression7_es5_es5.1.normal.js index 21d0a2821aa..81ecd5cf100 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression7_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression7_es5_es5.1.normal.js @@ -2,33 +2,31 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { - var b, _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var b; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - _ = o.fn; - _tmp = [ - a - ]; - return [ - 4, - p - ]; - case 1: - b = _.apply(void 0, _tmp.concat(_state.sent(), a)); + _ctx.t0 = o; + _ctx.t1 = a; + _ctx.next = 5; + return p; + case 5: + _ctx.t2 = _ctx.sent; + _ctx.t3 = a; + b = _ctx.t0.fn.call(_ctx.t0, _ctx.t1, _ctx.t2, _ctx.t3); after(); - return [ - 2 - ]; + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression7_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression7_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression7_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression7_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression7_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression7_es6_es5.1.normal.js index 064beed4e84..68ccb470c09 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression7_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression7_es6_es5.1.normal.js @@ -1,33 +1,31 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { - var b, _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var b; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - _ = o.fn; - _tmp = [ - a - ]; - return [ - 4, - p - ]; - case 1: - b = _.apply(void 0, _tmp.concat(_state.sent(), a)); + _ctx.t0 = o; + _ctx.t1 = a; + _ctx.next = 5; + return p; + case 5: + _ctx.t2 = _ctx.sent; + _ctx.t3 = a; + b = _ctx.t0.fn.call(_ctx.t0, _ctx.t1, _ctx.t2, _ctx.t3); after(); - return [ - 2 - ]; + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression7_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression7_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression7_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression7_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression8_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression8_es2017_es5.1.normal.js index 4c875449104..6999f561578 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression8_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression8_es2017_es5.1.normal.js @@ -1,29 +1,27 @@ // @target: es2017 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - po - ]; - case 1: - b = _state.sent().fn(a, a, a); + _ctx.next = 3; + return po; + case 3: + b = _ctx.sent.fn(a, a, a); after(); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression8_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression8_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression8_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression8_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression8_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression8_es5_es5.1.normal.js index e289f10b15b..bc091fa27f1 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression8_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression8_es5_es5.1.normal.js @@ -2,29 +2,27 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - po - ]; - case 1: - b = _state.sent().fn(a, a, a); + _ctx.next = 3; + return po; + case 3: + b = _ctx.sent.fn(a, a, a); after(); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression8_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression8_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression8_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression8_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitCallExpression8_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitCallExpression8_es6_es5.1.normal.js index d7e0aac138a..5f5059afcd9 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression8_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression8_es6_es5.1.normal.js @@ -1,29 +1,27 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: before(); - return [ - 4, - po - ]; - case 1: - b = _state.sent().fn(a, a, a); + _ctx.next = 3; + return po; + case 3: + b = _ctx.sent.fn(a, a, a); after(); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitCallExpression8_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitCallExpression8_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitCallExpression8_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitCallExpression8_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitClassExpression_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitClassExpression_es2017_es5.1.normal.js index 25d9748fc57..9b5e761d47d 100644 --- a/crates/swc/tests/tsc-references/awaitClassExpression_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitClassExpression_es2017_es5.1.normal.js @@ -4,17 +4,17 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var D; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ = function(_superClass) { + _ctx.t0 = function(_superClass) { "use strict"; _inherits(D, _superClass); var _super = _create_super(D); @@ -24,19 +24,16 @@ function _func() { } return D; }; - return [ - 4, - p - ]; - case 1: - D = /*#__PURE__*/ _.apply(void 0, [ - _state.sent() - ]); - return [ - 2 - ]; + _ctx.next = 3; + return p; + case 3: + _ctx.t1 = _ctx.sent; + D = /*#__PURE__*/ (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitClassExpression_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitClassExpression_es2017_es5.2.minified.js index 1cfbe4f5a2f..902b3208fff 100644 --- a/crates/swc/tests/tsc-references/awaitClassExpression_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitClassExpression_es2017_es5.2.minified.js @@ -2,4 +2,4 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitClassExpression_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitClassExpression_es5_es5.1.normal.js index 24ada7d3fb1..eca05dd35dd 100644 --- a/crates/swc/tests/tsc-references/awaitClassExpression_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitClassExpression_es5_es5.1.normal.js @@ -5,17 +5,17 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var D; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ = function(_superClass) { + _ctx.t0 = function(_superClass) { "use strict"; _inherits(D, _superClass); var _super = _create_super(D); @@ -25,19 +25,16 @@ function _func() { } return D; }; - return [ - 4, - p - ]; - case 1: - D = /*#__PURE__*/ _.apply(void 0, [ - _state.sent() - ]); - return [ - 2 - ]; + _ctx.next = 3; + return p; + case 3: + _ctx.t1 = _ctx.sent; + D = /*#__PURE__*/ (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitClassExpression_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitClassExpression_es5_es5.2.minified.js index 1cfbe4f5a2f..902b3208fff 100644 --- a/crates/swc/tests/tsc-references/awaitClassExpression_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitClassExpression_es5_es5.2.minified.js @@ -2,4 +2,4 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitClassExpression_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitClassExpression_es6_es5.1.normal.js index f66b54a7329..7f7e3041975 100644 --- a/crates/swc/tests/tsc-references/awaitClassExpression_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitClassExpression_es6_es5.1.normal.js @@ -4,17 +4,17 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var D; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ = function(_superClass) { + _ctx.t0 = function(_superClass) { "use strict"; _inherits(D, _superClass); var _super = _create_super(D); @@ -24,19 +24,16 @@ function _func() { } return D; }; - return [ - 4, - p - ]; - case 1: - D = /*#__PURE__*/ _.apply(void 0, [ - _state.sent() - ]); - return [ - 2 - ]; + _ctx.next = 3; + return p; + case 3: + _ctx.t1 = _ctx.sent; + D = /*#__PURE__*/ (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitClassExpression_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitClassExpression_es6_es5.2.minified.js index 1cfbe4f5a2f..902b3208fff 100644 --- a/crates/swc/tests/tsc-references/awaitClassExpression_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitClassExpression_es6_es5.2.minified.js @@ -2,4 +2,4 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitInheritedPromise_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitInheritedPromise_es2017_es5.1.normal.js index 218ee91d8a4..138ad78bf91 100644 --- a/crates/swc/tests/tsc-references/awaitInheritedPromise_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitInheritedPromise_es2017_es5.1.normal.js @@ -1,26 +1,22 @@ // @target: es2017 // @strictNullChecks: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f() { return _f.apply(this, arguments); } function _f() { - _f = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - a - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return a; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitInheritedPromise_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitInheritedPromise_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitInheritedPromise_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitInheritedPromise_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitUnion_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitUnion_es5_es5.1.normal.js index 252ea35a44d..35538455d60 100644 --- a/crates/swc/tests/tsc-references/awaitUnion_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUnion_es5_es5.1.normal.js @@ -2,51 +2,41 @@ // @lib: es5,es2015.promise // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f() { return _f.apply(this, arguments); } function _f() { - _f = _async_to_generator(function() { + _f = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var await_a, await_b, await_c, await_d, await_e; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - a - ]; - case 1: - await_a = _state.sent(); - return [ - 4, - b - ]; + _ctx.next = 2; + return a; case 2: - await_b = _state.sent(); - return [ - 4, - c - ]; - case 3: - await_c = _state.sent(); - return [ - 4, - d - ]; - case 4: - await_d = _state.sent(); - return [ - 4, - e - ]; + await_a = _ctx.sent; + _ctx.next = 5; + return b; case 5: - await_e = _state.sent(); - return [ - 2 - ]; + await_b = _ctx.sent; + _ctx.next = 8; + return c; + case 8: + await_c = _ctx.sent; + _ctx.next = 11; + return d; + case 11: + await_d = _ctx.sent; + _ctx.next = 14; + return e; + case 14: + await_e = _ctx.sent; + case 15: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitUnion_es5_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitUnion_es5_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitUnion_es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUnion_es5_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/awaitUnion_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/awaitUnion_es6_es5.1.normal.js index 934e0600bb0..8ead9003310 100644 --- a/crates/swc/tests/tsc-references/awaitUnion_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUnion_es6_es5.1.normal.js @@ -1,51 +1,41 @@ // @target: ES6 // @noEmitHelpers: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f() { return _f.apply(this, arguments); } function _f() { - _f = _async_to_generator(function() { + _f = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var await_a, await_b, await_c, await_d, await_e; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - a - ]; - case 1: - await_a = _state.sent(); - return [ - 4, - b - ]; + _ctx.next = 2; + return a; case 2: - await_b = _state.sent(); - return [ - 4, - c - ]; - case 3: - await_c = _state.sent(); - return [ - 4, - d - ]; - case 4: - await_d = _state.sent(); - return [ - 4, - e - ]; + await_a = _ctx.sent; + _ctx.next = 5; + return b; case 5: - await_e = _state.sent(); - return [ - 2 - ]; + await_b = _ctx.sent; + _ctx.next = 8; + return c; + case 8: + await_c = _ctx.sent; + _ctx.next = 11; + return d; + case 11: + await_d = _ctx.sent; + _ctx.next = 14; + return e; + case 14: + await_e = _ctx.sent; + case 15: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/awaitUnion_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/awaitUnion_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/awaitUnion_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUnion_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/await_unaryExpression_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/await_unaryExpression_es2017_es5.1.normal.js index bc5017dc9d3..7d49d188ae3 100644 --- a/crates/swc/tests/tsc-references/await_unaryExpression_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/await_unaryExpression_es2017_es5.1.normal.js @@ -1,91 +1,83 @@ // @target: es2017 import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function bar() { return _bar.apply(this, arguments); } function _bar() { - _bar = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _bar = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 42 - ]; - case 1: - !_state.sent(); // OK - return [ - 2 - ]; + _ctx.next = 2; + return 42; + case 2: + !_ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _bar.apply(this, arguments); } function bar1() { return _bar1.apply(this, arguments); } function _bar1() { - _bar1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _bar1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 42 - ]; - case 1: - +_state.sent(); // OK - return [ - 2 - ]; + _ctx.next = 2; + return 42; + case 2: + +_ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _bar1.apply(this, arguments); } function bar3() { return _bar3.apply(this, arguments); } function _bar3() { - _bar3 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _bar3 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 42 - ]; - case 1: - -_state.sent(); // OK - return [ - 2 - ]; + _ctx.next = 2; + return 42; + case 2: + -_ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _bar3.apply(this, arguments); } function bar4() { return _bar4.apply(this, arguments); } function _bar4() { - _bar4 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _bar4 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 42 - ]; - case 1: - ~_state.sent(); // OK - return [ - 2 - ]; + _ctx.next = 2; + return 42; + case 2: + ~_ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _bar4.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/await_unaryExpression_es2017_es5.2.minified.js b/crates/swc/tests/tsc-references/await_unaryExpression_es2017_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/await_unaryExpression_es2017_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/await_unaryExpression_es2017_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/await_unaryExpression_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/await_unaryExpression_es6_es5.1.normal.js index d93428588f9..6fdda589c12 100644 --- a/crates/swc/tests/tsc-references/await_unaryExpression_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/await_unaryExpression_es6_es5.1.normal.js @@ -1,91 +1,83 @@ // @target: es6 import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function bar() { return _bar.apply(this, arguments); } function _bar() { - _bar = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _bar = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 42 - ]; - case 1: - !_state.sent(); // OK - return [ - 2 - ]; + _ctx.next = 2; + return 42; + case 2: + !_ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _bar.apply(this, arguments); } function bar1() { return _bar1.apply(this, arguments); } function _bar1() { - _bar1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _bar1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 42 - ]; - case 1: - +_state.sent(); // OK - return [ - 2 - ]; + _ctx.next = 2; + return 42; + case 2: + +_ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _bar1.apply(this, arguments); } function bar3() { return _bar3.apply(this, arguments); } function _bar3() { - _bar3 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _bar3 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 42 - ]; - case 1: - -_state.sent(); // OK - return [ - 2 - ]; + _ctx.next = 2; + return 42; + case 2: + -_ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _bar3.apply(this, arguments); } function bar4() { return _bar4.apply(this, arguments); } function _bar4() { - _bar4 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _bar4 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 42 - ]; - case 1: - ~_state.sent(); // OK - return [ - 2 - ]; + _ctx.next = 2; + return 42; + case 2: + ~_ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _bar4.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/await_unaryExpression_es6_es5.2.minified.js b/crates/swc/tests/tsc-references/await_unaryExpression_es6_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/await_unaryExpression_es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/await_unaryExpression_es6_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/checkJsxSubtleSkipContextSensitiveBug_es5.1.normal.js b/crates/swc/tests/tsc-references/checkJsxSubtleSkipContextSensitiveBug_es5.1.normal.js index 097d3df3095..8eb0da960de 100644 --- a/crates/swc/tests/tsc-references/checkJsxSubtleSkipContextSensitiveBug_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/checkJsxSubtleSkipContextSensitiveBug_es5.1.normal.js @@ -7,7 +7,7 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import * as React from "react"; var AsyncLoader = /*#__PURE__*/ function(_Component) { "use strict"; @@ -27,16 +27,19 @@ function load() { return _load.apply(this, arguments); } function _load() { - _load = _async_to_generator(function() { - var _tmp; - return _ts_generator(this, function(_state) { - _tmp = {}; - return [ - 2, - (_tmp.success = true, _tmp) - ]; - }); - }); + _load = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", { + success: true + }); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _load.apply(this, arguments); } var loader = /*#__PURE__*/ React.createElement(AsyncLoader, { diff --git a/crates/swc/tests/tsc-references/checkJsxSubtleSkipContextSensitiveBug_es5.2.minified.js b/crates/swc/tests/tsc-references/checkJsxSubtleSkipContextSensitiveBug_es5.2.minified.js index 991dd6fdcef..5084326bc62 100644 --- a/crates/swc/tests/tsc-references/checkJsxSubtleSkipContextSensitiveBug_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/checkJsxSubtleSkipContextSensitiveBug_es5.2.minified.js @@ -2,6 +2,6 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import * as React from "react"; React.Component; diff --git a/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionAwaitOperand_es5.1.normal.js b/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionAwaitOperand_es5.1.normal.js index e310fb9f6e7..847b7595d1b 100644 --- a/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionAwaitOperand_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionAwaitOperand_es5.1.normal.js @@ -2,45 +2,41 @@ // @noImplicitAny: true // @noEmit: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function fn1() { return _fn1.apply(this, arguments); } function _fn1() { - _fn1 = _async_to_generator(function() { - var obj1, _tmp, obj2, _tmp1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _fn1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var obj1, obj2; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp = {}; - return [ - 4, - (_tmp.key = "value", _tmp) - ]; - case 1: - obj1 = _state.sent(); - return [ - 4, - new Promise(function(resolve) { - return resolve({ - key: "value" - }); - }) - ]; + _ctx.next = 2; + return { + key: "value" + }; case 2: - obj2 = _state.sent(); - _tmp1 = {}; - return [ - 4, - (_tmp1.key = "value", _tmp1) - ]; - case 3: - return [ - 2, - _state.sent() - ]; + obj1 = _ctx.sent; + _ctx.next = 5; + return new Promise(function(resolve) { + return resolve({ + key: "value" + }); + }); + case 5: + obj2 = _ctx.sent; + _ctx.next = 8; + return { + key: "value" + }; + case 8: + return _ctx.abrupt("return", _ctx.sent); + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn1.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionAwaitOperand_es5.2.minified.js b/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionAwaitOperand_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionAwaitOperand_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionAwaitOperand_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionReturnType_es5.1.normal.js b/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionReturnType_es5.1.normal.js index a590dc4e772..c389c06ff5d 100644 --- a/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionReturnType_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionReturnType_es5.1.normal.js @@ -2,88 +2,90 @@ // @noImplicitAny: true // @noEmit: true import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function fn1() { return _fn1.apply(this, arguments); } function _fn1() { - _fn1 = _async_to_generator(function() { - var _tmp; - return _ts_generator(this, function(_state) { - _tmp = {}; - return [ - 2, - (_tmp.key = "value", _tmp) - ]; - }); - }); + _fn1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", { + key: "value" + }); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn1.apply(this, arguments); } function fn2() { return _fn2.apply(this, arguments); } function _fn2() { - _fn2 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - new Promise(function(resolve) { - resolve({ - key: "value" - }); - }) - ]; - }); - }); + _fn2 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", new Promise(function(resolve) { + resolve({ + key: "value" + }); + })); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _fn2.apply(this, arguments); } function fn3() { return _fn3.apply(this, arguments); } function _fn3() { - _fn3 = _async_to_generator(function() { - var _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _fn3 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp = {}; - return [ - 4, - (_tmp.key = "value", _tmp) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return { + key: "value" + }; + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn3.apply(this, arguments); } function fn4() { return _fn4.apply(this, arguments); } function _fn4() { - _fn4 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _fn4 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - new Promise(function(resolve) { - resolve({ - key: "value" - }); - }) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return new Promise(function(resolve) { + resolve({ + key: "value" + }); + }); + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn4.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionReturnType_es5.2.minified.js b/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionReturnType_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionReturnType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/contextuallyTypeAsyncFunctionReturnType_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/controlFlowIIFE_es5.1.normal.js b/crates/swc/tests/tsc-references/controlFlowIIFE_es5.1.normal.js index bf33cc506b2..62ac7f737c7 100644 --- a/crates/swc/tests/tsc-references/controlFlowIIFE_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/controlFlowIIFE_es5.1.normal.js @@ -1,7 +1,7 @@ // @strictNullChecks: true // @target: ES2017 import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f1() { var x = getStringOrNumber(); if (typeof x === "string") { @@ -53,42 +53,37 @@ function f4() { } function f5() { var v; - (function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); + _ctx.next = 2; + return 1; + case 2: v = 1; - return [ - 2 - ]; + case 3: + case "end": + return _ctx.stop(); } - }); + }, _callee); })(); v; // still undefined } function f6() { var v; - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - v = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + v = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); v; // still undefined } diff --git a/crates/swc/tests/tsc-references/controlFlowIIFE_es5.2.minified.js b/crates/swc/tests/tsc-references/controlFlowIIFE_es5.2.minified.js index 16e2dd4831b..d93e8e6ceab 100644 --- a/crates/swc/tests/tsc-references/controlFlowIIFE_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/controlFlowIIFE_es5.2.minified.js @@ -1,5 +1,5 @@ var maybeNumber, test; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; if (maybeNumber = 1, ++maybeNumber, maybeNumber++, !test) throw Error("Test is not defined"); test.slice(1); diff --git a/crates/swc/tests/tsc-references/defaultExportInAwaitExpression01_es5.1.normal.js b/crates/swc/tests/tsc-references/defaultExportInAwaitExpression01_es5.1.normal.js index 3b48d7f1fcc..3a16ebf4d86 100644 --- a/crates/swc/tests/tsc-references/defaultExportInAwaitExpression01_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/defaultExportInAwaitExpression01_es5.1.normal.js @@ -7,22 +7,20 @@ var x = new Promise(function(resolve, reject) { export default x; // @filename: b.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import x from "./a"; -_async_to_generator(function() { +_async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var value; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - x - ]; - case 1: - value = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return x; + case 2: + value = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); -})(); + }, _callee); +}))(); diff --git a/crates/swc/tests/tsc-references/defaultExportInAwaitExpression01_es5.2.minified.js b/crates/swc/tests/tsc-references/defaultExportInAwaitExpression01_es5.2.minified.js index a0908ece210..938ed3fc1d0 100644 --- a/crates/swc/tests/tsc-references/defaultExportInAwaitExpression01_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/defaultExportInAwaitExpression01_es5.2.minified.js @@ -3,21 +3,19 @@ var x = new Promise(function(resolve, reject) { }); export default x; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import x from "./a"; -_async_to_generator(function() { +_async_to_generator(regeneratorRuntime.mark(function _callee() { var value; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - x - ]; - case 1: - return value = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, x; + case 2: + value = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); -})(); + }, _callee); +}))(); diff --git a/crates/swc/tests/tsc-references/defaultExportInAwaitExpression02_es5.1.normal.js b/crates/swc/tests/tsc-references/defaultExportInAwaitExpression02_es5.1.normal.js index 6faff6f5a60..52c240d92b3 100644 --- a/crates/swc/tests/tsc-references/defaultExportInAwaitExpression02_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/defaultExportInAwaitExpression02_es5.1.normal.js @@ -7,22 +7,20 @@ var x = new Promise(function(resolve, reject) { export default x; // @filename: b.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import x from "./a"; -_async_to_generator(function() { +_async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var value; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - x - ]; - case 1: - value = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return x; + case 2: + value = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); -})(); + }, _callee); +}))(); diff --git a/crates/swc/tests/tsc-references/defaultExportInAwaitExpression02_es5.2.minified.js b/crates/swc/tests/tsc-references/defaultExportInAwaitExpression02_es5.2.minified.js index a0908ece210..938ed3fc1d0 100644 --- a/crates/swc/tests/tsc-references/defaultExportInAwaitExpression02_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/defaultExportInAwaitExpression02_es5.2.minified.js @@ -3,21 +3,19 @@ var x = new Promise(function(resolve, reject) { }); export default x; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import x from "./a"; -_async_to_generator(function() { +_async_to_generator(regeneratorRuntime.mark(function _callee() { var value; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - x - ]; - case 1: - return value = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, x; + case 2: + value = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); -})(); + }, _callee); +}))(); diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2015_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2015_es5.1.normal.js index a713223ed4a..fd37b45fdcb 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2015_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2015_es5.1.normal.js @@ -3,7 +3,7 @@ // @filename: C1.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C1 = /*#__PURE__*/ function() { "use strict"; function C1() { @@ -11,20 +11,22 @@ var C1 = /*#__PURE__*/ function() { } var _proto = C1.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C1; }(); // @filename: C2.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C2 = /*#__PURE__*/ function() { "use strict"; function C2() { @@ -32,29 +34,28 @@ var C2 = /*#__PURE__*/ function() { } var _proto = C2.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C2; }(); // @filename: C3.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C3 = /*#__PURE__*/ function() { "use strict"; function C3() { @@ -62,23 +63,21 @@ var C3 = /*#__PURE__*/ function() { } var _proto = C3.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C3; }(); @@ -88,8 +87,7 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C4 = /*#__PURE__*/ function() { "use strict"; function C4() { @@ -97,25 +95,22 @@ var C4 = /*#__PURE__*/ function() { } var _proto = C4.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1 + ]), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C4; }(); @@ -125,8 +120,7 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C5 = /*#__PURE__*/ function() { "use strict"; function C5() { @@ -134,38 +128,31 @@ var C5 = /*#__PURE__*/ function() { } var _proto = C5.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C5; }(); @@ -173,7 +160,7 @@ var C5 = /*#__PURE__*/ function() { import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C6 = /*#__PURE__*/ function() { "use strict"; function C6() { @@ -181,30 +168,28 @@ var C6 = /*#__PURE__*/ function() { } var _proto = C6.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C6; }(); // @filename: C7.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C7 = /*#__PURE__*/ function() { "use strict"; function C7() { @@ -212,21 +197,24 @@ var C7 = /*#__PURE__*/ function() { } var _proto = C7.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C7; }(); // @filename: C8.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C8 = /*#__PURE__*/ function() { "use strict"; function C8() { @@ -236,14 +224,17 @@ var C8 = /*#__PURE__*/ function() { _proto.g = function g() {}; _proto.f = function f() { var _this = this; - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - _this.g(); - return [ - 2 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _this.g(); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C8; }(); @@ -254,7 +245,7 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var B9 = /*#__PURE__*/ function() { "use strict"; function B9() { @@ -278,14 +269,17 @@ var C9 = /*#__PURE__*/ function(B9) { var _this1 = this, _superprop_get_g = function() { return _get(_get_prototype_of(C9.prototype), "g", _this); }; - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - _superprop_get_g().call(_this1); - return [ - 2 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _superprop_get_g().call(_this1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C9; }(B9); diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2015_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2015_es5.2.minified.js index 5e5fd0543b0..58cec0b5ff6 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2015_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2015_es5.2.minified.js @@ -1,40 +1,38 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _get from "@swc/helpers/src/_get.mjs"; import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2018_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2018_es5.1.normal.js index 15cd186e978..712e7ee1d8a 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2018_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2018_es5.1.normal.js @@ -3,7 +3,7 @@ // @filename: C1.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C1 = /*#__PURE__*/ function() { "use strict"; function C1() { @@ -11,20 +11,22 @@ var C1 = /*#__PURE__*/ function() { } var _proto = C1.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C1; }(); // @filename: C2.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C2 = /*#__PURE__*/ function() { "use strict"; function C2() { @@ -32,29 +34,28 @@ var C2 = /*#__PURE__*/ function() { } var _proto = C2.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C2; }(); // @filename: C3.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C3 = /*#__PURE__*/ function() { "use strict"; function C3() { @@ -62,23 +63,21 @@ var C3 = /*#__PURE__*/ function() { } var _proto = C3.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C3; }(); @@ -88,8 +87,7 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C4 = /*#__PURE__*/ function() { "use strict"; function C4() { @@ -97,25 +95,22 @@ var C4 = /*#__PURE__*/ function() { } var _proto = C4.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1 + ]), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C4; }(); @@ -125,8 +120,7 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C5 = /*#__PURE__*/ function() { "use strict"; function C5() { @@ -134,38 +128,31 @@ var C5 = /*#__PURE__*/ function() { } var _proto = C5.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C5; }(); @@ -173,7 +160,7 @@ var C5 = /*#__PURE__*/ function() { import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C6 = /*#__PURE__*/ function() { "use strict"; function C6() { @@ -181,30 +168,28 @@ var C6 = /*#__PURE__*/ function() { } var _proto = C6.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C6; }(); // @filename: C7.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C7 = /*#__PURE__*/ function() { "use strict"; function C7() { @@ -212,21 +197,24 @@ var C7 = /*#__PURE__*/ function() { } var _proto = C7.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C7; }(); // @filename: C8.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C8 = /*#__PURE__*/ function() { "use strict"; function C8() { @@ -236,14 +224,17 @@ var C8 = /*#__PURE__*/ function() { _proto.g = function g() {}; _proto.f = function f() { var _this = this; - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - _this.g(); - return [ - 2 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _this.g(); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C8; }(); @@ -254,7 +245,7 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var B9 = /*#__PURE__*/ function() { "use strict"; function B9() { @@ -278,14 +269,17 @@ var C9 = /*#__PURE__*/ function(B9) { var _this1 = this, _superprop_get_g = function() { return _get(_get_prototype_of(C9.prototype), "g", _this); }; - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - _superprop_get_g().call(_this1); - return [ - 2 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _superprop_get_g().call(_this1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C9; }(B9); diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2018_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2018_es5.2.minified.js index 5e5fd0543b0..58cec0b5ff6 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2018_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es2018_es5.2.minified.js @@ -1,40 +1,38 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _get from "@swc/helpers/src/_get.mjs"; import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es5_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es5_es5.1.normal.js index 2eed97ff2d2..876c82e8b85 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es5_es5.1.normal.js @@ -3,7 +3,7 @@ // @filename: C1.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C1 = /*#__PURE__*/ function() { "use strict"; function C1() { @@ -11,20 +11,22 @@ var C1 = /*#__PURE__*/ function() { } var _proto = C1.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C1; }(); // @filename: C2.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C2 = /*#__PURE__*/ function() { "use strict"; function C2() { @@ -32,29 +34,28 @@ var C2 = /*#__PURE__*/ function() { } var _proto = C2.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C2; }(); // @filename: C3.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C3 = /*#__PURE__*/ function() { "use strict"; function C3() { @@ -62,23 +63,21 @@ var C3 = /*#__PURE__*/ function() { } var _proto = C3.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C3; }(); @@ -88,8 +87,7 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C4 = /*#__PURE__*/ function() { "use strict"; function C4() { @@ -97,25 +95,22 @@ var C4 = /*#__PURE__*/ function() { } var _proto = C4.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1 + ]), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C4; }(); @@ -125,8 +120,7 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C5 = /*#__PURE__*/ function() { "use strict"; function C5() { @@ -134,38 +128,31 @@ var C5 = /*#__PURE__*/ function() { } var _proto = C5.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C5; }(); @@ -173,7 +160,7 @@ var C5 = /*#__PURE__*/ function() { import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C6 = /*#__PURE__*/ function() { "use strict"; function C6() { @@ -181,30 +168,28 @@ var C6 = /*#__PURE__*/ function() { } var _proto = C6.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return C6; }(); // @filename: C7.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C7 = /*#__PURE__*/ function() { "use strict"; function C7() { @@ -212,21 +197,24 @@ var C7 = /*#__PURE__*/ function() { } var _proto = C7.prototype; _proto.f = function f() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C7; }(); // @filename: C8.ts import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C8 = /*#__PURE__*/ function() { "use strict"; function C8() { @@ -236,14 +224,17 @@ var C8 = /*#__PURE__*/ function() { _proto.g = function g() {}; _proto.f = function f() { var _this = this; - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - _this.g(); - return [ - 2 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _this.g(); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C8; }(); @@ -254,7 +245,7 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var B9 = /*#__PURE__*/ function() { "use strict"; function B9() { @@ -278,14 +269,17 @@ var C9 = /*#__PURE__*/ function(B9) { var _this1 = this, _superprop_get_g = function() { return _get(_get_prototype_of(C9.prototype), "g", _this); }; - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - _superprop_get_g().call(_this1); - return [ - 2 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _superprop_get_g().call(_this1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return C9; }(B9); diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es5_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es5_es5.2.minified.js index 5e5fd0543b0..58cec0b5ff6 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.classMethods.es5_es5.2.minified.js @@ -1,40 +1,38 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _get from "@swc/helpers/src/_get.mjs"; import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2015_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2015_es5.1.normal.js index 566c66dec0d..412fa0842e8 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2015_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2015_es5.1.normal.js @@ -2,69 +2,68 @@ // @lib: esnext // @filename: F1.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f1() { return _f1.apply(this, arguments); } function _f1() { - _f1 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } // @filename: F2.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f2() { return _f2.apply(this, arguments); } function _f2() { - _f2 = _wrap_async_generator(function() { + _f2 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f2.apply(this, arguments); } // @filename: F3.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f3() { return _f3.apply(this, arguments); } function _f3() { - _f3 = _wrap_async_generator(function() { + _f3 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f3.apply(this, arguments); } // @filename: F4.ts @@ -72,31 +71,27 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f4() { return _f4.apply(this, arguments); } function _f4() { - _f4 = _wrap_async_generator(function() { + _f4 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1 + ]), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f4.apply(this, arguments); } // @filename: F5.ts @@ -104,87 +99,80 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f5() { return _f5.apply(this, arguments); } function _f5() { - _f5 = _wrap_async_generator(function() { + _f5 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f5.apply(this, arguments); } // @filename: F6.ts import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f6() { return _f6.apply(this, arguments); } function _f6() { - _f6 = _wrap_async_generator(function() { + _f6 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f6.apply(this, arguments); } // @filename: F7.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f7() { return _f7.apply(this, arguments); } function _f7() { - _f7 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); - }); + _f7 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f7.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2015_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2015_es5.2.minified.js index 3ff46ab6824..f905629020e 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2015_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2015_es5.2.minified.js @@ -1,23 +1,21 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2018_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2018_es5.1.normal.js index 1171f273d29..7ece0dd9124 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2018_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2018_es5.1.normal.js @@ -2,69 +2,68 @@ // @lib: esnext // @filename: F1.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f1() { return _f1.apply(this, arguments); } function _f1() { - _f1 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } // @filename: F2.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f2() { return _f2.apply(this, arguments); } function _f2() { - _f2 = _wrap_async_generator(function() { + _f2 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f2.apply(this, arguments); } // @filename: F3.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f3() { return _f3.apply(this, arguments); } function _f3() { - _f3 = _wrap_async_generator(function() { + _f3 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f3.apply(this, arguments); } // @filename: F4.ts @@ -72,31 +71,27 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f4() { return _f4.apply(this, arguments); } function _f4() { - _f4 = _wrap_async_generator(function() { + _f4 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1 + ]), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f4.apply(this, arguments); } // @filename: F5.ts @@ -104,87 +99,80 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f5() { return _f5.apply(this, arguments); } function _f5() { - _f5 = _wrap_async_generator(function() { + _f5 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f5.apply(this, arguments); } // @filename: F6.ts import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f6() { return _f6.apply(this, arguments); } function _f6() { - _f6 = _wrap_async_generator(function() { + _f6 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f6.apply(this, arguments); } // @filename: F7.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f7() { return _f7.apply(this, arguments); } function _f7() { - _f7 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); - }); + _f7 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f7.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2018_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2018_es5.2.minified.js index 3ff46ab6824..f905629020e 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2018_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es2018_es5.2.minified.js @@ -1,23 +1,21 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es5_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es5_es5.1.normal.js index 96d145a6d85..90d72761f27 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es5_es5.1.normal.js @@ -2,69 +2,68 @@ // @lib: esnext // @filename: F1.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f1() { return _f1.apply(this, arguments); } function _f1() { - _f1 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _f1 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f1.apply(this, arguments); } // @filename: F2.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f2() { return _f2.apply(this, arguments); } function _f2() { - _f2 = _wrap_async_generator(function() { + _f2 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f2.apply(this, arguments); } // @filename: F3.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f3() { return _f3.apply(this, arguments); } function _f3() { - _f3 = _wrap_async_generator(function() { + _f3 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f3.apply(this, arguments); } // @filename: F4.ts @@ -72,31 +71,27 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f4() { return _f4.apply(this, arguments); } function _f4() { - _f4 = _wrap_async_generator(function() { + _f4 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1 + ]), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f4.apply(this, arguments); } // @filename: F5.ts @@ -104,87 +99,80 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f5() { return _f5.apply(this, arguments); } function _f5() { - _f5 = _wrap_async_generator(function() { + _f5 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f5.apply(this, arguments); } // @filename: F6.ts import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f6() { return _f6.apply(this, arguments); } function _f6() { - _f6 = _wrap_async_generator(function() { + _f6 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f6.apply(this, arguments); } // @filename: F7.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f7() { return _f7.apply(this, arguments); } function _f7() { - _f7 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); - }); + _f7 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f7.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es5_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es5_es5.2.minified.js index 3ff46ab6824..f905629020e 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionDeclarations.es5_es5.2.minified.js @@ -1,23 +1,21 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015_es5.1.normal.js index 9030fd396b9..0ce3a0b8826 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015_es5.1.normal.js @@ -2,64 +2,63 @@ // @lib: esnext // @filename: F1.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f1 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f1() { return _ref.apply(this, arguments); }; }(); // @filename: F2.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f2 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f2() { return _ref.apply(this, arguments); }; }(); // @filename: F3.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f3 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f3() { return _ref.apply(this, arguments); }; @@ -69,28 +68,24 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f4 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1 + ]), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f4() { return _ref.apply(this, arguments); }; @@ -100,41 +95,33 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f5 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f5() { return _ref.apply(this, arguments); }; @@ -142,41 +129,42 @@ var f5 = function() { // @filename: F6.ts import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f6 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f6() { return _ref.apply(this, arguments); }; }(); // @filename: F7.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f7 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); - }); + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f7() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015_es5.2.minified.js index 3ff46ab6824..f905629020e 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015_es5.2.minified.js @@ -1,23 +1,21 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2018_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2018_es5.1.normal.js index f3121d6fccb..3ccbb1431be 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2018_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2018_es5.1.normal.js @@ -2,64 +2,63 @@ // @lib: esnext // @filename: F1.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f1 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f1() { return _ref.apply(this, arguments); }; }(); // @filename: F2.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f2 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f2() { return _ref.apply(this, arguments); }; }(); // @filename: F3.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f3 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f3() { return _ref.apply(this, arguments); }; @@ -69,28 +68,24 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f4 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1 + ]), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f4() { return _ref.apply(this, arguments); }; @@ -100,41 +95,33 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f5 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f5() { return _ref.apply(this, arguments); }; @@ -142,41 +129,42 @@ var f5 = function() { // @filename: F6.ts import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f6 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f6() { return _ref.apply(this, arguments); }; }(); // @filename: F7.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f7 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); - }); + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f7() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2018_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2018_es5.2.minified.js index 3ff46ab6824..f905629020e 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2018_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2018_es5.2.minified.js @@ -1,23 +1,21 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5_es5.1.normal.js index b9d5f1534b2..8fce940960a 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5_es5.1.normal.js @@ -2,64 +2,63 @@ // @lib: esnext // @filename: F1.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f1 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f1() { return _ref.apply(this, arguments); }; }(); // @filename: F2.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f2 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f2() { return _ref.apply(this, arguments); }; }(); // @filename: F3.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f3 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f3() { return _ref.apply(this, arguments); }; @@ -69,28 +68,24 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f4 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1 + ]), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f4() { return _ref.apply(this, arguments); }; @@ -100,41 +95,33 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f5 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f5() { return _ref.apply(this, arguments); }; @@ -142,41 +129,42 @@ var f5 = function() { // @filename: F6.ts import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f6 = function() { - var _ref = _wrap_async_generator(function() { + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function f6() { return _ref.apply(this, arguments); }; }(); // @filename: F7.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var f7 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); - }); + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function f7() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5_es5.2.minified.js index 3ff46ab6824..f905629020e 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5_es5.2.minified.js @@ -1,23 +1,21 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2015_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2015_es5.1.normal.js index bbef5c3a326..f03662c98ae 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2015_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2015_es5.1.normal.js @@ -2,63 +2,62 @@ // @lib: esnext // @filename: O1.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o1 = { f: function f() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; // @filename: O2.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o2 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O3.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o3 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O4.ts @@ -66,29 +65,25 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o4 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1 + ]), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O5.ts @@ -96,81 +91,74 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o5 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O6.ts import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o6 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O7.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o7 = { f: function f() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2015_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2015_es5.2.minified.js index 3ff46ab6824..f905629020e 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2015_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2015_es5.2.minified.js @@ -1,23 +1,21 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2018_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2018_es5.1.normal.js index 8f5dd5f5e5b..5502658cd40 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2018_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2018_es5.1.normal.js @@ -2,63 +2,62 @@ // @lib: esnext // @filename: O1.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o1 = { f: function f() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; // @filename: O2.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o2 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O3.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o3 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O4.ts @@ -66,29 +65,25 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o4 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1 + ]), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O5.ts @@ -96,81 +91,74 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o5 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O6.ts import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o6 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O7.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o7 = { f: function f() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2018_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2018_es5.2.minified.js index 3ff46ab6824..f905629020e 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2018_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es2018_es5.2.minified.js @@ -1,23 +1,21 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es5_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es5_es5.1.normal.js index ae59cef5db7..043803d1177 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es5_es5.1.normal.js @@ -2,63 +2,62 @@ // @lib: esnext // @filename: O1.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o1 = { f: function f() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; // @filename: O2.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o2 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O3.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o3 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O4.ts @@ -66,29 +65,25 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o4 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1 + ]), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O5.ts @@ -96,81 +91,74 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o5 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O6.ts import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o6 = { f: function f() { - return _wrap_async_generator(function() { + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); } }; // @filename: O7.ts import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var o7 = { f: function f() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); - })(); + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }; diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es5_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es5_es5.2.minified.js index 3ff46ab6824..f905629020e 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.objectLiteralMethods.es5_es5.2.minified.js @@ -1,23 +1,21 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegate.mjs"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/emitter.forAwait_es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.forAwait_es5.1.normal.js index b406f971dab..52f8cf7d963 100644 --- a/crates/swc/tests/tsc-references/emitter.forAwait_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.forAwait_es5.1.normal.js @@ -3,500 +3,413 @@ // @filename: file1.ts import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f1() { return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: + ; _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 2; _iterator = _async_iterator(y); - _state.label = 2; - case 2: - return [ - 4, - _iterator.next() - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - x = _value; - _state.label = 4; case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 12 - ]; + _ctx.next = 6; + return _iterator.next(); case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; - case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; - case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; - case 10: - if (_didIteratorError) { - throw _iteratorError; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 11; + break; } - return [ - 7 - ]; + { + _value = _step.value; + x = _value; + } + case 8: + _iteratorAbruptCompletion = false; + _ctx.next = 4; + break; case 11: - return [ - 7 - ]; - case 12: - return [ - 2 - ]; + _ctx.next = 17; + break; + case 13: + _ctx.prev = 13; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 17: + _ctx.prev = 17; + _ctx.prev = 18; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 22; + break; + } + _ctx.next = 22; + return _iterator.return(); + case 22: + _ctx.prev = 22; + if (!_didIteratorError) { + _ctx.next = 25; + break; + } + throw _iteratorError; + case 25: + return _ctx.finish(22); + case 26: + return _ctx.finish(17); + case 27: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 2, + 13, + 17, + 27 + ], + [ + 18, + , + 22, + 26 + ] + ]); + })); return _f1.apply(this, arguments); } // @filename: file2.ts import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f2() { return _f2.apply(this, arguments); } function _f2() { - _f2 = _async_to_generator(function() { - var x, y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f2 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var x, y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: + ; _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 2; _iterator = _async_iterator(y); - _state.label = 2; - case 2: - return [ - 4, - _iterator.next() - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - x = _value; - _state.label = 4; case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 12 - ]; + _ctx.next = 6; + return _iterator.next(); case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; - case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; - case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; - case 10: - if (_didIteratorError) { - throw _iteratorError; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 11; + break; } - return [ - 7 - ]; + { + _value = _step.value; + x = _value; + } + case 8: + _iteratorAbruptCompletion = false; + _ctx.next = 4; + break; case 11: - return [ - 7 - ]; - case 12: - return [ - 2 - ]; + _ctx.next = 17; + break; + case 13: + _ctx.prev = 13; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 17: + _ctx.prev = 17; + _ctx.prev = 18; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 22; + break; + } + _ctx.next = 22; + return _iterator.return(); + case 22: + _ctx.prev = 22; + if (!_didIteratorError) { + _ctx.next = 25; + break; + } + throw _iteratorError; + case 25: + return _ctx.finish(22); + case 26: + return _ctx.finish(17); + case 27: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 2, + 13, + 17, + 27 + ], + [ + 18, + , + 22, + 26 + ] + ]); + })); return _f2.apply(this, arguments); } // @filename: file3.ts import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f3() { return _f3.apply(this, arguments); } function _f3() { - _f3 = _wrap_async_generator(function() { - var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f3 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: + ; _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 2; _iterator = _async_iterator(y); - _state.label = 2; - case 2: - return [ - 4, - _await_async_generator(_iterator.next()) - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - x = _value; - _state.label = 4; case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 12 - ]; + _ctx.next = 6; + return _await_async_generator(_iterator.next()); case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; - case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; - case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; - case 10: - if (_didIteratorError) { - throw _iteratorError; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 11; + break; } - return [ - 7 - ]; + { + _value = _step.value; + x = _value; + } + case 8: + _iteratorAbruptCompletion = false; + _ctx.next = 4; + break; case 11: - return [ - 7 - ]; - case 12: - return [ - 2 - ]; + _ctx.next = 17; + break; + case 13: + _ctx.prev = 13; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 17: + _ctx.prev = 17; + _ctx.prev = 18; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 22; + break; + } + _ctx.next = 22; + return _iterator.return(); + case 22: + _ctx.prev = 22; + if (!_didIteratorError) { + _ctx.next = 25; + break; + } + throw _iteratorError; + case 25: + return _ctx.finish(22); + case 26: + return _ctx.finish(17); + case 27: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 2, + 13, + 17, + 27 + ], + [ + 18, + , + 22, + 26 + ] + ]); + })); return _f3.apply(this, arguments); } // @filename: file4.ts import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f4() { return _f4.apply(this, arguments); } function _f4() { - _f4 = _wrap_async_generator(function() { - var x, y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f4 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var x, y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: + ; _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 2; _iterator = _async_iterator(y); - _state.label = 2; - case 2: - return [ - 4, - _await_async_generator(_iterator.next()) - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - x = _value; - _state.label = 4; case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 12 - ]; + _ctx.next = 6; + return _await_async_generator(_iterator.next()); case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; - case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; - case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; - case 10: - if (_didIteratorError) { - throw _iteratorError; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 11; + break; } - return [ - 7 - ]; + { + _value = _step.value; + x = _value; + } + case 8: + _iteratorAbruptCompletion = false; + _ctx.next = 4; + break; case 11: - return [ - 7 - ]; - case 12: - return [ - 2 - ]; + _ctx.next = 17; + break; + case 13: + _ctx.prev = 13; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 17: + _ctx.prev = 17; + _ctx.prev = 18; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 22; + break; + } + _ctx.next = 22; + return _iterator.return(); + case 22: + _ctx.prev = 22; + if (!_didIteratorError) { + _ctx.next = 25; + break; + } + throw _iteratorError; + case 25: + return _ctx.finish(22); + case 26: + return _ctx.finish(17); + case 27: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 2, + 13, + 17, + 27 + ], + [ + 18, + , + 22, + 26 + ] + ]); + })); return _f4.apply(this, arguments); } // @filename: file5.ts // https://github.com/Microsoft/TypeScript/issues/21363 import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f5() { return _f5.apply(this, arguments); } function _f5() { - _f5 = _async_to_generator(function() { - var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f5 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: + ; _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 2; _iterator = _async_iterator(y); - _state.label = 2; - case 2: - return [ - 4, - _iterator.next() - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; + case 4: + _ctx.next = 6; + return _iterator.next(); + case 6: + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 13; + break; + } _value = _step.value; x = _value; - continue outer; - _state.label = 4; - case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 12 - ]; - case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; - case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; - case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; + return _ctx.abrupt("continue", 29); case 10: - if (_didIteratorError) { - throw _iteratorError; + _iteratorAbruptCompletion = false; + _ctx.next = 4; + break; + case 13: + _ctx.next = 19; + break; + case 15: + _ctx.prev = 15; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 19: + _ctx.prev = 19; + _ctx.prev = 20; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 24; + break; } - return [ - 7 - ]; - case 11: - return [ - 7 - ]; - case 12: - return [ - 2 - ]; + _ctx.next = 24; + return _iterator.return(); + case 24: + _ctx.prev = 24; + if (!_didIteratorError) { + _ctx.next = 27; + break; + } + throw _iteratorError; + case 27: + return _ctx.finish(24); + case 28: + return _ctx.finish(19); + case 29: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 2, + 15, + 19, + 29 + ], + [ + 20, + , + 24, + 28 + ] + ]); + })); return _f5.apply(this, arguments); } // @filename: file6.ts @@ -504,101 +417,82 @@ function _f5() { import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f6() { return _f6.apply(this, arguments); } function _f6() { - _f6 = _wrap_async_generator(function() { - var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f6 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: + ; _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 2; _iterator = _async_iterator(y); - _state.label = 2; - case 2: - return [ - 4, - _await_async_generator(_iterator.next()) - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; + case 4: + _ctx.next = 6; + return _await_async_generator(_iterator.next()); + case 6: + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 13; + break; + } _value = _step.value; x = _value; - continue outer; - _state.label = 4; - case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 12 - ]; - case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; - case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; - case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; + return _ctx.abrupt("continue", 29); case 10: - if (_didIteratorError) { - throw _iteratorError; + _iteratorAbruptCompletion = false; + _ctx.next = 4; + break; + case 13: + _ctx.next = 19; + break; + case 15: + _ctx.prev = 15; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 19: + _ctx.prev = 19; + _ctx.prev = 20; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 24; + break; } - return [ - 7 - ]; - case 11: - return [ - 7 - ]; - case 12: - return [ - 2 - ]; + _ctx.next = 24; + return _iterator.return(); + case 24: + _ctx.prev = 24; + if (!_didIteratorError) { + _ctx.next = 27; + break; + } + throw _iteratorError; + case 27: + return _ctx.finish(24); + case 28: + return _ctx.finish(19); + case 29: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 2, + 15, + 19, + 29 + ], + [ + 20, + , + 24, + 28 + ] + ]); + })); return _f6.apply(this, arguments); } // @filename: file7.ts @@ -606,104 +500,86 @@ function _f6() { import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f7() { return _f7.apply(this, arguments); } function _f7() { - _f7 = _wrap_async_generator(function() { - var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f7 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; + ; case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _iteratorAbruptCompletion = false, _didIteratorError = false; + _ctx.prev = 2; _iterator = _async_iterator(y); - _state.label = 2; - case 2: - return [ - 4, - _await_async_generator(_iterator.next()) - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - x = _value; - _state.label = 4; case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 12 - ]; + _ctx.next = 6; + return _await_async_generator(_iterator.next()); case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; - case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; - case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; - case 10: - if (_didIteratorError) { - throw _iteratorError; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 11; + break; } - return [ - 7 - ]; + { + _value = _step.value; + x = _value; + } + case 8: + _iteratorAbruptCompletion = false; + _ctx.next = 4; + break; case 11: - return [ - 7 - ]; - case 12: - return [ - 3, - 0 - ]; + _ctx.next = 17; + break; case 13: - return [ - 2 - ]; + _ctx.prev = 13; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 17: + _ctx.prev = 17; + _ctx.prev = 18; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 22; + break; + } + _ctx.next = 22; + return _iterator.return(); + case 22: + _ctx.prev = 22; + if (!_didIteratorError) { + _ctx.next = 25; + break; + } + throw _iteratorError; + case 25: + return _ctx.finish(22); + case 26: + return _ctx.finish(17); + case 27: + _ctx.next = 1; + break; + case 29: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 2, + 13, + 17, + 27 + ], + [ + 18, + , + 22, + 26 + ] + ]); + })); return _f7.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/emitter.forAwait_es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.forAwait_es5.2.minified.js index f5885946212..ca2f9f6964c 100644 --- a/crates/swc/tests/tsc-references/emitter.forAwait_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.forAwait_es5.2.minified.js @@ -1,25 +1,25 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/errorOnFunctionReturnType_es5.1.normal.js b/crates/swc/tests/tsc-references/errorOnFunctionReturnType_es5.1.normal.js index c56bc462b5f..093dcd7908e 100644 --- a/crates/swc/tests/tsc-references/errorOnFunctionReturnType_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/errorOnFunctionReturnType_es5.1.normal.js @@ -6,7 +6,7 @@ * @callback FunctionReturningPromise * @returns {Promise} */ /** @type {FunctionReturningPromise} */ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function testPromise1() { console.log("Nope"); } @@ -14,14 +14,17 @@ function testPromise2() { return _testPromise2.apply(this, arguments); } function _testPromise2() { - _testPromise2 = /** @type {FunctionReturningPromise} */ _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - "asd" - ]; - }); - }); + _testPromise2 = /** @type {FunctionReturningPromise} */ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", "asd"); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _testPromise2.apply(this, arguments); } var testPromise3 = /** @type {FunctionReturningPromise} */ function testPromise3() { @@ -38,14 +41,17 @@ function testNever2() { return _testNever2.apply(this, arguments); } function _testNever2() { - _testNever2 = /** @type {FunctionReturningNever} */ _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - "asd" - ]; - }); - }); + _testNever2 = /** @type {FunctionReturningNever} */ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", "asd"); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _testNever2.apply(this, arguments); } var testNever3 = /** @type {FunctionReturningNever} */ function testNever3() { diff --git a/crates/swc/tests/tsc-references/errorOnFunctionReturnType_es5.2.minified.js b/crates/swc/tests/tsc-references/errorOnFunctionReturnType_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/errorOnFunctionReturnType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/errorOnFunctionReturnType_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorAssignability_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorAssignability_es5.1.normal.js index 05bfb9d072f..4587d8f0179 100644 --- a/crates/swc/tests/tsc-references/generatorAssignability_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorAssignability_es5.1.normal.js @@ -10,8 +10,8 @@ import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs"; import _to_array from "@swc/helpers/src/_to_array.mjs"; import _to_consumable_array from "@swc/helpers/src/_to_consumable_array.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(f1); // spread iterable _to_consumable_array(g1); // error _to_consumable_array(g2); // ok @@ -76,512 +76,392 @@ function asyncfn() { return _asyncfn.apply(this, arguments); } function _asyncfn() { - _asyncfn = _async_to_generator(function() { - var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, err, _iteratorAbruptCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value1, err1, _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, err2, _iteratorAbruptCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _value3, err3; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _asyncfn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, _iteratorAbruptCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value1, _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, _iteratorAbruptCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _value3; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 1; _iterator = _async_iterator(g1); - _state.label = 2; - case 2: - return [ - 4, - _iterator.next() - ]; case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - _ = _value; - _state.label = 4; - case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; + _ctx.next = 5; + return _iterator.next(); case 5: - return [ - 3, - 12 - ]; - case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 10; + break; + } + { + _value = _step.value; + _ = _value; + ; // error + } case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; - case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; + _iteratorAbruptCompletion = false; + _ctx.next = 3; + break; case 10: - if (_didIteratorError) { - throw _iteratorError; - } - return [ - 7 - ]; - case 11: - return [ - 7 - ]; + _ctx.next = 16; + break; case 12: - _iteratorAbruptCompletion1 = false, _didIteratorError1 = false; - _state.label = 13; - case 13: - _state.trys.push([ - 13, - 18, - 19, - 24 - ]); - _iterator1 = _async_iterator(g2); - _state.label = 14; - case 14: - return [ - 4, - _iterator1.next() - ]; - case 15: - if (!(_iteratorAbruptCompletion1 = !(_step1 = _state.sent()).done)) return [ - 3, - 17 - ]; - _value1 = _step1.value; - _ = _value1; - _state.label = 16; + _ctx.prev = 12; + _ctx.t0 = _ctx["catch"](1); + _didIteratorError = true; + _iteratorError = _ctx.t0; case 16: - _iteratorAbruptCompletion1 = false; - return [ - 3, - 14 - ]; - case 17: - return [ - 3, - 24 - ]; - case 18: - err1 = _state.sent(); - _didIteratorError1 = true; - _iteratorError1 = err1; - return [ - 3, - 24 - ]; - case 19: - _state.trys.push([ - 19, - , - 22, - 23 - ]); - if (!(_iteratorAbruptCompletion1 && _iterator1.return != null)) return [ - 3, - 21 - ]; - return [ - 4, - _iterator1.return() - ]; - case 20: - _state.sent(); - _state.label = 21; + _ctx.prev = 16; + _ctx.prev = 17; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 21; + break; + } + _ctx.next = 21; + return _iterator.return(); case 21: - return [ - 3, - 23 - ]; - case 22: - if (_didIteratorError1) { - throw _iteratorError1; + _ctx.prev = 21; + if (!_didIteratorError) { + _ctx.next = 24; + break; } - return [ - 7 - ]; - case 23: - return [ - 7 - ]; + throw _iteratorError; case 24: - _iteratorAbruptCompletion2 = false, _didIteratorError2 = false; - _state.label = 25; + return _ctx.finish(21); case 25: - _state.trys.push([ - 25, - 30, - 31, - 36 - ]); - _iterator2 = _async_iterator(g4); - _state.label = 26; + return _ctx.finish(16); case 26: - return [ - 4, - _iterator2.next() - ]; - case 27: - if (!(_iteratorAbruptCompletion2 = !(_step2 = _state.sent()).done)) return [ - 3, - 29 - ]; - _value2 = _step2.value; - _ = _value2; - _state.label = 28; - case 28: - _iteratorAbruptCompletion2 = false; - return [ - 3, - 26 - ]; + _iteratorAbruptCompletion1 = false, _didIteratorError1 = false; + _ctx.prev = 27; + _iterator1 = _async_iterator(g2); case 29: - return [ - 3, - 36 - ]; - case 30: - err2 = _state.sent(); - _didIteratorError2 = true; - _iteratorError2 = err2; - return [ - 3, - 36 - ]; + _ctx.next = 31; + return _iterator1.next(); case 31: - _state.trys.push([ - 31, - , - 34, - 35 - ]); - if (!(_iteratorAbruptCompletion2 && _iterator2.return != null)) return [ - 3, - 33 - ]; - return [ - 4, - _iterator2.return() - ]; - case 32: - _state.sent(); - _state.label = 33; + if (!(_iteratorAbruptCompletion1 = !(_step1 = _ctx.sent).done)) { + _ctx.next = 36; + break; + } + { + _value1 = _step1.value; + _ = _value1; + ; // ok + } case 33: - return [ - 3, - 35 - ]; - case 34: - if (_didIteratorError2) { - throw _iteratorError2; - } - return [ - 7 - ]; - case 35: - return [ - 7 - ]; + _iteratorAbruptCompletion1 = false; + _ctx.next = 29; + break; case 36: - _iteratorAbruptCompletion3 = false, _didIteratorError3 = false; - _state.label = 37; - case 37: - _state.trys.push([ - 37, - 42, - 43, - 48 - ]); - _iterator3 = _async_iterator(g5); - _state.label = 38; + _ctx.next = 42; + break; case 38: - return [ - 4, - _iterator3.next() - ]; - case 39: - if (!(_iteratorAbruptCompletion3 = !(_step3 = _state.sent()).done)) return [ - 3, - 41 - ]; - _value3 = _step3.value; - _ = _value3; - _state.label = 40; - case 40: - _iteratorAbruptCompletion3 = false; - return [ - 3, - 38 - ]; - case 41: - return [ - 3, - 48 - ]; + _ctx.prev = 38; + _ctx.t1 = _ctx["catch"](27); + _didIteratorError1 = true; + _iteratorError1 = _ctx.t1; case 42: - err3 = _state.sent(); - _didIteratorError3 = true; - _iteratorError3 = err3; - return [ - 3, - 48 - ]; - case 43: - _state.trys.push([ - 43, - , - 46, - 47 - ]); - if (!(_iteratorAbruptCompletion3 && _iterator3.return != null)) return [ - 3, - 45 - ]; - return [ - 4, - _iterator3.return() - ]; - case 44: - _state.sent(); - _state.label = 45; - case 45: - return [ - 3, - 47 - ]; - case 46: - if (_didIteratorError3) { - throw _iteratorError3; + _ctx.prev = 42; + _ctx.prev = 43; + if (!(_iteratorAbruptCompletion1 && _iterator1.return != null)) { + _ctx.next = 47; + break; } - return [ - 7 - ]; + _ctx.next = 47; + return _iterator1.return(); case 47: - return [ - 7 - ]; - case 48: - return [ - 2 - ]; + _ctx.prev = 47; + if (!_didIteratorError1) { + _ctx.next = 50; + break; + } + throw _iteratorError1; + case 50: + return _ctx.finish(47); + case 51: + return _ctx.finish(42); + case 52: + _iteratorAbruptCompletion2 = false, _didIteratorError2 = false; + _ctx.prev = 53; + _iterator2 = _async_iterator(g4); + case 55: + _ctx.next = 57; + return _iterator2.next(); + case 57: + if (!(_iteratorAbruptCompletion2 = !(_step2 = _ctx.sent).done)) { + _ctx.next = 62; + break; + } + { + _value2 = _step2.value; + _ = _value2; + ; // error + } + case 59: + _iteratorAbruptCompletion2 = false; + _ctx.next = 55; + break; + case 62: + _ctx.next = 68; + break; + case 64: + _ctx.prev = 64; + _ctx.t2 = _ctx["catch"](53); + _didIteratorError2 = true; + _iteratorError2 = _ctx.t2; + case 68: + _ctx.prev = 68; + _ctx.prev = 69; + if (!(_iteratorAbruptCompletion2 && _iterator2.return != null)) { + _ctx.next = 73; + break; + } + _ctx.next = 73; + return _iterator2.return(); + case 73: + _ctx.prev = 73; + if (!_didIteratorError2) { + _ctx.next = 76; + break; + } + throw _iteratorError2; + case 76: + return _ctx.finish(73); + case 77: + return _ctx.finish(68); + case 78: + _iteratorAbruptCompletion3 = false, _didIteratorError3 = false; + _ctx.prev = 79; + _iterator3 = _async_iterator(g5); + case 81: + _ctx.next = 83; + return _iterator3.next(); + case 83: + if (!(_iteratorAbruptCompletion3 = !(_step3 = _ctx.sent).done)) { + _ctx.next = 88; + break; + } + { + _value3 = _step3.value; + _ = _value3; + ; // ok + } + case 85: + _iteratorAbruptCompletion3 = false; + _ctx.next = 81; + break; + case 88: + _ctx.next = 94; + break; + case 90: + _ctx.prev = 90; + _ctx.t3 = _ctx["catch"](79); + _didIteratorError3 = true; + _iteratorError3 = _ctx.t3; + case 94: + _ctx.prev = 94; + _ctx.prev = 95; + if (!(_iteratorAbruptCompletion3 && _iterator3.return != null)) { + _ctx.next = 99; + break; + } + _ctx.next = 99; + return _iterator3.return(); + case 99: + _ctx.prev = 99; + if (!_didIteratorError3) { + _ctx.next = 102; + break; + } + throw _iteratorError3; + case 102: + return _ctx.finish(99); + case 103: + return _ctx.finish(94); + case 104: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 1, + 12, + 16, + 26 + ], + [ + 17, + , + 21, + 25 + ], + [ + 27, + 38, + 42, + 52 + ], + [ + 43, + , + 47, + 51 + ], + [ + 53, + 64, + 68, + 78 + ], + [ + 69, + , + 73, + 77 + ], + [ + 79, + 90, + 94, + 104 + ], + [ + 95, + , + 99, + 103 + ] + ]); + })); return _asyncfn.apply(this, arguments); } function f1() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function f1$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: // yield* over iterable - return [ - 5, - _ts_values(g1) - ]; + return _ctx.delegateYield(g1, "t0", 1); case 1: - _state.sent(); // error - return [ - 5, - _ts_values(g3) - ]; + return _ctx.delegateYield(g3, "t1", 2); case 2: - _state.sent(); // ok - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); + }, _marked); } function f2() { return _f2.apply(this, arguments); } function _f2() { - _f2 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f2 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: // yield* over iterable - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(g1), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(g1), _await_async_generator), "t0", 1); case 1: - _state.sent(); // error - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(g3), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(g3), _await_async_generator), "t1", 2); case 2: - _state.sent(); // ok // yield* over asynciterable - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(g4), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(g4), _await_async_generator), "t2", 3); case 3: - _state.sent(); // error - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(g6), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(g6), _await_async_generator), "t3", 4); case 4: - _state.sent(); // ok - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f2.apply(this, arguments); } function f3() { return _f3.apply(this, arguments); } function _f3() { - _f3 = _async_to_generator(function() { - var syncGenerator, o, _tmp, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f3 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var syncGenerator, o, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - syncGenerator = function syncGenerator() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + syncGenerator = /*#__PURE__*/ regeneratorRuntime.mark(function syncGenerator() { + return regeneratorRuntime.wrap(function syncGenerator$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 4, - 2 - ]; + _ctx.next = 2; + return 1; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return 2; + case 4: + case "end": + return _ctx.stop(); } - }); - }; - _tmp = {}; - o = _define_property(_tmp, Symbol.asyncIterator, syncGenerator); + }, syncGenerator); + }); + o = _define_property({}, Symbol.asyncIterator, syncGenerator); _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 3; _iterator = _async_iterator(o); - _state.label = 2; - case 2: - return [ - 4, - _iterator.next() - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - x = _value; - _state.label = 4; - case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; case 5: - return [ - 3, - 12 - ]; - case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; + _ctx.next = 7; + return _iterator.next(); case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; - case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; - case 10: - if (_didIteratorError) { - throw _iteratorError; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 12; + break; } - return [ - 7 - ]; - case 11: - return [ - 7 - ]; + { + _value = _step.value; + x = _value; + } + case 9: + _iteratorAbruptCompletion = false; + _ctx.next = 5; + break; case 12: - return [ - 2 - ]; + _ctx.next = 18; + break; + case 14: + _ctx.prev = 14; + _ctx.t0 = _ctx["catch"](3); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 18: + _ctx.prev = 18; + _ctx.prev = 19; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 23; + break; + } + _ctx.next = 23; + return _iterator.return(); + case 23: + _ctx.prev = 23; + if (!_didIteratorError) { + _ctx.next = 26; + break; + } + throw _iteratorError; + case 26: + return _ctx.finish(23); + case 27: + return _ctx.finish(18); + case 28: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 3, + 14, + 18, + 28 + ], + [ + 19, + , + 23, + 27 + ] + ]); + })); return _f3.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/generatorAssignability_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorAssignability_es5.2.minified.js index f791da7898c..19a97aa7d4d 100644 --- a/crates/swc/tests/tsc-references/generatorAssignability_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorAssignability_es5.2.minified.js @@ -7,8 +7,7 @@ import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs"; import _to_array from "@swc/helpers/src/_to_array.mjs"; import _to_consumable_array from "@swc/helpers/src/_to_consumable_array.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; _to_consumable_array(g1), _to_consumable_array(g2), _sliced_to_array(g1, 1)[0], _sliced_to_array(g2, 1)[0], _to_array(g1).slice(0), _to_array(g2).slice(0), _ = _sliced_to_array(g1, 1)[0], _ = _sliced_to_array(g2, 1)[0], _ = _to_array(g1).slice(0), _ = _to_array(g2).slice(0); var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0; try { diff --git a/crates/swc/tests/tsc-references/generatorExplicitReturnType_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorExplicitReturnType_es5.1.normal.js index fd57bb1c669..ef2b5231e0b 100644 --- a/crates/swc/tests/tsc-references/generatorExplicitReturnType_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorExplicitReturnType_es5.1.normal.js @@ -2,88 +2,76 @@ // @strictNullChecks: true // @noImplicitReturns: true // @noImplicitAny: true -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g4); +var _marked1 = /*#__PURE__*/ regeneratorRuntime.mark(g3); +var _marked2 = /*#__PURE__*/ regeneratorRuntime.mark(g2); +var _marked3 = /*#__PURE__*/ regeneratorRuntime.mark(g1); function g1() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g1$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); // error - return [ - 4, - "a" - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); // error - return [ - 4, - 1 - ]; - case 3: - x = _state.sent(); - return [ - 2, - 10 - ]; // error + _ctx.next = 4; + return "a"; + case 4: + _ctx.next = 6; + return 1; + case 6: + x = _ctx.sent; + return _ctx.abrupt("return", 10); + case 8: + case "end": + return _ctx.stop(); } - }); + }, _marked3); } function g2() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g2$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2, - true - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + return _ctx.abrupt("return", true); + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked2); } function g3() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g3$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(generator) - ]; + return _ctx.delegateYield(generator, "t0", 1); case 1: - x = _state.sent(); - return [ - 2, - true - ]; + x = _ctx.t0; + return _ctx.abrupt("return", true); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked1); } function g4() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g4$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(generator) - ]; + return _ctx.delegateYield(generator, "t0", 1); case 1: - x = _state.sent(); - return [ - 2, - true - ]; + x = _ctx.t0; + return _ctx.abrupt("return", true); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorExplicitReturnType_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorExplicitReturnType_es5.2.minified.js index 488ea2b0d50..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorExplicitReturnType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorExplicitReturnType_es5.2.minified.js @@ -1,2 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorImplicitAny_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorImplicitAny_es5.1.normal.js index 947a9fba637..6f0d9cbb05e 100644 --- a/crates/swc/tests/tsc-references/generatorImplicitAny_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorImplicitAny_es5.1.normal.js @@ -2,141 +2,130 @@ // @strictNullChecks: true // @noImplicitReturns: true // @noImplicitAny: true -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g6); +var _marked1 = /*#__PURE__*/ regeneratorRuntime.mark(g5); +var _marked2 = /*#__PURE__*/ regeneratorRuntime.mark(g4); +var _marked3 = /*#__PURE__*/ regeneratorRuntime.mark(g3); +var _marked4 = /*#__PURE__*/ regeneratorRuntime.mark(g2); +var _marked5 = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked5); } function g2() { var value; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g2$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - value = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + value = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked4); } function g3() { var value; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g3$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - value = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + value = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked3); } function g4() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g4$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); // ok, result is unused - return [ - 4 - ]; + _ctx.next = 2; + return; case 2: - _state.sent(), noop(); // ok, result is unused - noop(); - return [ - 4 - ]; - case 3: - _state.sent(), noop(); // ok, result is unused - return [ - 4 - ]; + _ctx.next = 4; + return; case 4: - _state.sent(); // ok, result is unused - return [ - 4 - ]; - case 5: - _state.sent(), noop(), noop(); // ok, result is unused - return [ - 4 - ]; - case 6: - _state.sent(); - _state.label = 7; - case 7: - if (!false) return [ - 3, - 10 - ]; - _state.label = 8; + noop(); + noop(); + _ctx.next = 8; + return; case 8: - return [ - 4 - ]; - case 9: - _state.sent(); - return [ - 3, - 7 - ]; - case 10: - return [ - 4 - ]; + noop(); + _ctx.next = 11; + return; case 11: - void _state.sent(); // ok, results are unused - return [ - 2 - ]; + _ctx.next = 13; + return; + case 13: + noop(); + noop(); + _ctx.next = 17; + return; + case 17: + if (!false) { + _ctx.next = 23; + break; + } + ; // ok, results are unused + case 19: + _ctx.next = 21; + return; + case 21: + _ctx.next = 17; + break; + case 23: + _ctx.next = 25; + return; + case 25: + void _ctx.sent; + case 26: + case "end": + return _ctx.stop(); } - }); + }, _marked2); } function g5() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g5$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - f.apply(void 0, [ - _state.sent() - ]); // error: implicit any - return [ - 2 - ]; + _ctx.t0 = f; + _ctx.next = 3; + return; + case 3: + _ctx.t1 = _ctx.sent; + (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); + }, _marked1); } function g6() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g6$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - f.apply(void 0, [ - _state.sent() - ]); // ok, contextually typed by f - return [ - 2 - ]; + _ctx.t0 = f; + _ctx.next = 3; + return; + case 3: + _ctx.t1 = _ctx.sent; + (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorImplicitAny_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorImplicitAny_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorImplicitAny_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorImplicitAny_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorInAmbientContext5_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorInAmbientContext5_es5.1.normal.js index 79065966b8e..036a046dcbe 100644 --- a/crates/swc/tests/tsc-references/generatorInAmbientContext5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorInAmbientContext5_es5.1.normal.js @@ -1,19 +1,21 @@ //@target: ES6 //@declaration: true import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { _class_call_check(this, C); } var _proto = C.prototype; - _proto.generator = function generator() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }; + _proto.generator = /*#__PURE__*/ regeneratorRuntime.mark(function generator() { + return regeneratorRuntime.wrap(function generator$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, generator); + }); return C; }(); diff --git a/crates/swc/tests/tsc-references/generatorInAmbientContext5_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorInAmbientContext5_es5.2.minified.js index e1e1ce181c9..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/generatorInAmbientContext5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorInAmbientContext5_es5.2.minified.js @@ -1,2 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorInAmbientContext6_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorInAmbientContext6_es5.1.normal.js index c9b5e833898..cddba06beae 100644 --- a/crates/swc/tests/tsc-references/generatorInAmbientContext6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorInAmbientContext6_es5.1.normal.js @@ -1,14 +1,16 @@ //@target: ES6 //@declaration: true -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var M; (function(M) { - var generator = function generator() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }; + var generator = /*#__PURE__*/ regeneratorRuntime.mark(function generator() { + return regeneratorRuntime.wrap(function generator$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, generator); + }); M.generator = generator; })(M || (M = {})); diff --git a/crates/swc/tests/tsc-references/generatorInAmbientContext6_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorInAmbientContext6_es5.2.minified.js index fea59e58459..e955b81ee98 100644 --- a/crates/swc/tests/tsc-references/generatorInAmbientContext6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorInAmbientContext6_es5.2.minified.js @@ -1,12 +1,14 @@ var M; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; !function(M) { - var generator = function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }; + var generator = regeneratorRuntime.mark(function() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, generator); + }); M.generator = generator; }(M || (M = {})); diff --git a/crates/swc/tests/tsc-references/generatorNoImplicitReturns_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorNoImplicitReturns_es5.1.normal.js index 01f3e034b8c..c4b4fa54d98 100644 --- a/crates/swc/tests/tsc-references/generatorNoImplicitReturns_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorNoImplicitReturns_es5.1.normal.js @@ -1,25 +1,23 @@ // @target: esnext // @noImplicitReturns: true // @strictNullChecks: false -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(testGenerator); function testGenerator() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function testGenerator$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - if (Math.random() > 0.5) { - return [ - 2 - ]; + if (!(Math.random() > 0.5)) { + _ctx.next = 2; + break; } - return [ - 4, - "hello" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + return _ctx.abrupt("return"); + case 2: + _ctx.next = 4; + return "hello"; + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorNoImplicitReturns_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorNoImplicitReturns_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorNoImplicitReturns_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorNoImplicitReturns_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorOverloads4_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorOverloads4_es5.1.normal.js index a074b650d55..e7ef9bba469 100644 --- a/crates/swc/tests/tsc-references/generatorOverloads4_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorOverloads4_es5.1.normal.js @@ -1,18 +1,20 @@ //@target: ES6 import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { _class_call_check(this, C); } var _proto = C.prototype; - _proto.f = function f(s) { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }; + _proto.f = /*#__PURE__*/ regeneratorRuntime.mark(function f(s) { + return regeneratorRuntime.wrap(function f$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, f); + }); return C; }(); diff --git a/crates/swc/tests/tsc-references/generatorOverloads4_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorOverloads4_es5.2.minified.js index e1e1ce181c9..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/generatorOverloads4_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorOverloads4_es5.2.minified.js @@ -1,2 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorOverloads5_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorOverloads5_es5.1.normal.js index 9d13e3562f4..cc248b45d94 100644 --- a/crates/swc/tests/tsc-references/generatorOverloads5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorOverloads5_es5.1.normal.js @@ -1,12 +1,14 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var M; (function(M) { - var f = function f(s) { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }; + var f = /*#__PURE__*/ regeneratorRuntime.mark(function f(s) { + return regeneratorRuntime.wrap(function f$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, f); + }); })(M || (M = {})); diff --git a/crates/swc/tests/tsc-references/generatorOverloads5_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorOverloads5_es5.2.minified.js index c5885a2c691..c10786e0894 100644 --- a/crates/swc/tests/tsc-references/generatorOverloads5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorOverloads5_es5.2.minified.js @@ -1,3 +1,3 @@ var M; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; M || (M = {}); diff --git a/crates/swc/tests/tsc-references/generatorReturnContextualType_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorReturnContextualType_es5.1.normal.js index d974b61b593..1fae8ac809d 100644 --- a/crates/swc/tests/tsc-references/generatorReturnContextualType_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorReturnContextualType_es5.1.normal.js @@ -2,63 +2,77 @@ // @strict: true // #35995 import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(f1); function f1() { - var _tmp; - return _ts_generator(this, function(_state) { - _tmp = {}; - return [ - 2, - (_tmp.x = "x", _tmp) - ]; - }); + return regeneratorRuntime.wrap(function f1$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", { + x: "x" + }); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked); } function f2() { return _f2.apply(this, arguments); } function _f2() { - _f2 = _wrap_async_generator(function() { - var _tmp; - return _ts_generator(this, function(_state) { - _tmp = {}; - return [ - 2, - (_tmp.x = "x", _tmp) - ]; - }); - }); + _f2 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", { + x: "x" + }); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f2.apply(this, arguments); } function f3() { return _f3.apply(this, arguments); } function _f3() { - _f3 = _wrap_async_generator(function() { - var _tmp; - return _ts_generator(this, function(_state) { - _tmp = {}; - return [ - 2, - Promise.resolve((_tmp.x = "x", _tmp)) - ]; - }); - }); + _f3 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", Promise.resolve({ + x: "x" + })); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f3.apply(this, arguments); } function f4() { return _f4.apply(this, arguments); } function _f4() { - _f4 = _wrap_async_generator(function() { - var ret, _tmp; - return _ts_generator(this, function(_state) { - _tmp = {}; - ret = (_tmp.x = "x", _tmp); - return [ - 2, - Promise.resolve(ret) - ]; // Error - }); - }); + _f4 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var ret; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ret = { + x: "x" + }; + return _ctx.abrupt("return", Promise.resolve(ret)); + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _f4.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/generatorReturnContextualType_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorReturnContextualType_es5.2.minified.js index 2c80eae8260..6d3ee447e76 100644 --- a/crates/swc/tests/tsc-references/generatorReturnContextualType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorReturnContextualType_es5.2.minified.js @@ -1,2 +1,2 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.1_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.1_es5.1.normal.js index 627853f2850..b6e57655c40 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.1_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.1_es5.1.normal.js @@ -3,20 +3,17 @@ // @noemit: true // @strict: true // Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(f); function f() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function f$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.1_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.1_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.1_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.1_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.2_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.2_es5.1.normal.js index 741a6f5aa97..527ee426cfd 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.2_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.2_es5.1.normal.js @@ -4,20 +4,17 @@ // @strict: true // Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. // Report an error if IterableIterator cannot be found. -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(f); function f() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function f$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.2_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.2_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.2_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.3_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.3_es5.1.normal.js index 067a51bd1f8..d835dbc5a27 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.3_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.3_es5.1.normal.js @@ -4,21 +4,20 @@ // @strict: true // Do not allow generators to fallback to IterableIterator while in strictNullChecks mode if they need a type for the sent value. // NOTE: In non-strictNullChecks mode, `undefined` (the default sent value) is assignable to everything. -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(f); function f() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function f$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.3_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.3_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.3_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.4_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.4_es5.1.normal.js index 8df69a4b092..f5f7ab4334f 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.4_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.4_es5.1.normal.js @@ -4,21 +4,20 @@ // @strict: false // Allow generators to fallback to IterableIterator if they are not in strictNullChecks mode // NOTE: In non-strictNullChecks mode, `undefined` (the default sent value) is assignable to everything. -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(f); function f() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function f$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.4_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.4_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.4_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.4_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.5_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.5_es5.1.normal.js index 627853f2850..b6e57655c40 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.5_es5.1.normal.js @@ -3,20 +3,17 @@ // @noemit: true // @strict: true // Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(f); function f() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function f$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.5_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.5_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeFallback.5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeFallback.5_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeIndirectReferenceToGlobalType_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorReturnTypeIndirectReferenceToGlobalType_es5.1.normal.js index a65e11a842c..5b9db9ca472 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeIndirectReferenceToGlobalType_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeIndirectReferenceToGlobalType_es5.1.normal.js @@ -1,21 +1,20 @@ // @strict: true // @target: esnext -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(f1); function f1() { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function f1$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 0 - ]; - case 1: - a = _state.sent(); - return [ - 2, - 1 - ]; + _ctx.next = 2; + return 0; + case 2: + a = _ctx.sent; + return _ctx.abrupt("return", 1); + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeIndirectReferenceToGlobalType_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorReturnTypeIndirectReferenceToGlobalType_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeIndirectReferenceToGlobalType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeIndirectReferenceToGlobalType_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeInferenceNonStrict_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorReturnTypeInferenceNonStrict_es5.1.normal.js index 403df2cbc66..38c12aa81b8 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeInferenceNonStrict_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeInferenceNonStrict_es5.1.normal.js @@ -3,461 +3,432 @@ // @noImplicitReturns: true // @noImplicitAny: true import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g311); +var _marked1 = /*#__PURE__*/ regeneratorRuntime.mark(g310); +var _marked2 = /*#__PURE__*/ regeneratorRuntime.mark(g309); +var _marked3 = /*#__PURE__*/ regeneratorRuntime.mark(g308); +var _marked4 = /*#__PURE__*/ regeneratorRuntime.mark(g307); +var _marked5 = /*#__PURE__*/ regeneratorRuntime.mark(g306); +var _marked6 = /*#__PURE__*/ regeneratorRuntime.mark(g305); +var _marked7 = /*#__PURE__*/ regeneratorRuntime.mark(g304); +var _marked8 = /*#__PURE__*/ regeneratorRuntime.mark(g303); +var _marked9 = /*#__PURE__*/ regeneratorRuntime.mark(g302); +var _marked10 = /*#__PURE__*/ regeneratorRuntime.mark(g301); +var _marked11 = /*#__PURE__*/ regeneratorRuntime.mark(g204); +var _marked12 = /*#__PURE__*/ regeneratorRuntime.mark(g203); +var _marked13 = /*#__PURE__*/ regeneratorRuntime.mark(g202); +var _marked14 = /*#__PURE__*/ regeneratorRuntime.mark(g201); +var _marked15 = /*#__PURE__*/ regeneratorRuntime.mark(g104); +var _marked16 = /*#__PURE__*/ regeneratorRuntime.mark(g103); +var _marked17 = /*#__PURE__*/ regeneratorRuntime.mark(g102); +var _marked18 = /*#__PURE__*/ regeneratorRuntime.mark(g007); +var _marked19 = /*#__PURE__*/ regeneratorRuntime.mark(g006); +var _marked20 = /*#__PURE__*/ regeneratorRuntime.mark(g005); +var _marked21 = /*#__PURE__*/ regeneratorRuntime.mark(g004); +var _marked22 = /*#__PURE__*/ regeneratorRuntime.mark(g003); +var _marked23 = /*#__PURE__*/ regeneratorRuntime.mark(g002); +var _marked24 = /*#__PURE__*/ regeneratorRuntime.mark(g001); +var _marked25 = /*#__PURE__*/ regeneratorRuntime.mark(g000); function g000() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g000$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked25); } // 'yield' iteration type inference function g001() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g001$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked24); } function g002() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g002$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked23); } function g003() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g003$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: // NOTE: In strict mode, `[]` produces the type `never[]`. // In non-strict mode, `[]` produces the type `undefined[]` which is implicitly any. - return [ - 5, - _ts_values([]) - ]; + return _ctx.delegateYield([], "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); + }, _marked22); } function g004() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g004$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(iterableIterator) - ]; + return _ctx.delegateYield(iterableIterator, "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); + }, _marked21); } function g005() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g005$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(generator) - ]; + return _ctx.delegateYield(generator, "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked20); } function g006() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g006$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 4, - 2 - ]; + _ctx.next = 2; + return 1; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return 2; + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked19); } function g007() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g007$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - never - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return never; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked18); } // 'return' iteration type inference function g102() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); + return regeneratorRuntime.wrap(function g102$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked17); } function g103() { - return _ts_generator(this, function(_state) { - if (Math.random()) return [ - 2, - 1 - ]; - return [ - 2, - 2 - ]; - }); + return regeneratorRuntime.wrap(function g103$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + if (!Math.random()) { + _ctx.next = 2; + break; + } + return _ctx.abrupt("return", 1); + case 2: + return _ctx.abrupt("return", 2); + case 3: + case "end": + return _ctx.stop(); + } + }, _marked16); } function g104() { - return _ts_generator(this, function(_state) { - return [ - 2, - never - ]; - }); + return regeneratorRuntime.wrap(function g104$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", never); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked15); } // 'next' iteration type inference function g201() { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g201$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - a = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + a = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked14); } function g202() { var a, b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g202$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - a = _state.sent(); - return [ - 4, - 2 - ]; + _ctx.next = 2; + return 1; case 2: - b = _state.sent(); - return [ - 2 - ]; + a = _ctx.sent; + _ctx.next = 5; + return 2; + case 5: + b = _ctx.sent; + case 6: + case "end": + return _ctx.stop(); } - }); + }, _marked13); } function g203() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g203$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = f1.apply(void 0, [ - _state.sent() - ]); - return [ - 2 - ]; + _ctx.t0 = f1; + _ctx.next = 3; + return 1; + case 3: + _ctx.t1 = _ctx.sent; + x = (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); + }, _marked12); } function g204() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g204$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = f2.apply(void 0, [ - _state.sent() - ]); - return [ - 2 - ]; + _ctx.t0 = f2; + _ctx.next = 3; + return 1; + case 3: + _ctx.t1 = _ctx.sent; + x = (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); + }, _marked11); } // mixed iteration types inference function g301() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g301$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + return _ctx.abrupt("return"); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked10); } function g302() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g302$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + return _ctx.abrupt("return"); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked9); } function g303() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g303$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 2, - "a" - ]; + _ctx.next = 2; + return; + case 2: + return _ctx.abrupt("return", "a"); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked8); } function g304() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g304$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2, - "a" - ]; + _ctx.next = 2; + return 1; + case 2: + return _ctx.abrupt("return", "a"); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked7); } function g305() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g305$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - if (!Math.random()) return [ - 3, - 2 - ]; - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - _state.label = 2; - case 2: - return [ - 4, - 2 - ]; + if (!Math.random()) { + _ctx.next = 3; + break; + } + _ctx.next = 3; + return 1; case 3: - _state.sent(); - if (Math.random()) return [ - 2, - "a" - ]; - return [ - 2, - "b" - ]; + _ctx.next = 5; + return 2; + case 5: + if (!Math.random()) { + _ctx.next = 7; + break; + } + return _ctx.abrupt("return", "a"); + case 7: + return _ctx.abrupt("return", "b"); + case 8: + case "end": + return _ctx.stop(); } - }); + }, _marked6); } function g306() { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g306$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - a = _state.sent(); - return [ - 2, - true - ]; + _ctx.next = 2; + return 1; + case 2: + a = _ctx.sent; + return _ctx.abrupt("return", true); + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked5); } function g307() { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g307$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 0 - ]; - case 1: - a = _state.sent(); - return [ - 2, - a - ]; + _ctx.next = 2; + return 0; + case 2: + a = _ctx.sent; + return _ctx.abrupt("return", a); + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked4); } function g308(x) { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g308$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - x - ]; - case 1: - a = _state.sent(); - return [ - 2, - a - ]; + _ctx.next = 2; + return x; + case 2: + a = _ctx.sent; + return _ctx.abrupt("return", a); + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked3); } function g309(x, y) { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g309$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - x - ]; - case 1: - a = _state.sent(); - return [ - 2, - y - ]; + _ctx.next = 2; + return x; + case 2: + a = _ctx.sent; + return _ctx.abrupt("return", y); + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked2); } function g310() { var ref, tmp, a, tmp1, b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g310$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - ref = _sliced_to_array.apply(void 0, [ - _state.sent(), - 2 - ]), tmp = ref[0], a = tmp === void 0 ? 1 : tmp, tmp1 = ref[1], b = tmp1 === void 0 ? 2 : tmp1; - return [ - 2 - ]; + _ctx.t0 = _sliced_to_array; + _ctx.next = 3; + return; + case 3: + _ctx.t1 = _ctx.sent; + ref = (0, _ctx.t0)(_ctx.t1, 2); + tmp = ref[0]; + a = tmp === void 0 ? 1 : tmp; + tmp1 = ref[1]; + b = tmp1 === void 0 ? 2 : tmp1; + case 9: + case "end": + return _ctx.stop(); } - }); + }, _marked1); } function g311() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g311$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(function() { - var y; - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4 - ]; - case 1: - y = _state.sent(); - return [ - 2 - ]; - } - }); - }()) - ]; + return _ctx.delegateYield(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var y; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return; + case 2: + y = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); + } + }, _callee); + })(), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeInferenceNonStrict_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorReturnTypeInferenceNonStrict_es5.2.minified.js index d91227ec728..60d47d962af 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeInferenceNonStrict_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeInferenceNonStrict_es5.2.minified.js @@ -1,3 +1,2 @@ import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeInference_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorReturnTypeInference_es5.1.normal.js index 6cff2d9cd59..6ec23fa203b 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeInference_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeInference_es5.1.normal.js @@ -3,459 +3,430 @@ // @noImplicitReturns: true // @noImplicitAny: true import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g311); +var _marked1 = /*#__PURE__*/ regeneratorRuntime.mark(g310); +var _marked2 = /*#__PURE__*/ regeneratorRuntime.mark(g309); +var _marked3 = /*#__PURE__*/ regeneratorRuntime.mark(g308); +var _marked4 = /*#__PURE__*/ regeneratorRuntime.mark(g307); +var _marked5 = /*#__PURE__*/ regeneratorRuntime.mark(g306); +var _marked6 = /*#__PURE__*/ regeneratorRuntime.mark(g305); +var _marked7 = /*#__PURE__*/ regeneratorRuntime.mark(g304); +var _marked8 = /*#__PURE__*/ regeneratorRuntime.mark(g303); +var _marked9 = /*#__PURE__*/ regeneratorRuntime.mark(g302); +var _marked10 = /*#__PURE__*/ regeneratorRuntime.mark(g301); +var _marked11 = /*#__PURE__*/ regeneratorRuntime.mark(g204); +var _marked12 = /*#__PURE__*/ regeneratorRuntime.mark(g203); +var _marked13 = /*#__PURE__*/ regeneratorRuntime.mark(g202); +var _marked14 = /*#__PURE__*/ regeneratorRuntime.mark(g201); +var _marked15 = /*#__PURE__*/ regeneratorRuntime.mark(g104); +var _marked16 = /*#__PURE__*/ regeneratorRuntime.mark(g103); +var _marked17 = /*#__PURE__*/ regeneratorRuntime.mark(g102); +var _marked18 = /*#__PURE__*/ regeneratorRuntime.mark(g007); +var _marked19 = /*#__PURE__*/ regeneratorRuntime.mark(g006); +var _marked20 = /*#__PURE__*/ regeneratorRuntime.mark(g005); +var _marked21 = /*#__PURE__*/ regeneratorRuntime.mark(g004); +var _marked22 = /*#__PURE__*/ regeneratorRuntime.mark(g003); +var _marked23 = /*#__PURE__*/ regeneratorRuntime.mark(g002); +var _marked24 = /*#__PURE__*/ regeneratorRuntime.mark(g001); +var _marked25 = /*#__PURE__*/ regeneratorRuntime.mark(g000); function g000() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g000$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked25); } // 'yield' iteration type inference function g001() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g001$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked24); } function g002() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g002$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked23); } function g003() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g003$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values([]) - ]; + return _ctx.delegateYield([], "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); + }, _marked22); } function g004() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g004$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(iterableIterator) - ]; + return _ctx.delegateYield(iterableIterator, "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); + }, _marked21); } function g005() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g005$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(generator) - ]; + return _ctx.delegateYield(generator, "t0", 1); case 1: - x = _state.sent(); - return [ - 2 - ]; + x = _ctx.t0; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked20); } function g006() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g006$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 4, - 2 - ]; + _ctx.next = 2; + return 1; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return 2; + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked19); } function g007() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g007$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - never - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return never; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked18); } // 'return' iteration type inference function g102() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); + return regeneratorRuntime.wrap(function g102$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked17); } function g103() { - return _ts_generator(this, function(_state) { - if (Math.random()) return [ - 2, - 1 - ]; - return [ - 2, - 2 - ]; - }); + return regeneratorRuntime.wrap(function g103$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + if (!Math.random()) { + _ctx.next = 2; + break; + } + return _ctx.abrupt("return", 1); + case 2: + return _ctx.abrupt("return", 2); + case 3: + case "end": + return _ctx.stop(); + } + }, _marked16); } function g104() { - return _ts_generator(this, function(_state) { - return [ - 2, - never - ]; - }); + return regeneratorRuntime.wrap(function g104$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", never); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked15); } // 'next' iteration type inference function g201() { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g201$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - a = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + a = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked14); } function g202() { var a, b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g202$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - a = _state.sent(); - return [ - 4, - 2 - ]; + _ctx.next = 2; + return 1; case 2: - b = _state.sent(); - return [ - 2 - ]; + a = _ctx.sent; + _ctx.next = 5; + return 2; + case 5: + b = _ctx.sent; + case 6: + case "end": + return _ctx.stop(); } - }); + }, _marked13); } function g203() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g203$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = f1.apply(void 0, [ - _state.sent() - ]); - return [ - 2 - ]; + _ctx.t0 = f1; + _ctx.next = 3; + return 1; + case 3: + _ctx.t1 = _ctx.sent; + x = (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); + }, _marked12); } function g204() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g204$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - x = f2.apply(void 0, [ - _state.sent() - ]); - return [ - 2 - ]; + _ctx.t0 = f2; + _ctx.next = 3; + return 1; + case 3: + _ctx.t1 = _ctx.sent; + x = (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); + }, _marked11); } // mixed iteration types inference function g301() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g301$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + return _ctx.abrupt("return"); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked10); } function g302() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g302$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + return _ctx.abrupt("return"); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked9); } function g303() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g303$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 2, - "a" - ]; + _ctx.next = 2; + return; + case 2: + return _ctx.abrupt("return", "a"); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked8); } function g304() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g304$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2, - "a" - ]; + _ctx.next = 2; + return 1; + case 2: + return _ctx.abrupt("return", "a"); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked7); } function g305() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g305$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - if (!Math.random()) return [ - 3, - 2 - ]; - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - _state.label = 2; - case 2: - return [ - 4, - 2 - ]; + if (!Math.random()) { + _ctx.next = 3; + break; + } + _ctx.next = 3; + return 1; case 3: - _state.sent(); - if (Math.random()) return [ - 2, - "a" - ]; - return [ - 2, - "b" - ]; + _ctx.next = 5; + return 2; + case 5: + if (!Math.random()) { + _ctx.next = 7; + break; + } + return _ctx.abrupt("return", "a"); + case 7: + return _ctx.abrupt("return", "b"); + case 8: + case "end": + return _ctx.stop(); } - }); + }, _marked6); } function g306() { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g306$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - a = _state.sent(); - return [ - 2, - true - ]; + _ctx.next = 2; + return 1; + case 2: + a = _ctx.sent; + return _ctx.abrupt("return", true); + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked5); } function g307() { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g307$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 0 - ]; - case 1: - a = _state.sent(); - return [ - 2, - a - ]; + _ctx.next = 2; + return 0; + case 2: + a = _ctx.sent; + return _ctx.abrupt("return", a); + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked4); } function g308(x) { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g308$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - x - ]; - case 1: - a = _state.sent(); - return [ - 2, - a - ]; + _ctx.next = 2; + return x; + case 2: + a = _ctx.sent; + return _ctx.abrupt("return", a); + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked3); } function g309(x, y) { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g309$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - x - ]; - case 1: - a = _state.sent(); - return [ - 2, - y - ]; + _ctx.next = 2; + return x; + case 2: + a = _ctx.sent; + return _ctx.abrupt("return", y); + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked2); } function g310() { var ref, tmp, a, tmp1, b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g310$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - ref = _sliced_to_array.apply(void 0, [ - _state.sent(), - 2 - ]), tmp = ref[0], a = tmp === void 0 ? 1 : tmp, tmp1 = ref[1], b = tmp1 === void 0 ? 2 : tmp1; - return [ - 2 - ]; + _ctx.t0 = _sliced_to_array; + _ctx.next = 3; + return; + case 3: + _ctx.t1 = _ctx.sent; + ref = (0, _ctx.t0)(_ctx.t1, 2); + tmp = ref[0]; + a = tmp === void 0 ? 1 : tmp; + tmp1 = ref[1]; + b = tmp1 === void 0 ? 2 : tmp1; + case 9: + case "end": + return _ctx.stop(); } - }); + }, _marked1); } function g311() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g311$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(function() { - var y; - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4 - ]; - case 1: - y = _state.sent(); - return [ - 2 - ]; - } - }); - }()) - ]; + return _ctx.delegateYield(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var y; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return; + case 2: + y = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); + } + }, _callee); + })(), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorReturnTypeInference_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorReturnTypeInference_es5.2.minified.js index d91227ec728..60d47d962af 100644 --- a/crates/swc/tests/tsc-references/generatorReturnTypeInference_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorReturnTypeInference_es5.2.minified.js @@ -1,3 +1,2 @@ import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck10_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck10_es5.1.normal.js index 2c65559562c..ef1dff20785 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck10_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck10_es5.1.normal.js @@ -1,9 +1,14 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return"); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck10_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck10_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck10_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck10_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck11_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck11_es5.1.normal.js index 9fe56216369..0898af3496c 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck11_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck11_es5.1.normal.js @@ -1,10 +1,14 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - return [ - 2, - 0 - ]; - }); + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 0); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck11_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck11_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck11_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck11_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck12_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck12_es5.1.normal.js index 6417efa4d25..9b80017a247 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck12_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck12_es5.1.normal.js @@ -1,10 +1,14 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - return [ - 2, - "" - ]; - }); + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", ""); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck12_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck12_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck12_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck12_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck13_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck13_es5.1.normal.js index 99053838458..105412a0f1c 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck13_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck13_es5.1.normal.js @@ -1,19 +1,17 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 0 - ]; - case 1: - _state.sent(); - return [ - 2, - "" - ]; + _ctx.next = 2; + return 0; + case 2: + return _ctx.abrupt("return", ""); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck13_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck13_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck13_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck13_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck14_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck14_es5.1.normal.js index 99053838458..105412a0f1c 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck14_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck14_es5.1.normal.js @@ -1,19 +1,17 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 0 - ]; - case 1: - _state.sent(); - return [ - 2, - "" - ]; + _ctx.next = 2; + return 0; + case 2: + return _ctx.abrupt("return", ""); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck14_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck14_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck14_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck14_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck15_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck15_es5.1.normal.js index 6417efa4d25..9b80017a247 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck15_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck15_es5.1.normal.js @@ -1,10 +1,14 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - return [ - 2, - "" - ]; - }); + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", ""); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck15_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck15_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck15_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck15_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck16_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck16_es5.1.normal.js index 2c65559562c..ef1dff20785 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck16_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck16_es5.1.normal.js @@ -1,9 +1,14 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return"); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck16_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck16_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck16_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck16_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck17_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck17_es5.1.normal.js index 949c4774e22..ddd9105aa92 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck17_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck17_es5.1.normal.js @@ -2,7 +2,8 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); var Foo = function Foo() { "use strict"; _class_call_check(this, Foo); @@ -18,23 +19,17 @@ var Bar = /*#__PURE__*/ function(Foo) { return Bar; }(Foo); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 4, - new Bar - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return new Bar; + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck17_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck17_es5.2.minified.js index e9e4ead7b21..e5bef2914be 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck17_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck17_es5.2.minified.js @@ -1,4 +1,4 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck18_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck18_es5.1.normal.js index eb1536d978a..dd6b9aedf37 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck18_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck18_es5.1.normal.js @@ -1,6 +1,7 @@ //@target: ES6 import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); var Foo = function Foo() { "use strict"; _class_call_check(this, Foo); @@ -10,23 +11,17 @@ var Baz = function Baz() { _class_call_check(this, Baz); }; function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 4, - new Baz - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return new Baz; + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck18_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck18_es5.2.minified.js index e1e1ce181c9..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck18_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck18_es5.2.minified.js @@ -1,2 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck19_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck19_es5.1.normal.js index f321ed6e154..8257ef78b04 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck19_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck19_es5.1.normal.js @@ -2,8 +2,8 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); var Foo = function Foo() { "use strict"; _class_call_check(this, Foo); @@ -19,25 +19,18 @@ var Bar = /*#__PURE__*/ function(Foo) { return Bar; }(Foo); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 5, - _ts_values([ - new Bar - ]) - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); - return [ - 2 - ]; + return _ctx.delegateYield([ + new Bar + ], "t0", 3); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck19_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck19_es5.2.minified.js index db46bfa80a5..e5bef2914be 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck19_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck19_es5.2.minified.js @@ -1,5 +1,4 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck1_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck1_es5.1.normal.js index 6654cec04eb..6b6cf1f0f80 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck1_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck1_es5.1.normal.js @@ -1,9 +1,12 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g1); function g1() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g1$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck1_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck1_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck1_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck1_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck20_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck20_es5.1.normal.js index a0aabe5bdc2..f8bc084a51e 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck20_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck20_es5.1.normal.js @@ -1,7 +1,7 @@ //@target: ES6 import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); var Foo = function Foo() { "use strict"; _class_call_check(this, Foo); @@ -11,25 +11,18 @@ var Baz = function Baz() { _class_call_check(this, Baz); }; function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 5, - _ts_values([ - new Baz - ]) - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); - return [ - 2 - ]; + return _ctx.delegateYield([ + new Baz + ], "t0", 3); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck20_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck20_es5.2.minified.js index 111c241cdaf..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck20_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck20_es5.2.minified.js @@ -1,3 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck21_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck21_es5.1.normal.js index 444ba45833d..e6aa512c708 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck21_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck21_es5.1.normal.js @@ -2,8 +2,8 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); var Foo = function Foo() { "use strict"; _class_call_check(this, Foo); @@ -19,23 +19,16 @@ var Bar = /*#__PURE__*/ function(Foo) { return Bar; }(Foo); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 5, - _ts_values(new Bar) - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); - return [ - 2 - ]; + return _ctx.delegateYield(new Bar, "t0", 3); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck21_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck21_es5.2.minified.js index db46bfa80a5..e5bef2914be 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck21_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck21_es5.2.minified.js @@ -1,5 +1,4 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck22_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck22_es5.1.normal.js index 93f62e401b2..e498b4d7a9a 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck22_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck22_es5.1.normal.js @@ -2,8 +2,8 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g3); var Foo = function Foo() { "use strict"; _class_call_check(this, Foo); @@ -23,45 +23,28 @@ var Baz = function Baz() { _class_call_check(this, Baz); }; function g3() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g3$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 4, - new Bar - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); - return [ - 4, - new Baz - ]; - case 3: - _state.sent(); - return [ - 5, - _ts_values([ - new Bar - ]) - ]; + _ctx.next = 4; + return new Bar; case 4: - _state.sent(); - return [ - 5, - _ts_values([ - new Baz - ]) - ]; - case 5: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 6; + return new Baz; + case 6: + return _ctx.delegateYield([ + new Bar + ], "t0", 7); + case 7: + return _ctx.delegateYield([ + new Baz + ], "t1", 8); + case 8: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck22_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck22_es5.2.minified.js index db46bfa80a5..e5bef2914be 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck22_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck22_es5.2.minified.js @@ -1,5 +1,4 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck23_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck23_es5.1.normal.js index ac5527b55f9..7234b93ee3c 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck23_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck23_es5.1.normal.js @@ -2,8 +2,8 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g3); var Foo = function Foo() { "use strict"; _class_call_check(this, Foo); @@ -23,51 +23,31 @@ var Baz = function Baz() { _class_call_check(this, Baz); }; function g3() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g3$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 4, - new Foo - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); - return [ - 4, - new Bar - ]; - case 3: - _state.sent(); - return [ - 4, - new Baz - ]; + _ctx.next = 4; + return new Foo; case 4: - _state.sent(); - return [ - 5, - _ts_values([ - new Bar - ]) - ]; - case 5: - _state.sent(); - return [ - 5, - _ts_values([ - new Baz - ]) - ]; + _ctx.next = 6; + return new Bar; case 6: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 8; + return new Baz; + case 8: + return _ctx.delegateYield([ + new Bar + ], "t0", 9); + case 9: + return _ctx.delegateYield([ + new Baz + ], "t1", 10); + case 10: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck23_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck23_es5.2.minified.js index db46bfa80a5..e5bef2914be 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck23_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck23_es5.2.minified.js @@ -1,5 +1,4 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck24_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck24_es5.1.normal.js index a11d6088f8b..08c10b5380a 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck24_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck24_es5.1.normal.js @@ -2,8 +2,8 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g3); var Foo = function Foo() { "use strict"; _class_call_check(this, Foo); @@ -23,53 +23,32 @@ var Baz = function Baz() { _class_call_check(this, Baz); }; function g3() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g3$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 5, - _ts_values([ - new Foo - ]) - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); - return [ - 4, - new Bar - ]; + return _ctx.delegateYield([ + new Foo + ], "t0", 3); case 3: - _state.sent(); - return [ - 4, - new Baz - ]; - case 4: - _state.sent(); - return [ - 5, - _ts_values([ - new Bar - ]) - ]; + _ctx.next = 5; + return new Bar; case 5: - _state.sent(); - return [ - 5, - _ts_values([ - new Baz - ]) - ]; - case 6: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 7; + return new Baz; + case 7: + return _ctx.delegateYield([ + new Bar + ], "t1", 8); + case 8: + return _ctx.delegateYield([ + new Baz + ], "t2", 9); + case 9: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck24_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck24_es5.2.minified.js index db46bfa80a5..e5bef2914be 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck24_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck24_es5.2.minified.js @@ -1,5 +1,4 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck25_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck25_es5.1.normal.js index 357c06d4347..2f9fc9614a4 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck25_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck25_es5.1.normal.js @@ -2,8 +2,7 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var Foo = function Foo() { "use strict"; _class_call_check(this, Foo); @@ -22,46 +21,29 @@ var Baz = function Baz() { "use strict"; _class_call_check(this, Baz); }; -var g3 = function g3() { - return _ts_generator(this, function(_state) { - switch(_state.label){ +var g3 = /*#__PURE__*/ regeneratorRuntime.mark(function g3() { + return regeneratorRuntime.wrap(function g3$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 4, - new Bar - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); - return [ - 4, - new Baz - ]; - case 3: - _state.sent(); - return [ - 5, - _ts_values([ - new Bar - ]) - ]; + _ctx.next = 4; + return new Bar; case 4: - _state.sent(); - return [ - 5, - _ts_values([ - new Baz - ]) - ]; - case 5: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 6; + return new Baz; + case 6: + return _ctx.delegateYield([ + new Bar + ], "t0", 7); + case 7: + return _ctx.delegateYield([ + new Baz + ], "t1", 8); + case 8: + case "end": + return _ctx.stop(); } - }); -}; + }, g3); +}); diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck25_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck25_es5.2.minified.js index db46bfa80a5..e5bef2914be 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck25_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck25_es5.2.minified.js @@ -1,5 +1,4 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck26_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck26_es5.1.normal.js index 9539ebfeffc..037c2b2f48c 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck26_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck26_es5.1.normal.js @@ -1,34 +1,27 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - function(x) { - return x.length; - } - ]; - case 1: - _state.sent(); - return [ - 5, - _ts_values([ - function(x) { - return x.length; - } - ]) - ]; + _ctx.next = 2; + return function(x) { + return x.length; + }; case 2: - _state.sent(); - return [ - 2, + return _ctx.delegateYield([ function(x) { return x.length; } - ]; + ], "t0", 3); + case 3: + return _ctx.abrupt("return", function(x) { + return x.length; + }); + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck26_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck26_es5.2.minified.js index 488ea2b0d50..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck26_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck26_es5.2.minified.js @@ -1,2 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck27_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck27_es5.1.normal.js index fb0547f9dbd..67dcb43a28c 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck27_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck27_es5.1.normal.js @@ -1,36 +1,27 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - function(x) { - return x.length; - } - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - }()) - ]; + return _ctx.delegateYield(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return function(x) { + return x.length; + }; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + })(), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck27_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck27_es5.2.minified.js index 488ea2b0d50..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck27_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck27_es5.2.minified.js @@ -1,2 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck28_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck28_es5.1.normal.js index 35ed93598d1..f5f58e42145 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck28_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck28_es5.1.normal.js @@ -1,39 +1,28 @@ //@target: ES6 import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - var _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp = {}; - return [ - 5, - _ts_values(_define_property(_tmp, Symbol.iterator, function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - function(x) { - return x.length; - } - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })) - ]; + return _ctx.delegateYield(_define_property({}, Symbol.iterator, /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return function(x) { + return x.length; + }; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + })), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck28_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck28_es5.2.minified.js index a46783bea5f..aac75dd6df5 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck28_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck28_es5.2.minified.js @@ -1,3 +1,2 @@ import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck29_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck29_es5.1.normal.js index 7a516093df2..db6233f7b8b 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck29_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck29_es5.1.normal.js @@ -1,35 +1,28 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g2); function g2() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g2$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - function(x) { - return x.length; - } - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - }() - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return function(x) { + return x.length; + }; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + })(); + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck29_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck29_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck29_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck29_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck2_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck2_es5.1.normal.js index 6654cec04eb..6b6cf1f0f80 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck2_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck2_es5.1.normal.js @@ -1,9 +1,12 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g1); function g1() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g1$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck2_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck2_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck2_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck30_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck30_es5.1.normal.js index 7a516093df2..db6233f7b8b 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck30_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck30_es5.1.normal.js @@ -1,35 +1,28 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g2); function g2() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g2$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - function(x) { - return x.length; - } - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - }() - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return function(x) { + return x.length; + }; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + })(); + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck30_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck30_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck30_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck30_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck31_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck31_es5.1.normal.js index 7a516093df2..db6233f7b8b 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck31_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck31_es5.1.normal.js @@ -1,35 +1,28 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g2); function g2() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g2$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - function(x) { - return x.length; - } - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - }() - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return function(x) { + return x.length; + }; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + })(); + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck31_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck31_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck31_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck31_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck33_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck33_es5.1.normal.js index 8f23bf1bb6d..2084d95c950 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck33_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck33_es5.1.normal.js @@ -1,35 +1,28 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { var g2; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - g2 = function g2() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + g2 = /*#__PURE__*/ regeneratorRuntime.mark(function g2() { + return regeneratorRuntime.wrap(function g2$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - "" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return ""; + case 2: + case "end": + return _ctx.stop(); } - }); - }; - return [ - 4, - 0 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + }, g2); + }); + _ctx.next = 3; + return 0; + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck33_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck33_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck33_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck33_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck34_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck34_es5.1.normal.js index abcef9e0b25..0958493cde9 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck34_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck34_es5.1.normal.js @@ -1,27 +1,27 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { var g2; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - g2 = function g2() { - return _ts_generator(this, function(_state) { - return [ - 2, - "" - ]; - }); - }; - return [ - 4, - 0 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + g2 = /*#__PURE__*/ regeneratorRuntime.mark(function g2() { + return regeneratorRuntime.wrap(function g2$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", ""); + case 1: + case "end": + return _ctx.stop(); + } + }, g2); + }); + _ctx.next = 3; + return 0; + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck34_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck34_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck34_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck34_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck35_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck35_es5.1.normal.js index f7072b8337d..6b7ca0b8066 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck35_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck35_es5.1.normal.js @@ -1,22 +1,19 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { var g2; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: g2 = function g2() { return ""; }; - return [ - 4, - 0 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 3; + return 0; + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck35_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck35_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck35_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck35_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck36_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck36_es5.1.normal.js index f8b34c02b1c..be9e74f7b2c 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck36_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck36_es5.1.normal.js @@ -1,23 +1,18 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 0 - ]; - case 1: - return [ - 4, - _state.sent() - ]; + _ctx.next = 2; + return 0; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return _ctx.sent; + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck36_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck36_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck36_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck36_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck37_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck37_es5.1.normal.js index fc708369851..3c4495521ab 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck37_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck37_es5.1.normal.js @@ -1,23 +1,20 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 0 - ]; - case 1: - return [ - 4, - _state.sent() - ]; + _ctx.next = 2; + return 0; case 2: - return [ - 2, - _state.sent() - ]; + _ctx.next = 4; + return _ctx.sent; + case 4: + return _ctx.abrupt("return", _ctx.sent); + case 5: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck37_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck37_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck37_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck37_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck3_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck3_es5.1.normal.js index 6654cec04eb..6b6cf1f0f80 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck3_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck3_es5.1.normal.js @@ -1,9 +1,12 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g1); function g1() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g1$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck3_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck3_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck3_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck40_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck40_es5.1.normal.js index b8ac2b4be77..d4aac45c76a 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck40_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck40_es5.1.normal.js @@ -2,13 +2,14 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { var C; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ = function(_superClass) { + _ctx.t0 = function(_superClass) { "use strict"; _inherits(C, _superClass); var _super = _create_super(C); @@ -18,17 +19,14 @@ function g() { } return C; }; - return [ - 4, - 0 - ]; - case 1: - C = /*#__PURE__*/ _.apply(void 0, [ - _state.sent() - ]); - return [ - 2 - ]; + _ctx.next = 3; + return 0; + case 3: + _ctx.t1 = _ctx.sent; + C = /*#__PURE__*/ (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck40_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck40_es5.2.minified.js index e9e4ead7b21..e5bef2914be 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck40_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck40_es5.2.minified.js @@ -1,4 +1,4 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck41_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck41_es5.1.normal.js index 8bbd0048e0b..dc805c5db32 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck41_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck41_es5.1.normal.js @@ -1,24 +1,22 @@ //@target: ES6 import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - var x, _tmp, _tmp1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + var x; + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp1 = {}; - _tmp = [ - _tmp1 - ]; - return [ - 4, - 0 - ]; - case 1: - x = _define_property.apply(void 0, _tmp.concat(_state.sent(), 0)); - return [ - 2 - ]; + _ctx.t0 = _define_property; + _ctx.t1 = {}; + _ctx.next = 4; + return 0; + case 4: + _ctx.t2 = _ctx.sent; + x = (0, _ctx.t0)(_ctx.t1, _ctx.t2, 0); + case 6: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck41_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck41_es5.2.minified.js index 5b0bb03ca6d..aac75dd6df5 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck41_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck41_es5.2.minified.js @@ -1,2 +1,2 @@ import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck42_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck42_es5.1.normal.js index 23f0971daa9..c83f00fd926 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck42_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck42_es5.1.normal.js @@ -1,24 +1,23 @@ //@target: ES6 import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - var x, _tmp, _tmp1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + var x; + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp1 = {}; - _tmp = [ - _tmp1 - ]; - return [ - 4, - 0 - ]; - case 1: - x = _define_property.apply(void 0, _tmp.concat(_state.sent(), function() {})); - return [ - 2 - ]; + _ctx.t0 = _define_property; + _ctx.t1 = {}; + _ctx.next = 4; + return 0; + case 4: + _ctx.t2 = _ctx.sent; + _ctx.t3 = function() {}; + x = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); + case 7: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck42_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck42_es5.2.minified.js index 5b0bb03ca6d..aac75dd6df5 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck42_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck42_es5.2.minified.js @@ -1,2 +1,2 @@ import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck43_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck43_es5.1.normal.js index 2fbba14962f..e98124413a7 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck43_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck43_es5.1.normal.js @@ -1,30 +1,31 @@ //@target: ES6 import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - var x, _tmp, _tmp1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + var x; + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp1 = {}; - _tmp = [ - _tmp1 - ]; - return [ - 4, - 0 - ]; - case 1: - x = _define_property.apply(void 0, _tmp.concat(_state.sent(), function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })); - return [ - 2 - ]; + _ctx.t0 = _define_property; + _ctx.t1 = {}; + _ctx.next = 4; + return 0; + case 4: + _ctx.t2 = _ctx.sent; + _ctx.t3 = /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }); + x = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); + case 7: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck43_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck43_es5.2.minified.js index 5b0bb03ca6d..aac75dd6df5 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck43_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck43_es5.2.minified.js @@ -1,2 +1,2 @@ import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck44_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck44_es5.1.normal.js index 1230cd0eb09..d4b0e62c90b 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck44_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck44_es5.1.normal.js @@ -1,33 +1,42 @@ //@target: ES6 import _define_enumerable_properties from "@swc/helpers/src/_define_enumerable_properties.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - var _obj, _mutatorMap, _tmp, x, _tmp1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _obj, _mutatorMap, x; + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp = {}; - _mutatorMap = _tmp; + _mutatorMap = {}; _obj = {}; - return [ - 4, - 0 - ]; - case 1: - _ = _state.sent(); - return [ - 4, - 0 - ]; - case 2: - _tmp1 = {}; - _mutatorMap[_] = _mutatorMap[_state.sent()] || _tmp1; - x = (_mutatorMap[yield 0].get = function() { + _ctx.next = 4; + return 0; + case 4: + _ctx.t0 = _ctx.sent; + _ctx.next = 7; + return 0; + case 7: + _ctx.t2 = _ctx.sent; + _ctx.t1 = _mutatorMap[_ctx.t2]; + if (_ctx.t1) { + _ctx.next = 11; + break; + } + _ctx.t1 = {}; + case 11: + _mutatorMap[_ctx.t0] = _ctx.t1; + _ctx.next = 14; + return 0; + case 14: + _ctx.t3 = _ctx.sent; + _mutatorMap[_ctx.t3].get = function() { return 0; - }, _define_enumerable_properties(_obj, _mutatorMap), _obj); - return [ - 2 - ]; + }; + _define_enumerable_properties(_obj, _mutatorMap); + x = (0, _obj); + case 18: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck44_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck44_es5.2.minified.js index 9864847e516..407a1e8c07d 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck44_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck44_es5.2.minified.js @@ -1,2 +1,2 @@ import _define_enumerable_properties from "@swc/helpers/src/_define_enumerable_properties.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck45_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck45_es5.1.normal.js index 28fd9416d09..816f2ec46cb 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck45_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck45_es5.1.normal.js @@ -1,22 +1,18 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -foo("", function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ +import regeneratorRuntime from "regenerator-runtime"; +foo("", /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - function(x) { - return x.length; - } - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return function(x) { + return x.length; + }; + case 2: + case "end": + return _ctx.stop(); } - }); -}, function(p) { + }, _callee); +}), function(p) { return undefined; }); // T is fixed, should be string diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck45_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck45_es5.2.minified.js index 5621e378783..add392a0ac4 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck45_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck45_es5.2.minified.js @@ -1,18 +1,14 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -foo("", function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ +import regeneratorRuntime from "regenerator-runtime"; +foo("", regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - function(x) { - return x.length; - } - ]; - case 1: - return _state.sent(), [ - 2 - ]; + return _ctx.next = 2, function(x) { + return x.length; + }; + case 2: + case "end": + return _ctx.stop(); } - }); -}, function(p) {}); + }, _callee); +}), function(p) {}); diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck46_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck46_es5.1.normal.js index 23f56f4412f..a1a234a798a 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck46_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck46_es5.1.normal.js @@ -1,41 +1,29 @@ //@target: ES6 import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; -foo("", function() { - var _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ +import regeneratorRuntime from "regenerator-runtime"; +foo("", /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp = {}; - return [ - 5, - _ts_values(_define_property(_tmp, Symbol.iterator, function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - function(x) { - return x.length; - } - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })) - ]; + return _ctx.delegateYield(_define_property({}, Symbol.iterator, /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return function(x) { + return x.length; + }; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + })), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); -}, function(p) { + }, _callee); +}), function(p) { return undefined; }); // T is fixed, should be string diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck46_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck46_es5.2.minified.js index 4c51162faa7..5a422ac8c64 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck46_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck46_es5.2.minified.js @@ -1,35 +1,25 @@ import _define_property from "@swc/helpers/src/_define_property.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; -foo("", function() { - var _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ +import regeneratorRuntime from "regenerator-runtime"; +foo("", regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_define_property(_tmp = {}, Symbol.iterator, function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - function(x) { - return x.length; - } - ]; - case 1: - return _state.sent(), [ - 2 - ]; - } - }); - })) - ]; + return _ctx.delegateYield(_define_property({}, Symbol.iterator, regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.next = 2, function(x) { + return x.length; + }; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + })), "t0", 1); case 1: - return _state.sent(), [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); -}, function(p) {}); + }, _callee); +}), function(p) {}); diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck47_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck47_es5.1.normal.js index cf0c6957497..62c13ab30c4 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck47_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck47_es5.1.normal.js @@ -1,10 +1,13 @@ //@target: ES6 //@noImplicitAny: true -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck47_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck47_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck47_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck47_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck48_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck48_es5.1.normal.js index 4bf226d3a7d..c8d25d08a59 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck48_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck48_es5.1.normal.js @@ -1,34 +1,29 @@ //@target: ES6 //@noImplicitAny: true -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(h); +var _marked1 = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked1); } function h() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function h$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - undefined - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return undefined; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck48_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck48_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck48_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck48_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck49_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck49_es5.1.normal.js index 96639391ad5..7053194ffeb 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck49_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck49_es5.1.normal.js @@ -1,19 +1,16 @@ //@target: ES6 //@noImplicitAny: true -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 0 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 0; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck49_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck49_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck49_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck49_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck4_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck4_es5.1.normal.js index 6654cec04eb..6b6cf1f0f80 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck4_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck4_es5.1.normal.js @@ -1,9 +1,12 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g1); function g1() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g1$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck4_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck4_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck4_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck4_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck50_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck50_es5.1.normal.js index c215b17bdf2..f33533e7fdd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck50_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck50_es5.1.normal.js @@ -1,23 +1,19 @@ //@target: ES6 //@noImplicitAny: true -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - return [ - 4, - _state.sent() - ]; + _ctx.next = 2; + return; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return _ctx.sent; + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck50_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck50_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck50_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck50_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck51_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck51_es5.1.normal.js index 13989f18115..70a65ad4d0d 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck51_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck51_es5.1.normal.js @@ -1,27 +1,27 @@ //@target: ES6 //@noImplicitAny: true -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { var h; - return _ts_generator(this, function(_state) { - h = function h() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 0 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - }; - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + h = /*#__PURE__*/ regeneratorRuntime.mark(function h() { + return regeneratorRuntime.wrap(function h$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 0; + case 2: + case "end": + return _ctx.stop(); + } + }, h); + }); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck51_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck51_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck51_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck51_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck52_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck52_es5.1.normal.js index 7945961e491..f7fc79a749a 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck52_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck52_es5.1.normal.js @@ -1,6 +1,7 @@ //@target: ES6 import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); var Foo = function Foo() { "use strict"; _class_call_check(this, Foo); @@ -10,24 +11,17 @@ var Baz = function Baz() { _class_call_check(this, Baz); }; function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - new Foo - ]; - case 1: - _state.sent(); - return [ - 4, - new Baz - ]; + _ctx.next = 2; + return new Foo; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return new Baz; + case 4: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck52_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck52_es5.2.minified.js index e1e1ce181c9..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck52_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck52_es5.2.minified.js @@ -1,2 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck53_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck53_es5.1.normal.js index cb13f163d2c..62acbef41bd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck53_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck53_es5.1.normal.js @@ -1,7 +1,7 @@ //@target: ES6 import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); var Foo = function Foo() { "use strict"; _class_call_check(this, Foo); @@ -11,26 +11,18 @@ var Baz = function Baz() { _class_call_check(this, Baz); }; function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - new Foo - ]; - case 1: - _state.sent(); - return [ - 5, - _ts_values([ - new Baz - ]) - ]; + _ctx.next = 2; + return new Foo; case 2: - _state.sent(); - return [ - 2 - ]; + return _ctx.delegateYield([ + new Baz + ], "t0", 3); + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck53_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck53_es5.2.minified.js index 111c241cdaf..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck53_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck53_es5.2.minified.js @@ -1,3 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck54_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck54_es5.1.normal.js index c3bbbe995fa..9b89380e0ed 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck54_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck54_es5.1.normal.js @@ -1,7 +1,7 @@ //@target: ES6 import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); var Foo = function Foo() { "use strict"; _class_call_check(this, Foo); @@ -11,28 +11,19 @@ var Baz = function Baz() { _class_call_check(this, Baz); }; function g() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values([ - new Foo - ]) - ]; + return _ctx.delegateYield([ + new Foo + ], "t0", 1); case 1: - _state.sent(); - return [ - 5, - _ts_values([ - new Baz - ]) - ]; + return _ctx.delegateYield([ + new Baz + ], "t1", 2); case 2: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck54_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck54_es5.2.minified.js index 111c241cdaf..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck54_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck54_es5.2.minified.js @@ -1,3 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck55_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck55_es5.1.normal.js index 99514309afc..e7425daaf65 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck55_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck55_es5.1.normal.js @@ -2,13 +2,14 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ = /*#__PURE__*/ function(_superClass) { + _ctx.t0 = /*#__PURE__*/ function(_superClass) { "use strict"; _inherits(C, _superClass); var _super = _create_super(C); @@ -18,16 +19,14 @@ function g() { } return C; }; - return [ - 4 - ]; - case 1: - x = _.apply(void 0, [ - _state.sent() - ]); - return [ - 2 - ]; + _ctx.next = 3; + return; + case 3: + _ctx.t1 = _ctx.sent; + x = (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck55_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck55_es5.2.minified.js index e9e4ead7b21..e5bef2914be 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck55_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck55_es5.2.minified.js @@ -1,4 +1,4 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck56_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck56_es5.1.normal.js index 9c7ea9f6964..87949c051b9 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck56_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck56_es5.1.normal.js @@ -1,35 +1,35 @@ //@target: ES6 import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { var x; - return _ts_generator(this, function(_state) { - x = /*#__PURE__*/ function() { - "use strict"; - function C() { - _class_call_check(this, C); - } - var _proto = C.prototype; - _proto[yield 0] = function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 0 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + x = /*#__PURE__*/ function() { + "use strict"; + function C() { + _class_call_check(this, C); } - }); - }; - return C; - }(); - return [ - 2 - ]; - }); + var _proto = C.prototype; + _proto[yield 0] = /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 0; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }); + return C; + }(); + case 1: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck56_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck56_es5.2.minified.js index e1e1ce181c9..8ec43e04e81 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck56_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck56_es5.2.minified.js @@ -1,2 +1,2 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck5_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck5_es5.1.normal.js index 6654cec04eb..6b6cf1f0f80 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck5_es5.1.normal.js @@ -1,9 +1,12 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g1); function g1() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g1$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck5_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck5_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck5_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck60_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck60_es5.1.normal.js index f8b7ca4b160..a3239aa312e 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck60_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck60_es5.1.normal.js @@ -2,13 +2,14 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { var C; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ = function(_superClass) { + _ctx.t0 = function(_superClass) { "use strict"; _inherits(C, _superClass); var _super = _create_super(C); @@ -18,16 +19,14 @@ function g() { } return C; }; - return [ - 4 - ]; - case 1: - C = /*#__PURE__*/ _.apply(void 0, [ - _state.sent() - ]); - return [ - 2 - ]; + _ctx.next = 3; + return; + case 3: + _ctx.t1 = _ctx.sent; + C = /*#__PURE__*/ (0, _ctx.t0)(_ctx.t1); + case 5: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck60_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck60_es5.2.minified.js index e9e4ead7b21..e5bef2914be 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck60_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck60_es5.2.minified.js @@ -1,4 +1,4 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck62_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck62_es5.1.normal.js index 460fe4a14f1..22acb417520 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck62_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck62_es5.1.normal.js @@ -1,117 +1,110 @@ // @module: commonjs // @target: es6 // @noImplicitAny: true -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function strategy(stratName, gen) { - return function(state) { - var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, next, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return /*#__PURE__*/ regeneratorRuntime.mark(function _callee(state) { + var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, next; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 8 - ]); + _ctx.prev = 1; _iterator = gen(state)[Symbol.iterator](); - _state.label = 2; - case 2: - if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [ - 3, - 5 - ]; + case 3: + if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { + _ctx.next = 11; + break; + } next = _step.value; if (next) { next.lastStrategyApplied = stratName; } - return [ - 4, - next - ]; - case 3: - _state.sent(); - _state.label = 4; - case 4: - _iteratorNormalCompletion = true; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 8 - ]; - case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 8 - ]; - case 7: - try { - if (!_iteratorNormalCompletion && _iterator.return != null) { - _iterator.return(); - } - } finally{ - if (_didIteratorError) { - throw _iteratorError; - } - } - return [ - 7 - ]; + _ctx.next = 8; + return next; case 8: - return [ - 2 - ]; + _iteratorNormalCompletion = true; + _ctx.next = 3; + break; + case 11: + _ctx.next = 17; + break; + case 13: + _ctx.prev = 13; + _ctx.t0 = _ctx["catch"](1); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 17: + _ctx.prev = 17; + _ctx.prev = 18; + if (!_iteratorNormalCompletion && _iterator.return != null) { + _iterator.return(); + } + case 20: + _ctx.prev = 20; + if (!_didIteratorError) { + _ctx.next = 23; + break; + } + throw _iteratorError; + case 23: + return _ctx.finish(20); + case 24: + return _ctx.finish(17); + case 25: + case "end": + return _ctx.stop(); } - }); - }; + }, _callee, null, [ + [ + 1, + 13, + 17, + 25 + ], + [ + 18, + , + 20, + 24 + ] + ]); + }); } -export var Nothing1 = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - return [ - 2, - state - ]; - }); -}); -export var Nothing2 = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - switch(_state.label){ +export var Nothing1 = strategy("Nothing", /*#__PURE__*/ regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - state - ]; + return _ctx.abrupt("return", state); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); -}); -export var Nothing3 = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - switch(_state.label){ + }, _callee); +})); +export var Nothing2 = strategy("Nothing", /*#__PURE__*/ regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 2, - state - ]; + _ctx.next = 2; + return state; + case 2: + case "end": + return _ctx.stop(); } - }); -}); + }, _callee); +})); +export var Nothing3 = strategy("Nothing", /*#__PURE__*/ regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return; + case 2: + return _ctx.abrupt("return", state); + case 3: + case "end": + return _ctx.stop(); + } + }, _callee); +})); diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck62_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck62_es5.2.minified.js index 3cc42b58c52..1a91083fd43 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck62_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck62_es5.2.minified.js @@ -1,96 +1,90 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function strategy(stratName, gen) { - return function(state) { - var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, next, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.mark(function _callee(state) { + var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, next; + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0, _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 8 - ]), _iterator = gen(state)[Symbol.iterator](), _state.label = 2; - case 2: - if (_iteratorNormalCompletion = (_step = _iterator.next()).done) return [ - 3, - 5 - ]; - return (next = _step.value) && (next.lastStrategyApplied = stratName), [ - 4, - next - ]; + _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0, _ctx.prev = 1, _iterator = gen(state)[Symbol.iterator](); case 3: - _state.sent(), _state.label = 4; - case 4: - return _iteratorNormalCompletion = !0, [ - 3, - 2 - ]; - case 5: - return [ - 3, - 8 - ]; - case 6: - return err = _state.sent(), _didIteratorError = !0, _iteratorError = err, [ - 3, - 8 - ]; - case 7: - try { - _iteratorNormalCompletion || null == _iterator.return || _iterator.return(); - } finally{ - if (_didIteratorError) throw _iteratorError; + if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { + _ctx.next = 11; + break; } - return [ - 7 - ]; + return (next = _step.value) && (next.lastStrategyApplied = stratName), _ctx.next = 8, next; case 8: - return [ - 2 - ]; + _iteratorNormalCompletion = !0, _ctx.next = 3; + break; + case 11: + _ctx.next = 17; + break; + case 13: + _ctx.prev = 13, _ctx.t0 = _ctx.catch(1), _didIteratorError = !0, _iteratorError = _ctx.t0; + case 17: + _ctx.prev = 17, _ctx.prev = 18, _iteratorNormalCompletion || null == _iterator.return || _iterator.return(); + case 20: + if (_ctx.prev = 20, !_didIteratorError) { + _ctx.next = 23; + break; + } + throw _iteratorError; + case 23: + return _ctx.finish(20); + case 24: + return _ctx.finish(17); + case 25: + case "end": + return _ctx.stop(); } - }); - }; + }, _callee, null, [ + [ + 1, + 13, + 17, + 25 + ], + [ + 18, + , + 20, + 24 + ] + ]); + }); } -export var Nothing1 = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - return [ - 2, - state - ]; - }); -}); -export var Nothing2 = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - switch(_state.label){ +export var Nothing1 = strategy("Nothing", regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - state - ]; + return _ctx.abrupt("return", state); case 1: - return _state.sent(), [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); -}); -export var Nothing3 = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - switch(_state.label){ + }, _callee); +})); +export var Nothing2 = strategy("Nothing", regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - return _state.sent(), [ - 2, - state - ]; + return _ctx.next = 2, state; + case 2: + case "end": + return _ctx.stop(); } - }); -}); + }, _callee); +})); +export var Nothing3 = strategy("Nothing", regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return; + case 2: + return _ctx.abrupt("return", state); + case 3: + case "end": + return _ctx.stop(); + } + }, _callee); +})); diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck63_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck63_es5.1.normal.js index 185195dad06..335d0cf8951 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck63_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck63_es5.1.normal.js @@ -1,126 +1,121 @@ // @module: commonjs // @target: es6 // @noImplicitAny: true -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function strategy(stratName, gen) { - return function(state) { - var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, next, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return /*#__PURE__*/ regeneratorRuntime.mark(function _callee(state) { + var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, next; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 8 - ]); + _ctx.prev = 1; _iterator = gen(state)[Symbol.iterator](); - _state.label = 2; - case 2: - if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [ - 3, - 5 - ]; + case 3: + if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { + _ctx.next = 11; + break; + } next = _step.value; if (next) { next.lastStrategyApplied = stratName; } - return [ - 4, - next - ]; - case 3: - _state.sent(); - _state.label = 4; - case 4: - _iteratorNormalCompletion = true; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 8 - ]; - case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 8 - ]; - case 7: - try { - if (!_iteratorNormalCompletion && _iterator.return != null) { - _iterator.return(); - } - } finally{ - if (_didIteratorError) { - throw _iteratorError; - } - } - return [ - 7 - ]; + _ctx.next = 8; + return next; case 8: - return [ - 2 - ]; + _iteratorNormalCompletion = true; + _ctx.next = 3; + break; + case 11: + _ctx.next = 17; + break; + case 13: + _ctx.prev = 13; + _ctx.t0 = _ctx["catch"](1); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 17: + _ctx.prev = 17; + _ctx.prev = 18; + if (!_iteratorNormalCompletion && _iterator.return != null) { + _iterator.return(); + } + case 20: + _ctx.prev = 20; + if (!_didIteratorError) { + _ctx.next = 23; + break; + } + throw _iteratorError; + case 23: + return _ctx.finish(20); + case 24: + return _ctx.finish(17); + case 25: + case "end": + return _ctx.stop(); } - }); - }; + }, _callee, null, [ + [ + 1, + 13, + 17, + 25 + ], + [ + 18, + , + 20, + 24 + ] + ]); + }); } -export var Nothing = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - switch(_state.label){ +export var Nothing = strategy("Nothing", /*#__PURE__*/ regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2, - state - ]; + _ctx.next = 2; + return 1; + case 2: + return _ctx.abrupt("return", state); + case 3: + case "end": + return _ctx.stop(); } - }); -}); -export var Nothing1 = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}); -export var Nothing2 = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); -}); -export var Nothing3 = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - switch(_state.label){ + }, _callee); +})); +export var Nothing1 = strategy("Nothing", /*#__PURE__*/ regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - state - ]; - case 1: - _state.sent(); - return [ - 2, - 1 - ]; + case "end": + return _ctx.stop(); } - }); -}); + }, _callee); +})); +export var Nothing2 = strategy("Nothing", /*#__PURE__*/ regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); +})); +export var Nothing3 = strategy("Nothing", /*#__PURE__*/ regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return state; + case 2: + return _ctx.abrupt("return", 1); + case 3: + case "end": + return _ctx.stop(); + } + }, _callee); +})); diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck63_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck63_es5.2.minified.js index d075e7e9cbd..6bfd6054b1a 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck63_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck63_es5.2.minified.js @@ -1,105 +1,100 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function strategy(stratName, gen) { - return function(state) { - var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, next, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.mark(function _callee(state) { + var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, next; + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0, _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 8 - ]), _iterator = gen(state)[Symbol.iterator](), _state.label = 2; - case 2: - if (_iteratorNormalCompletion = (_step = _iterator.next()).done) return [ - 3, - 5 - ]; - return (next = _step.value) && (next.lastStrategyApplied = stratName), [ - 4, - next - ]; + _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0, _ctx.prev = 1, _iterator = gen(state)[Symbol.iterator](); case 3: - _state.sent(), _state.label = 4; - case 4: - return _iteratorNormalCompletion = !0, [ - 3, - 2 - ]; - case 5: - return [ - 3, - 8 - ]; - case 6: - return err = _state.sent(), _didIteratorError = !0, _iteratorError = err, [ - 3, - 8 - ]; - case 7: - try { - _iteratorNormalCompletion || null == _iterator.return || _iterator.return(); - } finally{ - if (_didIteratorError) throw _iteratorError; + if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { + _ctx.next = 11; + break; } - return [ - 7 - ]; + return (next = _step.value) && (next.lastStrategyApplied = stratName), _ctx.next = 8, next; case 8: - return [ - 2 - ]; + _iteratorNormalCompletion = !0, _ctx.next = 3; + break; + case 11: + _ctx.next = 17; + break; + case 13: + _ctx.prev = 13, _ctx.t0 = _ctx.catch(1), _didIteratorError = !0, _iteratorError = _ctx.t0; + case 17: + _ctx.prev = 17, _ctx.prev = 18, _iteratorNormalCompletion || null == _iterator.return || _iterator.return(); + case 20: + if (_ctx.prev = 20, !_didIteratorError) { + _ctx.next = 23; + break; + } + throw _iteratorError; + case 23: + return _ctx.finish(20); + case 24: + return _ctx.finish(17); + case 25: + case "end": + return _ctx.stop(); } - }); - }; + }, _callee, null, [ + [ + 1, + 13, + 17, + 25 + ], + [ + 18, + , + 20, + 24 + ] + ]); + }); } -export var Nothing = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - switch(_state.label){ +export var Nothing = strategy("Nothing", regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - return _state.sent(), [ - 2, - state - ]; + return _ctx.next = 2, 1; + case 2: + return _ctx.abrupt("return", state); + case 3: + case "end": + return _ctx.stop(); } - }); -}); -export var Nothing1 = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}); -export var Nothing2 = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); -}); -export var Nothing3 = strategy("Nothing", function(state) { - return _ts_generator(this, function(_state) { - switch(_state.label){ + }, _callee); +})); +export var Nothing1 = strategy("Nothing", regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - state - ]; - case 1: - return _state.sent(), [ - 2, - 1 - ]; + case "end": + return _ctx.stop(); } - }); -}); + }, _callee); +})); +export var Nothing2 = strategy("Nothing", regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); +})); +export var Nothing3 = strategy("Nothing", regeneratorRuntime.mark(function _callee(state) { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.next = 2, state; + case 2: + return _ctx.abrupt("return", 1); + case 3: + case "end": + return _ctx.stop(); + } + }, _callee); +})); diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck6_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck6_es5.1.normal.js index 6654cec04eb..6b6cf1f0f80 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck6_es5.1.normal.js @@ -1,9 +1,12 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g1); function g1() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g1$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck6_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck7_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck7_es5.1.normal.js index 6654cec04eb..6b6cf1f0f80 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck7_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck7_es5.1.normal.js @@ -1,9 +1,12 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g1); function g1() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g1$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck7_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck7_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck7_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck7_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck8_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck8_es5.1.normal.js index 2a3ff743e20..ae6b10131cf 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck8_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck8_es5.1.normal.js @@ -1,9 +1,12 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g3); function g3() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g3$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck8_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck8_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck8_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck8_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck9_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorTypeCheck9_es5.1.normal.js index 2a3ff743e20..ae6b10131cf 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck9_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck9_es5.1.normal.js @@ -1,9 +1,12 @@ //@target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g3); function g3() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); + return regeneratorRuntime.wrap(function g3$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _marked); } diff --git a/crates/swc/tests/tsc-references/generatorTypeCheck9_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorTypeCheck9_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/generatorTypeCheck9_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorTypeCheck9_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/generatorYieldContextualType_es5.1.normal.js b/crates/swc/tests/tsc-references/generatorYieldContextualType_es5.1.normal.js index 053b97828da..965cf73a6ca 100644 --- a/crates/swc/tests/tsc-references/generatorYieldContextualType_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/generatorYieldContextualType_es5.1.normal.js @@ -2,40 +2,36 @@ // @strict: true // @noEmit: true import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -f1(function() { +import regeneratorRuntime from "regenerator-runtime"; +f1(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 0 - ]; - case 1: - a = _state.sent(); - return [ - 2, - 0 - ]; + _ctx.next = 2; + return 0; + case 2: + a = _ctx.sent; + return _ctx.abrupt("return", 0); + case 4: + case "end": + return _ctx.stop(); } - }); -}); -f2(/*#__PURE__*/ _wrap_async_generator(function() { - var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 0 - ]; - case 1: - a = _state.sent(); - return [ - 2, - 0 - ]; - } - }); + }, _callee); })); +f2(/*#__PURE__*/ _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var a; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 0; + case 2: + a = _ctx.sent; + return _ctx.abrupt("return", 0); + case 4: + case "end": + return _ctx.stop(); + } + }, _callee); +}))); diff --git a/crates/swc/tests/tsc-references/generatorYieldContextualType_es5.2.minified.js b/crates/swc/tests/tsc-references/generatorYieldContextualType_es5.2.minified.js index 5b00a66c3ed..9ef2a2b31db 100644 --- a/crates/swc/tests/tsc-references/generatorYieldContextualType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatorYieldContextualType_es5.2.minified.js @@ -1,35 +1,29 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -f1(function() { +import regeneratorRuntime from "regenerator-runtime"; +f1(regeneratorRuntime.mark(function _callee() { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 0 - ]; - case 1: - return a = _state.sent(), [ - 2, - 0 - ]; + return _ctx.next = 2, 0; + case 2: + return a = _ctx.sent, _ctx.abrupt("return", 0); + case 4: + case "end": + return _ctx.stop(); } - }); -}), f2(_wrap_async_generator(function() { + }, _callee); +})), f2(_wrap_async_generator(regeneratorRuntime.mark(function _callee() { var a; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 0 - ]; - case 1: - return a = _state.sent(), [ - 2, - 0 - ]; + return _ctx.next = 2, 0; + case 2: + return a = _ctx.sent, _ctx.abrupt("return", 0); + case 4: + case "end": + return _ctx.stop(); } - }); -})); + }, _callee); +}))); diff --git a/crates/swc/tests/tsc-references/importCallExpression3ES2020_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpression3ES2020_es5.1.normal.js index 6edb89d304e..0f7bb8095dd 100644 --- a/crates/swc/tests/tsc-references/importCallExpression3ES2020_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpression3ES2020_es5.1.normal.js @@ -18,17 +18,17 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var C, c; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ = function(_B) { + _ctx.t0 = function(_B) { "use strict"; _inherits(C, _B); var _super = _create_super(C); @@ -38,22 +38,19 @@ function _foo() { } return C; }; - return [ - 4, - import("./0") - ]; - case 1: - C = /*#__PURE__*/ _.apply(void 0, [ - _state.sent().B - ]); + _ctx.next = 3; + return import("./0"); + case 3: + _ctx.t1 = _ctx.sent.B; + C = /*#__PURE__*/ (0, _ctx.t0)(_ctx.t1); c = new C(); c.print(); - return [ - 2 - ]; + case 7: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } foo(); diff --git a/crates/swc/tests/tsc-references/importCallExpression3ES2020_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpression3ES2020_es5.2.minified.js index e28b9a802dc..27b17337335 100644 --- a/crates/swc/tests/tsc-references/importCallExpression3ES2020_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpression3ES2020_es5.2.minified.js @@ -12,14 +12,14 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function _foo() { - return (_foo = _async_to_generator(function() { + return (_foo = _async_to_generator(regeneratorRuntime.mark(function _callee() { var C, c; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return _ = function(_B) { + return _ctx.t0 = function(_B) { "use strict"; _inherits(C, _B); var _super = _create_super(C); @@ -27,19 +27,15 @@ function _foo() { return _class_call_check(this, C), _super.apply(this, arguments); } return C; - }, [ - 4, - import("./0") - ]; - case 1: - return (c = new (C = _.apply(void 0, [ - _state.sent().B - ]))()).print(), [ - 2 - ]; + }, _ctx.next = 3, import("./0"); + case 3: + _ctx.t1 = _ctx.sent.B, (c = new (C = (0, _ctx.t0)(_ctx.t1))()).print(); + case 7: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } !function() { return _foo.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/importCallExpression4ES2020_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpression4ES2020_es5.1.normal.js index 34996e780b9..d5ea21bd52e 100644 --- a/crates/swc/tests/tsc-references/importCallExpression4ES2020_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpression4ES2020_es5.1.normal.js @@ -24,7 +24,7 @@ export function backup() { // @filename: 2.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -37,25 +37,23 @@ var C = /*#__PURE__*/ function() { this.myModule.then(function(Zero) { console.log(Zero.foo()); }, function() { - var _ref = _async_to_generator(function(err) { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: console.log(err); - return [ - 4, - import("./1") - ]; - case 1: - one = _state.sent(); + _ctx.next = 3; + return import("./1"); + case 3: + one = _ctx.sent; console.log(one.backup()); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function(err) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpression4ES2020_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpression4ES2020_es5.2.minified.js index 903dc3f53cc..a90dfbedb8d 100644 --- a/crates/swc/tests/tsc-references/importCallExpression4ES2020_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpression4ES2020_es5.2.minified.js @@ -16,4 +16,4 @@ export function backup() { } import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES2020_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES2020_es5.1.normal.js index 9a1119295d7..9d6b1ece340 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES2020_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES2020_es5.1.normal.js @@ -3,28 +3,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -34,86 +33,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES2020_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES2020_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES2020_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES2020_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3AMD_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3AMD_es5.1.normal.js index 574a9e469a9..6ca3e5496c8 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3AMD_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3AMD_es5.1.normal.js @@ -4,28 +4,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -35,86 +34,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3AMD_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3AMD_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3AMD_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3AMD_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3CJS_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3CJS_es5.1.normal.js index 589d141a805..fea7f6f56cc 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3CJS_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3CJS_es5.1.normal.js @@ -4,28 +4,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -35,86 +34,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3CJS_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3CJS_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3CJS_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3CJS_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3System_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3System_es5.1.normal.js index e47b975a431..39d198a1423 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3System_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3System_es5.1.normal.js @@ -4,28 +4,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -35,86 +34,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3System_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3System_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3System_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3System_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3UMD_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3UMD_es5.1.normal.js index 8c27ca199bb..05a50730efb 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3UMD_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3UMD_es5.1.normal.js @@ -4,28 +4,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -35,86 +34,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3UMD_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3UMD_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3UMD_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3UMD_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5AMD_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5AMD_es5.1.normal.js index 4317a35ae22..0c753ee5b6d 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5AMD_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5AMD_es5.1.normal.js @@ -4,28 +4,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -35,86 +34,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5AMD_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5AMD_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5AMD_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5AMD_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS_es5.1.normal.js index 4e082d7949f..b1d6f650db0 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS_es5.1.normal.js @@ -4,28 +4,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -35,86 +34,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5System_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5System_es5.1.normal.js index bdd20c7bf01..fcc0e1a3bf7 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5System_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5System_es5.1.normal.js @@ -4,28 +4,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -35,86 +34,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5System_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5System_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5System_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5System_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5UMD_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5UMD_es5.1.normal.js index ac314ff3b49..86a68b6e155 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5UMD_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5UMD_es5.1.normal.js @@ -4,28 +4,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -35,86 +34,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5UMD_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5UMD_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5UMD_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5UMD_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6AMD_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6AMD_es5.1.normal.js index 07b0622241f..82f435e4502 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6AMD_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6AMD_es5.1.normal.js @@ -3,28 +3,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -34,86 +33,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6AMD_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6AMD_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6AMD_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6AMD_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS_es5.1.normal.js index 0f00e188138..68730563251 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS_es5.1.normal.js @@ -3,28 +3,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -34,86 +33,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6System_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6System_es5.1.normal.js index 7a538a6fb96..275d82a6ab3 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6System_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6System_es5.1.normal.js @@ -3,28 +3,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -34,86 +33,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6System_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6System_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6System_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6System_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6UMD_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6UMD_es5.1.normal.js index 5f59c9b6eae..536a8416a66 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6UMD_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6UMD_es5.1.normal.js @@ -3,28 +3,27 @@ // @filename: test.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - _fn = _async_to_generator(function() { + _fn = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // ONE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // ONE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _fn.apply(this, arguments); } export var cl1 = /*#__PURE__*/ function() { @@ -34,86 +33,82 @@ export var cl1 = /*#__PURE__*/ function() { } var _proto = cl1.prototype; _proto.m = function m() { - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // TWO - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // TWO + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return cl1; }(); export var obj = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // THREE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // THREE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function cl2() { "use strict"; _class_call_check(this, cl2); this.p = { - m: /*#__PURE__*/ _async_to_generator(function() { + m: /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FOUR - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FOUR + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") // FIVE - ]; - case 1: - req = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./test") // FIVE + ; + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function l() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6UMD_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6UMD_es5.2.minified.js index c219822f9b1..d7caac3b781 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6UMD_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6UMD_es5.2.minified.js @@ -1,105 +1,95 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export function fn() { return _fn.apply(this, arguments); } function _fn() { - return (_fn = _async_to_generator(function() { + return (_fn = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } export var cl1 = function() { "use strict"; function cl1() {} return cl1.prototype.m = function() { - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, cl1; }(); export var obj = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; export var cl2 = function() { "use strict"; this.p = { - m: _async_to_generator(function() { + m: _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }) + }, _callee); + })) }; }; export var l = function() { - var _ref = _async_to_generator(function() { + var _ref = _async_to_generator(regeneratorRuntime.mark(function _callee() { var req; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./test") - ]; - case 1: - return req = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./test"); + case 2: + req = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function() { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInAMD3_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInAMD3_es5.1.normal.js index 2f947441c0a..8d6622d5ee7 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInAMD3_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInAMD3_es5.1.normal.js @@ -18,17 +18,17 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var C, c; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ = function(_B) { + _ctx.t0 = function(_B) { "use strict"; _inherits(C, _B); var _super = _create_super(C); @@ -38,22 +38,19 @@ function _foo() { } return C; }; - return [ - 4, - import("./0") - ]; - case 1: - C = /*#__PURE__*/ _.apply(void 0, [ - _state.sent().B - ]); + _ctx.next = 3; + return import("./0"); + case 3: + _ctx.t1 = _ctx.sent.B; + C = /*#__PURE__*/ (0, _ctx.t0)(_ctx.t1); c = new C(); c.print(); - return [ - 2 - ]; + case 7: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } foo(); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInAMD3_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInAMD3_es5.2.minified.js index e28b9a802dc..27b17337335 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInAMD3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInAMD3_es5.2.minified.js @@ -12,14 +12,14 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function _foo() { - return (_foo = _async_to_generator(function() { + return (_foo = _async_to_generator(regeneratorRuntime.mark(function _callee() { var C, c; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return _ = function(_B) { + return _ctx.t0 = function(_B) { "use strict"; _inherits(C, _B); var _super = _create_super(C); @@ -27,19 +27,15 @@ function _foo() { return _class_call_check(this, C), _super.apply(this, arguments); } return C; - }, [ - 4, - import("./0") - ]; - case 1: - return (c = new (C = _.apply(void 0, [ - _state.sent().B - ]))()).print(), [ - 2 - ]; + }, _ctx.next = 3, import("./0"); + case 3: + _ctx.t1 = _ctx.sent.B, (c = new (C = (0, _ctx.t0)(_ctx.t1))()).print(); + case 7: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } !function() { return _foo.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInAMD4_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInAMD4_es5.1.normal.js index bccdf3e58b4..81c1c203e7d 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInAMD4_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInAMD4_es5.1.normal.js @@ -24,7 +24,7 @@ export function backup() { // @filename: 2.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -37,25 +37,23 @@ var C = /*#__PURE__*/ function() { this.myModule.then(function(Zero) { console.log(Zero.foo()); }, function() { - var _ref = _async_to_generator(function(err) { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: console.log(err); - return [ - 4, - import("./1") - ]; - case 1: - one = _state.sent(); + _ctx.next = 3; + return import("./1"); + case 3: + one = _ctx.sent; console.log(one.backup()); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function(err) { return _ref.apply(this, arguments); }; @@ -75,25 +73,23 @@ export var D = /*#__PURE__*/ function() { this.myModule.then(function(Zero) { console.log(Zero.foo()); }, function() { - var _ref = _async_to_generator(function(err) { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: console.log(err); - return [ - 4, - import("./1") - ]; - case 1: - one = _state.sent(); + _ctx.next = 3; + return import("./1"); + case 3: + one = _ctx.sent; console.log(one.backup()); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function(err) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInAMD4_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInAMD4_es5.2.minified.js index 2235fa4ad1e..b5c0ffc160b 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInAMD4_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInAMD4_es5.2.minified.js @@ -16,7 +16,7 @@ export function backup() { } import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export var D = function() { "use strict"; function D() { @@ -26,22 +26,20 @@ export var D = function() { var _ref; import("./0"), this.myModule.then(function(Zero) { console.log(Zero.foo()); - }, (_ref = _async_to_generator(function(err) { + }, (_ref = _async_to_generator(regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return console.log(err), [ - 4, - import("./1") - ]; - case 1: - return one = _state.sent(), console.log(one.backup()), [ - 2 - ]; + return console.log(err), _ctx.next = 3, import("./1"); + case 3: + one = _ctx.sent, console.log(one.backup()); + case 5: + case "end": + return _ctx.stop(); } - }); - }), function(err) { + }, _callee); + })), function(err) { return _ref.apply(this, arguments); })); }, D; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInCJS2_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInCJS2_es5.1.normal.js index 4be7ca5e2dc..e7e1a9b2675 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInCJS2_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInCJS2_es5.1.normal.js @@ -10,44 +10,37 @@ export function backup() { } // @filename: 2.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function compute(promise) { return _compute.apply(this, arguments); } function _compute() { - _compute = _async_to_generator(function(promise) { + _compute = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(promise) { var j; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - promise - ]; - case 1: - j = _state.sent(); - if (!!j) return [ - 3, - 3 - ]; - return [ - 4, - import("./1") - ]; + _ctx.next = 2; + return promise; case 2: - j = _state.sent(); - return [ - 2, - j.backup() - ]; - case 3: - return [ - 2, - j.foo() - ]; + j = _ctx.sent; + if (j) { + _ctx.next = 8; + break; + } + _ctx.next = 6; + return import("./1"); + case 6: + j = _ctx.sent; + return _ctx.abrupt("return", j.backup()); + case 8: + return _ctx.abrupt("return", j.foo()); + case 9: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _compute.apply(this, arguments); } compute(import("./0")); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInCJS2_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInCJS2_es5.2.minified.js index 1231d763bf8..9066ab713fe 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInCJS2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInCJS2_es5.2.minified.js @@ -5,39 +5,30 @@ export function backup() { return "backup"; } import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function _compute() { - return (_compute = _async_to_generator(function(promise) { + return (_compute = _async_to_generator(regeneratorRuntime.mark(function _callee(promise) { var j; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - promise - ]; - case 1: - if (j = _state.sent()) return [ - 3, - 3 - ]; - return [ - 4, - import("./1") - ]; + return _ctx.next = 2, promise; case 2: - return [ - 2, - (j = _state.sent()).backup() - ]; - case 3: - return [ - 2, - j.foo() - ]; + if (j = _ctx.sent) { + _ctx.next = 8; + break; + } + return _ctx.next = 6, import("./1"); + case 6: + return j = _ctx.sent, _ctx.abrupt("return", j.backup()); + case 8: + return _ctx.abrupt("return", j.foo()); + case 9: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } !function(promise) { return _compute.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInCJS4_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInCJS4_es5.1.normal.js index a37630c78bb..7c12b107f9c 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInCJS4_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInCJS4_es5.1.normal.js @@ -18,17 +18,17 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var C, c; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ = function(_B) { + _ctx.t0 = function(_B) { "use strict"; _inherits(C, _B); var _super = _create_super(C); @@ -38,22 +38,19 @@ function _foo() { } return C; }; - return [ - 4, - import("./0") - ]; - case 1: - C = /*#__PURE__*/ _.apply(void 0, [ - _state.sent().B - ]); + _ctx.next = 3; + return import("./0"); + case 3: + _ctx.t1 = _ctx.sent.B; + C = /*#__PURE__*/ (0, _ctx.t0)(_ctx.t1); c = new C(); c.print(); - return [ - 2 - ]; + case 7: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } foo(); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInCJS4_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInCJS4_es5.2.minified.js index e28b9a802dc..27b17337335 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInCJS4_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInCJS4_es5.2.minified.js @@ -12,14 +12,14 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function _foo() { - return (_foo = _async_to_generator(function() { + return (_foo = _async_to_generator(regeneratorRuntime.mark(function _callee() { var C, c; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return _ = function(_B) { + return _ctx.t0 = function(_B) { "use strict"; _inherits(C, _B); var _super = _create_super(C); @@ -27,19 +27,15 @@ function _foo() { return _class_call_check(this, C), _super.apply(this, arguments); } return C; - }, [ - 4, - import("./0") - ]; - case 1: - return (c = new (C = _.apply(void 0, [ - _state.sent().B - ]))()).print(), [ - 2 - ]; + }, _ctx.next = 3, import("./0"); + case 3: + _ctx.t1 = _ctx.sent.B, (c = new (C = (0, _ctx.t0)(_ctx.t1))()).print(); + case 7: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } !function() { return _foo.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInCJS5_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInCJS5_es5.1.normal.js index 7a648d13717..7ea5fe1f260 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInCJS5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInCJS5_es5.1.normal.js @@ -24,7 +24,7 @@ export function backup() { // @filename: 2.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -37,25 +37,23 @@ var C = /*#__PURE__*/ function() { this.myModule.then(function(Zero) { console.log(Zero.foo()); }, function() { - var _ref = _async_to_generator(function(err) { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: console.log(err); - return [ - 4, - import("./1") - ]; - case 1: - one = _state.sent(); + _ctx.next = 3; + return import("./1"); + case 3: + one = _ctx.sent; console.log(one.backup()); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function(err) { return _ref.apply(this, arguments); }; @@ -75,25 +73,23 @@ export var D = /*#__PURE__*/ function() { this.myModule.then(function(Zero) { console.log(Zero.foo()); }, function() { - var _ref = _async_to_generator(function(err) { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: console.log(err); - return [ - 4, - import("./1") - ]; - case 1: - one = _state.sent(); + _ctx.next = 3; + return import("./1"); + case 3: + one = _ctx.sent; console.log(one.backup()); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function(err) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInCJS5_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInCJS5_es5.2.minified.js index 2235fa4ad1e..b5c0ffc160b 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInCJS5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInCJS5_es5.2.minified.js @@ -16,7 +16,7 @@ export function backup() { } import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export var D = function() { "use strict"; function D() { @@ -26,22 +26,20 @@ export var D = function() { var _ref; import("./0"), this.myModule.then(function(Zero) { console.log(Zero.foo()); - }, (_ref = _async_to_generator(function(err) { + }, (_ref = _async_to_generator(regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return console.log(err), [ - 4, - import("./1") - ]; - case 1: - return one = _state.sent(), console.log(one.backup()), [ - 2 - ]; + return console.log(err), _ctx.next = 3, import("./1"); + case 3: + one = _ctx.sent, console.log(one.backup()); + case 5: + case "end": + return _ctx.stop(); } - }); - }), function(err) { + }, _callee); + })), function(err) { return _ref.apply(this, arguments); })); }, D; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsAMD_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsAMD_es5.1.normal.js index 3c64fc3c553..a38e5bdf5a8 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsAMD_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsAMD_es5.1.normal.js @@ -5,22 +5,20 @@ module.exports = 42; export { }; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -module.exports = /*#__PURE__*/ _async_to_generator(function() { +import regeneratorRuntime from "regenerator-runtime"; +module.exports = /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var something; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./something") - ]; - case 1: - something = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./something"); + case 2: + something = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); -}); + }, _callee); +})); export { }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsAMD_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsAMD_es5.2.minified.js index 628d399f11e..7655076e732 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsAMD_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsAMD_es5.2.minified.js @@ -1,20 +1,18 @@ module.exports = 42; export { }; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -module.exports = _async_to_generator(function() { +import regeneratorRuntime from "regenerator-runtime"; +module.exports = _async_to_generator(regeneratorRuntime.mark(function _callee() { var something; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./something") - ]; - case 1: - return something = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./something"); + case 2: + something = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); -}); + }, _callee); +})); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsCJS_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsCJS_es5.1.normal.js index 6127bb59f78..c521cd1d08d 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsCJS_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsCJS_es5.1.normal.js @@ -5,22 +5,20 @@ module.exports = 42; export { }; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -module.exports = /*#__PURE__*/ _async_to_generator(function() { +import regeneratorRuntime from "regenerator-runtime"; +module.exports = /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var something; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./something") - ]; - case 1: - something = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./something"); + case 2: + something = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); -}); + }, _callee); +})); export { }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsCJS_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsCJS_es5.2.minified.js index 628d399f11e..7655076e732 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsCJS_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsCJS_es5.2.minified.js @@ -1,20 +1,18 @@ module.exports = 42; export { }; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -module.exports = _async_to_generator(function() { +import regeneratorRuntime from "regenerator-runtime"; +module.exports = _async_to_generator(regeneratorRuntime.mark(function _callee() { var something; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./something") - ]; - case 1: - return something = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./something"); + case 2: + something = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); -}); + }, _callee); +})); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsUMD_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsUMD_es5.1.normal.js index b308562b87e..3d9a1c41edf 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsUMD_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsUMD_es5.1.normal.js @@ -5,22 +5,20 @@ module.exports = 42; export { }; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -module.exports = /*#__PURE__*/ _async_to_generator(function() { +import regeneratorRuntime from "regenerator-runtime"; +module.exports = /*#__PURE__*/ _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var something; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./something") - ]; - case 1: - something = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return import("./something"); + case 2: + something = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); -}); + }, _callee); +})); export { }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsUMD_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsUMD_es5.2.minified.js index 628d399f11e..7655076e732 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsUMD_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInExportEqualsUMD_es5.2.minified.js @@ -1,20 +1,18 @@ module.exports = 42; export { }; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -module.exports = _async_to_generator(function() { +import regeneratorRuntime from "regenerator-runtime"; +module.exports = _async_to_generator(regeneratorRuntime.mark(function _callee() { var something; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./something") - ]; - case 1: - return something = _state.sent(), [ - 2 - ]; + return _ctx.next = 2, import("./something"); + case 2: + something = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); -}); + }, _callee); +})); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInSystem3_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInSystem3_es5.1.normal.js index 7f02fd04d59..6e5f166c426 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInSystem3_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInSystem3_es5.1.normal.js @@ -18,17 +18,17 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var C, c; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ = function(_B) { + _ctx.t0 = function(_B) { "use strict"; _inherits(C, _B); var _super = _create_super(C); @@ -38,22 +38,19 @@ function _foo() { } return C; }; - return [ - 4, - import("./0") - ]; - case 1: - C = /*#__PURE__*/ _.apply(void 0, [ - _state.sent().B - ]); + _ctx.next = 3; + return import("./0"); + case 3: + _ctx.t1 = _ctx.sent.B; + C = /*#__PURE__*/ (0, _ctx.t0)(_ctx.t1); c = new C(); c.print(); - return [ - 2 - ]; + case 7: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } foo(); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInSystem3_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInSystem3_es5.2.minified.js index e28b9a802dc..27b17337335 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInSystem3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInSystem3_es5.2.minified.js @@ -12,14 +12,14 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function _foo() { - return (_foo = _async_to_generator(function() { + return (_foo = _async_to_generator(regeneratorRuntime.mark(function _callee() { var C, c; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return _ = function(_B) { + return _ctx.t0 = function(_B) { "use strict"; _inherits(C, _B); var _super = _create_super(C); @@ -27,19 +27,15 @@ function _foo() { return _class_call_check(this, C), _super.apply(this, arguments); } return C; - }, [ - 4, - import("./0") - ]; - case 1: - return (c = new (C = _.apply(void 0, [ - _state.sent().B - ]))()).print(), [ - 2 - ]; + }, _ctx.next = 3, import("./0"); + case 3: + _ctx.t1 = _ctx.sent.B, (c = new (C = (0, _ctx.t0)(_ctx.t1))()).print(); + case 7: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } !function() { return _foo.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInSystem4_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInSystem4_es5.1.normal.js index af3c8d10014..b608ea9201b 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInSystem4_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInSystem4_es5.1.normal.js @@ -24,7 +24,7 @@ export function backup() { // @filename: 2.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -37,25 +37,23 @@ var C = /*#__PURE__*/ function() { this.myModule.then(function(Zero) { console.log(Zero.foo()); }, function() { - var _ref = _async_to_generator(function(err) { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: console.log(err); - return [ - 4, - import("./1") - ]; - case 1: - one = _state.sent(); + _ctx.next = 3; + return import("./1"); + case 3: + one = _ctx.sent; console.log(one.backup()); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function(err) { return _ref.apply(this, arguments); }; @@ -75,25 +73,23 @@ export var D = /*#__PURE__*/ function() { this.myModule.then(function(Zero) { console.log(Zero.foo()); }, function() { - var _ref = _async_to_generator(function(err) { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: console.log(err); - return [ - 4, - import("./1") - ]; - case 1: - one = _state.sent(); + _ctx.next = 3; + return import("./1"); + case 3: + one = _ctx.sent; console.log(one.backup()); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function(err) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInSystem4_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInSystem4_es5.2.minified.js index 2235fa4ad1e..b5c0ffc160b 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInSystem4_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInSystem4_es5.2.minified.js @@ -16,7 +16,7 @@ export function backup() { } import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export var D = function() { "use strict"; function D() { @@ -26,22 +26,20 @@ export var D = function() { var _ref; import("./0"), this.myModule.then(function(Zero) { console.log(Zero.foo()); - }, (_ref = _async_to_generator(function(err) { + }, (_ref = _async_to_generator(regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return console.log(err), [ - 4, - import("./1") - ]; - case 1: - return one = _state.sent(), console.log(one.backup()), [ - 2 - ]; + return console.log(err), _ctx.next = 3, import("./1"); + case 3: + one = _ctx.sent, console.log(one.backup()); + case 5: + case "end": + return _ctx.stop(); } - }); - }), function(err) { + }, _callee); + })), function(err) { return _ref.apply(this, arguments); })); }, D; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInUMD3_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInUMD3_es5.1.normal.js index e13371cf122..1dcd6424e0a 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInUMD3_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInUMD3_es5.1.normal.js @@ -18,17 +18,17 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var C, c; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ = function(_B) { + _ctx.t0 = function(_B) { "use strict"; _inherits(C, _B); var _super = _create_super(C); @@ -38,22 +38,19 @@ function _foo() { } return C; }; - return [ - 4, - import("./0") - ]; - case 1: - C = /*#__PURE__*/ _.apply(void 0, [ - _state.sent().B - ]); + _ctx.next = 3; + return import("./0"); + case 3: + _ctx.t1 = _ctx.sent.B; + C = /*#__PURE__*/ (0, _ctx.t0)(_ctx.t1); c = new C(); c.print(); - return [ - 2 - ]; + case 7: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } foo(); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInUMD3_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInUMD3_es5.2.minified.js index e28b9a802dc..27b17337335 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInUMD3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInUMD3_es5.2.minified.js @@ -12,14 +12,14 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function _foo() { - return (_foo = _async_to_generator(function() { + return (_foo = _async_to_generator(regeneratorRuntime.mark(function _callee() { var C, c; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return _ = function(_B) { + return _ctx.t0 = function(_B) { "use strict"; _inherits(C, _B); var _super = _create_super(C); @@ -27,19 +27,15 @@ function _foo() { return _class_call_check(this, C), _super.apply(this, arguments); } return C; - }, [ - 4, - import("./0") - ]; - case 1: - return (c = new (C = _.apply(void 0, [ - _state.sent().B - ]))()).print(), [ - 2 - ]; + }, _ctx.next = 3, import("./0"); + case 3: + _ctx.t1 = _ctx.sent.B, (c = new (C = (0, _ctx.t0)(_ctx.t1))()).print(); + case 7: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } !function() { return _foo.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInUMD4_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInUMD4_es5.1.normal.js index 33ed0492910..1eada77e526 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInUMD4_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInUMD4_es5.1.normal.js @@ -24,7 +24,7 @@ export function backup() { // @filename: 2.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -37,25 +37,23 @@ var C = /*#__PURE__*/ function() { this.myModule.then(function(Zero) { console.log(Zero.foo()); }, function() { - var _ref = _async_to_generator(function(err) { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: console.log(err); - return [ - 4, - import("./1") - ]; - case 1: - one = _state.sent(); + _ctx.next = 3; + return import("./1"); + case 3: + one = _ctx.sent; console.log(one.backup()); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function(err) { return _ref.apply(this, arguments); }; @@ -75,25 +73,23 @@ export var D = /*#__PURE__*/ function() { this.myModule.then(function(Zero) { console.log(Zero.foo()); }, function() { - var _ref = _async_to_generator(function(err) { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: console.log(err); - return [ - 4, - import("./1") - ]; - case 1: - one = _state.sent(); + _ctx.next = 3; + return import("./1"); + case 3: + one = _ctx.sent; console.log(one.backup()); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function(err) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInUMD4_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInUMD4_es5.2.minified.js index 2235fa4ad1e..b5c0ffc160b 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInUMD4_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInUMD4_es5.2.minified.js @@ -16,7 +16,7 @@ export function backup() { } import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; export var D = function() { "use strict"; function D() { @@ -26,22 +26,20 @@ export var D = function() { var _ref; import("./0"), this.myModule.then(function(Zero) { console.log(Zero.foo()); - }, (_ref = _async_to_generator(function(err) { + }, (_ref = _async_to_generator(regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return console.log(err), [ - 4, - import("./1") - ]; - case 1: - return one = _state.sent(), console.log(one.backup()), [ - 2 - ]; + return console.log(err), _ctx.next = 3, import("./1"); + case 3: + one = _ctx.sent, console.log(one.backup()); + case 5: + case "end": + return _ctx.stop(); } - }); - }), function(err) { + }, _callee); + })), function(err) { return _ref.apply(this, arguments); })); }, D; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInUMD5_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInUMD5_es5.1.normal.js index 8689a36e617..673566358d2 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInUMD5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInUMD5_es5.1.normal.js @@ -7,28 +7,26 @@ export function foo() { // @filename: 1.ts // https://github.com/microsoft/TypeScript/issues/36780 import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function func() { return _func.apply(this, arguments); } function _func() { - _func = _async_to_generator(function() { + _func = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var packageName, packageJson; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: packageName = "."; - return [ - 4, - import(packageName + "/package.json") - ]; - case 1: - packageJson = _state.sent(); - return [ - 2 - ]; + _ctx.next = 3; + return import(packageName + "/package.json"); + case 3: + packageJson = _ctx.sent; + case 4: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _func.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionInUMD5_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionInUMD5_es5.2.minified.js index 8a8b1c0df07..7cfcc256f61 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInUMD5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInUMD5_es5.2.minified.js @@ -2,4 +2,4 @@ export function foo() { return "foo"; } import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedAMD2_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNestedAMD2_es5.1.normal.js index b2ce4af2544..db2560b7819 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedAMD2_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedAMD2_es5.1.normal.js @@ -6,31 +6,28 @@ export default "./foo"; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./foo") - ]; - case 1: - return [ - 4, - import(_state.sent().default) - ]; + _ctx.next = 2; + return import("./foo"); case 2: - return [ - 2, - _state.sent() - ]; + _ctx.t0 = _ctx.sent.default; + _ctx.next = 5; + return import(_ctx.t0); + case 5: + return _ctx.abrupt("return", _ctx.sent); + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedAMD2_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNestedAMD2_es5.2.minified.js index 74e3bd8104a..cf8ad2fce58 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedAMD2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedAMD2_es5.2.minified.js @@ -1,3 +1,3 @@ export default "./foo"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedAMD_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNestedAMD_es5.1.normal.js index 5a416a0d8ff..98eaf9dbd12 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedAMD_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedAMD_es5.1.normal.js @@ -6,31 +6,28 @@ export default "./foo"; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./foo") - ]; - case 1: - return [ - 4, - import(_state.sent().default) - ]; + _ctx.next = 2; + return import("./foo"); case 2: - return [ - 2, - _state.sent() - ]; + _ctx.t0 = _ctx.sent.default; + _ctx.next = 5; + return import(_ctx.t0); + case 5: + return _ctx.abrupt("return", _ctx.sent); + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedAMD_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNestedAMD_es5.2.minified.js index 74e3bd8104a..cf8ad2fce58 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedAMD_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedAMD_es5.2.minified.js @@ -1,3 +1,3 @@ export default "./foo"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedCJS2_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNestedCJS2_es5.1.normal.js index d4bd77808d5..41465ce3dc6 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedCJS2_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedCJS2_es5.1.normal.js @@ -6,31 +6,28 @@ export default "./foo"; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./foo") - ]; - case 1: - return [ - 4, - import(_state.sent().default) - ]; + _ctx.next = 2; + return import("./foo"); case 2: - return [ - 2, - _state.sent() - ]; + _ctx.t0 = _ctx.sent.default; + _ctx.next = 5; + return import(_ctx.t0); + case 5: + return _ctx.abrupt("return", _ctx.sent); + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedCJS2_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNestedCJS2_es5.2.minified.js index 74e3bd8104a..cf8ad2fce58 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedCJS2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedCJS2_es5.2.minified.js @@ -1,3 +1,3 @@ export default "./foo"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedCJS_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNestedCJS_es5.1.normal.js index 17eb3e999f9..4bc5ffbfaf1 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedCJS_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedCJS_es5.1.normal.js @@ -6,31 +6,28 @@ export default "./foo"; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./foo") - ]; - case 1: - return [ - 4, - import(_state.sent().default) - ]; + _ctx.next = 2; + return import("./foo"); case 2: - return [ - 2, - _state.sent() - ]; + _ctx.t0 = _ctx.sent.default; + _ctx.next = 5; + return import(_ctx.t0); + case 5: + return _ctx.abrupt("return", _ctx.sent); + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedCJS_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNestedCJS_es5.2.minified.js index 74e3bd8104a..cf8ad2fce58 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedCJS_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedCJS_es5.2.minified.js @@ -1,3 +1,3 @@ export default "./foo"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedES20152_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNestedES20152_es5.1.normal.js index 637c5b87829..d346662e024 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedES20152_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedES20152_es5.1.normal.js @@ -6,31 +6,28 @@ export default "./foo"; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./foo") - ]; - case 1: - return [ - 4, - import(_state.sent().default) - ]; + _ctx.next = 2; + return import("./foo"); case 2: - return [ - 2, - _state.sent() - ]; + _ctx.t0 = _ctx.sent.default; + _ctx.next = 5; + return import(_ctx.t0); + case 5: + return _ctx.abrupt("return", _ctx.sent); + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedES20152_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNestedES20152_es5.2.minified.js index 74e3bd8104a..cf8ad2fce58 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedES20152_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedES20152_es5.2.minified.js @@ -1,3 +1,3 @@ export default "./foo"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedES2015_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNestedES2015_es5.1.normal.js index 892027be167..0c23aaa03ab 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedES2015_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedES2015_es5.1.normal.js @@ -6,31 +6,28 @@ export default "./foo"; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./foo") - ]; - case 1: - return [ - 4, - import(_state.sent().default) - ]; + _ctx.next = 2; + return import("./foo"); case 2: - return [ - 2, - _state.sent() - ]; + _ctx.t0 = _ctx.sent.default; + _ctx.next = 5; + return import(_ctx.t0); + case 5: + return _ctx.abrupt("return", _ctx.sent); + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedES2015_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNestedES2015_es5.2.minified.js index 74e3bd8104a..cf8ad2fce58 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedES2015_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedES2015_es5.2.minified.js @@ -1,3 +1,3 @@ export default "./foo"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedES20202_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNestedES20202_es5.1.normal.js index 521d6bbc5ba..a54f186b018 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedES20202_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedES20202_es5.1.normal.js @@ -6,31 +6,28 @@ export default "./foo"; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./foo") - ]; - case 1: - return [ - 4, - import(_state.sent().default) - ]; + _ctx.next = 2; + return import("./foo"); case 2: - return [ - 2, - _state.sent() - ]; + _ctx.t0 = _ctx.sent.default; + _ctx.next = 5; + return import(_ctx.t0); + case 5: + return _ctx.abrupt("return", _ctx.sent); + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedES20202_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNestedES20202_es5.2.minified.js index 74e3bd8104a..cf8ad2fce58 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedES20202_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedES20202_es5.2.minified.js @@ -1,3 +1,3 @@ export default "./foo"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedES2020_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNestedES2020_es5.1.normal.js index e91c42a0ea1..d19dc52e654 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedES2020_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedES2020_es5.1.normal.js @@ -6,31 +6,28 @@ export default "./foo"; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./foo") - ]; - case 1: - return [ - 4, - import(_state.sent().default) - ]; + _ctx.next = 2; + return import("./foo"); case 2: - return [ - 2, - _state.sent() - ]; + _ctx.t0 = _ctx.sent.default; + _ctx.next = 5; + return import(_ctx.t0); + case 5: + return _ctx.abrupt("return", _ctx.sent); + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedES2020_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNestedES2020_es5.2.minified.js index 74e3bd8104a..cf8ad2fce58 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedES2020_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedES2020_es5.2.minified.js @@ -1,3 +1,3 @@ export default "./foo"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedSystem2_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNestedSystem2_es5.1.normal.js index 08ea4f8b51f..37cad87a2ac 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedSystem2_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedSystem2_es5.1.normal.js @@ -6,31 +6,28 @@ export default "./foo"; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./foo") - ]; - case 1: - return [ - 4, - import(_state.sent().default) - ]; + _ctx.next = 2; + return import("./foo"); case 2: - return [ - 2, - _state.sent() - ]; + _ctx.t0 = _ctx.sent.default; + _ctx.next = 5; + return import(_ctx.t0); + case 5: + return _ctx.abrupt("return", _ctx.sent); + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedSystem2_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNestedSystem2_es5.2.minified.js index 74e3bd8104a..cf8ad2fce58 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedSystem2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedSystem2_es5.2.minified.js @@ -1,3 +1,3 @@ export default "./foo"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedSystem_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNestedSystem_es5.1.normal.js index 79c7fb387f5..207415b798c 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedSystem_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedSystem_es5.1.normal.js @@ -6,31 +6,28 @@ export default "./foo"; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./foo") - ]; - case 1: - return [ - 4, - import(_state.sent().default) - ]; + _ctx.next = 2; + return import("./foo"); case 2: - return [ - 2, - _state.sent() - ]; + _ctx.t0 = _ctx.sent.default; + _ctx.next = 5; + return import(_ctx.t0); + case 5: + return _ctx.abrupt("return", _ctx.sent); + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedSystem_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNestedSystem_es5.2.minified.js index 74e3bd8104a..cf8ad2fce58 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedSystem_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedSystem_es5.2.minified.js @@ -1,3 +1,3 @@ export default "./foo"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedUMD2_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNestedUMD2_es5.1.normal.js index ac0109503c4..9cf71c99cf4 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedUMD2_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedUMD2_es5.1.normal.js @@ -6,31 +6,28 @@ export default "./foo"; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./foo") - ]; - case 1: - return [ - 4, - import(_state.sent().default) - ]; + _ctx.next = 2; + return import("./foo"); case 2: - return [ - 2, - _state.sent() - ]; + _ctx.t0 = _ctx.sent.default; + _ctx.next = 5; + return import(_ctx.t0); + case 5: + return _ctx.abrupt("return", _ctx.sent); + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedUMD2_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNestedUMD2_es5.2.minified.js index 74e3bd8104a..cf8ad2fce58 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedUMD2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedUMD2_es5.2.minified.js @@ -1,3 +1,3 @@ export default "./foo"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedUMD_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNestedUMD_es5.1.normal.js index 1a7467a3ee1..483354521c4 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedUMD_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedUMD_es5.1.normal.js @@ -6,31 +6,28 @@ export default "./foo"; // @filename: index.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function foo() { return _foo.apply(this, arguments); } function _foo() { - _foo = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _foo = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - import("./foo") - ]; - case 1: - return [ - 4, - import(_state.sent().default) - ]; + _ctx.next = 2; + return import("./foo"); case 2: - return [ - 2, - _state.sent() - ]; + _ctx.t0 = _ctx.sent.default; + _ctx.next = 5; + return import(_ctx.t0); + case 5: + return _ctx.abrupt("return", _ctx.sent); + case 6: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _foo.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionNestedUMD_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNestedUMD_es5.2.minified.js index 74e3bd8104a..cf8ad2fce58 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNestedUMD_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNestedUMD_es5.2.minified.js @@ -1,3 +1,3 @@ export default "./foo"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNoModuleKindSpecified_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNoModuleKindSpecified_es5.1.normal.js index 3a8007c1b44..ea5d167df96 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNoModuleKindSpecified_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNoModuleKindSpecified_es5.1.normal.js @@ -22,7 +22,7 @@ export function backup() { // @filename: 2.ts import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var C = /*#__PURE__*/ function() { "use strict"; function C() { @@ -35,25 +35,23 @@ var C = /*#__PURE__*/ function() { this.myModule.then(function(Zero) { console.log(Zero.foo()); }, function() { - var _ref = _async_to_generator(function(err) { + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(err) { var one; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: console.log(err); - return [ - 4, - import("./1") - ]; - case 1: - one = _state.sent(); + _ctx.next = 3; + return import("./1"); + case 3: + one = _ctx.sent; console.log(one.backup()); - return [ - 2 - ]; + case 5: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function(err) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNoModuleKindSpecified_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionNoModuleKindSpecified_es5.2.minified.js index 903dc3f53cc..a90dfbedb8d 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNoModuleKindSpecified_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNoModuleKindSpecified_es5.2.minified.js @@ -16,4 +16,4 @@ export function backup() { } import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/importCallExpressionReturnPromiseOfAny_es5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionReturnPromiseOfAny_es5.1.normal.js index fc1b8fa1cca..45edb7d57c2 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionReturnPromiseOfAny_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionReturnPromiseOfAny_es5.1.normal.js @@ -8,9 +8,10 @@ export var C = function C() { _class_call_check(this, C); }; // @filename: 1.ts +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(loadModule); import("".concat(directory, "\\").concat(moduleFile)); import(getSpecifier()); -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; var p1 = import(ValidSomeCondition() ? "./0" : "externalModule"); var p1 = import(getSpecifier()); var p11 = import(getSpecifier()); @@ -21,72 +22,71 @@ p1.then(function(zero) { var j; var p3 = import(j = getSpecifier()); function loadModule(directories) { - var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _$directory, path, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _$directory, path; + return regeneratorRuntime.wrap(function loadModule$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 8 - ]); + _ctx.prev = 1; _iterator = directories[Symbol.iterator](); - _state.label = 2; - case 2: - if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [ - 3, - 5 - ]; + case 3: + if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { + _ctx.next = 13; + break; + } _$directory = _step.value; path = "".concat(_$directory, "\\moduleFile"); - return [ - 4, - path - ]; - case 3: - import(_state.sent()); - _state.label = 4; - case 4: - _iteratorNormalCompletion = true; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 8 - ]; - case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 8 - ]; - case 7: - try { - if (!_iteratorNormalCompletion && _iterator.return != null) { - _iterator.return(); - } - } finally{ - if (_didIteratorError) { - throw _iteratorError; - } - } - return [ - 7 - ]; + _ctx.next = 8; + return path; case 8: - return [ - 2 - ]; + _ctx.t0 = _ctx.sent; + import(_ctx.t0); + case 10: + _iteratorNormalCompletion = true; + _ctx.next = 3; + break; + case 13: + _ctx.next = 19; + break; + case 15: + _ctx.prev = 15; + _ctx.t1 = _ctx["catch"](1); + _didIteratorError = true; + _iteratorError = _ctx.t1; + case 19: + _ctx.prev = 19; + _ctx.prev = 20; + if (!_iteratorNormalCompletion && _iterator.return != null) { + _iterator.return(); + } + case 22: + _ctx.prev = 22; + if (!_didIteratorError) { + _ctx.next = 25; + break; + } + throw _iteratorError; + case 25: + return _ctx.finish(22); + case 26: + return _ctx.finish(19); + case 27: + case "end": + return _ctx.stop(); } - }); + }, _marked, null, [ + [ + 1, + 15, + 19, + 27 + ], + [ + 20, + , + 22, + 26 + ] + ]); } export { }; diff --git a/crates/swc/tests/tsc-references/importCallExpressionReturnPromiseOfAny_es5.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionReturnPromiseOfAny_es5.2.minified.js index b72eaa505b5..625dd315946 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionReturnPromiseOfAny_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionReturnPromiseOfAny_es5.2.minified.js @@ -3,8 +3,8 @@ export var C = function C() { "use strict"; _class_call_check(this, C); }; +import regeneratorRuntime from "regenerator-runtime"; import("".concat(directory, "\\").concat(moduleFile)), import(getSpecifier()); -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; var p1 = (import(ValidSomeCondition() ? "./0" : "externalModule"), import(getSpecifier())); import(getSpecifier()), import(whatToLoad ? getSpecifier() : "defaulPath"), p1.then(function(zero) { return zero.foo(); diff --git a/crates/swc/tests/tsc-references/jsDeclarationsClassAccessor_es5.1.normal.js b/crates/swc/tests/tsc-references/jsDeclarationsClassAccessor_es5.1.normal.js index b5da698278c..71a9d879e43 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsClassAccessor_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsClassAccessor_es5.1.normal.js @@ -28,7 +28,7 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _create_class from "@swc/helpers/src/_create_class.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import { Base } from "./base.js"; export var Argument = /*#__PURE__*/ function(Base) { "use strict"; @@ -41,13 +41,15 @@ export var Argument = /*#__PURE__*/ function(Base) { var _proto = Argument.prototype; /** * @param {*} defs - */ _proto.validate = function validate(defs) { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }; + */ _proto.validate = /*#__PURE__*/ regeneratorRuntime.mark(function validate(defs) { + return regeneratorRuntime.wrap(function validate$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, validate); + }); /** * @param {*} tokeniser */ Argument.parse = function parse(tokeniser) { diff --git a/crates/swc/tests/tsc-references/jsDeclarationsClassAccessor_es5.2.minified.js b/crates/swc/tests/tsc-references/jsDeclarationsClassAccessor_es5.2.minified.js index 0c37a740588..c24a7727563 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsClassAccessor_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsClassAccessor_es5.2.minified.js @@ -17,7 +17,7 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _create_class from "@swc/helpers/src/_create_class.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import { Base } from "./base.js"; export var Argument = function(Base) { "use strict"; @@ -26,13 +26,15 @@ export var Argument = function(Base) { function Argument() { return _class_call_check(this, Argument), _super.apply(this, arguments); } - return Argument.prototype.validate = function(defs) { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }, Argument.parse = function(tokeniser) {}, _create_class(Argument, [ + return Argument.prototype.validate = regeneratorRuntime.mark(function validate(defs) { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, validate); + }), Argument.parse = function(tokeniser) {}, _create_class(Argument, [ { key: "type", get: function() { diff --git a/crates/swc/tests/tsc-references/jsDeclarationsNestedParams_es5.1.normal.js b/crates/swc/tests/tsc-references/jsDeclarationsNestedParams_es5.1.normal.js index 421cf16d4a2..9f58e46583d 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsNestedParams_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsNestedParams_es5.1.normal.js @@ -6,7 +6,7 @@ // @filename: file.js import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var X = /*#__PURE__*/ function() { "use strict"; function X() { @@ -21,13 +21,15 @@ var X = /*#__PURE__*/ function() { * @returns {Promise.<*>} resolves when the event has been sent. */ _proto.cancel = function cancel(param) { var reason = param.reason, code = param.code; - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return X; }(); @@ -47,13 +49,15 @@ var Y = /*#__PURE__*/ function() { * @returns {Promise.<*>} resolves when the event has been sent. */ _proto.cancel = function cancel(param) { var reason = param.reason, suberr = param.suberr; - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return Y; }(); diff --git a/crates/swc/tests/tsc-references/jsDeclarationsNestedParams_es5.2.minified.js b/crates/swc/tests/tsc-references/jsDeclarationsNestedParams_es5.2.minified.js index 8d9671bc20d..2514aa8cd1f 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsNestedParams_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsNestedParams_es5.2.minified.js @@ -1,3 +1,3 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/nullishCoalescingOperatorInAsyncGenerator_es5.1.normal.js b/crates/swc/tests/tsc-references/nullishCoalescingOperatorInAsyncGenerator_es5.1.normal.js index 4c775d2b8e3..fbdfb1a95b5 100644 --- a/crates/swc/tests/tsc-references/nullishCoalescingOperatorInAsyncGenerator_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/nullishCoalescingOperatorInAsyncGenerator_es5.1.normal.js @@ -4,39 +4,33 @@ // @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/37686 import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f(a) { return _f.apply(this, arguments); } function _f() { - _f = _wrap_async_generator(function(a) { + _f = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(a) { var _b, c; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: + ; c = (_b = a.b) !== null && _b !== void 0 ? _b : 10; - _state.label = 1; - case 1: - if (!c) return [ - 3, - 3 - ]; - return [ - 4, - c-- - ]; case 2: - _state.sent(); - return [ - 3, - 1 - ]; - case 3: - return [ - 2 - ]; + if (!c) { + _ctx.next = 7; + break; + } + _ctx.next = 5; + return c--; + case 5: + _ctx.next = 2; + break; + case 7: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _f.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/nullishCoalescingOperatorInAsyncGenerator_es5.2.minified.js b/crates/swc/tests/tsc-references/nullishCoalescingOperatorInAsyncGenerator_es5.2.minified.js index 2c80eae8260..6d3ee447e76 100644 --- a/crates/swc/tests/tsc-references/nullishCoalescingOperatorInAsyncGenerator_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/nullishCoalescingOperatorInAsyncGenerator_es5.2.minified.js @@ -1,2 +1,2 @@ import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/objectRest2_es5.1.normal.js b/crates/swc/tests/tsc-references/objectRest2_es5.1.normal.js index da96283c949..2dab29a27d2 100644 --- a/crates/swc/tests/tsc-references/objectRest2_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/objectRest2_es5.1.normal.js @@ -3,30 +3,28 @@ // test for #12203 import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _object_spread from "@swc/helpers/src/_object_spread.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function rootConnection(name) { return { resolve: function() { - var _ref = _async_to_generator(function(context, args) { - var objects, _tmp, _tmp1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(context, args) { + var objects; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp = {}; - return [ - 4, - (_tmp.objects = 12, _tmp) - ]; - case 1: - objects = _state.sent().objects; - _tmp1 = {}; - return [ - 2, - _object_spread(_tmp1, connectionFromArray(objects, args)) - ]; + _ctx.next = 2; + return { + objects: 12 + }; + case 2: + objects = _ctx.sent.objects; + return _ctx.abrupt("return", _object_spread({}, connectionFromArray(objects, args))); + case 4: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function(context, args) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/objectRest2_es5.2.minified.js b/crates/swc/tests/tsc-references/objectRest2_es5.2.minified.js index a407a7c97b2..82260c26411 100644 --- a/crates/swc/tests/tsc-references/objectRest2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/objectRest2_es5.2.minified.js @@ -1,26 +1,25 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _object_spread from "@swc/helpers/src/_object_spread.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; !function(name) { var _ref; return { - resolve: (_ref = _async_to_generator(function(context, args) { - var objects, _tmp, _tmp1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + resolve: (_ref = _async_to_generator(regeneratorRuntime.mark(function _callee(context, args) { + var objects; + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - ((_tmp = {}).objects = 12, _tmp) - ]; - case 1: - return [ - 2, - _object_spread(_tmp1 = {}, connectionFromArray(objects = _state.sent().objects, args)) - ]; + return _ctx.next = 2, { + objects: 12 + }; + case 2: + return objects = _ctx.sent.objects, _ctx.abrupt("return", _object_spread({}, connectionFromArray(objects, args))); + case 4: + case "end": + return _ctx.stop(); } - }); - }), function(context, args) { + }, _callee); + })), function(context, args) { return _ref.apply(this, arguments); }) }; diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression7_es5.1.normal.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression7_es5.1.normal.js index 0c570462f63..e114689b063 100644 --- a/crates/swc/tests/tsc-references/parserArrowFunctionExpression7_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression7_es5.1.normal.js @@ -1,15 +1,18 @@ // @target: esnext import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; ({ m: function m() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - for(;;){} - return [ - 2 - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + for(;;){} + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); } }); diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression7_es5.2.minified.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression7_es5.2.minified.js index 68c3ad827a6..3417dabd0f2 100644 --- a/crates/swc/tests/tsc-references/parserArrowFunctionExpression7_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression7_es5.2.minified.js @@ -1,2 +1,2 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/privateNameMethodAsync_es5.1.normal.js b/crates/swc/tests/tsc-references/privateNameMethodAsync_es5.1.normal.js index e42c464b7a0..ae459532e3f 100644 --- a/crates/swc/tests/tsc-references/privateNameMethodAsync_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/privateNameMethodAsync_es5.1.normal.js @@ -5,7 +5,8 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _class_private_method_get from "@swc/helpers/src/_class_private_method_get.mjs"; import _class_private_method_init from "@swc/helpers/src/_class_private_method_init.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(baz); var _bar, _baz, _qux, _class; var C = (_bar = /*#__PURE__*/ new WeakSet(), _baz = /*#__PURE__*/ new WeakSet(), _qux = /*#__PURE__*/ new WeakSet(), _class = /*#__PURE__*/ function() { "use strict"; @@ -18,30 +19,34 @@ var C = (_bar = /*#__PURE__*/ new WeakSet(), _baz = /*#__PURE__*/ new WeakSet(), var _proto = _class.prototype; _proto.foo = function foo() { var _this = this; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _class_private_method_get(_this, _bar, bar).call(_this) - ]; - case 1: - b = _state.sent(); - _ = b + (_class_private_method_get(_this, _baz, baz).call(_this).next().value || 0); - return [ - 4, - _class_private_method_get(_this, _qux, qux).call(_this).next() - ]; + _ctx.next = 2; + return _class_private_method_get(_this, _bar, bar).call(_this); case 2: - return [ - 2, - _ + (_state.sent().value || 0) - ]; + b = _ctx.sent; + _ctx.t0 = b + (_class_private_method_get(_this, _baz, baz).call(_this).next().value || 0); + _ctx.next = 6; + return _class_private_method_get(_this, _qux, qux).call(_this).next(); + case 6: + _ctx.t1 = _ctx.sent.value; + if (_ctx.t1) { + _ctx.next = 9; + break; + } + _ctx.t1 = 0; + case 9: + _ctx.t2 = _ctx.t1; + return _ctx.abrupt("return", _ctx.t0 + _ctx.t2); + case 11: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; return _class; }(), _class); @@ -50,64 +55,52 @@ function bar() { return _bar1.apply(this, arguments); } function _bar1() { - _bar1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _bar1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - Promise.resolve(42) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + _ctx.next = 2; + return Promise.resolve(42); + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _bar1.apply(this, arguments); } function baz() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function baz$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 42 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 42; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } function qux() { return _qux1.apply(this, arguments); } function _qux1() { - _qux1 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _qux1 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(Promise.resolve(42)) - ]; - case 1: - return [ - 4, - _state.sent() - ]; + _ctx.next = 2; + return _await_async_generator(Promise.resolve(42)); case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return _ctx.sent; + case 4: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _qux1.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/privateNameMethodAsync_es5.2.minified.js b/crates/swc/tests/tsc-references/privateNameMethodAsync_es5.2.minified.js index 5282285a5be..b9e0f262a87 100644 --- a/crates/swc/tests/tsc-references/privateNameMethodAsync_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/privateNameMethodAsync_es5.2.minified.js @@ -1,71 +1,57 @@ -var _bar, _baz, _qux; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _class_private_method_get from "@swc/helpers/src/_class_private_method_get.mjs"; import _class_private_method_init from "@swc/helpers/src/_class_private_method_init.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _bar, _baz, _qux, _marked = regeneratorRuntime.mark(baz); function bar() { return _bar1.apply(this, arguments); } function _bar1() { - return (_bar1 = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return (_bar1 = _async_to_generator(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - Promise.resolve(42) - ]; - case 1: - return [ - 2, - _state.sent() - ]; + return _ctx.next = 2, Promise.resolve(42); + case 2: + return _ctx.abrupt("return", _ctx.sent); + case 3: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } function baz() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 42 - ]; - case 1: - return _state.sent(), [ - 2 - ]; + return _ctx.next = 2, 42; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } function qux() { return _qux1.apply(this, arguments); } function _qux1() { - return (_qux1 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return (_qux1 = _wrap_async_generator(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(Promise.resolve(42)) - ]; - case 1: - return [ - 4, - _state.sent() - ]; + return _ctx.next = 2, _await_async_generator(Promise.resolve(42)); case 2: - return _state.sent(), [ - 2 - ]; + return _ctx.next = 4, _ctx.sent; + case 4: + case "end": + return _ctx.stop(); } - }); - })).apply(this, arguments); + }, _callee); + }))).apply(this, arguments); } new (_bar = new WeakSet(), _baz = new WeakSet(), _qux = new WeakSet(), function() { "use strict"; @@ -74,27 +60,27 @@ new (_bar = new WeakSet(), _baz = new WeakSet(), _qux = new WeakSet(), function( } return _class.prototype.foo = function() { var _this = this; - return _async_to_generator(function() { + return _async_to_generator(regeneratorRuntime.mark(function _callee() { var b; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _class_private_method_get(_this, _bar, bar).call(_this) - ]; - case 1: - return _ = (b = _state.sent()) + (_class_private_method_get(_this, _baz, baz).call(_this).next().value || 0), [ - 4, - _class_private_method_get(_this, _qux, qux).call(_this).next() - ]; + return _ctx.next = 2, _class_private_method_get(_this, _bar, bar).call(_this); case 2: - return [ - 2, - _ + (_state.sent().value || 0) - ]; + return b = _ctx.sent, _ctx.t0 = b + (_class_private_method_get(_this, _baz, baz).call(_this).next().value || 0), _ctx.next = 6, _class_private_method_get(_this, _qux, qux).call(_this).next(); + case 6: + if (_ctx.t1 = _ctx.sent.value, _ctx.t1) { + _ctx.next = 9; + break; + } + _ctx.t1 = 0; + case 9: + return _ctx.t2 = _ctx.t1, _ctx.abrupt("return", _ctx.t0 + _ctx.t2); + case 11: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, _class; }())().foo().then(console.log); diff --git a/crates/swc/tests/tsc-references/privateNameStaticsAndStaticMethods_es5.1.normal.js b/crates/swc/tests/tsc-references/privateNameStaticsAndStaticMethods_es5.1.normal.js index 6ed48e67e9f..b9910c01e9a 100644 --- a/crates/swc/tests/tsc-references/privateNameStaticsAndStaticMethods_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/privateNameStaticsAndStaticMethods_es5.1.normal.js @@ -11,7 +11,7 @@ import _inherits from "@swc/helpers/src/_inherits.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _class_static_private_method_get from "@swc/helpers/src/_class_static_private_method_get.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var A = function A() { "use strict"; _class_call_check(this, A); @@ -34,27 +34,32 @@ function bar(a) { return _bar.apply(this, arguments); } function _bar() { - _bar = _async_to_generator(function(a) { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _bar = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(a) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _bar.apply(this, arguments); } function baz(a) { return _baz.apply(this, arguments); } function _baz() { - _baz = _wrap_async_generator(function(a) { - return _ts_generator(this, function(_state) { - return [ - 2, - 3 - ]; - }); - }); + _baz = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(a) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 3); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _baz.apply(this, arguments); } function get_quux() { diff --git a/crates/swc/tests/tsc-references/privateNameStaticsAndStaticMethods_es5.2.minified.js b/crates/swc/tests/tsc-references/privateNameStaticsAndStaticMethods_es5.2.minified.js index 958e79c567a..b75b5fd3062 100644 --- a/crates/swc/tests/tsc-references/privateNameStaticsAndStaticMethods_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/privateNameStaticsAndStaticMethods_es5.2.minified.js @@ -7,7 +7,7 @@ import _inherits from "@swc/helpers/src/_inherits.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _class_static_private_method_get from "@swc/helpers/src/_class_static_private_method_get.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var A = function A() { "use strict"; _class_call_check(this, A), _class_static_private_method_get(A, A, foo).call(A, 30), _class_static_private_method_get(A, A, bar).call(A, 30), _class_static_private_method_get(A, A, bar).call(A, 30), _class_static_private_field_spec_set(A, A, _quux, _class_static_private_field_spec_get(A, A, _quux) + 1), _class_static_private_field_update(A, A, _quux).value++; @@ -27,11 +27,13 @@ function bar(a) { return _bar.apply(this, arguments); } function _bar() { - return (_bar = _async_to_generator(function(a) { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })).apply(this, arguments); + return (_bar = _async_to_generator(regeneratorRuntime.mark(function _callee(a) { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))).apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/privateNamesAndMethods_es5.1.normal.js b/crates/swc/tests/tsc-references/privateNamesAndMethods_es5.1.normal.js index 010cc605cf3..9402704c6ba 100644 --- a/crates/swc/tests/tsc-references/privateNamesAndMethods_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/privateNamesAndMethods_es5.1.normal.js @@ -13,7 +13,7 @@ import _class_private_method_init from "@swc/helpers/src/_class_private_method_i import _inherits from "@swc/helpers/src/_inherits.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var _foo = /*#__PURE__*/ new WeakSet(), _bar = /*#__PURE__*/ new WeakSet(), _baz = /*#__PURE__*/ new WeakSet(), __quux = /*#__PURE__*/ new WeakMap(), _quux = /*#__PURE__*/ new WeakMap(); var A = function A() { "use strict"; @@ -40,27 +40,32 @@ function bar(a) { return _bar1.apply(this, arguments); } function _bar1() { - _bar1 = _async_to_generator(function(a) { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _bar1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(a) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _bar1.apply(this, arguments); } function baz(a) { return _baz1.apply(this, arguments); } function _baz1() { - _baz1 = _wrap_async_generator(function(a) { - return _ts_generator(this, function(_state) { - return [ - 2, - 3 - ]; - }); - }); + _baz1 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(a) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 3); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _baz1.apply(this, arguments); } function get_quux() { diff --git a/crates/swc/tests/tsc-references/privateNamesAndMethods_es5.2.minified.js b/crates/swc/tests/tsc-references/privateNamesAndMethods_es5.2.minified.js index 53c7777d8dc..4aa81e2f1e8 100644 --- a/crates/swc/tests/tsc-references/privateNamesAndMethods_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/privateNamesAndMethods_es5.2.minified.js @@ -10,4 +10,4 @@ import _class_private_method_init from "@swc/helpers/src/_class_private_method_i import _inherits from "@swc/helpers/src/_inherits.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/privateNamesAndStaticMethods_es5.1.normal.js b/crates/swc/tests/tsc-references/privateNamesAndStaticMethods_es5.1.normal.js index 6ed48e67e9f..b9910c01e9a 100644 --- a/crates/swc/tests/tsc-references/privateNamesAndStaticMethods_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/privateNamesAndStaticMethods_es5.1.normal.js @@ -11,7 +11,7 @@ import _inherits from "@swc/helpers/src/_inherits.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _class_static_private_method_get from "@swc/helpers/src/_class_static_private_method_get.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var A = function A() { "use strict"; _class_call_check(this, A); @@ -34,27 +34,32 @@ function bar(a) { return _bar.apply(this, arguments); } function _bar() { - _bar = _async_to_generator(function(a) { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _bar = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(a) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _bar.apply(this, arguments); } function baz(a) { return _baz.apply(this, arguments); } function _baz() { - _baz = _wrap_async_generator(function(a) { - return _ts_generator(this, function(_state) { - return [ - 2, - 3 - ]; - }); - }); + _baz = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(a) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 3); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _baz.apply(this, arguments); } function get_quux() { diff --git a/crates/swc/tests/tsc-references/privateNamesAndStaticMethods_es5.2.minified.js b/crates/swc/tests/tsc-references/privateNamesAndStaticMethods_es5.2.minified.js index 958e79c567a..b75b5fd3062 100644 --- a/crates/swc/tests/tsc-references/privateNamesAndStaticMethods_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/privateNamesAndStaticMethods_es5.2.minified.js @@ -7,7 +7,7 @@ import _inherits from "@swc/helpers/src/_inherits.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; import _class_static_private_method_get from "@swc/helpers/src/_class_static_private_method_get.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var A = function A() { "use strict"; _class_call_check(this, A), _class_static_private_method_get(A, A, foo).call(A, 30), _class_static_private_method_get(A, A, bar).call(A, 30), _class_static_private_method_get(A, A, bar).call(A, 30), _class_static_private_field_spec_set(A, A, _quux, _class_static_private_field_spec_get(A, A, _quux) + 1), _class_static_private_field_update(A, A, _quux).value++; @@ -27,11 +27,13 @@ function bar(a) { return _bar.apply(this, arguments); } function _bar() { - return (_bar = _async_to_generator(function(a) { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })).apply(this, arguments); + return (_bar = _async_to_generator(regeneratorRuntime.mark(function _callee(a) { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + }))).apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/restParameterInDownlevelGenerator_es5.1.normal.js b/crates/swc/tests/tsc-references/restParameterInDownlevelGenerator_es5.1.normal.js index 483ffc7600d..fa45d98fbb0 100644 --- a/crates/swc/tests/tsc-references/restParameterInDownlevelGenerator_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/restParameterInDownlevelGenerator_es5.1.normal.js @@ -3,36 +3,62 @@ // @downlevelIteration: true // @noEmitHelpers: true // https://github.com/Microsoft/TypeScript/issues/30653 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(mergeStringLists); function mergeStringLists() { - var _len, strings, _key, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, str; - var _arguments = arguments; - return _ts_generator(this, function(_state) { - for(_len = _arguments.length, strings = new Array(_len), _key = 0; _key < _len; _key++){ - strings[_key] = _arguments[_key]; - } - _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - try { - for(_iterator = strings[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ - str = _step.value; - ; - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally{ - try { + var _len, strings, _key, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, str, _args = arguments; + return regeneratorRuntime.wrap(function mergeStringLists$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + for(_len = _args.length, strings = new Array(_len), _key = 0; _key < _len; _key++){ + strings[_key] = _args[_key]; + } + _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; + _ctx.prev = 2; + for(_iterator = strings[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ + str = _step.value; + ; + } + _ctx.next = 10; + break; + case 6: + _ctx.prev = 6; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 10: + _ctx.prev = 10; + _ctx.prev = 11; if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } - } finally{ - if (_didIteratorError) { - throw _iteratorError; + case 13: + _ctx.prev = 13; + if (!_didIteratorError) { + _ctx.next = 16; + break; } - } + throw _iteratorError; + case 16: + return _ctx.finish(13); + case 17: + return _ctx.finish(10); + case 18: + case "end": + return _ctx.stop(); } - return [ - 2 - ]; - }); + }, _marked, null, [ + [ + 2, + 6, + 10, + 18 + ], + [ + 11, + , + 13, + 17 + ] + ]); } diff --git a/crates/swc/tests/tsc-references/restParameterInDownlevelGenerator_es5.2.minified.js b/crates/swc/tests/tsc-references/restParameterInDownlevelGenerator_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/restParameterInDownlevelGenerator_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/restParameterInDownlevelGenerator_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/superMethodCall_es5.1.normal.js b/crates/swc/tests/tsc-references/superMethodCall_es5.1.normal.js index 979e1ff9cdf..7c4d53fcbe7 100644 --- a/crates/swc/tests/tsc-references/superMethodCall_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/superMethodCall_es5.1.normal.js @@ -6,7 +6,7 @@ import _get from "@swc/helpers/src/_get.mjs"; import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var Base = /*#__PURE__*/ function() { "use strict"; function Base() { @@ -34,15 +34,19 @@ var Derived = /*#__PURE__*/ function(Base) { var _this1 = this, _superprop_get_method = function() { return _get(_get_prototype_of(Derived.prototype), "method", _this); }; - return _async_to_generator(function() { + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var ref; - return _ts_generator(this, function(_state) { - return [ - 2, - (ref = _superprop_get_method()) === null || ref === void 0 ? void 0 : ref.call(_this1) - ]; - }); - })(); + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + ; + return _ctx.abrupt("return", (ref = _superprop_get_method()) === null || ref === void 0 ? void 0 : ref.call(_this1)); + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; return Derived; }(Base); diff --git a/crates/swc/tests/tsc-references/superMethodCall_es5.2.minified.js b/crates/swc/tests/tsc-references/superMethodCall_es5.2.minified.js index c31bdfbeed9..0c9d6c0898b 100644 --- a/crates/swc/tests/tsc-references/superMethodCall_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/superMethodCall_es5.2.minified.js @@ -4,4 +4,4 @@ import _get from "@swc/helpers/src/_get.mjs"; import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs"; import _inherits from "@swc/helpers/src/_inherits.mjs"; import _create_super from "@swc/helpers/src/_create_super.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/templateStringInYieldKeyword_es5.1.normal.js b/crates/swc/tests/tsc-references/templateStringInYieldKeyword_es5.1.normal.js index 78a7d33b9ed..0052e5c52dc 100644 --- a/crates/swc/tests/tsc-references/templateStringInYieldKeyword_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/templateStringInYieldKeyword_es5.1.normal.js @@ -1,19 +1,18 @@ // @target: es6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(gen); function gen() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function gen$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - "abc".concat(x, "def") - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return "abc".concat(x, "def"); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/templateStringInYieldKeyword_es5.2.minified.js b/crates/swc/tests/tsc-references/templateStringInYieldKeyword_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/templateStringInYieldKeyword_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringInYieldKeyword_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/templateStringWithEmbeddedYieldKeywordES6_es5.1.normal.js b/crates/swc/tests/tsc-references/templateStringWithEmbeddedYieldKeywordES6_es5.1.normal.js index 556e6f90b6e..356853c35c0 100644 --- a/crates/swc/tests/tsc-references/templateStringWithEmbeddedYieldKeywordES6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/templateStringWithEmbeddedYieldKeywordES6_es5.1.normal.js @@ -1,23 +1,20 @@ // @target: ES6 -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(gen); function gen() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function gen$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ = "abc".concat; - return [ - 4, - 10 - ]; - case 1: - x = _.apply(void 0, [ - _state.sent(), - "def" - ]); - return [ - 2 - ]; + _ctx.t0 = "abc"; + _ctx.next = 3; + return 10; + case 3: + _ctx.t1 = _ctx.sent; + x = _ctx.t0.concat.call(_ctx.t0, _ctx.t1, "def"); + case 5: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/templateStringWithEmbeddedYieldKeywordES6_es5.2.minified.js b/crates/swc/tests/tsc-references/templateStringWithEmbeddedYieldKeywordES6_es5.2.minified.js index b28f0ea921c..4b227d072cd 100644 --- a/crates/swc/tests/tsc-references/templateStringWithEmbeddedYieldKeywordES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringWithEmbeddedYieldKeywordES6_es5.2.minified.js @@ -1 +1 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.1_es5.1.normal.js b/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.1_es5.1.normal.js index e2af475c966..d954a90054f 100644 --- a/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.1_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.1_es5.1.normal.js @@ -5,571 +5,454 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function inferReturnType1() { return _inferReturnType1.apply(this, arguments); } function _inferReturnType1() { - _inferReturnType1 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - }); + _inferReturnType1 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _inferReturnType1.apply(this, arguments); } function inferReturnType2() { return _inferReturnType2.apply(this, arguments); } function _inferReturnType2() { - _inferReturnType2 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _inferReturnType2 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _inferReturnType2.apply(this, arguments); } function inferReturnType3() { return _inferReturnType3.apply(this, arguments); } function _inferReturnType3() { - _inferReturnType3 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _inferReturnType3 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _inferReturnType3.apply(this, arguments); } function inferReturnType4() { return _inferReturnType4.apply(this, arguments); } function _inferReturnType4() { - _inferReturnType4 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _inferReturnType4 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - Promise.resolve(1) - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return Promise.resolve(1); + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _inferReturnType4.apply(this, arguments); } function inferReturnType5() { return _inferReturnType5.apply(this, arguments); } function _inferReturnType5() { - _inferReturnType5 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _inferReturnType5 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 4, - Promise.resolve(2) - ]; + _ctx.next = 2; + return 1; case 2: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 4; + return Promise.resolve(2); + case 4: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _inferReturnType5.apply(this, arguments); } function inferReturnType6() { return _inferReturnType6.apply(this, arguments); } function _inferReturnType6() { - _inferReturnType6 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _inferReturnType6 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1, - 2 - ]), _await_async_generator)) - ]; - case 1: - _state.sent(); - return [ + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1, 2 - ]; + ]), _await_async_generator), "t0", 1); + case 1: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _inferReturnType6.apply(this, arguments); } function inferReturnType7() { return _inferReturnType7.apply(this, arguments); } function _inferReturnType7() { - _inferReturnType7 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _inferReturnType7 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - Promise.resolve(1) - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + Promise.resolve(1) + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _inferReturnType7.apply(this, arguments); } function inferReturnType8() { return _inferReturnType8.apply(this, arguments); } function _inferReturnType8() { - _inferReturnType8 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _inferReturnType8 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _inferReturnType8.apply(this, arguments); } var assignability1 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability1() { return _ref.apply(this, arguments); }; }(); var assignability2 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - Promise.resolve(1) - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return Promise.resolve(1); + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability2() { return _ref.apply(this, arguments); }; }(); var assignability3 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1, - 2 - ]), _await_async_generator)) - ]; - case 1: - _state.sent(); - return [ + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1, 2 - ]; + ]), _await_async_generator), "t0", 1); + case 1: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability3() { return _ref.apply(this, arguments); }; }(); var assignability4 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - Promise.resolve(1) - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + Promise.resolve(1) + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability4() { return _ref.apply(this, arguments); }; }(); var assignability5 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability5() { return _ref.apply(this, arguments); }; }(); var assignability6 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability6() { return _ref.apply(this, arguments); }; }(); var assignability7 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - Promise.resolve(1) - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return Promise.resolve(1); + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability7() { return _ref.apply(this, arguments); }; }(); var assignability8 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1, - 2 - ]), _await_async_generator)) - ]; - case 1: - _state.sent(); - return [ + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1, 2 - ]; + ]), _await_async_generator), "t0", 1); + case 1: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability8() { return _ref.apply(this, arguments); }; }(); var assignability9 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - Promise.resolve(1) - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + Promise.resolve(1) + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability9() { return _ref.apply(this, arguments); }; }(); var assignability10 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability10() { return _ref.apply(this, arguments); }; }(); var assignability11 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability11() { return _ref.apply(this, arguments); }; }(); var assignability12 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - Promise.resolve(1) - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return Promise.resolve(1); + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability12() { return _ref.apply(this, arguments); }; }(); var assignability13 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1, - 2 - ]), _await_async_generator)) - ]; - case 1: - _state.sent(); - return [ + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1, 2 - ]; + ]), _await_async_generator), "t0", 1); + case 1: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability13() { return _ref.apply(this, arguments); }; }(); var assignability14 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - Promise.resolve(1) - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + Promise.resolve(1) + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability14() { return _ref.apply(this, arguments); }; }(); var assignability15 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability15() { return _ref.apply(this, arguments); }; @@ -578,479 +461,389 @@ function explicitReturnType1() { return _explicitReturnType1.apply(this, arguments); } function _explicitReturnType1() { - _explicitReturnType1 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType1 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType1.apply(this, arguments); } function explicitReturnType2() { return _explicitReturnType2.apply(this, arguments); } function _explicitReturnType2() { - _explicitReturnType2 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType2 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - Promise.resolve(1) - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return Promise.resolve(1); + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType2.apply(this, arguments); } function explicitReturnType3() { return _explicitReturnType3.apply(this, arguments); } function _explicitReturnType3() { - _explicitReturnType3 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType3 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1, - 2 - ]), _await_async_generator)) - ]; - case 1: - _state.sent(); - return [ + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1, 2 - ]; + ]), _await_async_generator), "t0", 1); + case 1: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType3.apply(this, arguments); } function explicitReturnType4() { return _explicitReturnType4.apply(this, arguments); } function _explicitReturnType4() { - _explicitReturnType4 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType4 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - Promise.resolve(1) - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + Promise.resolve(1) + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType4.apply(this, arguments); } function explicitReturnType5() { return _explicitReturnType5.apply(this, arguments); } function _explicitReturnType5() { - _explicitReturnType5 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType5 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType5.apply(this, arguments); } function explicitReturnType6() { return _explicitReturnType6.apply(this, arguments); } function _explicitReturnType6() { - _explicitReturnType6 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType6 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType6.apply(this, arguments); } function explicitReturnType7() { return _explicitReturnType7.apply(this, arguments); } function _explicitReturnType7() { - _explicitReturnType7 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType7 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - Promise.resolve(1) - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return Promise.resolve(1); + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType7.apply(this, arguments); } function explicitReturnType8() { return _explicitReturnType8.apply(this, arguments); } function _explicitReturnType8() { - _explicitReturnType8 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType8 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1, - 2 - ]), _await_async_generator)) - ]; - case 1: - _state.sent(); - return [ + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1, 2 - ]; + ]), _await_async_generator), "t0", 1); + case 1: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType8.apply(this, arguments); } function explicitReturnType9() { return _explicitReturnType9.apply(this, arguments); } function _explicitReturnType9() { - _explicitReturnType9 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType9 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - Promise.resolve(1) - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + Promise.resolve(1) + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType9.apply(this, arguments); } function explicitReturnType10() { return _explicitReturnType10.apply(this, arguments); } function _explicitReturnType10() { - _explicitReturnType10 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType10 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType10.apply(this, arguments); } function explicitReturnType11() { return _explicitReturnType11.apply(this, arguments); } function _explicitReturnType11() { - _explicitReturnType11 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType11 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType11.apply(this, arguments); } function explicitReturnType12() { return _explicitReturnType12.apply(this, arguments); } function _explicitReturnType12() { - _explicitReturnType12 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType12 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - Promise.resolve(1) - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return Promise.resolve(1); + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType12.apply(this, arguments); } function explicitReturnType13() { return _explicitReturnType13.apply(this, arguments); } function _explicitReturnType13() { - _explicitReturnType13 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType13 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1, - 2 - ]), _await_async_generator)) - ]; - case 1: - _state.sent(); - return [ + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + 1, 2 - ]; + ]), _await_async_generator), "t0", 1); + case 1: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType13.apply(this, arguments); } function explicitReturnType14() { return _explicitReturnType14.apply(this, arguments); } function _explicitReturnType14() { - _explicitReturnType14 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType14 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - Promise.resolve(1) - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + Promise.resolve(1) + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType14.apply(this, arguments); } function explicitReturnType15() { return _explicitReturnType15.apply(this, arguments); } function _explicitReturnType15() { - _explicitReturnType15 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType15 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType15.apply(this, arguments); } function explicitReturnType16() { return _explicitReturnType16.apply(this, arguments); } function _explicitReturnType16() { - _explicitReturnType16 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType16 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType16.apply(this, arguments); } function awaitedType1() { return _awaitedType1.apply(this, arguments); } function _awaitedType1() { - _awaitedType1 = _wrap_async_generator(function() { + _awaitedType1 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(1); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _awaitedType1.apply(this, arguments); } function awaitedType2() { return _awaitedType2.apply(this, arguments); } function _awaitedType2() { - _awaitedType2 = _wrap_async_generator(function() { + _awaitedType2 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - _await_async_generator(Promise.resolve(1)) - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return _await_async_generator(Promise.resolve(1)); + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _awaitedType2.apply(this, arguments); } function nextType1() { return _nextType1.apply(this, arguments); } function _nextType1() { - _nextType1 = _wrap_async_generator(function() { + _nextType1 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { var x; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4 - ]; - case 1: - x = _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return; + case 2: + x = _ctx.sent; + case 3: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _nextType1.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.1_es5.2.minified.js b/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.1_es5.2.minified.js index d427396f700..de0d8b08415 100644 --- a/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.1_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.1_es5.2.minified.js @@ -2,5 +2,4 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.2_es5.1.normal.js b/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.2_es5.1.normal.js index 924ad9dd131..1eaa42bdee8 100644 --- a/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.2_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.2_es5.1.normal.js @@ -5,318 +5,246 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function inferReturnType1() { return _inferReturnType1.apply(this, arguments); } function _inferReturnType1() { - _inferReturnType1 = _wrap_async_generator(function() { - var _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _inferReturnType1 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp = {}; - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_tmp), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator({}), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _inferReturnType1.apply(this, arguments); } function inferReturnType2() { return _inferReturnType2.apply(this, arguments); } function _inferReturnType2() { - _inferReturnType2 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _inferReturnType2 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(inferReturnType2()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(inferReturnType2()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _inferReturnType2.apply(this, arguments); } function inferReturnType3() { return _inferReturnType3.apply(this, arguments); } function _inferReturnType3() { - _inferReturnType3 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _inferReturnType3 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(Promise.resolve([ - 1, - 2 - ])), _await_async_generator)) - ]; - case 1: - _state.sent(); - return [ + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(Promise.resolve([ + 1, 2 - ]; + ])), _await_async_generator), "t0", 1); + case 1: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _inferReturnType3.apply(this, arguments); } var assignability1 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - "a" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return "a"; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability1() { return _ref.apply(this, arguments); }; }(); var assignability2 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - "a", - "b" - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + "a", + "b" + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability2() { return _ref.apply(this, arguments); }; }(); var assignability3 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - "a" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return "a"; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability3() { return _ref.apply(this, arguments); }; }(); var assignability4 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - "a" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return "a"; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability4() { return _ref.apply(this, arguments); }; }(); var assignability5 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - "a", - "b" - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + "a", + "b" + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability5() { return _ref.apply(this, arguments); }; }(); var assignability6 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - "a" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return "a"; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability6() { return _ref.apply(this, arguments); }; }(); var assignability7 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - "a" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return "a"; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability7() { return _ref.apply(this, arguments); }; }(); var assignability8 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - "a", - "b" - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + "a", + "b" + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability8() { return _ref.apply(this, arguments); }; }(); var assignability9 = function() { - var _ref = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + var _ref = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - "a" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return "a"; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return function assignability9() { return _ref.apply(this, arguments); }; @@ -325,341 +253,268 @@ function explicitReturnType1() { return _explicitReturnType1.apply(this, arguments); } function _explicitReturnType1() { - _explicitReturnType1 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType1 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - "a" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return "a"; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType1.apply(this, arguments); } function explicitReturnType2() { return _explicitReturnType2.apply(this, arguments); } function _explicitReturnType2() { - _explicitReturnType2 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType2 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - "a", - "b" - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + "a", + "b" + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType2.apply(this, arguments); } function explicitReturnType3() { return _explicitReturnType3.apply(this, arguments); } function _explicitReturnType3() { - _explicitReturnType3 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType3 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - "a" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return "a"; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType3.apply(this, arguments); } function explicitReturnType4() { return _explicitReturnType4.apply(this, arguments); } function _explicitReturnType4() { - _explicitReturnType4 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType4 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - "a" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return "a"; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType4.apply(this, arguments); } function explicitReturnType5() { return _explicitReturnType5.apply(this, arguments); } function _explicitReturnType5() { - _explicitReturnType5 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType5 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - "a", - "b" - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + "a", + "b" + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType5.apply(this, arguments); } function explicitReturnType6() { return _explicitReturnType6.apply(this, arguments); } function _explicitReturnType6() { - _explicitReturnType6 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType6 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - "a" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return "a"; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType6.apply(this, arguments); } function explicitReturnType7() { return _explicitReturnType7.apply(this, arguments); } function _explicitReturnType7() { - _explicitReturnType7 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType7 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - "a" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return "a"; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType7.apply(this, arguments); } function explicitReturnType8() { return _explicitReturnType8.apply(this, arguments); } function _explicitReturnType8() { - _explicitReturnType8 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType8 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - "a", - "b" - ]), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator([ + "a", + "b" + ]), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType8.apply(this, arguments); } function explicitReturnType9() { return _explicitReturnType9.apply(this, arguments); } function _explicitReturnType9() { - _explicitReturnType9 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType9 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - "a" - ]; - case 1: - _state.sent(); - return [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(_wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.next = 2; + return "a"; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))()), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType9.apply(this, arguments); } function explicitReturnType10() { return _explicitReturnType10.apply(this, arguments); } function _explicitReturnType10() { - _explicitReturnType10 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType10 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType10.apply(this, arguments); } function explicitReturnType11() { return _explicitReturnType11.apply(this, arguments); } function _explicitReturnType11() { - _explicitReturnType11 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType11 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType11.apply(this, arguments); } function explicitReturnType12() { return _explicitReturnType12.apply(this, arguments); } function _explicitReturnType12() { - _explicitReturnType12 = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _explicitReturnType12 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - 1 - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return 1; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _explicitReturnType12.apply(this, arguments); } function yieldStar() { return _yieldStar.apply(this, arguments); } function _yieldStar() { - _yieldStar = _wrap_async_generator(function() { - var _tmp; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _yieldStar = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - _tmp = {}; - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator(_tmp), _await_async_generator)) - ]; + return _ctx.delegateYield(_async_generator_delegate(_async_iterator({}), _await_async_generator), "t0", 1); case 1: - _state.sent(); - return [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _yieldStar.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.2_es5.2.minified.js b/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.2_es5.2.minified.js index d427396f700..e135be91caa 100644 --- a/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/types.asyncGenerators.es2018.2_es5.2.minified.js @@ -2,5 +2,20 @@ import _async_generator_delegate from "@swc/helpers/src/_async_generator_delegat import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +function inferReturnType2() { + return _inferReturnType2.apply(this, arguments); +} +function _inferReturnType2() { + return (_inferReturnType2 = _wrap_async_generator(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.delegateYield(_async_generator_delegate(_async_iterator(inferReturnType2()), _await_async_generator), "t0", 1); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))).apply(this, arguments); +} diff --git a/crates/swc/tests/tsc-references/types.forAwait.es2018.1_es5.1.normal.js b/crates/swc/tests/tsc-references/types.forAwait.es2018.1_es5.1.normal.js index 2eec9171cfe..9c7d4568681 100644 --- a/crates/swc/tests/tsc-references/types.forAwait.es2018.1_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/types.forAwait.es2018.1_es5.1.normal.js @@ -5,974 +5,760 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f1() { return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, err, _iteratorAbruptCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value1, x1, err1, _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, x2, err2, _iteratorAbruptCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _value3, err3, _iteratorAbruptCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _value4, err4, _iteratorAbruptCompletion5, _didIteratorError5, _iteratorError5, _iterator5, _step5, _value5, err5; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, _iteratorAbruptCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value1, x1, _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, x2, _iteratorAbruptCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _value3, _iteratorAbruptCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _value4, _iteratorAbruptCompletion5, _didIteratorError5, _iteratorError5, _iterator5, _step5, _value5; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: + ; _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 2; _iterator = _async_iterator(asyncIterable); - _state.label = 2; - case 2: - return [ - 4, - _iterator.next() - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - x = _value; - _state.label = 4; case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 12 - ]; + _ctx.next = 6; + return _iterator.next(); case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; - case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 11; + break; + } + { + _value = _step.value; + x = _value; + } case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; - case 10: - if (_didIteratorError) { - throw _iteratorError; - } - return [ - 7 - ]; + _iteratorAbruptCompletion = false; + _ctx.next = 4; + break; case 11: - return [ - 7 - ]; - case 12: - _iteratorAbruptCompletion1 = false, _didIteratorError1 = false; - _state.label = 13; + _ctx.next = 17; + break; case 13: - _state.trys.push([ - 13, - 18, - 19, - 24 - ]); - _iterator1 = _async_iterator(iterable); - _state.label = 14; - case 14: - return [ - 4, - _iterator1.next() - ]; - case 15: - if (!(_iteratorAbruptCompletion1 = !(_step1 = _state.sent()).done)) return [ - 3, - 17 - ]; - _value1 = _step1.value; - x1 = _value1; - _state.label = 16; - case 16: - _iteratorAbruptCompletion1 = false; - return [ - 3, - 14 - ]; + _ctx.prev = 13; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; case 17: - return [ - 3, - 24 - ]; - case 18: - err1 = _state.sent(); - _didIteratorError1 = true; - _iteratorError1 = err1; - return [ - 3, - 24 - ]; - case 19: - _state.trys.push([ - 19, - , - 22, - 23 - ]); - if (!(_iteratorAbruptCompletion1 && _iterator1.return != null)) return [ - 3, - 21 - ]; - return [ - 4, - _iterator1.return() - ]; - case 20: - _state.sent(); - _state.label = 21; - case 21: - return [ - 3, - 23 - ]; + _ctx.prev = 17; + _ctx.prev = 18; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 22; + break; + } + _ctx.next = 22; + return _iterator.return(); case 22: - if (_didIteratorError1) { - throw _iteratorError1; + _ctx.prev = 22; + if (!_didIteratorError) { + _ctx.next = 25; + break; } - return [ - 7 - ]; - case 23: - return [ - 7 - ]; - case 24: - _iteratorAbruptCompletion2 = false, _didIteratorError2 = false; - _state.label = 25; + throw _iteratorError; case 25: - _state.trys.push([ - 25, - 30, - 31, - 36 - ]); - _iterator2 = _async_iterator(iterableOfPromise); - _state.label = 26; + return _ctx.finish(22); case 26: - return [ - 4, - _iterator2.next() - ]; + return _ctx.finish(17); case 27: - if (!(_iteratorAbruptCompletion2 = !(_step2 = _state.sent()).done)) return [ - 3, - 29 - ]; - _value2 = _step2.value; - x2 = _value2; - _state.label = 28; - case 28: - _iteratorAbruptCompletion2 = false; - return [ - 3, - 26 - ]; - case 29: - return [ - 3, - 36 - ]; + _iteratorAbruptCompletion1 = false, _didIteratorError1 = false; + _ctx.prev = 28; + _iterator1 = _async_iterator(iterable); case 30: - err2 = _state.sent(); - _didIteratorError2 = true; - _iteratorError2 = err2; - return [ - 3, - 36 - ]; - case 31: - _state.trys.push([ - 31, - , - 34, - 35 - ]); - if (!(_iteratorAbruptCompletion2 && _iterator2.return != null)) return [ - 3, - 33 - ]; - return [ - 4, - _iterator2.return() - ]; + _ctx.next = 32; + return _iterator1.next(); case 32: - _state.sent(); - _state.label = 33; - case 33: - return [ - 3, - 35 - ]; + if (!(_iteratorAbruptCompletion1 = !(_step1 = _ctx.sent).done)) { + _ctx.next = 37; + break; + } + { + _value1 = _step1.value; + x1 = _value1; + } case 34: - if (_didIteratorError2) { - throw _iteratorError2; - } - return [ - 7 - ]; - case 35: - return [ - 7 - ]; - case 36: - _iteratorAbruptCompletion3 = false, _didIteratorError3 = false; - _state.label = 37; + _iteratorAbruptCompletion1 = false; + _ctx.next = 30; + break; case 37: - _state.trys.push([ - 37, - 42, - 43, - 48 - ]); - _iterator3 = _async_iterator(asyncIterable); - _state.label = 38; - case 38: - return [ - 4, - _iterator3.next() - ]; + _ctx.next = 43; + break; case 39: - if (!(_iteratorAbruptCompletion3 = !(_step3 = _state.sent()).done)) return [ - 3, - 41 - ]; - _value3 = _step3.value; - y = _value3; - _state.label = 40; - case 40: - _iteratorAbruptCompletion3 = false; - return [ - 3, - 38 - ]; - case 41: - return [ - 3, - 48 - ]; - case 42: - err3 = _state.sent(); - _didIteratorError3 = true; - _iteratorError3 = err3; - return [ - 3, - 48 - ]; + _ctx.prev = 39; + _ctx.t1 = _ctx["catch"](28); + _didIteratorError1 = true; + _iteratorError1 = _ctx.t1; case 43: - _state.trys.push([ - 43, - , - 46, - 47 - ]); - if (!(_iteratorAbruptCompletion3 && _iterator3.return != null)) return [ - 3, - 45 - ]; - return [ - 4, - _iterator3.return() - ]; - case 44: - _state.sent(); - _state.label = 45; - case 45: - return [ - 3, - 47 - ]; - case 46: - if (_didIteratorError3) { - throw _iteratorError3; + _ctx.prev = 43; + _ctx.prev = 44; + if (!(_iteratorAbruptCompletion1 && _iterator1.return != null)) { + _ctx.next = 48; + break; } - return [ - 7 - ]; - case 47: - return [ - 7 - ]; + _ctx.next = 48; + return _iterator1.return(); case 48: - _iteratorAbruptCompletion4 = false, _didIteratorError4 = false; - _state.label = 49; - case 49: - _state.trys.push([ - 49, - 54, - 55, - 60 - ]); - _iterator4 = _async_iterator(iterable); - _state.label = 50; - case 50: - return [ - 4, - _iterator4.next() - ]; + _ctx.prev = 48; + if (!_didIteratorError1) { + _ctx.next = 51; + break; + } + throw _iteratorError1; case 51: - if (!(_iteratorAbruptCompletion4 = !(_step4 = _state.sent()).done)) return [ - 3, - 53 - ]; - _value4 = _step4.value; - y = _value4; - _state.label = 52; + return _ctx.finish(48); case 52: - _iteratorAbruptCompletion4 = false; - return [ - 3, - 50 - ]; + return _ctx.finish(43); case 53: - return [ - 3, - 60 - ]; - case 54: - err4 = _state.sent(); - _didIteratorError4 = true; - _iteratorError4 = err4; - return [ - 3, - 60 - ]; - case 55: - _state.trys.push([ - 55, - , - 58, - 59 - ]); - if (!(_iteratorAbruptCompletion4 && _iterator4.return != null)) return [ - 3, - 57 - ]; - return [ - 4, - _iterator4.return() - ]; + _iteratorAbruptCompletion2 = false, _didIteratorError2 = false; + _ctx.prev = 54; + _iterator2 = _async_iterator(iterableOfPromise); case 56: - _state.sent(); - _state.label = 57; - case 57: - return [ - 3, - 59 - ]; + _ctx.next = 58; + return _iterator2.next(); case 58: - if (_didIteratorError4) { - throw _iteratorError4; + if (!(_iteratorAbruptCompletion2 = !(_step2 = _ctx.sent).done)) { + _ctx.next = 63; + break; + } + { + _value2 = _step2.value; + x2 = _value2; } - return [ - 7 - ]; - case 59: - return [ - 7 - ]; case 60: - _iteratorAbruptCompletion5 = false, _didIteratorError5 = false; - _state.label = 61; - case 61: - _state.trys.push([ - 61, - 66, - 67, - 72 - ]); - _iterator5 = _async_iterator(iterableOfPromise); - _state.label = 62; - case 62: - return [ - 4, - _iterator5.next() - ]; + _iteratorAbruptCompletion2 = false; + _ctx.next = 56; + break; case 63: - if (!(_iteratorAbruptCompletion5 = !(_step5 = _state.sent()).done)) return [ - 3, - 65 - ]; - _value5 = _step5.value; - y = _value5; - _state.label = 64; - case 64: - _iteratorAbruptCompletion5 = false; - return [ - 3, - 62 - ]; + _ctx.next = 69; + break; case 65: - return [ - 3, - 72 - ]; - case 66: - err5 = _state.sent(); - _didIteratorError5 = true; - _iteratorError5 = err5; - return [ - 3, - 72 - ]; - case 67: - _state.trys.push([ - 67, - , - 70, - 71 - ]); - if (!(_iteratorAbruptCompletion5 && _iterator5.return != null)) return [ - 3, - 69 - ]; - return [ - 4, - _iterator5.return() - ]; - case 68: - _state.sent(); - _state.label = 69; + _ctx.prev = 65; + _ctx.t2 = _ctx["catch"](54); + _didIteratorError2 = true; + _iteratorError2 = _ctx.t2; case 69: - return [ - 3, - 71 - ]; - case 70: - if (_didIteratorError5) { - throw _iteratorError5; + _ctx.prev = 69; + _ctx.prev = 70; + if (!(_iteratorAbruptCompletion2 && _iterator2.return != null)) { + _ctx.next = 74; + break; } - return [ - 7 - ]; - case 71: - return [ - 7 - ]; - case 72: - return [ - 2 - ]; + _ctx.next = 74; + return _iterator2.return(); + case 74: + _ctx.prev = 74; + if (!_didIteratorError2) { + _ctx.next = 77; + break; + } + throw _iteratorError2; + case 77: + return _ctx.finish(74); + case 78: + return _ctx.finish(69); + case 79: + _iteratorAbruptCompletion3 = false, _didIteratorError3 = false; + _ctx.prev = 80; + _iterator3 = _async_iterator(asyncIterable); + case 82: + _ctx.next = 84; + return _iterator3.next(); + case 84: + if (!(_iteratorAbruptCompletion3 = !(_step3 = _ctx.sent).done)) { + _ctx.next = 89; + break; + } + { + _value3 = _step3.value; + y = _value3; + } + case 86: + _iteratorAbruptCompletion3 = false; + _ctx.next = 82; + break; + case 89: + _ctx.next = 95; + break; + case 91: + _ctx.prev = 91; + _ctx.t3 = _ctx["catch"](80); + _didIteratorError3 = true; + _iteratorError3 = _ctx.t3; + case 95: + _ctx.prev = 95; + _ctx.prev = 96; + if (!(_iteratorAbruptCompletion3 && _iterator3.return != null)) { + _ctx.next = 100; + break; + } + _ctx.next = 100; + return _iterator3.return(); + case 100: + _ctx.prev = 100; + if (!_didIteratorError3) { + _ctx.next = 103; + break; + } + throw _iteratorError3; + case 103: + return _ctx.finish(100); + case 104: + return _ctx.finish(95); + case 105: + _iteratorAbruptCompletion4 = false, _didIteratorError4 = false; + _ctx.prev = 106; + _iterator4 = _async_iterator(iterable); + case 108: + _ctx.next = 110; + return _iterator4.next(); + case 110: + if (!(_iteratorAbruptCompletion4 = !(_step4 = _ctx.sent).done)) { + _ctx.next = 115; + break; + } + { + _value4 = _step4.value; + y = _value4; + } + case 112: + _iteratorAbruptCompletion4 = false; + _ctx.next = 108; + break; + case 115: + _ctx.next = 121; + break; + case 117: + _ctx.prev = 117; + _ctx.t4 = _ctx["catch"](106); + _didIteratorError4 = true; + _iteratorError4 = _ctx.t4; + case 121: + _ctx.prev = 121; + _ctx.prev = 122; + if (!(_iteratorAbruptCompletion4 && _iterator4.return != null)) { + _ctx.next = 126; + break; + } + _ctx.next = 126; + return _iterator4.return(); + case 126: + _ctx.prev = 126; + if (!_didIteratorError4) { + _ctx.next = 129; + break; + } + throw _iteratorError4; + case 129: + return _ctx.finish(126); + case 130: + return _ctx.finish(121); + case 131: + _iteratorAbruptCompletion5 = false, _didIteratorError5 = false; + _ctx.prev = 132; + _iterator5 = _async_iterator(iterableOfPromise); + case 134: + _ctx.next = 136; + return _iterator5.next(); + case 136: + if (!(_iteratorAbruptCompletion5 = !(_step5 = _ctx.sent).done)) { + _ctx.next = 141; + break; + } + { + _value5 = _step5.value; + y = _value5; + } + case 138: + _iteratorAbruptCompletion5 = false; + _ctx.next = 134; + break; + case 141: + _ctx.next = 147; + break; + case 143: + _ctx.prev = 143; + _ctx.t5 = _ctx["catch"](132); + _didIteratorError5 = true; + _iteratorError5 = _ctx.t5; + case 147: + _ctx.prev = 147; + _ctx.prev = 148; + if (!(_iteratorAbruptCompletion5 && _iterator5.return != null)) { + _ctx.next = 152; + break; + } + _ctx.next = 152; + return _iterator5.return(); + case 152: + _ctx.prev = 152; + if (!_didIteratorError5) { + _ctx.next = 155; + break; + } + throw _iteratorError5; + case 155: + return _ctx.finish(152); + case 156: + return _ctx.finish(147); + case 157: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 2, + 13, + 17, + 27 + ], + [ + 18, + , + 22, + 26 + ], + [ + 28, + 39, + 43, + 53 + ], + [ + 44, + , + 48, + 52 + ], + [ + 54, + 65, + 69, + 79 + ], + [ + 70, + , + 74, + 78 + ], + [ + 80, + 91, + 95, + 105 + ], + [ + 96, + , + 100, + 104 + ], + [ + 106, + 117, + 121, + 131 + ], + [ + 122, + , + 126, + 130 + ], + [ + 132, + 143, + 147, + 157 + ], + [ + 148, + , + 152, + 156 + ] + ]); + })); return _f1.apply(this, arguments); } function f2() { return _f2.apply(this, arguments); } function _f2() { - _f2 = _wrap_async_generator(function() { - var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, err, _iteratorAbruptCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value1, x1, err1, _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, x2, err2, _iteratorAbruptCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _value3, err3, _iteratorAbruptCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _value4, err4, _iteratorAbruptCompletion5, _didIteratorError5, _iteratorError5, _iterator5, _step5, _value5, err5; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f2 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, _iteratorAbruptCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value1, x1, _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, x2, _iteratorAbruptCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _value3, _iteratorAbruptCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _value4, _iteratorAbruptCompletion5, _didIteratorError5, _iteratorError5, _iterator5, _step5, _value5; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: + ; _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); + _ctx.prev = 2; _iterator = _async_iterator(asyncIterable); - _state.label = 2; - case 2: - return [ - 4, - _await_async_generator(_iterator.next()) - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - x = _value; - _state.label = 4; case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 12 - ]; + _ctx.next = 6; + return _await_async_generator(_iterator.next()); case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; - case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 11; + break; + } + { + _value = _step.value; + x = _value; + } case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; - case 10: - if (_didIteratorError) { - throw _iteratorError; - } - return [ - 7 - ]; + _iteratorAbruptCompletion = false; + _ctx.next = 4; + break; case 11: - return [ - 7 - ]; - case 12: - _iteratorAbruptCompletion1 = false, _didIteratorError1 = false; - _state.label = 13; + _ctx.next = 17; + break; case 13: - _state.trys.push([ - 13, - 18, - 19, - 24 - ]); - _iterator1 = _async_iterator(iterable); - _state.label = 14; - case 14: - return [ - 4, - _await_async_generator(_iterator1.next()) - ]; - case 15: - if (!(_iteratorAbruptCompletion1 = !(_step1 = _state.sent()).done)) return [ - 3, - 17 - ]; - _value1 = _step1.value; - x1 = _value1; - _state.label = 16; - case 16: - _iteratorAbruptCompletion1 = false; - return [ - 3, - 14 - ]; + _ctx.prev = 13; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; case 17: - return [ - 3, - 24 - ]; - case 18: - err1 = _state.sent(); - _didIteratorError1 = true; - _iteratorError1 = err1; - return [ - 3, - 24 - ]; - case 19: - _state.trys.push([ - 19, - , - 22, - 23 - ]); - if (!(_iteratorAbruptCompletion1 && _iterator1.return != null)) return [ - 3, - 21 - ]; - return [ - 4, - _iterator1.return() - ]; - case 20: - _state.sent(); - _state.label = 21; - case 21: - return [ - 3, - 23 - ]; + _ctx.prev = 17; + _ctx.prev = 18; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 22; + break; + } + _ctx.next = 22; + return _iterator.return(); case 22: - if (_didIteratorError1) { - throw _iteratorError1; + _ctx.prev = 22; + if (!_didIteratorError) { + _ctx.next = 25; + break; } - return [ - 7 - ]; - case 23: - return [ - 7 - ]; - case 24: - _iteratorAbruptCompletion2 = false, _didIteratorError2 = false; - _state.label = 25; + throw _iteratorError; case 25: - _state.trys.push([ - 25, - 30, - 31, - 36 - ]); - _iterator2 = _async_iterator(iterableOfPromise); - _state.label = 26; + return _ctx.finish(22); case 26: - return [ - 4, - _await_async_generator(_iterator2.next()) - ]; + return _ctx.finish(17); case 27: - if (!(_iteratorAbruptCompletion2 = !(_step2 = _state.sent()).done)) return [ - 3, - 29 - ]; - _value2 = _step2.value; - x2 = _value2; - _state.label = 28; - case 28: - _iteratorAbruptCompletion2 = false; - return [ - 3, - 26 - ]; - case 29: - return [ - 3, - 36 - ]; + _iteratorAbruptCompletion1 = false, _didIteratorError1 = false; + _ctx.prev = 28; + _iterator1 = _async_iterator(iterable); case 30: - err2 = _state.sent(); - _didIteratorError2 = true; - _iteratorError2 = err2; - return [ - 3, - 36 - ]; - case 31: - _state.trys.push([ - 31, - , - 34, - 35 - ]); - if (!(_iteratorAbruptCompletion2 && _iterator2.return != null)) return [ - 3, - 33 - ]; - return [ - 4, - _iterator2.return() - ]; + _ctx.next = 32; + return _await_async_generator(_iterator1.next()); case 32: - _state.sent(); - _state.label = 33; - case 33: - return [ - 3, - 35 - ]; + if (!(_iteratorAbruptCompletion1 = !(_step1 = _ctx.sent).done)) { + _ctx.next = 37; + break; + } + { + _value1 = _step1.value; + x1 = _value1; + } case 34: - if (_didIteratorError2) { - throw _iteratorError2; - } - return [ - 7 - ]; - case 35: - return [ - 7 - ]; - case 36: - _iteratorAbruptCompletion3 = false, _didIteratorError3 = false; - _state.label = 37; + _iteratorAbruptCompletion1 = false; + _ctx.next = 30; + break; case 37: - _state.trys.push([ - 37, - 42, - 43, - 48 - ]); - _iterator3 = _async_iterator(asyncIterable); - _state.label = 38; - case 38: - return [ - 4, - _await_async_generator(_iterator3.next()) - ]; + _ctx.next = 43; + break; case 39: - if (!(_iteratorAbruptCompletion3 = !(_step3 = _state.sent()).done)) return [ - 3, - 41 - ]; - _value3 = _step3.value; - y = _value3; - _state.label = 40; - case 40: - _iteratorAbruptCompletion3 = false; - return [ - 3, - 38 - ]; - case 41: - return [ - 3, - 48 - ]; - case 42: - err3 = _state.sent(); - _didIteratorError3 = true; - _iteratorError3 = err3; - return [ - 3, - 48 - ]; + _ctx.prev = 39; + _ctx.t1 = _ctx["catch"](28); + _didIteratorError1 = true; + _iteratorError1 = _ctx.t1; case 43: - _state.trys.push([ - 43, - , - 46, - 47 - ]); - if (!(_iteratorAbruptCompletion3 && _iterator3.return != null)) return [ - 3, - 45 - ]; - return [ - 4, - _iterator3.return() - ]; - case 44: - _state.sent(); - _state.label = 45; - case 45: - return [ - 3, - 47 - ]; - case 46: - if (_didIteratorError3) { - throw _iteratorError3; + _ctx.prev = 43; + _ctx.prev = 44; + if (!(_iteratorAbruptCompletion1 && _iterator1.return != null)) { + _ctx.next = 48; + break; } - return [ - 7 - ]; - case 47: - return [ - 7 - ]; + _ctx.next = 48; + return _iterator1.return(); case 48: - _iteratorAbruptCompletion4 = false, _didIteratorError4 = false; - _state.label = 49; - case 49: - _state.trys.push([ - 49, - 54, - 55, - 60 - ]); - _iterator4 = _async_iterator(iterable); - _state.label = 50; - case 50: - return [ - 4, - _await_async_generator(_iterator4.next()) - ]; + _ctx.prev = 48; + if (!_didIteratorError1) { + _ctx.next = 51; + break; + } + throw _iteratorError1; case 51: - if (!(_iteratorAbruptCompletion4 = !(_step4 = _state.sent()).done)) return [ - 3, - 53 - ]; - _value4 = _step4.value; - y = _value4; - _state.label = 52; + return _ctx.finish(48); case 52: - _iteratorAbruptCompletion4 = false; - return [ - 3, - 50 - ]; + return _ctx.finish(43); case 53: - return [ - 3, - 60 - ]; - case 54: - err4 = _state.sent(); - _didIteratorError4 = true; - _iteratorError4 = err4; - return [ - 3, - 60 - ]; - case 55: - _state.trys.push([ - 55, - , - 58, - 59 - ]); - if (!(_iteratorAbruptCompletion4 && _iterator4.return != null)) return [ - 3, - 57 - ]; - return [ - 4, - _iterator4.return() - ]; + _iteratorAbruptCompletion2 = false, _didIteratorError2 = false; + _ctx.prev = 54; + _iterator2 = _async_iterator(iterableOfPromise); case 56: - _state.sent(); - _state.label = 57; - case 57: - return [ - 3, - 59 - ]; + _ctx.next = 58; + return _await_async_generator(_iterator2.next()); case 58: - if (_didIteratorError4) { - throw _iteratorError4; + if (!(_iteratorAbruptCompletion2 = !(_step2 = _ctx.sent).done)) { + _ctx.next = 63; + break; + } + { + _value2 = _step2.value; + x2 = _value2; } - return [ - 7 - ]; - case 59: - return [ - 7 - ]; case 60: - _iteratorAbruptCompletion5 = false, _didIteratorError5 = false; - _state.label = 61; - case 61: - _state.trys.push([ - 61, - 66, - 67, - 72 - ]); - _iterator5 = _async_iterator(iterableOfPromise); - _state.label = 62; - case 62: - return [ - 4, - _await_async_generator(_iterator5.next()) - ]; + _iteratorAbruptCompletion2 = false; + _ctx.next = 56; + break; case 63: - if (!(_iteratorAbruptCompletion5 = !(_step5 = _state.sent()).done)) return [ - 3, - 65 - ]; - _value5 = _step5.value; - y = _value5; - _state.label = 64; - case 64: - _iteratorAbruptCompletion5 = false; - return [ - 3, - 62 - ]; + _ctx.next = 69; + break; case 65: - return [ - 3, - 72 - ]; - case 66: - err5 = _state.sent(); - _didIteratorError5 = true; - _iteratorError5 = err5; - return [ - 3, - 72 - ]; - case 67: - _state.trys.push([ - 67, - , - 70, - 71 - ]); - if (!(_iteratorAbruptCompletion5 && _iterator5.return != null)) return [ - 3, - 69 - ]; - return [ - 4, - _iterator5.return() - ]; - case 68: - _state.sent(); - _state.label = 69; + _ctx.prev = 65; + _ctx.t2 = _ctx["catch"](54); + _didIteratorError2 = true; + _iteratorError2 = _ctx.t2; case 69: - return [ - 3, - 71 - ]; - case 70: - if (_didIteratorError5) { - throw _iteratorError5; + _ctx.prev = 69; + _ctx.prev = 70; + if (!(_iteratorAbruptCompletion2 && _iterator2.return != null)) { + _ctx.next = 74; + break; } - return [ - 7 - ]; - case 71: - return [ - 7 - ]; - case 72: - return [ - 2 - ]; + _ctx.next = 74; + return _iterator2.return(); + case 74: + _ctx.prev = 74; + if (!_didIteratorError2) { + _ctx.next = 77; + break; + } + throw _iteratorError2; + case 77: + return _ctx.finish(74); + case 78: + return _ctx.finish(69); + case 79: + _iteratorAbruptCompletion3 = false, _didIteratorError3 = false; + _ctx.prev = 80; + _iterator3 = _async_iterator(asyncIterable); + case 82: + _ctx.next = 84; + return _await_async_generator(_iterator3.next()); + case 84: + if (!(_iteratorAbruptCompletion3 = !(_step3 = _ctx.sent).done)) { + _ctx.next = 89; + break; + } + { + _value3 = _step3.value; + y = _value3; + } + case 86: + _iteratorAbruptCompletion3 = false; + _ctx.next = 82; + break; + case 89: + _ctx.next = 95; + break; + case 91: + _ctx.prev = 91; + _ctx.t3 = _ctx["catch"](80); + _didIteratorError3 = true; + _iteratorError3 = _ctx.t3; + case 95: + _ctx.prev = 95; + _ctx.prev = 96; + if (!(_iteratorAbruptCompletion3 && _iterator3.return != null)) { + _ctx.next = 100; + break; + } + _ctx.next = 100; + return _iterator3.return(); + case 100: + _ctx.prev = 100; + if (!_didIteratorError3) { + _ctx.next = 103; + break; + } + throw _iteratorError3; + case 103: + return _ctx.finish(100); + case 104: + return _ctx.finish(95); + case 105: + _iteratorAbruptCompletion4 = false, _didIteratorError4 = false; + _ctx.prev = 106; + _iterator4 = _async_iterator(iterable); + case 108: + _ctx.next = 110; + return _await_async_generator(_iterator4.next()); + case 110: + if (!(_iteratorAbruptCompletion4 = !(_step4 = _ctx.sent).done)) { + _ctx.next = 115; + break; + } + { + _value4 = _step4.value; + y = _value4; + } + case 112: + _iteratorAbruptCompletion4 = false; + _ctx.next = 108; + break; + case 115: + _ctx.next = 121; + break; + case 117: + _ctx.prev = 117; + _ctx.t4 = _ctx["catch"](106); + _didIteratorError4 = true; + _iteratorError4 = _ctx.t4; + case 121: + _ctx.prev = 121; + _ctx.prev = 122; + if (!(_iteratorAbruptCompletion4 && _iterator4.return != null)) { + _ctx.next = 126; + break; + } + _ctx.next = 126; + return _iterator4.return(); + case 126: + _ctx.prev = 126; + if (!_didIteratorError4) { + _ctx.next = 129; + break; + } + throw _iteratorError4; + case 129: + return _ctx.finish(126); + case 130: + return _ctx.finish(121); + case 131: + _iteratorAbruptCompletion5 = false, _didIteratorError5 = false; + _ctx.prev = 132; + _iterator5 = _async_iterator(iterableOfPromise); + case 134: + _ctx.next = 136; + return _await_async_generator(_iterator5.next()); + case 136: + if (!(_iteratorAbruptCompletion5 = !(_step5 = _ctx.sent).done)) { + _ctx.next = 141; + break; + } + { + _value5 = _step5.value; + y = _value5; + } + case 138: + _iteratorAbruptCompletion5 = false; + _ctx.next = 134; + break; + case 141: + _ctx.next = 147; + break; + case 143: + _ctx.prev = 143; + _ctx.t5 = _ctx["catch"](132); + _didIteratorError5 = true; + _iteratorError5 = _ctx.t5; + case 147: + _ctx.prev = 147; + _ctx.prev = 148; + if (!(_iteratorAbruptCompletion5 && _iterator5.return != null)) { + _ctx.next = 152; + break; + } + _ctx.next = 152; + return _iterator5.return(); + case 152: + _ctx.prev = 152; + if (!_didIteratorError5) { + _ctx.next = 155; + break; + } + throw _iteratorError5; + case 155: + return _ctx.finish(152); + case 156: + return _ctx.finish(147); + case 157: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 2, + 13, + 17, + 27 + ], + [ + 18, + , + 22, + 26 + ], + [ + 28, + 39, + 43, + 53 + ], + [ + 44, + , + 48, + 52 + ], + [ + 54, + 65, + 69, + 79 + ], + [ + 70, + , + 74, + 78 + ], + [ + 80, + 91, + 95, + 105 + ], + [ + 96, + , + 100, + 104 + ], + [ + 106, + 117, + 121, + 131 + ], + [ + 122, + , + 126, + 130 + ], + [ + 132, + 143, + 147, + 157 + ], + [ + 148, + , + 152, + 156 + ] + ]); + })); return _f2.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/types.forAwait.es2018.1_es5.2.minified.js b/crates/swc/tests/tsc-references/types.forAwait.es2018.1_es5.2.minified.js index 590a4546c31..01badd98087 100644 --- a/crates/swc/tests/tsc-references/types.forAwait.es2018.1_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/types.forAwait.es2018.1_es5.2.minified.js @@ -2,4 +2,4 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/types.forAwait.es2018.2_es5.1.normal.js b/crates/swc/tests/tsc-references/types.forAwait.es2018.2_es5.1.normal.js index ff35c84cdba..b9e649234a6 100644 --- a/crates/swc/tests/tsc-references/types.forAwait.es2018.2_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/types.forAwait.es2018.2_es5.1.normal.js @@ -3,373 +3,347 @@ // @noEmit: true import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f() { return _f.apply(this, arguments); } function _f() { - _f = _async_to_generator(function() { - var y, z, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _tmp, _value, x, err, _iteratorAbruptCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _tmp1, _value1, err1, _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, err2, _iteratorAbruptCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _value3, err3, _iteratorNormalCompletion, _didIteratorError4, _iteratorError4, _iterator4, _step4, x1, _iteratorNormalCompletion1, _didIteratorError5, _iteratorError5, _iterator5, _step5; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var y, z, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, _iteratorAbruptCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value1, _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, _iteratorAbruptCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _value3, _iteratorNormalCompletion, _didIteratorError4, _iteratorError4, _iterator4, _step4, x1, _iteratorNormalCompletion1, _didIteratorError5, _iteratorError5, _iterator5, _step5; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: + ; + ; _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); - _tmp = {}; - _iterator = _async_iterator(_tmp); - _state.label = 2; - case 2: - return [ - 4, - _iterator.next() - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - x = _value; - _state.label = 4; - case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; + _ctx.prev = 3; + _iterator = _async_iterator({}); case 5: - return [ - 3, - 12 - ]; - case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; + _ctx.next = 7; + return _iterator.next(); case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; - case 8: - _state.sent(); - _state.label = 9; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 12; + break; + } + { + _value = _step.value; + x = _value; + } case 9: - return [ - 3, - 11 - ]; - case 10: - if (_didIteratorError) { - throw _iteratorError; - } - return [ - 7 - ]; - case 11: - return [ - 7 - ]; + _iteratorAbruptCompletion = false; + _ctx.next = 5; + break; case 12: - _iteratorAbruptCompletion1 = false, _didIteratorError1 = false; - _state.label = 13; - case 13: - _state.trys.push([ - 13, - 18, - 19, - 24 - ]); - _tmp1 = {}; - _iterator1 = _async_iterator(_tmp1); - _state.label = 14; + _ctx.next = 18; + break; case 14: - return [ - 4, - _iterator1.next() - ]; - case 15: - if (!(_iteratorAbruptCompletion1 = !(_step1 = _state.sent()).done)) return [ - 3, - 17 - ]; - _value1 = _step1.value; - y = _value1; - _state.label = 16; - case 16: - _iteratorAbruptCompletion1 = false; - return [ - 3, - 14 - ]; - case 17: - return [ - 3, - 24 - ]; + _ctx.prev = 14; + _ctx.t0 = _ctx["catch"](3); + _didIteratorError = true; + _iteratorError = _ctx.t0; case 18: - err1 = _state.sent(); - _didIteratorError1 = true; - _iteratorError1 = err1; - return [ - 3, - 24 - ]; - case 19: - _state.trys.push([ - 19, - , - 22, - 23 - ]); - if (!(_iteratorAbruptCompletion1 && _iterator1.return != null)) return [ - 3, - 21 - ]; - return [ - 4, - _iterator1.return() - ]; - case 20: - _state.sent(); - _state.label = 21; - case 21: - return [ - 3, - 23 - ]; - case 22: - if (_didIteratorError1) { - throw _iteratorError1; + _ctx.prev = 18; + _ctx.prev = 19; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 23; + break; } - return [ - 7 - ]; + _ctx.next = 23; + return _iterator.return(); case 23: - return [ - 7 - ]; - case 24: - _iteratorAbruptCompletion2 = false, _didIteratorError2 = false; - _state.label = 25; - case 25: - _state.trys.push([ - 25, - 30, - 31, - 36 - ]); - _iterator2 = _async_iterator(asyncIterable); - _state.label = 26; + _ctx.prev = 23; + if (!_didIteratorError) { + _ctx.next = 26; + break; + } + throw _iteratorError; case 26: - return [ - 4, - _iterator2.next() - ]; + return _ctx.finish(23); case 27: - if (!(_iteratorAbruptCompletion2 = !(_step2 = _state.sent()).done)) return [ - 3, - 29 - ]; - _value2 = _step2.value; - z = _value2; - _state.label = 28; + return _ctx.finish(18); case 28: - _iteratorAbruptCompletion2 = false; - return [ - 3, - 26 - ]; - case 29: - return [ - 3, - 36 - ]; - case 30: - err2 = _state.sent(); - _didIteratorError2 = true; - _iteratorError2 = err2; - return [ - 3, - 36 - ]; + _iteratorAbruptCompletion1 = false, _didIteratorError1 = false; + _ctx.prev = 29; + _iterator1 = _async_iterator({}); case 31: - _state.trys.push([ - 31, - , - 34, - 35 - ]); - if (!(_iteratorAbruptCompletion2 && _iterator2.return != null)) return [ - 3, - 33 - ]; - return [ - 4, - _iterator2.return() - ]; - case 32: - _state.sent(); - _state.label = 33; + _ctx.next = 33; + return _iterator1.next(); case 33: - return [ - 3, - 35 - ]; - case 34: - if (_didIteratorError2) { - throw _iteratorError2; + if (!(_iteratorAbruptCompletion1 = !(_step1 = _ctx.sent).done)) { + _ctx.next = 38; + break; + } + { + _value1 = _step1.value; + y = _value1; } - return [ - 7 - ]; case 35: - return [ - 7 - ]; - case 36: - _iteratorAbruptCompletion3 = false, _didIteratorError3 = false; - _state.label = 37; - case 37: - _state.trys.push([ - 37, - 42, - 43, - 48 - ]); - _iterator3 = _async_iterator(iterable); - _state.label = 38; + _iteratorAbruptCompletion1 = false; + _ctx.next = 31; + break; case 38: - return [ - 4, - _iterator3.next() - ]; - case 39: - if (!(_iteratorAbruptCompletion3 = !(_step3 = _state.sent()).done)) return [ - 3, - 41 - ]; - _value3 = _step3.value; - z = _value3; - _state.label = 40; + _ctx.next = 44; + break; case 40: - _iteratorAbruptCompletion3 = false; - return [ - 3, - 38 - ]; - case 41: - return [ - 3, - 48 - ]; - case 42: - err3 = _state.sent(); - _didIteratorError3 = true; - _iteratorError3 = err3; - return [ - 3, - 48 - ]; - case 43: - _state.trys.push([ - 43, - , - 46, - 47 - ]); - if (!(_iteratorAbruptCompletion3 && _iterator3.return != null)) return [ - 3, - 45 - ]; - return [ - 4, - _iterator3.return() - ]; + _ctx.prev = 40; + _ctx.t1 = _ctx["catch"](29); + _didIteratorError1 = true; + _iteratorError1 = _ctx.t1; case 44: - _state.sent(); - _state.label = 45; - case 45: - return [ - 3, - 47 - ]; - case 46: - if (_didIteratorError3) { - throw _iteratorError3; + _ctx.prev = 44; + _ctx.prev = 45; + if (!(_iteratorAbruptCompletion1 && _iterator1.return != null)) { + _ctx.next = 49; + break; } - return [ - 7 - ]; - case 47: - return [ - 7 - ]; - case 48: + _ctx.next = 49; + return _iterator1.return(); + case 49: + _ctx.prev = 49; + if (!_didIteratorError1) { + _ctx.next = 52; + break; + } + throw _iteratorError1; + case 52: + return _ctx.finish(49); + case 53: + return _ctx.finish(44); + case 54: + _iteratorAbruptCompletion2 = false, _didIteratorError2 = false; + _ctx.prev = 55; + _iterator2 = _async_iterator(asyncIterable); + case 57: + _ctx.next = 59; + return _iterator2.next(); + case 59: + if (!(_iteratorAbruptCompletion2 = !(_step2 = _ctx.sent).done)) { + _ctx.next = 64; + break; + } + { + _value2 = _step2.value; + z = _value2; + } + case 61: + _iteratorAbruptCompletion2 = false; + _ctx.next = 57; + break; + case 64: + _ctx.next = 70; + break; + case 66: + _ctx.prev = 66; + _ctx.t2 = _ctx["catch"](55); + _didIteratorError2 = true; + _iteratorError2 = _ctx.t2; + case 70: + _ctx.prev = 70; + _ctx.prev = 71; + if (!(_iteratorAbruptCompletion2 && _iterator2.return != null)) { + _ctx.next = 75; + break; + } + _ctx.next = 75; + return _iterator2.return(); + case 75: + _ctx.prev = 75; + if (!_didIteratorError2) { + _ctx.next = 78; + break; + } + throw _iteratorError2; + case 78: + return _ctx.finish(75); + case 79: + return _ctx.finish(70); + case 80: + _iteratorAbruptCompletion3 = false, _didIteratorError3 = false; + _ctx.prev = 81; + _iterator3 = _async_iterator(iterable); + case 83: + _ctx.next = 85; + return _iterator3.next(); + case 85: + if (!(_iteratorAbruptCompletion3 = !(_step3 = _ctx.sent).done)) { + _ctx.next = 90; + break; + } + { + _value3 = _step3.value; + z = _value3; + } + case 87: + _iteratorAbruptCompletion3 = false; + _ctx.next = 83; + break; + case 90: + _ctx.next = 96; + break; + case 92: + _ctx.prev = 92; + _ctx.t3 = _ctx["catch"](81); + _didIteratorError3 = true; + _iteratorError3 = _ctx.t3; + case 96: + _ctx.prev = 96; + _ctx.prev = 97; + if (!(_iteratorAbruptCompletion3 && _iterator3.return != null)) { + _ctx.next = 101; + break; + } + _ctx.next = 101; + return _iterator3.return(); + case 101: + _ctx.prev = 101; + if (!_didIteratorError3) { + _ctx.next = 104; + break; + } + throw _iteratorError3; + case 104: + return _ctx.finish(101); + case 105: + return _ctx.finish(96); + case 106: _iteratorNormalCompletion = true, _didIteratorError4 = false, _iteratorError4 = undefined; - try { - for(_iterator4 = asyncIterable[Symbol.iterator](); !(_iteratorNormalCompletion = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion = true){ - x1 = _step4.value; - } - } catch (err4) { - _didIteratorError4 = true; - _iteratorError4 = err4; - } finally{ - try { - if (!_iteratorNormalCompletion && _iterator4.return != null) { - _iterator4.return(); - } - } finally{ - if (_didIteratorError4) { - throw _iteratorError4; - } - } + _ctx.prev = 107; + for(_iterator4 = asyncIterable[Symbol.iterator](); !(_iteratorNormalCompletion = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion = true){ + x1 = _step4.value; } + _ctx.next = 115; + break; + case 111: + _ctx.prev = 111; + _ctx.t4 = _ctx["catch"](107); + _didIteratorError4 = true; + _iteratorError4 = _ctx.t4; + case 115: + _ctx.prev = 115; + _ctx.prev = 116; + if (!_iteratorNormalCompletion && _iterator4.return != null) { + _iterator4.return(); + } + case 118: + _ctx.prev = 118; + if (!_didIteratorError4) { + _ctx.next = 121; + break; + } + throw _iteratorError4; + case 121: + return _ctx.finish(118); + case 122: + return _ctx.finish(115); + case 123: _iteratorNormalCompletion1 = true, _didIteratorError5 = false, _iteratorError5 = undefined; - try { - for(_iterator5 = asyncIterable[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion1 = true){ - y = _step5.value; - } - } catch (err4) { - _didIteratorError5 = true; - _iteratorError5 = err4; - } finally{ - try { - if (!_iteratorNormalCompletion1 && _iterator5.return != null) { - _iterator5.return(); - } - } finally{ - if (_didIteratorError5) { - throw _iteratorError5; - } - } + _ctx.prev = 124; + for(_iterator5 = asyncIterable[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion1 = true){ + y = _step5.value; } - return [ - 2 - ]; + _ctx.next = 132; + break; + case 128: + _ctx.prev = 128; + _ctx.t5 = _ctx["catch"](124); + _didIteratorError5 = true; + _iteratorError5 = _ctx.t5; + case 132: + _ctx.prev = 132; + _ctx.prev = 133; + if (!_iteratorNormalCompletion1 && _iterator5.return != null) { + _iterator5.return(); + } + case 135: + _ctx.prev = 135; + if (!_didIteratorError5) { + _ctx.next = 138; + break; + } + throw _iteratorError5; + case 138: + return _ctx.finish(135); + case 139: + return _ctx.finish(132); + case 140: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 3, + 14, + 18, + 28 + ], + [ + 19, + , + 23, + 27 + ], + [ + 29, + 40, + 44, + 54 + ], + [ + 45, + , + 49, + 53 + ], + [ + 55, + 66, + 70, + 80 + ], + [ + 71, + , + 75, + 79 + ], + [ + 81, + 92, + 96, + 106 + ], + [ + 97, + , + 101, + 105 + ], + [ + 107, + 111, + 115, + 123 + ], + [ + 116, + , + 118, + 122 + ], + [ + 124, + 128, + 132, + 140 + ], + [ + 133, + , + 135, + 139 + ] + ]); + })); return _f.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/types.forAwait.es2018.2_es5.2.minified.js b/crates/swc/tests/tsc-references/types.forAwait.es2018.2_es5.2.minified.js index 37d964a0b01..500bf52381a 100644 --- a/crates/swc/tests/tsc-references/types.forAwait.es2018.2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/types.forAwait.es2018.2_es5.2.minified.js @@ -1,3 +1,3 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/types.forAwait.es2018.3_es5.1.normal.js b/crates/swc/tests/tsc-references/types.forAwait.es2018.3_es5.1.normal.js index 369adaad187..f86dd154e57 100644 --- a/crates/swc/tests/tsc-references/types.forAwait.es2018.3_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/types.forAwait.es2018.3_es5.1.normal.js @@ -5,354 +5,280 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; function f1() { return _f1.apply(this, arguments); } function _f1() { - _f1 = _async_to_generator(function() { - var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _tmp, _value, x, err, _iteratorAbruptCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _tmp1, _value1, err1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f1 = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, _iteratorAbruptCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value1; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: + ; _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); - _tmp = {}; - _iterator = _async_iterator(_tmp); - _state.label = 2; - case 2: - return [ - 4, - _iterator.next() - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - x = _value; - _state.label = 4; + _ctx.prev = 2; + _iterator = _async_iterator({}); case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 12 - ]; + _ctx.next = 6; + return _iterator.next(); case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; - case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 11; + break; + } + { + _value = _step.value; + x = _value; + } case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; - case 10: - if (_didIteratorError) { - throw _iteratorError; - } - return [ - 7 - ]; + _iteratorAbruptCompletion = false; + _ctx.next = 4; + break; case 11: - return [ - 7 - ]; - case 12: - _iteratorAbruptCompletion1 = false, _didIteratorError1 = false; - _state.label = 13; + _ctx.next = 17; + break; case 13: - _state.trys.push([ - 13, - 18, - 19, - 24 - ]); - _tmp1 = {}; - _iterator1 = _async_iterator(_tmp1); - _state.label = 14; - case 14: - return [ - 4, - _iterator1.next() - ]; - case 15: - if (!(_iteratorAbruptCompletion1 = !(_step1 = _state.sent()).done)) return [ - 3, - 17 - ]; - _value1 = _step1.value; - y = _value1; - _state.label = 16; - case 16: - _iteratorAbruptCompletion1 = false; - return [ - 3, - 14 - ]; + _ctx.prev = 13; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; case 17: - return [ - 3, - 24 - ]; - case 18: - err1 = _state.sent(); - _didIteratorError1 = true; - _iteratorError1 = err1; - return [ - 3, - 24 - ]; - case 19: - _state.trys.push([ - 19, - , - 22, - 23 - ]); - if (!(_iteratorAbruptCompletion1 && _iterator1.return != null)) return [ - 3, - 21 - ]; - return [ - 4, - _iterator1.return() - ]; - case 20: - _state.sent(); - _state.label = 21; - case 21: - return [ - 3, - 23 - ]; - case 22: - if (_didIteratorError1) { - throw _iteratorError1; + _ctx.prev = 17; + _ctx.prev = 18; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 22; + break; } - return [ - 7 - ]; - case 23: - return [ - 7 - ]; - case 24: - return [ - 2 - ]; + _ctx.next = 22; + return _iterator.return(); + case 22: + _ctx.prev = 22; + if (!_didIteratorError) { + _ctx.next = 25; + break; + } + throw _iteratorError; + case 25: + return _ctx.finish(22); + case 26: + return _ctx.finish(17); + case 27: + _iteratorAbruptCompletion1 = false, _didIteratorError1 = false; + _ctx.prev = 28; + _iterator1 = _async_iterator({}); + case 30: + _ctx.next = 32; + return _iterator1.next(); + case 32: + if (!(_iteratorAbruptCompletion1 = !(_step1 = _ctx.sent).done)) { + _ctx.next = 37; + break; + } + { + _value1 = _step1.value; + y = _value1; + } + case 34: + _iteratorAbruptCompletion1 = false; + _ctx.next = 30; + break; + case 37: + _ctx.next = 43; + break; + case 39: + _ctx.prev = 39; + _ctx.t1 = _ctx["catch"](28); + _didIteratorError1 = true; + _iteratorError1 = _ctx.t1; + case 43: + _ctx.prev = 43; + _ctx.prev = 44; + if (!(_iteratorAbruptCompletion1 && _iterator1.return != null)) { + _ctx.next = 48; + break; + } + _ctx.next = 48; + return _iterator1.return(); + case 48: + _ctx.prev = 48; + if (!_didIteratorError1) { + _ctx.next = 51; + break; + } + throw _iteratorError1; + case 51: + return _ctx.finish(48); + case 52: + return _ctx.finish(43); + case 53: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 2, + 13, + 17, + 27 + ], + [ + 18, + , + 22, + 26 + ], + [ + 28, + 39, + 43, + 53 + ], + [ + 44, + , + 48, + 52 + ] + ]); + })); return _f1.apply(this, arguments); } function f2() { return _f2.apply(this, arguments); } function _f2() { - _f2 = _wrap_async_generator(function() { - var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _tmp, _value, x, err, _iteratorAbruptCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _tmp1, _value1, err1; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _f2 = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + var y, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, x, _iteratorAbruptCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value1; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: + ; _iteratorAbruptCompletion = false, _didIteratorError = false; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 6, - 7, - 12 - ]); - _tmp = {}; - _iterator = _async_iterator(_tmp); - _state.label = 2; - case 2: - return [ - 4, - _await_async_generator(_iterator.next()) - ]; - case 3: - if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [ - 3, - 5 - ]; - _value = _step.value; - x = _value; - _state.label = 4; + _ctx.prev = 2; + _iterator = _async_iterator({}); case 4: - _iteratorAbruptCompletion = false; - return [ - 3, - 2 - ]; - case 5: - return [ - 3, - 12 - ]; + _ctx.next = 6; + return _await_async_generator(_iterator.next()); case 6: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 12 - ]; - case 7: - _state.trys.push([ - 7, - , - 10, - 11 - ]); - if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [ - 3, - 9 - ]; - return [ - 4, - _iterator.return() - ]; + if (!(_iteratorAbruptCompletion = !(_step = _ctx.sent).done)) { + _ctx.next = 11; + break; + } + { + _value = _step.value; + x = _value; + } case 8: - _state.sent(); - _state.label = 9; - case 9: - return [ - 3, - 11 - ]; - case 10: - if (_didIteratorError) { - throw _iteratorError; - } - return [ - 7 - ]; + _iteratorAbruptCompletion = false; + _ctx.next = 4; + break; case 11: - return [ - 7 - ]; - case 12: - _iteratorAbruptCompletion1 = false, _didIteratorError1 = false; - _state.label = 13; + _ctx.next = 17; + break; case 13: - _state.trys.push([ - 13, - 18, - 19, - 24 - ]); - _tmp1 = {}; - _iterator1 = _async_iterator(_tmp1); - _state.label = 14; - case 14: - return [ - 4, - _await_async_generator(_iterator1.next()) - ]; - case 15: - if (!(_iteratorAbruptCompletion1 = !(_step1 = _state.sent()).done)) return [ - 3, - 17 - ]; - _value1 = _step1.value; - y = _value1; - _state.label = 16; - case 16: - _iteratorAbruptCompletion1 = false; - return [ - 3, - 14 - ]; + _ctx.prev = 13; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; case 17: - return [ - 3, - 24 - ]; - case 18: - err1 = _state.sent(); - _didIteratorError1 = true; - _iteratorError1 = err1; - return [ - 3, - 24 - ]; - case 19: - _state.trys.push([ - 19, - , - 22, - 23 - ]); - if (!(_iteratorAbruptCompletion1 && _iterator1.return != null)) return [ - 3, - 21 - ]; - return [ - 4, - _iterator1.return() - ]; - case 20: - _state.sent(); - _state.label = 21; - case 21: - return [ - 3, - 23 - ]; - case 22: - if (_didIteratorError1) { - throw _iteratorError1; + _ctx.prev = 17; + _ctx.prev = 18; + if (!(_iteratorAbruptCompletion && _iterator.return != null)) { + _ctx.next = 22; + break; } - return [ - 7 - ]; - case 23: - return [ - 7 - ]; - case 24: - return [ - 2 - ]; + _ctx.next = 22; + return _iterator.return(); + case 22: + _ctx.prev = 22; + if (!_didIteratorError) { + _ctx.next = 25; + break; + } + throw _iteratorError; + case 25: + return _ctx.finish(22); + case 26: + return _ctx.finish(17); + case 27: + _iteratorAbruptCompletion1 = false, _didIteratorError1 = false; + _ctx.prev = 28; + _iterator1 = _async_iterator({}); + case 30: + _ctx.next = 32; + return _await_async_generator(_iterator1.next()); + case 32: + if (!(_iteratorAbruptCompletion1 = !(_step1 = _ctx.sent).done)) { + _ctx.next = 37; + break; + } + { + _value1 = _step1.value; + y = _value1; + } + case 34: + _iteratorAbruptCompletion1 = false; + _ctx.next = 30; + break; + case 37: + _ctx.next = 43; + break; + case 39: + _ctx.prev = 39; + _ctx.t1 = _ctx["catch"](28); + _didIteratorError1 = true; + _iteratorError1 = _ctx.t1; + case 43: + _ctx.prev = 43; + _ctx.prev = 44; + if (!(_iteratorAbruptCompletion1 && _iterator1.return != null)) { + _ctx.next = 48; + break; + } + _ctx.next = 48; + return _iterator1.return(); + case 48: + _ctx.prev = 48; + if (!_didIteratorError1) { + _ctx.next = 51; + break; + } + throw _iteratorError1; + case 51: + return _ctx.finish(48); + case 52: + return _ctx.finish(43); + case 53: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 2, + 13, + 17, + 27 + ], + [ + 18, + , + 22, + 26 + ], + [ + 28, + 39, + 43, + 53 + ], + [ + 44, + , + 48, + 52 + ] + ]); + })); return _f2.apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/types.forAwait.es2018.3_es5.2.minified.js b/crates/swc/tests/tsc-references/types.forAwait.es2018.3_es5.2.minified.js index 590a4546c31..01badd98087 100644 --- a/crates/swc/tests/tsc-references/types.forAwait.es2018.3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/types.forAwait.es2018.3_es5.2.minified.js @@ -2,4 +2,4 @@ import _async_iterator from "@swc/helpers/src/_async_iterator.mjs"; import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _await_async_generator from "@swc/helpers/src/_await_async_generator.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/tsc-references/unionAndIntersectionInference3_es5.1.normal.js b/crates/swc/tests/tsc-references/unionAndIntersectionInference3_es5.1.normal.js index b68224c8af4..ebc1faf50a6 100644 --- a/crates/swc/tests/tsc-references/unionAndIntersectionInference3_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/unionAndIntersectionInference3_es5.1.normal.js @@ -2,7 +2,7 @@ // @target: esnext // Repro from #30720 import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; concatMaybe([ 1, 2, @@ -10,11 +10,17 @@ concatMaybe([ ], 4); // Repros from #32247 var g = function() { - var _ref = _async_to_generator(function(com) { - return _ts_generator(this, function(_state) { - throw com; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(com) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + throw com; + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function g(com) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/tsc-references/unionAndIntersectionInference3_es5.2.minified.js b/crates/swc/tests/tsc-references/unionAndIntersectionInference3_es5.2.minified.js index 097fae82e6f..1d3d8c0270b 100644 --- a/crates/swc/tests/tsc-references/unionAndIntersectionInference3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/unionAndIntersectionInference3_es5.2.minified.js @@ -1,5 +1,5 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; concatMaybe([ 1, 2, diff --git a/crates/swc/tests/tsc-references/unionTypeInference_es5.1.normal.js b/crates/swc/tests/tsc-references/unionTypeInference_es5.1.normal.js index 744668725ba..061192d28d3 100644 --- a/crates/swc/tests/tsc-references/unionTypeInference_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/unionTypeInference_es5.1.normal.js @@ -1,7 +1,7 @@ // @strict: true // @target: esnext import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var a1 = f1(1, 2); // 1 | 2 var a2 = f1(1, "hello"); // 1 var a3 = f1(1, sn); // number @@ -32,85 +32,79 @@ function fun(deepPromised) { return _fun.apply(this, arguments); } function _fun() { - _fun = _async_to_generator(function(deepPromised) { - var deepPromisedWithIndexer, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, value, awaitedValue, err; - return _ts_generator(this, function(_state) { - switch(_state.label){ + _fun = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(deepPromised) { + var deepPromisedWithIndexer, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, value, awaitedValue; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: deepPromisedWithIndexer = deepPromised; _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - _state.label = 1; - case 1: - _state.trys.push([ - 1, - 7, - 8, - 9 - ]); + _ctx.prev = 2; _iterator = Object.values(deepPromisedWithIndexer)[Symbol.iterator](); - _state.label = 2; - case 2: - if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [ - 3, - 6 - ]; - value = _step.value; - return [ - 4, - value - ]; - case 3: - awaitedValue = _state.sent(); - if (!awaitedValue) return [ - 3, - 5 - ]; - return [ - 4, - fun(awaitedValue) - ]; case 4: - _state.sent(); - _state.label = 5; - case 5: - _iteratorNormalCompletion = true; - return [ - 3, - 2 - ]; - case 6: - return [ - 3, - 9 - ]; - case 7: - err = _state.sent(); - _didIteratorError = true; - _iteratorError = err; - return [ - 3, - 9 - ]; - case 8: - try { - if (!_iteratorNormalCompletion && _iterator.return != null) { - _iterator.return(); - } - } finally{ - if (_didIteratorError) { - throw _iteratorError; - } + if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { + _ctx.next = 15; + break; } - return [ - 7 - ]; - case 9: - return [ - 2 - ]; + value = _step.value; + _ctx.next = 8; + return value; + case 8: + awaitedValue = _ctx.sent; + if (!awaitedValue) { + _ctx.next = 12; + break; + } + _ctx.next = 12; + return fun(awaitedValue); + case 12: + _iteratorNormalCompletion = true; + _ctx.next = 4; + break; + case 15: + _ctx.next = 21; + break; + case 17: + _ctx.prev = 17; + _ctx.t0 = _ctx["catch"](2); + _didIteratorError = true; + _iteratorError = _ctx.t0; + case 21: + _ctx.prev = 21; + _ctx.prev = 22; + if (!_iteratorNormalCompletion && _iterator.return != null) { + _iterator.return(); + } + case 24: + _ctx.prev = 24; + if (!_didIteratorError) { + _ctx.next = 27; + break; + } + throw _iteratorError; + case 27: + return _ctx.finish(24); + case 28: + return _ctx.finish(21); + case 29: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee, null, [ + [ + 2, + 17, + 21, + 29 + ], + [ + 22, + , + 24, + 28 + ] + ]); + })); return _fun.apply(this, arguments); } baz(xx); diff --git a/crates/swc/tests/tsc-references/unionTypeInference_es5.2.minified.js b/crates/swc/tests/tsc-references/unionTypeInference_es5.2.minified.js index e548b4ef9f7..e5767df31c6 100644 --- a/crates/swc/tests/tsc-references/unionTypeInference_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/unionTypeInference_es5.2.minified.js @@ -1,5 +1,67 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +function fun(deepPromised) { + return _fun.apply(this, arguments); +} +function _fun() { + return (_fun = _async_to_generator(regeneratorRuntime.mark(function _callee(deepPromised) { + var deepPromisedWithIndexer, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, value, awaitedValue; + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + deepPromisedWithIndexer = deepPromised, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0, _ctx.prev = 2, _iterator = Object.values(deepPromisedWithIndexer)[Symbol.iterator](); + case 4: + if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { + _ctx.next = 15; + break; + } + return value = _step.value, _ctx.next = 8, value; + case 8: + if (!(awaitedValue = _ctx.sent)) { + _ctx.next = 12; + break; + } + return _ctx.next = 12, fun(awaitedValue); + case 12: + _iteratorNormalCompletion = !0, _ctx.next = 4; + break; + case 15: + _ctx.next = 21; + break; + case 17: + _ctx.prev = 17, _ctx.t0 = _ctx.catch(2), _didIteratorError = !0, _iteratorError = _ctx.t0; + case 21: + _ctx.prev = 21, _ctx.prev = 22, _iteratorNormalCompletion || null == _iterator.return || _iterator.return(); + case 24: + if (_ctx.prev = 24, !_didIteratorError) { + _ctx.next = 27; + break; + } + throw _iteratorError; + case 27: + return _ctx.finish(24); + case 28: + return _ctx.finish(21); + case 29: + case "end": + return _ctx.stop(); + } + }, _callee, null, [ + [ + 2, + 17, + 21, + 29 + ], + [ + 22, + , + 24, + 28 + ] + ]); + }))).apply(this, arguments); +} f1(1, 2), f1(1, "hello"), f1(1, sn), f1(void 0, "abc"), f1("foo", "bar"), f1(!0, !1), f1("hello", 1), f2([ "string", !0 diff --git a/crates/swc/tests/tsc-references/uniqueSymbolsDeclarations_es5.1.normal.js b/crates/swc/tests/tsc-references/uniqueSymbolsDeclarations_es5.1.normal.js index 51651c21bdb..ca2cda7a8e9 100644 --- a/crates/swc/tests/tsc-references/uniqueSymbolsDeclarations_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/uniqueSymbolsDeclarations_es5.1.normal.js @@ -7,7 +7,11 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _define_property from "@swc/helpers/src/_define_property.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(genFuncYieldConstCallWithTypeQuery); +var _marked1 = /*#__PURE__*/ regeneratorRuntime.mark(genFuncYieldVarCall); +var _marked2 = /*#__PURE__*/ regeneratorRuntime.mark(genFuncYieldLetCall); +var _marked3 = /*#__PURE__*/ regeneratorRuntime.mark(genFuncYieldConstCall); var constCall = Symbol(); var letCall = Symbol(); var varCall = Symbol(); @@ -45,111 +49,104 @@ function funcReturnConstCallWithTypeQuery() { } // generator function yield inference function genFuncYieldConstCall() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function genFuncYieldConstCall$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - constCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return constCall; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked3); } function genFuncYieldLetCall() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function genFuncYieldLetCall$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - letCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return letCall; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked2); } function genFuncYieldVarCall() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function genFuncYieldVarCall$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - varCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return varCall; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked1); } // generator function yield with return type query function genFuncYieldConstCallWithTypeQuery() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function genFuncYieldConstCallWithTypeQuery$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - constCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return constCall; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } function asyncFuncReturnConstCall() { return _asyncFuncReturnConstCall.apply(this, arguments); } function _asyncFuncReturnConstCall() { _asyncFuncReturnConstCall = // async function return inference - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - constCall - ]; - }); - }); + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", constCall); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _asyncFuncReturnConstCall.apply(this, arguments); } function asyncFuncReturnLetCall() { return _asyncFuncReturnLetCall.apply(this, arguments); } function _asyncFuncReturnLetCall() { - _asyncFuncReturnLetCall = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - letCall - ]; - }); - }); + _asyncFuncReturnLetCall = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", letCall); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _asyncFuncReturnLetCall.apply(this, arguments); } function asyncFuncReturnVarCall() { return _asyncFuncReturnVarCall.apply(this, arguments); } function _asyncFuncReturnVarCall() { - _asyncFuncReturnVarCall = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - varCall - ]; - }); - }); + _asyncFuncReturnVarCall = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", varCall); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _asyncFuncReturnVarCall.apply(this, arguments); } function asyncGenFuncYieldConstCall() { @@ -157,66 +154,54 @@ function asyncGenFuncYieldConstCall() { } function _asyncGenFuncYieldConstCall() { _asyncGenFuncYieldConstCall = // async generator function yield inference - _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - constCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return constCall; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _asyncGenFuncYieldConstCall.apply(this, arguments); } function asyncGenFuncYieldLetCall() { return _asyncGenFuncYieldLetCall.apply(this, arguments); } function _asyncGenFuncYieldLetCall() { - _asyncGenFuncYieldLetCall = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _asyncGenFuncYieldLetCall = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - letCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return letCall; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _asyncGenFuncYieldLetCall.apply(this, arguments); } function asyncGenFuncYieldVarCall() { return _asyncGenFuncYieldVarCall.apply(this, arguments); } function _asyncGenFuncYieldVarCall() { - _asyncGenFuncYieldVarCall = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _asyncGenFuncYieldVarCall = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - varCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return varCall; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _asyncGenFuncYieldVarCall.apply(this, arguments); } // classes @@ -281,49 +266,44 @@ var o2 = { return s; }, method2: function method2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - s - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", s); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, method3: function method3() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return s; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, - method4: function method4() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + method4: /*#__PURE__*/ regeneratorRuntime.mark(function method4() { + return regeneratorRuntime.wrap(function method4$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return s; + case 2: + case "end": + return _ctx.stop(); } - }); - }, + }, method4); + }), method5: function method5() { var p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : s; return p; @@ -346,49 +326,44 @@ var C0 = /*#__PURE__*/ function() { return s; }; _proto.method2 = function method2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - s - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", s); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.method3 = function method3() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return s; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; - _proto.method4 = function method4() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _proto.method4 = /*#__PURE__*/ regeneratorRuntime.mark(function method4() { + return regeneratorRuntime.wrap(function method4$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return s; + case 2: + case "end": + return _ctx.stop(); } - }); - }; + }, method4); + }); _proto.method5 = function method5() { var p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : s; return p; @@ -433,49 +408,44 @@ var o4 = { return s; // return type should not widen due to contextual type }, method2: function method2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - s - ]; // return type should not widen due to contextual type - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", s); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, method3: function method3() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - _state.sent(); // yield type should not widen due to contextual type - return [ - 2 - ]; + _ctx.next = 2; + return s; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, - method4: function method4() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + method4: /*#__PURE__*/ regeneratorRuntime.mark(function method4() { + return regeneratorRuntime.wrap(function method4$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - _state.sent(); // yield type should not widen due to contextual type - return [ - 2 - ]; + _ctx.next = 2; + return s; + case 2: + case "end": + return _ctx.stop(); } - }); - }, + }, method4); + }), method5: function method5() { var p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : s; return p; diff --git a/crates/swc/tests/tsc-references/uniqueSymbolsDeclarations_es5.2.minified.js b/crates/swc/tests/tsc-references/uniqueSymbolsDeclarations_es5.2.minified.js index 91b80f8aaea..42819080ce8 100644 --- a/crates/swc/tests/tsc-references/uniqueSymbolsDeclarations_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/uniqueSymbolsDeclarations_es5.2.minified.js @@ -2,7 +2,7 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _define_property from "@swc/helpers/src/_define_property.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var _obj, constCall = Symbol(); Symbol(), Symbol(), Symbol(); var C = function C() { @@ -19,45 +19,40 @@ var C0 = function() { return _proto.method1 = function() { return s; }, _proto.method2 = function() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - s - ]; - }); - })(); - }, _proto.method3 = function() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return _async_to_generator(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; + return _ctx.abrupt("return", s); case 1: - return _state.sent(), [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - })(); - }, _proto.method4 = function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + }, _callee); + }))(); + }, _proto.method3 = function() { + return _wrap_async_generator(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.next = 2, s; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); + }, _proto.method4 = regeneratorRuntime.mark(function method4() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - return _state.sent(), [ - 2 - ]; + return _ctx.next = 2, s; + case 2: + case "end": + return _ctx.stop(); } - }); - }, _proto.method5 = function() { + }, method4); + }), _proto.method5 = function() { var p = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : s; return p; }, C0; diff --git a/crates/swc/tests/tsc-references/uniqueSymbols_es5.1.normal.js b/crates/swc/tests/tsc-references/uniqueSymbols_es5.1.normal.js index bd141ad9e13..d452ceaacb2 100644 --- a/crates/swc/tests/tsc-references/uniqueSymbols_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/uniqueSymbols_es5.1.normal.js @@ -7,7 +7,11 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _define_property from "@swc/helpers/src/_define_property.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(genFuncYieldConstCallWithTypeQuery); +var _marked1 = /*#__PURE__*/ regeneratorRuntime.mark(genFuncYieldVarCall); +var _marked2 = /*#__PURE__*/ regeneratorRuntime.mark(genFuncYieldLetCall); +var _marked3 = /*#__PURE__*/ regeneratorRuntime.mark(genFuncYieldConstCall); var constCall = Symbol(); var letCall = Symbol(); var varCall = Symbol(); @@ -48,111 +52,104 @@ function funcReturnConstCallWithTypeQuery() { } // generator function yield inference function genFuncYieldConstCall() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function genFuncYieldConstCall$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - constCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return constCall; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked3); } function genFuncYieldLetCall() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function genFuncYieldLetCall$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - letCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return letCall; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked2); } function genFuncYieldVarCall() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function genFuncYieldVarCall$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - varCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return varCall; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked1); } // generator function yield with return type query function genFuncYieldConstCallWithTypeQuery() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function genFuncYieldConstCallWithTypeQuery$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - constCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return constCall; + case 2: + case "end": + return _ctx.stop(); } - }); + }, _marked); } function asyncFuncReturnConstCall() { return _asyncFuncReturnConstCall.apply(this, arguments); } function _asyncFuncReturnConstCall() { _asyncFuncReturnConstCall = // async function return inference - _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - constCall - ]; - }); - }); + _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", constCall); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _asyncFuncReturnConstCall.apply(this, arguments); } function asyncFuncReturnLetCall() { return _asyncFuncReturnLetCall.apply(this, arguments); } function _asyncFuncReturnLetCall() { - _asyncFuncReturnLetCall = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - letCall - ]; - }); - }); + _asyncFuncReturnLetCall = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", letCall); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _asyncFuncReturnLetCall.apply(this, arguments); } function asyncFuncReturnVarCall() { return _asyncFuncReturnVarCall.apply(this, arguments); } function _asyncFuncReturnVarCall() { - _asyncFuncReturnVarCall = _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - varCall - ]; - }); - }); + _asyncFuncReturnVarCall = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", varCall); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return _asyncFuncReturnVarCall.apply(this, arguments); } function asyncGenFuncYieldConstCall() { @@ -160,66 +157,54 @@ function asyncGenFuncYieldConstCall() { } function _asyncGenFuncYieldConstCall() { _asyncGenFuncYieldConstCall = // async generator function yield inference - _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - constCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return constCall; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _asyncGenFuncYieldConstCall.apply(this, arguments); } function asyncGenFuncYieldLetCall() { return _asyncGenFuncYieldLetCall.apply(this, arguments); } function _asyncGenFuncYieldLetCall() { - _asyncGenFuncYieldLetCall = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _asyncGenFuncYieldLetCall = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - letCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return letCall; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _asyncGenFuncYieldLetCall.apply(this, arguments); } function asyncGenFuncYieldVarCall() { return _asyncGenFuncYieldVarCall.apply(this, arguments); } function _asyncGenFuncYieldVarCall() { - _asyncGenFuncYieldVarCall = _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _asyncGenFuncYieldVarCall = _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - varCall - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return varCall; + case 2: + case "end": + return _ctx.stop(); } - }); - }); + }, _callee); + })); return _asyncGenFuncYieldVarCall.apply(this, arguments); } // classes @@ -284,49 +269,44 @@ var o2 = { return s; }, method2: function method2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - s - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", s); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, method3: function method3() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return s; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, - method4: function method4() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + method4: /*#__PURE__*/ regeneratorRuntime.mark(function method4() { + return regeneratorRuntime.wrap(function method4$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return s; + case 2: + case "end": + return _ctx.stop(); } - }); - }, + }, method4); + }), method5: function method5() { var p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : s; return p; @@ -349,49 +329,44 @@ var C0 = /*#__PURE__*/ function() { return s; }; _proto.method2 = function method2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - s - ]; - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", s); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }; _proto.method3 = function method3() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return s; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }; - _proto.method4 = function method4() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + _proto.method4 = /*#__PURE__*/ regeneratorRuntime.mark(function method4() { + return regeneratorRuntime.wrap(function method4$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - _state.sent(); - return [ - 2 - ]; + _ctx.next = 2; + return s; + case 2: + case "end": + return _ctx.stop(); } - }); - }; + }, method4); + }); _proto.method5 = function method5() { var p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : s; return p; @@ -436,49 +411,44 @@ var o3 = { return s; // return type should not widen due to contextual type }, method2: function method2() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - s - ]; // return type should not widen due to contextual type - }); - })(); + return _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", s); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); }, method3: function method3() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return _wrap_async_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - _state.sent(); // yield type should not widen due to contextual type - return [ - 2 - ]; + _ctx.next = 2; + return s; + case 2: + case "end": + return _ctx.stop(); } - }); - })(); + }, _callee); + }))(); }, - method4: function method4() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + method4: /*#__PURE__*/ regeneratorRuntime.mark(function method4() { + return regeneratorRuntime.wrap(function method4$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - _state.sent(); // yield type should not widen due to contextual type - return [ - 2 - ]; + _ctx.next = 2; + return s; + case 2: + case "end": + return _ctx.stop(); } - }); - }, + }, method4); + }), method5: function method5() { var p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : s; return p; diff --git a/crates/swc/tests/tsc-references/uniqueSymbols_es5.2.minified.js b/crates/swc/tests/tsc-references/uniqueSymbols_es5.2.minified.js index 91b80f8aaea..42819080ce8 100644 --- a/crates/swc/tests/tsc-references/uniqueSymbols_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/uniqueSymbols_es5.2.minified.js @@ -2,7 +2,7 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; import _define_property from "@swc/helpers/src/_define_property.mjs"; import _wrap_async_generator from "@swc/helpers/src/_wrap_async_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var _obj, constCall = Symbol(); Symbol(), Symbol(), Symbol(); var C = function C() { @@ -19,45 +19,40 @@ var C0 = function() { return _proto.method1 = function() { return s; }, _proto.method2 = function() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - s - ]; - }); - })(); - }, _proto.method3 = function() { - return _wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + return _async_to_generator(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; + return _ctx.abrupt("return", s); case 1: - return _state.sent(), [ - 2 - ]; + case "end": + return _ctx.stop(); } - }); - })(); - }, _proto.method4 = function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ + }, _callee); + }))(); + }, _proto.method3 = function() { + return _wrap_async_generator(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.next = 2, s; + case 2: + case "end": + return _ctx.stop(); + } + }, _callee); + }))(); + }, _proto.method4 = regeneratorRuntime.mark(function method4() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return [ - 4, - s - ]; - case 1: - return _state.sent(), [ - 2 - ]; + return _ctx.next = 2, s; + case 2: + case "end": + return _ctx.stop(); } - }); - }, _proto.method5 = function() { + }, method4); + }), _proto.method5 = function() { var p = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : s; return p; }, C0; diff --git a/crates/swc/tests/tsc-references/yieldExpressionInControlFlow_es5.1.normal.js b/crates/swc/tests/tsc-references/yieldExpressionInControlFlow_es5.1.normal.js index b27a4da7d5d..725538fca04 100644 --- a/crates/swc/tests/tsc-references/yieldExpressionInControlFlow_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/yieldExpressionInControlFlow_es5.1.normal.js @@ -4,63 +4,54 @@ // @noImplicitAny: true // @lib: esnext // @Filename: bug25149.js -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(f); function f() { var o; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function f$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: - if (!true) return [ - 3, - 2 - ]; - return [ - 4, - o - ]; + ; case 1: - o = _state.sent(); - return [ - 3, - 0 - ]; - case 2: - return [ - 2 - ]; + if (!true) { + _ctx.next = 7; + break; + } + _ctx.next = 4; + return o; + case 4: + o = _ctx.sent; + _ctx.next = 1; + break; + case 7: + case "end": + return _ctx.stop(); } - }); + }, _marked); } // @Filename: alsoFails.ts // fails in Typescript too -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +var _marked = /*#__PURE__*/ regeneratorRuntime.mark(g); function g() { var o; - return _ts_generator(this, function(_state) { - switch(_state.label){ + return regeneratorRuntime.wrap(function g$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ case 0: o = []; - _state.label = 1; case 1: - if (!true) return [ - 3, - 3 - ]; - return [ - 5, - _ts_values(o) - ]; - case 2: - o = _state.sent(); - return [ - 3, - 1 - ]; + if (!true) { + _ctx.next = 6; + break; + } + return _ctx.delegateYield(o, "t0", 3); case 3: - return [ - 2 - ]; + o = _ctx.t0; + _ctx.next = 1; + break; + case 6: + case "end": + return _ctx.stop(); } - }); + }, _marked); } diff --git a/crates/swc/tests/tsc-references/yieldExpressionInControlFlow_es5.2.minified.js b/crates/swc/tests/tsc-references/yieldExpressionInControlFlow_es5.2.minified.js index fe661d03e7e..b2319a09537 100644 --- a/crates/swc/tests/tsc-references/yieldExpressionInControlFlow_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/yieldExpressionInControlFlow_es5.2.minified.js @@ -1,3 +1,2 @@ -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; -import _ts_values from "@swc/helpers/src/_ts_values.mjs"; +import regeneratorRuntime from "regenerator-runtime"; +import regeneratorRuntime from "regenerator-runtime"; diff --git a/crates/swc/tests/vercel/full/next-31419/1/output/index.js b/crates/swc/tests/vercel/full/next-31419/1/output/index.js index eeb4ce46626..4e62123ad70 100644 --- a/crates/swc/tests/vercel/full/next-31419/1/output/index.js +++ b/crates/swc/tests/vercel/full/next-31419/1/output/index.js @@ -1,54 +1,49 @@ -import n from "@swc/helpers/src/_async_to_generator.mjs"; -import r from "@swc/helpers/src/_ts_generator.mjs"; +import t from "@swc/helpers/src/_async_to_generator.mjs"; +import n from "regenerator-runtime"; Promise.all(assignAll).then(function() { - var t = n(function(n) { - var t, e, c, i, u, o, a; - return r(this, function(r) { - switch(r.label){ + var r = t(n.mark(function t(r) { + var e, c, a, o; + return n.wrap(function(t) { + for(;;)switch(t.prev = t.next){ case 0: - for(c in t = 'DELETE FROM "TABLE" WHERE "UUID" IN ( ', e = [], n); - i = 0, r.label = 1; - case 1: - if (!(i < e.length)) return [ - 3, - 4 - ]; - return o = n[u = e[i]], t += "'".concat(o.id, "', "), [ - 4, - listOfUser(o.id) - ]; + e = 'DELETE FROM "TABLE" WHERE "UUID" IN ( ', t.t0 = regeneratorRuntime.keys(r); case 2: - (a = r.sent()).forEach(function(n) { - insertQuery += 'INSERT INTO "TABLE"("UUID", id, other_ids_here) VALUES (\''.concat(uuidv4(), "', '").concat(o.id, "', now());"); - }), r.label = 3; - case 3: - return i++, [ - 3, - 1 - ]; - case 4: - return [ - 2 - ]; + if ((t.t1 = t.t0()).done) { + t.next = 12; + break; + } + return a = r[c = t.t1.value], e += "'".concat(a.id, "', "), t.next = 8, listOfUser(a.id); + case 8: + (o = t.sent).forEach(function(t) { + insertQuery += 'INSERT INTO "TABLE"("UUID", id, other_ids_here) VALUES (\''.concat(uuidv4(), "', '").concat(a.id, "', now());"); + }), t.next = 2; + break; + case 12: + case "end": + return t.stop(); } - }); - }); - return function(n) { - return t.apply(this, arguments); + }, t); + })); + return function(r) { + return r.apply(this, arguments); }; }()); -export var listOfUser = function(t) { +export var listOfUser = function(r) { var e; - return new Promise((e = n(function(n, e) { - var c; - return r(this, function(r) { - return c = 'Select Distinct id from "TABLE" Where id = \''.concat(t, "' And user_id IS not null"), postgreSQL.query(c, null, function(r, t) { - r ? e(r) : n(t.rows); - }), [ - 2 - ]; - }); - }), function(n, e) { + return new Promise((e = t(n.mark(function t(e, c) { + var a; + return n.wrap(function(t) { + for(;;)switch(t.prev = t.next){ + case 0: + a = 'Select Distinct id from "TABLE" Where id = \''.concat(r, "' And user_id IS not null"), postgreSQL.query(a, null, function(t, n) { + t ? c(t) : e(n.rows); + }); + case 2: + case "end": + return t.stop(); + } + }, t); + })), function(e, c) { return e.apply(this, arguments); })); }; diff --git a/crates/swc/tests/vercel/full/next-33088/output/index.js b/crates/swc/tests/vercel/full/next-33088/output/index.js index 11ccf358f7a..7863c5f2650 100644 --- a/crates/swc/tests/vercel/full/next-33088/output/index.js +++ b/crates/swc/tests/vercel/full/next-33088/output/index.js @@ -1,51 +1,46 @@ import t from "@swc/helpers/src/_async_to_generator.mjs"; import r from "@swc/helpers/src/_sliced_to_array.mjs"; -import e from "@swc/helpers/src/_ts_generator.mjs"; -import { jsx as n, jsxs as i, Fragment as u } from "react/jsx-runtime"; -import * as o from "react"; -export default function s() { - var s = r(o.useState({ +import e from "regenerator-runtime"; +import { jsx as n, jsxs as a, Fragment as o } from "react/jsx-runtime"; +import * as s from "react"; +export default function i() { + var i = r(s.useState({ hits: [] - }), 2), a = s[0], c = s[1], f = r(o.useState("react"), 2), l = f[0], h = f[1]; - return o.useEffect(function() { - "" !== l && function() { + }), 2), u = i[0], c = i[1], f = r(s.useState("react"), 2), p = f[0], m = f[1]; + return s.useEffect(function() { + "" !== p && function() { r.apply(this, arguments); }(); function r() { - return (r = t(function() { - var t, r; - return e(this, function(e) { - switch(e.label){ + return (r = t(e.mark(function t() { + var r, n; + return e.wrap(function(t) { + for(;;)switch(t.prev = t.next){ case 0: - return [ - 4, - fetch("https://hn.algolia.com/api/v1/search?query=" + l) - ]; - case 1: - return [ - 4, - (t = e.sent()).json() - ]; + return t.next = 2, fetch("https://hn.algolia.com/api/v1/search?query=" + p); case 2: - return c(r = e.sent()), [ - 2 - ]; + return r = t.sent, t.next = 5, r.json(); + case 5: + c(n = t.sent); + case 7: + case "end": + return t.stop(); } - }); - })).apply(this, arguments); + }, t); + }))).apply(this, arguments); } }, [ - l - ]), i(u, { + p + ]), a(o, { children: [ n("input", { - value: l, + value: p, onChange: function(t) { - return h(t.target.value); + return m(t.target.value); } }), n("ul", { - children: a.hits.map(function(t) { + children: u.hits.map(function(t) { return n("li", { children: n("a", { href: t.url, diff --git a/crates/swc/tests/vercel/full/utf8-1/output/index.js b/crates/swc/tests/vercel/full/utf8-1/output/index.js index 42cbb6308a2..316c0a4dc19 100644 --- a/crates/swc/tests/vercel/full/utf8-1/output/index.js +++ b/crates/swc/tests/vercel/full/utf8-1/output/index.js @@ -1,69 +1,64 @@ import t from "@swc/helpers/src/_async_to_generator.mjs"; -import a from "@swc/helpers/src/_ts_generator.mjs"; -import { displayContent as r } from "./fouc"; +import r from "regenerator-runtime"; +import { displayContent as a } from "./fouc"; import n from "./on-demand-entries-client"; import { addMessageListener as e, connectHMR as c } from "./error-overlay/websocket"; var o = JSON.parse(document.getElementById("__NEXT_DATA__").textContent); window.__NEXT_DATA__ = o; -var s = o.assetPrefix, i = o.page, f = null, u = __webpack_hash__, l = (s = s || "") + (s.endsWith("/") ? "" : "/") + "_next/static/webpack/"; -function p() { - return (p = t(function() { - var t, r, n, e, c; - return a(this, function(a) { - switch(a.label){ +var i = o.assetPrefix, s = o.page, f = null, p = __webpack_hash__, u = (i = i || "") + (i.endsWith("/") ? "" : "/") + "_next/static/webpack/"; +function l() { + return f !== __webpack_hash__; +} +function h() { + return "idle" === module.hot.status(); +} +function m() { + return (m = t(r.mark(function t() { + var a, n, e, c; + return r.wrap(function(t) { + for(;;)switch(t.prev = t.next){ case 0: - if (!(f !== __webpack_hash__) || "idle" !== module.hot.status()) return [ - 2 - ]; - a.label = 1; - case 1: - return a.trys.push([ - 1, - 4, - , - 5 - ]), [ - 4, - fetch("undefined" != typeof __webpack_runtime_id__ ? "".concat(l).concat(u, ".").concat(__webpack_runtime_id__, ".hot-update.json") : "".concat(l).concat(u, ".hot-update.json")) - ]; + if (!(!l() || !h())) { + t.next = 2; + break; + } + return t.abrupt("return"); case 2: - return [ - 4, - (t = a.sent()).json() - ]; - case 3: - return r = a.sent(), n = "/" === i ? "index" : i, (e = (Array.isArray(r.c) ? r.c : Object.keys(r.c)).some(function(t) { - return -1 !== t.indexOf("pages".concat(n.startsWith("/") ? n : "/".concat(n))) || -1 !== t.indexOf("pages".concat(n.startsWith("/") ? n : "/".concat(n)).replace(/\//g, "\\")); - })) ? document.location.reload(!0) : u = f, [ - 3, - 5 - ]; - case 4: - return c = a.sent(), console.error("Error occurred checking for update", c), document.location.reload(!0), [ - 3, - 5 - ]; + return t.prev = 2, t.next = 5, fetch("undefined" != typeof __webpack_runtime_id__ ? "".concat(u).concat(p, ".").concat(__webpack_runtime_id__, ".hot-update.json") : "".concat(u).concat(p, ".hot-update.json")); case 5: - return [ - 2 - ]; + return a = t.sent, t.next = 8, a.json(); + case 8: + n = t.sent, e = "/" === s ? "index" : s, (c = (Array.isArray(n.c) ? n.c : Object.keys(n.c)).some(function(t) { + return -1 !== t.indexOf("pages".concat(e.startsWith("/") ? e : "/".concat(e))) || -1 !== t.indexOf("pages".concat(e.startsWith("/") ? e : "/".concat(e)).replace(/\//g, "\\")); + })) ? document.location.reload(!0) : p = f, t.next = 18; + break; + case 14: + t.prev = 14, t.t0 = t.catch(2), console.error("Error occurred checking for update", t.t0), document.location.reload(!0); + case 18: + case "end": + return t.stop(); } - }); - })).apply(this, arguments); + }, t, null, [ + [ + 2, + 14 + ] + ]); + }))).apply(this, arguments); } e(function(t) { if ("\uD83D\uDC93" !== t.data) try { - var a = JSON.parse(t.data); - if ("sync" === a.action || "built" === a.action) { - if (!a.hash) return; - f = a.hash, function() { - p.apply(this, arguments); + var r = JSON.parse(t.data); + if ("sync" === r.action || "built" === r.action) { + if (!r.hash) return; + f = r.hash, function() { + m.apply(this, arguments); }(); - } else "reloadPage" === a.action && document.location.reload(!0); - } catch (r) { - console.warn("Invalid HMR message: " + t.data + "\n" + r); + } else "reloadPage" === r.action && document.location.reload(!0); + } catch (a) { + console.warn("Invalid HMR message: " + t.data + "\n" + a); } }), c({ - assetPrefix: s, + assetPrefix: i, path: "/_next/webpack-hmr" -}), r(), n(o.page); +}), a(), n(o.page); diff --git a/crates/swc/tests/vercel/loader-only/regressions/1/full/output/index.js b/crates/swc/tests/vercel/loader-only/regressions/1/full/output/index.js index f6841d06d33..4b67fe9a865 100644 --- a/crates/swc/tests/vercel/loader-only/regressions/1/full/output/index.js +++ b/crates/swc/tests/vercel/loader-only/regressions/1/full/output/index.js @@ -1,6 +1,6 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime"; import { useEffect } from "react"; var Test = function Test(name) { @@ -8,14 +8,17 @@ var Test = function Test(name) { _class_call_check(this, Test); var _this = this; this.print = function() { - var _ref = _async_to_generator(function(arg) { - return _ts_generator(this, function(_state) { - console.log(_this.name, arg); - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(arg) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + console.log(_this.name, arg); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function(arg) { return _ref.apply(this, arguments); }; diff --git a/crates/swc/tests/vercel/loader-only/regressions/1/simplified/output/index.js b/crates/swc/tests/vercel/loader-only/regressions/1/simplified/output/index.js index 891d895486e..da7c3f0898d 100644 --- a/crates/swc/tests/vercel/loader-only/regressions/1/simplified/output/index.js +++ b/crates/swc/tests/vercel/loader-only/regressions/1/simplified/output/index.js @@ -1,19 +1,22 @@ import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs"; import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; -import _ts_generator from "@swc/helpers/src/_ts_generator.mjs"; +import regeneratorRuntime from "regenerator-runtime"; var Test = function Test(name) { "use strict"; _class_call_check(this, Test); var _this = this; this.print = function() { - var _ref = _async_to_generator(function(arg) { - return _ts_generator(this, function(_state) { - console.log(_this.name, arg); - return [ - 2 - ]; - }); - }); + var _ref = _async_to_generator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(arg) { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + console.log(_this.name, arg); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); + })); return function(arg) { return _ref.apply(this, arguments); }; diff --git a/crates/swc_ecma_ast/src/expr.rs b/crates/swc_ecma_ast/src/expr.rs index 1d4dd1816d8..8822c1fefa0 100644 --- a/crates/swc_ecma_ast/src/expr.rs +++ b/crates/swc_ecma_ast/src/expr.rs @@ -189,25 +189,6 @@ impl Expr { _ => self, } } - - /// Creates an expression from `exprs`. This will return first element if - /// the length is 1 and a sequential expression otherwise. - /// - /// # Panics - /// - /// Panics if `exprs` is empty. - pub fn from_exprs(mut exprs: Vec>) -> Box { - debug_assert_ne!(exprs, vec![], "exprs must not be empty"); - - if exprs.len() == 1 { - exprs.remove(0) - } else { - Box::new(Expr::Seq(SeqExpr { - span: DUMMY_SP, - exprs, - })) - } - } } // Implement Clone without inline to avoid multiple copies of the @@ -264,12 +245,6 @@ impl Take for Expr { } bridge_expr_from!(Ident, Id); -bridge_expr_from!(FnExpr, Function); - -bridge_from!(Box, Expr, ArrayLit); -bridge_from!(Box, Expr, ObjectLit); -bridge_from!(Box, Expr, MemberExpr); -bridge_from!(Box, Expr, SuperPropExpr); #[ast_node("ThisExpression")] #[derive(Eq, Hash, Copy, EqIgnoreSpan)] @@ -336,15 +311,6 @@ impl From for PropOrSpread { } } -impl Take for PropOrSpread { - fn dummy() -> Self { - PropOrSpread::Spread(SpreadElement { - dot3_token: DUMMY_SP, - expr: Take::dummy(), - }) - } -} - #[ast_node("SpreadElement")] #[derive(Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] @@ -463,15 +429,6 @@ impl Take for FnExpr { } } -impl From for FnExpr { - fn from(function: Function) -> Self { - Self { - ident: None, - function, - } - } -} - /// Class expression. #[ast_node("ClassExpression")] #[derive(Eq, Hash, EqIgnoreSpan)] @@ -1165,12 +1122,17 @@ pub enum PatOrExpr { Pat(Box), } -bridge_from!(PatOrExpr, Box, Pat); -bridge_from!(PatOrExpr, Pat, Ident); -bridge_from!(PatOrExpr, Pat, Id); -bridge_from!(PatOrExpr, Box, Expr); -bridge_from!(PatOrExpr, Box, MemberExpr); -bridge_from!(PatOrExpr, Box, SuperPropExpr); +impl From for PatOrExpr { + fn from(p: Pat) -> Self { + Self::Pat(Box::new(p)) + } +} + +impl From for PatOrExpr { + fn from(e: Expr) -> Self { + Self::Expr(Box::new(e)) + } +} impl PatOrExpr { /// Returns the [Pat] if this is a pattern, otherwise returns [None]. diff --git a/crates/swc_ecma_ast/src/ident.rs b/crates/swc_ecma_ast/src/ident.rs index 3400e1c5714..96949056fbc 100644 --- a/crates/swc_ecma_ast/src/ident.rs +++ b/crates/swc_ecma_ast/src/ident.rs @@ -44,7 +44,7 @@ impl std::ops::Deref for BindingIdent { } impl BindingIdent { - /// See [`Ident::to_id`] for documentation. + /// See [Ident#to_id] for documentation. pub fn to_id(&self) -> Id { self.id.to_id() } @@ -56,8 +56,6 @@ impl From for BindingIdent { } } -bridge_from!(BindingIdent, Ident, Id); - /// A complete identifier with span. /// /// Identifier of swc consists of two parts. The first one is symbol, which is diff --git a/crates/swc_ecma_ast/src/pat.rs b/crates/swc_ecma_ast/src/pat.rs index ddd116fb9bc..a21d4c466d6 100644 --- a/crates/swc_ecma_ast/src/pat.rs +++ b/crates/swc_ecma_ast/src/pat.rs @@ -6,7 +6,7 @@ use crate::{ ident::{BindingIdent, Ident}, prop::PropName, typescript::TsTypeAnn, - Id, Invalid, + Invalid, }; #[ast_node(no_clone)] @@ -60,7 +60,6 @@ impl Take for Pat { } bridge_pat_from!(BindingIdent, Ident); -bridge_pat_from!(BindingIdent, Id); bridge_from!(crate::Param, crate::Pat, BindingIdent); bridge_from!(Box, crate::Pat, BindingIdent); diff --git a/crates/swc_ecma_ast/src/prop.rs b/crates/swc_ecma_ast/src/prop.rs index 89fb8ca0a40..b75d0e2bb58 100644 --- a/crates/swc_ecma_ast/src/prop.rs +++ b/crates/swc_ecma_ast/src/prop.rs @@ -9,7 +9,6 @@ use crate::{ pat::Pat, stmt::BlockStmt, typescript::TsTypeAnn, - MemberProp, }; #[ast_node] @@ -115,27 +114,6 @@ impl Take for PropName { } } -impl From for MemberProp { - fn from(p: PropName) -> Self { - match p { - PropName::Ident(p) => MemberProp::Ident(p), - PropName::Computed(p) => MemberProp::Computed(p), - PropName::Str(p) => MemberProp::Computed(ComputedPropName { - span: DUMMY_SP, - expr: p.into(), - }), - PropName::Num(p) => MemberProp::Computed(ComputedPropName { - span: DUMMY_SP, - expr: p.into(), - }), - PropName::BigInt(p) => MemberProp::Computed(ComputedPropName { - span: DUMMY_SP, - expr: p.into(), - }), - } - } -} - #[ast_node("Computed")] #[derive(Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] diff --git a/crates/swc_ecma_ast/src/source_map.rs b/crates/swc_ecma_ast/src/source_map.rs index 6b71be33859..cd9ffb56f8a 100644 --- a/crates/swc_ecma_ast/src/source_map.rs +++ b/crates/swc_ecma_ast/src/source_map.rs @@ -136,23 +136,27 @@ impl SourceMapperExt for dyn SourceMapper { } } +#[allow(clippy::explicit_auto_deref)] impl SourceMapperExt for Arc { fn get_code_map(&self) -> &dyn SourceMapper { &**self } } +#[allow(clippy::explicit_auto_deref)] impl SourceMapperExt for Rc { fn get_code_map(&self) -> &dyn SourceMapper { &**self } } +#[allow(clippy::explicit_auto_deref)] impl SourceMapperExt for Arc { fn get_code_map(&self) -> &dyn SourceMapper { &**self } } +#[allow(clippy::explicit_auto_deref)] impl SourceMapperExt for Rc { fn get_code_map(&self) -> &dyn SourceMapper { &**self diff --git a/crates/swc_ecma_preset_env/src/lib.rs b/crates/swc_ecma_preset_env/src/lib.rs index 80821fd5447..e2c3b4b4342 100644 --- a/crates/swc_ecma_preset_env/src/lib.rs +++ b/crates/swc_ecma_preset_env/src/lib.rs @@ -12,9 +12,7 @@ use swc_common::{chain, collections::AHashSet, comments::Comments, FromVariant, use swc_ecma_ast::*; use swc_ecma_transforms::{ compat::{ - bugfixes, - es2015::{self, generator::generator}, - es2016, es2017, es2018, es2019, es2020, es2021, es2022, es3, + bugfixes, es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, es3, regexp::{self, regexp}, }, feature::FeatureFlag, @@ -262,7 +260,12 @@ where es2015::destructuring(es2015::destructuring::Config { loose }), true ); - let pass = add!(pass, Regenerator, generator(global_mark, comments), true); + let pass = add!( + pass, + Regenerator, + es2015::regenerator(Default::default(), comments, global_mark), + true + ); let pass = add!(pass, BlockScoping, es2015::block_scoping(global_mark), true); let pass = add!(pass, NewTarget, es2015::new_target(), true); diff --git a/crates/swc_ecma_transforms_base/src/helpers/_ts_generator.js b/crates/swc_ecma_transforms_base/src/helpers/_ts_generator.js deleted file mode 100644 index 076f0ad913e..00000000000 --- a/crates/swc_ecma_transforms_base/src/helpers/_ts_generator.js +++ /dev/null @@ -1,27 +0,0 @@ -var __generator = (this && this.__generator) || function (thisArg, body) { - var f, y, t, g, _ = { label: 0, sent: function () { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; \ No newline at end of file diff --git a/crates/swc_ecma_transforms_base/src/helpers/_ts_values.js b/crates/swc_ecma_transforms_base/src/helpers/_ts_values.js deleted file mode 100644 index 2c27544885a..00000000000 --- a/crates/swc_ecma_transforms_base/src/helpers/_ts_values.js +++ /dev/null @@ -1,11 +0,0 @@ -var __values = (this && this.__values) || function (o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; \ No newline at end of file diff --git a/crates/swc_ecma_transforms_base/src/helpers/mod.rs b/crates/swc_ecma_transforms_base/src/helpers/mod.rs index 5ad32d9feb4..60a167b9a18 100644 --- a/crates/swc_ecma_transforms_base/src/helpers/mod.rs +++ b/crates/swc_ecma_transforms_base/src/helpers/mod.rs @@ -357,10 +357,8 @@ define_helpers!(Helpers { ), ts_decorate: (), - ts_generator: (), ts_metadata: (), ts_param: (), - ts_values: (), }); pub fn inject_helpers() -> impl Fold + VisitMut { diff --git a/crates/swc_ecma_transforms_compat/src/es2015/generator.rs b/crates/swc_ecma_transforms_compat/src/es2015/generator.rs deleted file mode 100644 index 5157b3b4f8e..00000000000 --- a/crates/swc_ecma_transforms_compat/src/es2015/generator.rs +++ /dev/null @@ -1,3499 +0,0 @@ -use std::{ - cell::{RefCell, RefMut}, - iter::once, - mem::take, - rc::Rc, -}; - -use is_macro::Is; -use swc_atoms::{js_word, JsWord}; -use swc_common::{ - comments::Comments, util::take::Take, BytePos, EqIgnoreSpan, Mark, Span, Spanned, - SyntaxContext, DUMMY_SP, -}; -use swc_ecma_ast::*; -use swc_ecma_transforms_base::{ext::AsOptExpr, helper}; -use swc_ecma_utils::{ - function::FnEnvHoister, private_ident, prop_name_to_expr_value, quote_ident, undefined, - ExprFactory, -}; -use swc_ecma_visit::{ - as_folder, noop_visit_mut_type, noop_visit_type, Fold, Visit, VisitMut, VisitMutWith, VisitWith, -}; -use tracing::debug; - -/// Generator based on tsc generator at https://github.com/microsoft/TypeScript/blob/162224763681465b417274383317ca9a0a573835/src/compiler/transformers/generators.ts -pub fn generator(unresolved_mark: Mark, _comments: C) -> impl VisitMut + Fold -where - C: Comments, -{ - as_folder(Wrapper { - unresolved_ctxt: SyntaxContext::empty().apply_mark(unresolved_mark), - }) -} - -/// Instead of saving state, we just create another instance of [Generator]. -struct Wrapper { - unresolved_ctxt: SyntaxContext, -} - -impl VisitMut for Wrapper { - noop_visit_mut_type!(); - - fn visit_mut_function(&mut self, f: &mut Function) { - f.visit_mut_children_with(self); - - if f.is_generator { - let mut v = Generator::default(); - - let mut hoister = FnEnvHoister::new(self.unresolved_ctxt); - hoister.disable_super(); - hoister.disable_this(); - - f.visit_mut_children_with(&mut hoister); - - v.transform_and_emit_stmts(f.body.as_mut().unwrap().stmts.take(), 0); - f.is_generator = false; - - let mut stmts = v.build_stmts(); - stmts.visit_mut_with(&mut InvalidToLit { - map: v.label_exprs.as_deref(), - }); - let inner_fn = Function { - span: DUMMY_SP, - params: vec![Param { - span: DUMMY_SP, - decorators: Default::default(), - pat: Pat::Ident(v.state.clone().into()), - }], - decorators: Default::default(), - body: Some(BlockStmt { - span: DUMMY_SP, - stmts, - }), - is_generator: false, - is_async: false, - type_params: Default::default(), - return_type: Default::default(), - }; - let generator_object = Box::new(Expr::Call(CallExpr { - span: DUMMY_SP, - callee: helper!(ts, ts_generator, "__generator"), - args: vec![ - ThisExpr { span: DUMMY_SP }.as_arg(), - FnExpr { - ident: None, - function: inner_fn, - } - .as_arg(), - ], - type_args: Default::default(), - })); - let mut stmts = vec![]; - if !v.hoisted_vars.is_empty() { - stmts.push(Stmt::Decl(Decl::Var(VarDecl { - span: DUMMY_SP, - kind: VarDeclKind::Var, - declare: Default::default(), - decls: v.hoisted_vars.take(), - }))) - } - let vars = hoister.to_decl(); - if !vars.is_empty() { - stmts.push(Stmt::Decl(Decl::Var(VarDecl { - span: DUMMY_SP, - kind: VarDeclKind::Var, - declare: Default::default(), - decls: vars, - }))) - } - stmts.extend(v.hoisted_fns.into_iter().map(Decl::Fn).map(Stmt::Decl)); - - stmts.push(Stmt::Return(ReturnStmt { - span: DUMMY_SP, - arg: Some(generator_object), - })); - f.body.as_mut().unwrap().stmts = stmts; - } - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -struct Label(isize); - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -enum OpCode { - /// No operation, used to force a new case in the state machine - Nop, - /// A regular javascript statement - Statement, - /// An assignment - Assign, - /// A break instruction used to jump to a label - Break, - /// A break instruction used to jump to a label if a condition evaluates to - /// true - BreakWhenTrue, - /// A break instruction used to jump to a label if a condition evaluates to - /// false - BreakWhenFalse, - /// A completion instruction for the `yield` keyword - Yield, - /// A completion instruction for the `yield*` keyword (not implemented, but - /// reserved for future use) - YieldStar, - /// A completion instruction for the `return` keyword - Return, - /// A completion instruction for the `throw` keyword - Throw, - /// Marks the end of a `finally` block - Endfinally, -} - -#[derive(Debug, Is, Clone)] -enum OpArgs { - Label(Label), - LabelExpr(Label, Box), - Stmt(Box), - OptExpr(Option>), - PatAndExpr(PatOrExpr, Box), -} - -/// whether a generated code block is opening or closing at the current -/// operation for a FunctionBuilder -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -enum BlockAction { - Open, - Close, -} - -/// the kind for a generated code block in a FunctionBuilder -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -enum CodeBlockKind { - Exception, - With, - Switch, - Loop, - Labeled, -} - -/// the state for a generated code exception block -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] -enum ExceptionBlockState { - Try, - Catch, - Finally, - Done, -} - -/// A generated code block -#[derive(Debug)] -enum CodeBlock { - Exception(ExceptionBlock), - Labeled(LabeledBlock), - Switch(SwitchBlock), - Loop(LoopBlock), - With(WithBlock), -} - -impl CodeBlock { - fn is_script(&self) -> bool { - match self { - Self::Exception(..) => false, - Self::Labeled(b) => b.is_script, - Self::Switch(b) => b.is_script, - Self::Loop(b) => b.is_script, - Self::With(..) => false, - } - } - - fn label_text(&self) -> Option { - match self { - Self::Labeled(s) => Some(s.label_text.clone()), - _ => None, - } - } - - fn break_label(&self) -> Option