From f63a481833ebe9b5eae0708ee69b6a50b946ee28 Mon Sep 17 00:00:00 2001 From: magic-akari Date: Mon, 9 Sep 2024 09:05:41 +0800 Subject: [PATCH] feat(es/common): Introduce pure `Span` and `BytePos` to handle `#__PURE__` (#9539) **Related issue:** - #9538 --- .changeset/serious-houses-help.md | 5 + crates/swc/src/builder.rs | 2 - crates/swc/src/config/mod.rs | 4 - .../issues-1xxx/1455/case1/output/index.ts | 2 +- .../issues-1xxx/1455/case2/output/index.ts | 2 +- .../issues-1xxx/1718/case1/output/index.ts | 2 +- .../issues-1xxx/1718/case2/output/index.ts | 2 +- .../1799/case2-no-loose/output/index.js | 2 +- .../issues-2xxx/2248/es5/output/index.js | 2 +- .../issues-4xxx/4108/1/output/index.ts | 10 +- .../fixture/issues-4xxx/4226/1/output/exec.js | 2 +- .../fixture/issues-4xxx/4226/2/output/exec.js | 2 +- .../fixture/issues-4xxx/4226/3/output/exec.js | 2 +- .../fixture/issues-5xxx/5272/1/output/a.map | 2 +- .../fixture/issues-6xxx/6353/output/input.js | 10 +- .../fixture/issues-6xxx/6730/output/index.ts | 2 +- .../fixture/issues-8xxx/8155/1/output/1.js | 4 +- .../fixture/issues-8xxx/8155/2/output/1.js | 4 +- .../issues-8xxx/8375/1/output/index.ts | 4 +- .../fixture/issues-9xxx/9527/output/exec.js | 16 +- .../fixture/issues-9xxx/9527/output/test.js | 8 +- .../nanoid/async/index.browser.js | 4 +- .../fixture/sourcemap/005/output/index.map | 2 +- .../fixture/sourcemap/006/output/index.map | 2 +- .../oxc/output/async-function.ts | 4 +- .../ES5SymbolProperty3.2.minified.js | 2 +- .../ES5SymbolProperty4.2.minified.js | 2 +- .../ES5SymbolProperty5.2.minified.js | 2 +- .../ES5SymbolProperty6.2.minified.js | 2 +- .../ES5SymbolProperty7.2.minified.js | 2 +- .../asyncArrowFunction10_es5.1.normal.js | 2 +- .../asyncArrowFunction10_es5.2.minified.js | 7 - .../asyncArrowFunction10_es6.1.normal.js | 2 +- .../asyncArrowFunction10_es6.2.minified.js | 1 - .../asyncArrowFunction1_es5.1.normal.js | 2 +- .../asyncArrowFunction1_es5.2.minified.js | 7 - .../asyncArrowFunction1_es6.1.normal.js | 2 +- .../asyncArrowFunction1_es6.2.minified.js | 1 - ...wFunctionCapturesArguments_es5.1.normal.js | 2 +- ...wFunctionCapturesArguments_es6.1.normal.js | 4 +- ...cArrowFunctionCapturesThis_es5.1.normal.js | 2 +- ...cArrowFunctionCapturesThis_es6.1.normal.js | 2 +- .../asyncAwaitIsolatedModules_es5.1.normal.js | 20 +- ...syncAwaitIsolatedModules_es5.2.minified.js | 66 +- .../asyncAwaitIsolatedModules_es6.1.normal.js | 20 +- ...syncAwaitIsolatedModules_es6.2.minified.js | 10 +- .../tsc-references/asyncAwait_es5.1.normal.js | 20 +- .../asyncAwait_es5.2.minified.js | 66 +- .../tsc-references/asyncAwait_es6.1.normal.js | 20 +- .../asyncAwait_es6.2.minified.js | 10 +- ...asyncFunctionDeclaration16_es5.1.normal.js | 10 +- ...yncFunctionDeclaration16_es5.2.minified.js | 36 - ...meterEvaluation(target=es2015).1.normal.js | 38 +- .../asyncMethodWithSuper_es6.1.normal.js | 40 +- ...ParenthesizedArrowFunction_es5.1.normal.js | 4 +- ...renthesizedArrowFunction_es5.2.minified.js | 31 - ...ParenthesizedArrowFunction_es6.1.normal.js | 4 +- ...renthesizedArrowFunction_es6.2.minified.js | 5 - ...gDeclarations.1(target=es2015).1.normal.js | 2 +- ...eclarations.1(target=es2015).2.minified.js | 11 - ...singDeclarations.1(target=es5).1.normal.js | 2 +- ...ngDeclarations.1(target=es5).2.minified.js | 44 +- ...unctionWithZeroTypeArguments.2.minified.js | 4 +- ...ricFunctionWithTypeArguments.2.minified.js | 4 +- ...IntersectionElementPropsType.2.minified.js | 2 +- .../classAbstractAsIdentifier.2.minified.js | 2 +- ...CanExtendConstructorFunction.2.minified.js | 4 +- .../classExpression3.2.minified.js | 2 +- .../classExpression5.1.normal.js | 2 +- .../classExpression5.2.minified.js | 2 +- ...erBindingPattern.2(target=es5).1.normal.js | 4 +- ...BindingPattern.2(target=es5).2.minified.js | 4 +- ...ors.functionExpressions.es2015.1.normal.js | 14 +- ...s.functionExpressions.es2015.2.minified.js | 23 - ...rators.functionExpressions.es5.1.normal.js | 14 +- ...tors.functionExpressions.es5.2.minified.js | 105 --- ...ricCallTypeArgumentInference.2.minified.js | 2 +- ...traintsTypeArgumentInference.2.minified.js | 2 +- ...FunctionTypedMemberArguments.2.minified.js | 4 +- ...mportCallExpressionAsyncES5AMD.1.normal.js | 2 +- ...mportCallExpressionAsyncES5CJS.1.normal.js | 2 +- ...rtCallExpressionAsyncES5System.1.normal.js | 2 +- ...mportCallExpressionAsyncES5UMD.1.normal.js | 2 +- ...mportCallExpressionAsyncES6AMD.1.normal.js | 2 +- ...mportCallExpressionAsyncES6CJS.1.normal.js | 2 +- ...rtCallExpressionAsyncES6System.1.normal.js | 2 +- ...mportCallExpressionAsyncES6UMD.1.normal.js | 2 +- ...xpressionNoModuleKindSpecified.1.normal.js | 2 +- .../indexersInClassType.2.minified.js | 2 +- ...ClassMembersFromAssignments7.2.minified.js | 2 +- ...ertiesInheritedIntoClassType.2.minified.js | 4 +- .../instancePropertyInClassType.2.minified.js | 4 +- .../keyofAndIndexedAccess.2.minified.js | 2 +- .../tsc-references/localTypes5.2.minified.js | 2 +- .../looseThisTypeInFunctions.2.minified.js | 2 +- .../mappedTypeErrors.2.minified.js | 2 +- ...edMembersSatisfyAbstractBase.2.minified.js | 2 +- .../moduleExportAssignment5.2.minified.js | 2 +- .../tsc-references/objectRest2.1.normal.js | 2 +- .../tsc-references/objectSpread.2.minified.js | 2 +- .../parserAstSpans1.2.minified.js | 2 +- ...reNotAccessibleDestructuring.2.minified.js | 2 +- ...TypeParameterWithConstraints.2.minified.js | 2 +- ...ypeParameterWithConstraints4.2.minified.js | 2 +- ...ypeParameterWithConstraints5.2.minified.js | 2 +- ...eParameterWithoutConstraints.2.minified.js | 2 +- .../superPropertyAccessNoError.2.minified.js | 2 +- ...metersAvailableInNestedScope.2.minified.js | 2 +- ...ithSpecializedCallSignatures.2.minified.js | 2 +- ...appedAndRecursiveConstraints.2.minified.js | 2 +- ...ppedAndRecursiveConstraints3.2.minified.js | 2 +- ...ppedAndRecursiveConstraints4.2.minified.js | 2 +- .../full/react-autowhatever/1/output/index.js | 46 +- .../full/react-autowhatever/2/output/index.js | 32 +- .../regressions/1/full/output/index.js | 2 +- .../regressions/1/simplified/output/index.js | 2 +- crates/swc_common/src/syntax_pos.rs | 15 + crates/swc_ecma_codegen/src/comments.rs | 14 + crates/swc_ecma_codegen/src/lib.rs | 6 +- .../swc_ecma_compat_es2015/src/classes/mod.rs | 39 +- .../swc_ecma_compat_es2015/src/generator.rs | 2 +- crates/swc_ecma_compat_es2015/src/lib.rs | 2 +- .../src/object_super.rs | 2 +- crates/swc_ecma_compat_es2015/src/spread.rs | 2 +- .../src/async_to_generator.rs | 45 +- crates/swc_ecma_compat_es2017/src/lib.rs | 10 +- .../src/class_properties/mod.rs | 36 +- crates/swc_ecma_compat_es2022/src/lib.rs | 6 +- crates/swc_ecma_minifier/src/metadata/mod.rs | 2 +- crates/swc_ecma_preset_env/src/lib.rs | 17 +- .../swc_ecma_transforms/tests/decorators.rs | 240 ++---- .../tests/es2015_function_name.rs | 69 +- crates/swc_ecma_transforms_base/src/fixer.rs | 14 +- .../es2015_block_scoping.rs/issue_1036_2.js | 2 +- .../tests/es2015_generator.rs/issue_1799_1.js | 2 +- .../tests/es2015_generator.rs/issue_1799_2.js | 2 +- .../tests/es2015_generator.rs/issue_1799_3.js | 2 +- .../tests/es2015_generator.rs/issue_1799_5.js | 2 +- .../async_arrow_in_method.js | 2 +- .../async_iife.js | 4 +- ...sync_to_generator_async_arrow_in_method.js | 2 +- ...async_to_generator_deeply_nested_asyncs.js | 4 +- .../async_to_generator_expression.js | 6 +- .../async_to_generator_named_expression.js | 2 +- ..._to_generator_object_method_with_arrows.js | 4 +- .../async_with_optional_params_2.js | 2 +- .../async_wrap_arguments.js | 2 +- .../async_wrap_super_and_new_target.js | 4 +- .../async_wrap_this.js | 2 +- .../deeply_nested_asyncs.js | 4 +- .../expression.js | 6 +- .../function_length_issue_3135_3.js | 2 +- .../function_length_issue_3135_4.js | 2 +- .../function_length_issue_3135_5.js | 2 +- .../function_length_issue_3135_6.js | 2 +- .../function_length_issue_3135_7.js | 2 +- .../issue_1036_1.js | 4 +- .../issue_1455_1.js | 2 +- .../issue_2305_2.js | 2 +- .../issue_2402_2.js | 2 +- .../issue_4208.js | 2 +- .../issue_8452.js | 2 +- .../issue_9432.js | 2 +- .../named_expression.js | 2 +- .../no_parameters_and_no_id.js | 2 +- .../object_method_with_arrows.js | 4 +- .../regression_4599.js | 4 +- .../regression_t7194.js | 4 +- .../tests/es2015_block_scoping.rs | 6 +- .../tests/es2015_classes.rs | 281 +++---- .../tests/es2015_generator.rs | 30 +- .../tests/es2015_new_target.rs | 8 +- .../tests/es2015_parameters.rs | 20 +- .../tests/es2017_async_to_generator.rs | 196 ++--- .../tests/es2020_optional_chaining.rs | 6 +- .../tests/es2022_class_properties.rs | 734 +++++------------- .../tests/es2022_private_in_object.rs | 9 +- .../tests/es2022_static_blocks.rs | 4 +- crates/swc_ecma_transforms_module/src/amd.rs | 31 +- .../src/common_js.rs | 66 +- crates/swc_ecma_transforms_module/src/umd.rs | 60 +- .../tests/common_js.rs | 14 +- .../swc_ecma_transforms_module/tests/umd.rs | 8 +- .../tests/simplify.rs | 16 +- .../tests/simplify_dce.rs | 9 +- .../tests/simplify_inlining.rs | 6 +- .../tests/decorators.rs | 2 - .../src/jsx/tests.rs | 4 +- .../benches/compat.rs | 53 +- .../tests/strip.rs | 12 +- 190 files changed, 962 insertions(+), 2180 deletions(-) create mode 100644 .changeset/serious-houses-help.md diff --git a/.changeset/serious-houses-help.md b/.changeset/serious-houses-help.md new file mode 100644 index 000000000000..e8ecd211031f --- /dev/null +++ b/.changeset/serious-houses-help.md @@ -0,0 +1,5 @@ +--- +swc_common: minor +--- + +feat(es/common): Introduce pure Span and BytePos to handle `#__PURE__` diff --git a/crates/swc/src/builder.rs b/crates/swc/src/builder.rs index 20fe98237a66..9e0831f5cf14 100644 --- a/crates/swc/src/builder.rs +++ b/crates/swc/src/builder.rs @@ -215,7 +215,6 @@ impl<'a, 'b, P: swc_ecma_visit::Fold> PassBuilder<'a, 'b, P> { ), Optional::new( compat::es2022::es2022( - comments, compat::es2022::Config { class_properties: compat::es2022::class_properties::Config { private_as_properties: assumptions.private_fields_as_properties, @@ -271,7 +270,6 @@ impl<'a, 'b, P: swc_ecma_visit::Fold> PassBuilder<'a, 'b, P> { ignore_function_length: assumptions.ignore_function_length }, }, - comments, self.unresolved_mark ), should_enable(self.target, EsVersion::Es2017) diff --git a/crates/swc/src/config/mod.rs b/crates/swc/src/config/mod.rs index 9a826a9a88e6..6e91f474bc46 100644 --- a/crates/swc/src/config/mod.rs +++ b/crates/swc/src/config/mod.rs @@ -1329,7 +1329,6 @@ impl ModuleConfig { unresolved_mark, config, available_features, - comments, )) } else { let resolver = build_resolver(base_url, paths, config.resolve_fully); @@ -1339,7 +1338,6 @@ impl ModuleConfig { unresolved_mark, config, available_features, - comments, )) } } @@ -1350,7 +1348,6 @@ impl ModuleConfig { unresolved_mark, config, available_features, - comments, )) } else { let resolver = build_resolver(base_url, paths, config.config.resolve_fully); @@ -1362,7 +1359,6 @@ impl ModuleConfig { unresolved_mark, config, available_features, - comments, )) } } diff --git a/crates/swc/tests/fixture/issues-1xxx/1455/case1/output/index.ts b/crates/swc/tests/fixture/issues-1xxx/1455/case1/output/index.ts index 4df3d754ac77..f822393414bd 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1455/case1/output/index.ts +++ b/crates/swc/tests/fixture/issues-1xxx/1455/case1/output/index.ts @@ -1,6 +1,6 @@ var _async_to_generator = require("@swc/helpers/_/_async_to_generator"); const SampleData = typedModel("SampleVideo", VideosSchema, undefined, undefined, { - byPlatform: function() { + byPlatform: /*#__PURE__*/ function() { var _ref = _async_to_generator._(function*(platform) { const result = yield this.find({ platform: { 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 8e6d500eb3c9..965ea90d8e27 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 @@ -7,7 +7,7 @@ var obj = { platform: platform }; }, - byPlatform: function() { + byPlatform: /*#__PURE__*/ function() { var _ref = _async_to_generator._(function(platform) { var result; return _ts_generator._(this, function(_state) { 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 50280bb5720b..bce5d9bccc0e 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 @@ -10,7 +10,7 @@ function _scanUser() { case 0: return [ 4, - Promise.all(groups.map(function() { + Promise.all(groups.map(/*#__PURE__*/ function() { var _ref = _async_to_generator._(function(param) { var users, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, user, err; return _ts_generator._(this, function(_state) { diff --git a/crates/swc/tests/fixture/issues-1xxx/1718/case2/output/index.ts b/crates/swc/tests/fixture/issues-1xxx/1718/case2/output/index.ts index 388b0ddcf866..642613432312 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1718/case2/output/index.ts +++ b/crates/swc/tests/fixture/issues-1xxx/1718/case2/output/index.ts @@ -4,7 +4,7 @@ function scanUser(groups) { } function _scanUser() { _scanUser = _async_to_generator._(function*(groups) { - yield Promise.all(groups.map(function() { + yield Promise.all(groups.map(/*#__PURE__*/ function() { var _ref = _async_to_generator._(function*({ users }) { for (const user of users){ console.log("user", user); diff --git a/crates/swc/tests/fixture/issues-1xxx/1799/case2-no-loose/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1799/case2-no-loose/output/index.js index 4d144672360d..8b3f847d9083 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1799/case2-no-loose/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1799/case2-no-loose/output/index.js @@ -13,7 +13,7 @@ const _interop_require_default = require("@swc/helpers/_/_interop_require_defaul const _react = /*#__PURE__*/ _interop_require_default._(require("react")); function Foo() { return /*#__PURE__*/ _react.default.createElement("div", { - onClick: function() { + onClick: /*#__PURE__*/ function() { var _ref = _async_to_generator._(function*(e) { yield doSomething(); }); 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 f9ed5c8b7485..3f2258db26d4 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,6 +1,6 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -export var foo = function() { +export var foo = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { try { 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 4bac7b627213..2cc798b298e1 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 @@ -6,7 +6,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; import { _ as _ts_values } from "@swc/helpers/_/_ts_values"; import { Transaction } from "@solana/web3.js"; import { WalletNotConnectedError } from "@solana/wallet-adapter-base"; -export var getErrorForTransaction = function() { +export var getErrorForTransaction = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(connection, txid) { var tx, errors; return _ts_generator(this, function(_state) { @@ -157,7 +157,7 @@ function _sendTransactionsWithManualRetry() { }); return _sendTransactionsWithManualRetry.apply(this, arguments); } -export var sendTransactions = function() { +export var sendTransactions = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(connection, wallet, instructionSet, signersSet) { var _loop, _loop1, sequenceType, commitment, successCallback, failCallback, block, beforeTransactions, afterTransactions, _unsignedTxns, unsignedTxns, i, partiallySignedTransactions, fullySignedTransactions, signedTxns, pendingTxns, i1, _ret, result, _tmp; var _arguments = arguments; @@ -364,7 +364,7 @@ export var sendTransactions = function() { return _ref.apply(this, arguments); }; }(); -export var sendTransaction = function() { +export var sendTransaction = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(connection, wallet, instructions, signers) { var awaitConfirmation, commitment, includesFeePayer, block, transaction, _tmp, _transaction, _transaction1, _transaction2, rawTransaction, options, txid, slot, confirmation, errors; var _arguments = arguments; @@ -482,7 +482,7 @@ export var sendTransaction = function() { return _ref.apply(this, arguments); }; }(); -export var sendTransactionWithRetry = function() { +export var sendTransactionWithRetry = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(connection, wallet, instructions, signers) { var commitment, includesFeePayer, block, beforeSend, transaction, _tmp, _transaction, _transaction1, _transaction2, _ref, txid, slot; var _arguments = arguments; @@ -777,7 +777,7 @@ function _awaitTransactionSignatureConfirmation() { subId = 0; return [ 4, - new Promise(function() { + new Promise(/*#__PURE__*/ function() { var _ref = _async_to_generator(function(resolve, reject) { return _ts_generator(this, function(_state) { switch(_state.label){ 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 07a9c2d10773..2968310ea37f 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,7 +1,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; import "reflect-metadata"; -var v0 = function() { +var v0 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(v1) { return _ts_generator(this, function(_state) { return [ diff --git a/crates/swc/tests/fixture/issues-4xxx/4226/2/output/exec.js b/crates/swc/tests/fixture/issues-4xxx/4226/2/output/exec.js index cd7eb0138134..dc043519def5 100644 --- a/crates/swc/tests/fixture/issues-4xxx/4226/2/output/exec.js +++ b/crates/swc/tests/fixture/issues-4xxx/4226/2/output/exec.js @@ -1,6 +1,6 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import "reflect-metadata"; -const v0 = function() { +const v0 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(v1) { return v1; }); 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 e0850947b01e..49abfcf0eae5 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 @@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", { var _async_to_generator = require("@swc/helpers/_/_async_to_generator"); var _ts_generator = require("@swc/helpers/_/_ts_generator"); require("reflect-metadata"); -var v0 = function() { +var v0 = /*#__PURE__*/ function() { var _ref = _async_to_generator._(function(v1) { return _ts_generator._(this, function(_state) { return [ diff --git a/crates/swc/tests/fixture/issues-5xxx/5272/1/output/a.map b/crates/swc/tests/fixture/issues-5xxx/5272/1/output/a.map index 2b748f6f9128..3c83a03282c0 100644 --- a/crates/swc/tests/fixture/issues-5xxx/5272/1/output/a.map +++ b/crates/swc/tests/fixture/issues-5xxx/5272/1/output/a.map @@ -1,5 +1,5 @@ { - "mappings": ";;;+BACaA;;;eAAAA;;;;;;;oBADQ;AACd,IAAA,AAAMA,oBAAD,AAAL;;gBAAMA;aAAAA;kCAAAA;mCAAAA;;oBAAAA;;YACTC,KAAAA;mBAAAA,SAAAA;gBACI,OAAO,IAAI,IAAI,CAACC,GAAG;YACvB;;;WAHSF;EAAYG,UAAI", + "mappings": ";;;+BACaA;;;eAAAA;;;;;;;oBADQ;AACd,IAAA,AAAMA,oBAAN;;gBAAMA;aAAAA;kCAAAA;mCAAAA;;oBAAAA;;YACTC,KAAAA;mBAAAA,SAAAA;gBACI,OAAO,IAAI,IAAI,CAACC,GAAG;YACvB;;;WAHSF;EAAYG,UAAI", "names": [ "Foo", "bar", diff --git a/crates/swc/tests/fixture/issues-6xxx/6353/output/input.js b/crates/swc/tests/fixture/issues-6xxx/6353/output/input.js index 7239165b85c8..22f71795911b 100644 --- a/crates/swc/tests/fixture/issues-6xxx/6353/output/input.js +++ b/crates/swc/tests/fixture/issues-6xxx/6353/output/input.js @@ -1,5 +1,5 @@ var _async_to_generator = require("@swc/helpers/_/_async_to_generator"); -(function() { +/*#__PURE__*/ (function() { var _ref = _async_to_generator._(function*(x) { return 0; }); @@ -7,7 +7,7 @@ var _async_to_generator = require("@swc/helpers/_/_async_to_generator"); return _ref.apply(this, arguments); }; })().x++; -(function() { +/*#__PURE__*/ (function() { var _ref = _async_to_generator._(function*(x) { return 0; }); @@ -15,7 +15,7 @@ var _async_to_generator = require("@swc/helpers/_/_async_to_generator"); return _ref.apply(this, arguments); }; })().x--; -++function() { +++/*#__PURE__*/ function() { var _ref = _async_to_generator._(function*(x) { return 0; }); @@ -23,7 +23,7 @@ var _async_to_generator = require("@swc/helpers/_/_async_to_generator"); return _ref.apply(this, arguments); }; }().x; ---function() { +--/*#__PURE__*/ function() { var _ref = _async_to_generator._(function*(x) { return 0; }); @@ -31,7 +31,7 @@ var _async_to_generator = require("@swc/helpers/_/_async_to_generator"); return _ref.apply(this, arguments); }; }().x; -(function() { +/*#__PURE__*/ (function() { var _ref = _async_to_generator._(function*(x) { return 0; }); diff --git a/crates/swc/tests/fixture/issues-6xxx/6730/output/index.ts b/crates/swc/tests/fixture/issues-6xxx/6730/output/index.ts index cea473d5bbf3..e23eae868279 100644 --- a/crates/swc/tests/fixture/issues-6xxx/6730/output/index.ts +++ b/crates/swc/tests/fixture/issues-6xxx/6730/output/index.ts @@ -2,7 +2,7 @@ import { _ as r } from "@swc/helpers/_/_async_to_generator"; export const styleLoader = ()=>{ return { setup (t) { - t.onLoad(function() { + t.onLoad(/*#__PURE__*/ function() { var t = r(function*(r) {}); return function(r) { return t.apply(this, arguments); diff --git a/crates/swc/tests/fixture/issues-8xxx/8155/1/output/1.js b/crates/swc/tests/fixture/issues-8xxx/8155/1/output/1.js index 8c4360bac85c..0f92af5fe99e 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8155/1/output/1.js +++ b/crates/swc/tests/fixture/issues-8xxx/8155/1/output/1.js @@ -6,14 +6,14 @@ let someFn = (xx, x, y)=>[ 1, 2, 3 - ], goodFunction = function() { + ], goodFunction = /*#__PURE__*/ function() { var _ref = _async_to_generator._(function*() { console.log(someFn(1, (yield getArray()), (yield getArray()))); }); return function() { return _ref.apply(this, arguments); }; -}(), badFunction = function() { +}(), badFunction = /*#__PURE__*/ function() { var _ref = _async_to_generator._(function*() { console.log(someFn(1, (yield getArray()), (yield getArray()))); }); diff --git a/crates/swc/tests/fixture/issues-8xxx/8155/2/output/1.js b/crates/swc/tests/fixture/issues-8xxx/8155/2/output/1.js index b38659986e89..f0fd45e51168 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8155/2/output/1.js +++ b/crates/swc/tests/fixture/issues-8xxx/8155/2/output/1.js @@ -8,7 +8,7 @@ const getArray = ()=>[ 2, 3 ]; -const goodFunction = function() { +const goodFunction = /*#__PURE__*/ function() { var _ref = _async_to_generator._(function*() { const rb = yield getArray(); const rc = yield getArray(); @@ -18,7 +18,7 @@ const goodFunction = function() { return _ref.apply(this, arguments); }; }(); -const badFunction = function() { +const badFunction = /*#__PURE__*/ function() { var _ref = _async_to_generator._(function*() { console.log(someFn(1, (yield getArray()), (yield getArray()))); }); diff --git a/crates/swc/tests/fixture/issues-8xxx/8375/1/output/index.ts b/crates/swc/tests/fixture/issues-8xxx/8375/1/output/index.ts index 053665f9a7f9..7cc3da7d5615 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8375/1/output/index.ts +++ b/crates/swc/tests/fixture/issues-8xxx/8375/1/output/index.ts @@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", { }); const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard"); const _hello = require("./src/hello"); -const _node = _interop_require_wildcard._(require("@sentry/node")); +const _node = /*#__PURE__*/ _interop_require_wildcard._(require("@sentry/node")); _node; -(0, _hello.helloWorld)("SWC"); /*#__PURE__*/ +(0, _hello.helloWorld)("SWC"); diff --git a/crates/swc/tests/fixture/issues-9xxx/9527/output/exec.js b/crates/swc/tests/fixture/issues-9xxx/9527/output/exec.js index 7a323996f378..1161ae0a45dc 100644 --- a/crates/swc/tests/fixture/issues-9xxx/9527/output/exec.js +++ b/crates/swc/tests/fixture/issues-9xxx/9527/output/exec.js @@ -8,7 +8,7 @@ var Base = function Base() { }; ; expect(function() { - return new /*#__PURE__*/ (function(Base) { + return new (/*#__PURE__*/ function(Base) { "use strict"; _inherits._(_class, Base); function _class() { @@ -24,7 +24,7 @@ expect(function() { }(Base)); }).toThrow(); expect(function() { - return new /*#__PURE__*/ (function(Base) { + return new (/*#__PURE__*/ function(Base) { "use strict"; _inherits._(_class, Base); function _class() { @@ -39,7 +39,7 @@ expect(function() { }(Base)); }).toThrow(); expect(function() { - return new /*#__PURE__*/ (function(Base) { + return new (/*#__PURE__*/ function(Base) { "use strict"; _inherits._(_class, Base); function _class() { @@ -55,7 +55,7 @@ expect(function() { }(Base)); }).toThrow(); expect(function() { - return new /*#__PURE__*/ (function(Base) { + return new (/*#__PURE__*/ function(Base) { "use strict"; _inherits._(_class, Base); function _class() { @@ -68,7 +68,7 @@ expect(function() { }(Base)); }).toThrow(); expect(function() { - return new /*#__PURE__*/ (function(Base) { + return new (/*#__PURE__*/ function(Base) { "use strict"; _inherits._(_class, Base); function _class() { @@ -82,7 +82,7 @@ expect(function() { }(Base)); }).toThrow(); expect(function() { - return new /*#__PURE__*/ (function(Base) { + return new (/*#__PURE__*/ function(Base) { "use strict"; _inherits._(_class, Base); function _class() { @@ -95,7 +95,7 @@ expect(function() { }(Base)); }).toThrow(); expect(function() { - return new /*#__PURE__*/ (function(Base) { + return new (/*#__PURE__*/ function(Base) { "use strict"; _inherits._(_class, Base); function _class() { @@ -109,7 +109,7 @@ expect(function() { }(Base)); }).toThrow(); expect(function() { - return new /*#__PURE__*/ (function(Base) { + return new (/*#__PURE__*/ function(Base) { "use strict"; _inherits._(_class, Base); function _class() { diff --git a/crates/swc/tests/fixture/issues-9xxx/9527/output/test.js b/crates/swc/tests/fixture/issues-9xxx/9527/output/test.js index ad860c3e6932..662951854665 100644 --- a/crates/swc/tests/fixture/issues-9xxx/9527/output/test.js +++ b/crates/swc/tests/fixture/issues-9xxx/9527/output/test.js @@ -6,7 +6,7 @@ var Base = function Base() { _class_call_check._(this, Base); }; ; -new /*#__PURE__*/ (function(Base) { +new (/*#__PURE__*/ function(Base) { "use strict"; _inherits._(_class, Base); function _class() { @@ -17,7 +17,7 @@ new /*#__PURE__*/ (function(Base) { } return _class; }(Base)); -new /*#__PURE__*/ (function(Base) { +new (/*#__PURE__*/ function(Base) { "use strict"; _inherits._(_class, Base); function _class() { @@ -29,7 +29,7 @@ new /*#__PURE__*/ (function(Base) { } return _class; }(Base)); -new /*#__PURE__*/ (function(Base) { +new (/*#__PURE__*/ function(Base) { "use strict"; _inherits._(_class, Base); function _class() { @@ -41,7 +41,7 @@ new /*#__PURE__*/ (function(Base) { } return _class; }(Base)); -new /*#__PURE__*/ (function(Base) { +new (/*#__PURE__*/ function(Base) { "use strict"; _inherits._(_class, Base); function _class() { diff --git a/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.browser.js b/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.browser.js index 0add4f1f3f1a..0d5b70e026a7 100644 --- a/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.browser.js +++ b/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.browser.js @@ -1,6 +1,6 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -export var random = function() { +export var random = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(bytes) { return _ts_generator(this, function(_state) { return [ @@ -40,7 +40,7 @@ export var customAlphabet = function(alphabet) { }); }); }; -export var nanoid = function() { +export var nanoid = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { var size, id, bytes, byte; var _arguments = arguments; diff --git a/crates/swc/tests/fixture/sourcemap/005/output/index.map b/crates/swc/tests/fixture/sourcemap/005/output/index.map index b980a15ae7e7..add80c78870e 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,GAAG,6EAA+D,sBAAA;QACxDC,OACAC,MAQAC,MAQAC,MAQAC,MACAC,MACAC;;;;gBA3BAN,QAAQ;oBAAEO,KAAK;oBAAaC,GAAAA;oBAAGC,GAAG;gBAAG;gBAC9B;;oBAAMC,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMZ,OAAO;gBAKba,OAAOb,KAAKc,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOb,KAAKW,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEjC;;oBAAMN,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMX,OAAO;gBAKbY,OAAOZ,KAAKa,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOZ,KAAKU,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEjC;;oBAAMN,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMV,OAAO;gBAKbW,OAAOX,KAAKY,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOX,KAAKS,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEhC;;oBAAMf,KAAKiB,MAAM;;;gBAAzBd,OAAO,AAAC,cAAqBe,UAAU;gBAC/B;;oBAAMjB,KAAKgB,MAAM;;;gBAAzBb,OAAO,AAAC,cAAqBc,UAAU;gBAC/B;;oBAAMhB,KAAKe,MAAM;;;gBAAzBZ,OAAO,AAAC,cAAqBa,UAAU;gBAE7CC,QAAQC,GAAG,CAAC;oBAAEC,SAAAA;oBAASd,GAAAA;oBAAGJ,MAAAA;oBAAMC,MAAAA;oBAAMC,MAAAA;gBAAK;gBAE3CQ,OAAOT,MAAMkB,YAAY,CAACjB;gBAC1BQ,OAAOV,MAAMmB,YAAY,CAAClB;;;;;;AAC9B", + "mappings": ";;AAAAA,GAAG,mGAA+D;QACxDC,OACAC,MAQAC,MAQAC,MAQAC,MACAC,MACAC;;;;gBA3BAN,QAAQ;oBAAEO,KAAK;oBAAaC,GAAAA;oBAAGC,GAAG;gBAAG;gBAC9B;;oBAAMC,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMZ,OAAO;gBAKba,OAAOb,KAAKc,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOb,KAAKW,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEjC;;oBAAMN,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMX,OAAO;gBAKbY,OAAOZ,KAAKa,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOZ,KAAKU,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEjC;;oBAAMN,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMV,OAAO;gBAKbW,OAAOX,KAAKY,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOX,KAAKS,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEhC;;oBAAMf,KAAKiB,MAAM;;;gBAAzBd,OAAO,AAAC,cAAqBe,UAAU;gBAC/B;;oBAAMjB,KAAKgB,MAAM;;;gBAAzBb,OAAO,AAAC,cAAqBc,UAAU;gBAC/B;;oBAAMhB,KAAKe,MAAM;;;gBAAzBZ,OAAO,AAAC,cAAqBa,UAAU;gBAE7CC,QAAQC,GAAG,CAAC;oBAAEC,SAAAA;oBAASd,GAAAA;oBAAGJ,MAAAA;oBAAMC,MAAAA;oBAAMC,MAAAA;gBAAK;gBAE3CQ,OAAOT,MAAMkB,YAAY,CAACjB;gBAC1BQ,OAAOV,MAAMmB,YAAY,CAAClB;;;;;;AAC9B", "names": [ "it", "query", diff --git a/crates/swc/tests/fixture/sourcemap/006/output/index.map b/crates/swc/tests/fixture/sourcemap/006/output/index.map index bbf69b5f86f4..cb4928a54a6a 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,GAAG,6EAA+D,sBAAA;QAOxDC,OACAC,MAQAC,MAQAC,MAQAC,MACAC,MACAC;;;;gBAjCN;;;;;KAKC,GACKN,QAAQ;oBAAEO,KAAK;oBAAaC,GAAAA;oBAAGC,GAAG;gBAAG;gBAC9B;;oBAAMC,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMZ,OAAO;gBAKba,OAAOb,KAAKc,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOb,KAAKW,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEjC;;oBAAMN,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMX,OAAO;gBAKbY,OAAOZ,KAAKa,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOZ,KAAKU,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEjC;;oBAAMN,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMV,OAAO;gBAKbW,OAAOX,KAAKY,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOX,KAAKS,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEhC;;oBAAMf,KAAKiB,MAAM;;;gBAAzBd,OAAO,AAAC,cAAqBe,UAAU;gBAC/B;;oBAAMjB,KAAKgB,MAAM;;;gBAAzBb,OAAO,AAAC,cAAqBc,UAAU;gBAC/B;;oBAAMhB,KAAKe,MAAM;;;gBAAzBZ,OAAO,AAAC,cAAqBa,UAAU;gBAE7CC,QAAQC,GAAG,CAAC;oBAAEC,SAAAA;oBAASd,GAAAA;oBAAGJ,MAAAA;oBAAMC,MAAAA;oBAAMC,MAAAA;gBAAK;gBAE3CQ,OAAOT,MAAMkB,YAAY,CAACjB;gBAC1BQ,OAAOV,MAAMmB,YAAY,CAAClB;;;;;;AAC9B", + "mappings": ";;AAAAA,GAAG,mGAA+D;QAOxDC,OACAC,MAQAC,MAQAC,MAQAC,MACAC,MACAC;;;;gBAjCN;;;;;KAKC,GACKN,QAAQ;oBAAEO,KAAK;oBAAaC,GAAAA;oBAAGC,GAAG;gBAAG;gBAC9B;;oBAAMC,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMZ,OAAO;gBAKba,OAAOb,KAAKc,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOb,KAAKW,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEjC;;oBAAMN,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMX,OAAO;gBAKbY,OAAOZ,KAAKa,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOZ,KAAKU,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEjC;;oBAAMN,aAAaC,SAAS,gBAAgBX,OAAO;wBAC5DY,SAAS;4BACLC,QAAQ;wBACZ;oBACJ;;;gBAJMV,OAAO;gBAKbW,OAAOX,KAAKY,MAAM,EAAEC,IAAI,CAAC;gBACzBF,OAAOX,KAAKS,OAAO,CAACK,GAAG,CAAC,iBAAiBD,IAAI,CAAC;gBAEhC;;oBAAMf,KAAKiB,MAAM;;;gBAAzBd,OAAO,AAAC,cAAqBe,UAAU;gBAC/B;;oBAAMjB,KAAKgB,MAAM;;;gBAAzBb,OAAO,AAAC,cAAqBc,UAAU;gBAC/B;;oBAAMhB,KAAKe,MAAM;;;gBAAzBZ,OAAO,AAAC,cAAqBa,UAAU;gBAE7CC,QAAQC,GAAG,CAAC;oBAAEC,SAAAA;oBAASd,GAAAA;oBAAGJ,MAAAA;oBAAMC,MAAAA;oBAAMC,MAAAA;gBAAK;gBAE3CQ,OAAOT,MAAMkB,YAAY,CAACjB;gBAC1BQ,OAAOV,MAAMmB,YAAY,CAAClB;;;;;;AAC9B", "names": [ "it", "query", diff --git a/crates/swc/tests/ts-isolated-declaration/oxc/output/async-function.ts b/crates/swc/tests/ts-isolated-declaration/oxc/output/async-function.ts index f5588800c7ff..2f0d5cd31cc0 100644 --- a/crates/swc/tests/ts-isolated-declaration/oxc/output/async-function.ts +++ b/crates/swc/tests/ts-isolated-declaration/oxc/output/async-function.ts @@ -14,7 +14,7 @@ function _asyncFunctionGood() { }); return _asyncFunctionGood.apply(this, arguments); } -var asyncFunctionGoo2 = function() { +var asyncFunctionGoo2 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -43,7 +43,7 @@ function _asyncFunction() { }); return _asyncFunction.apply(this, arguments); } -var asyncFunction2 = function() { +var asyncFunction2 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ diff --git a/crates/swc/tests/tsc-references/ES5SymbolProperty3.2.minified.js b/crates/swc/tests/tsc-references/ES5SymbolProperty3.2.minified.js index d69ecbd11542..974cddbd6f1a 100644 --- a/crates/swc/tests/tsc-references/ES5SymbolProperty3.2.minified.js +++ b/crates/swc/tests/tsc-references/ES5SymbolProperty3.2.minified.js @@ -1,7 +1,7 @@ //// [ES5SymbolProperty3.ts] var Symbol; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(new /*#__PURE__*/ (function() { +(new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/ES5SymbolProperty4.2.minified.js b/crates/swc/tests/tsc-references/ES5SymbolProperty4.2.minified.js index 221e5e81c968..eb27256b039a 100644 --- a/crates/swc/tests/tsc-references/ES5SymbolProperty4.2.minified.js +++ b/crates/swc/tests/tsc-references/ES5SymbolProperty4.2.minified.js @@ -1,7 +1,7 @@ //// [ES5SymbolProperty4.ts] var Symbol; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(new /*#__PURE__*/ (function() { +(new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/ES5SymbolProperty5.2.minified.js b/crates/swc/tests/tsc-references/ES5SymbolProperty5.2.minified.js index 866663f71691..3a8770ded2aa 100644 --- a/crates/swc/tests/tsc-references/ES5SymbolProperty5.2.minified.js +++ b/crates/swc/tests/tsc-references/ES5SymbolProperty5.2.minified.js @@ -1,7 +1,7 @@ //// [ES5SymbolProperty5.ts] var Symbol; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(new /*#__PURE__*/ (function() { +(new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/ES5SymbolProperty6.2.minified.js b/crates/swc/tests/tsc-references/ES5SymbolProperty6.2.minified.js index 801b7301b546..d560b30325d7 100644 --- a/crates/swc/tests/tsc-references/ES5SymbolProperty6.2.minified.js +++ b/crates/swc/tests/tsc-references/ES5SymbolProperty6.2.minified.js @@ -1,6 +1,6 @@ //// [ES5SymbolProperty6.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(new /*#__PURE__*/ (function() { +(new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/ES5SymbolProperty7.2.minified.js b/crates/swc/tests/tsc-references/ES5SymbolProperty7.2.minified.js index 5b1585214c69..7f3a58a1bc1f 100644 --- a/crates/swc/tests/tsc-references/ES5SymbolProperty7.2.minified.js +++ b/crates/swc/tests/tsc-references/ES5SymbolProperty7.2.minified.js @@ -1,7 +1,7 @@ //// [ES5SymbolProperty7.ts] var Symbol; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(new /*#__PURE__*/ (function() { +(new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction10_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunction10_es5.1.normal.js index 8cacdfc1310e..287216117f4c 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction10_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction10_es5.1.normal.js @@ -1,7 +1,7 @@ //// [asyncArrowFunction10_es5.ts] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -var foo = function() { +var foo = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { var v; return _ts_generator(this, function(_state) { diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction10_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction10_es5.2.minified.js index cc7929ec445f..f40558828a07 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction10_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction10_es5.2.minified.js @@ -1,10 +1,3 @@ //// [asyncArrowFunction10_es5.ts] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -_async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}); diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction10_es6.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunction10_es6.1.normal.js index 5e7ed27b36dc..5aef90234aa2 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction10_es6.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction10_es6.1.normal.js @@ -1,6 +1,6 @@ //// [asyncArrowFunction10_es6.ts] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; -var foo = function() { +var foo = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { // Legal to use 'await' in a type context. var v; diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction10_es6.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction10_es6.2.minified.js index 256709ccfe44..c60b9d405bcb 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction10_es6.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction10_es6.2.minified.js @@ -1,3 +1,2 @@ //// [asyncArrowFunction10_es6.ts] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; -_async_to_generator(function*() {}); diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction1_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunction1_es5.1.normal.js index 1a01bb7e789b..30e8bdf42a4c 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction1_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction1_es5.1.normal.js @@ -1,7 +1,7 @@ //// [asyncArrowFunction1_es5.ts] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -var foo = function() { +var foo = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction1_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction1_es5.2.minified.js index 0814e8a21860..3ef432144774 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction1_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction1_es5.2.minified.js @@ -1,10 +1,3 @@ //// [asyncArrowFunction1_es5.ts] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -_async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}); diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction1_es6.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunction1_es6.1.normal.js index f750c04ead04..e29ce89fc18f 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction1_es6.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction1_es6.1.normal.js @@ -1,6 +1,6 @@ //// [asyncArrowFunction1_es6.ts] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; -var foo = function() { +var foo = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function foo() { return _ref.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction1_es6.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction1_es6.2.minified.js index 663ebbb05d52..2c95d5f4f725 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction1_es6.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction1_es6.2.minified.js @@ -1,3 +1,2 @@ //// [asyncArrowFunction1_es6.ts] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; -_async_to_generator(function*() {}); diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es5.1.normal.js index 9fa5c09dc29d..713827727ec9 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es5.1.normal.js @@ -11,7 +11,7 @@ var C = /*#__PURE__*/ function() { _proto.method = function method() { function other() {} var _this = this, _arguments = arguments; - var fn = function() { + var fn = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { switch(_state.label){ diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es6.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es6.1.normal.js index a9beacab46ec..3f4ee8c572a8 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es6.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesArguments_es6.1.normal.js @@ -4,7 +4,7 @@ class C { method() { function other() {} var _this = this, _arguments = arguments; - var fn = function() { + var fn = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return yield other.apply(_this, _arguments); }); @@ -17,7 +17,7 @@ class C { function f() { var _arguments = arguments; return /*#__PURE__*/ _async_to_generator(function*() { - /*#__PURE__*/ return _async_to_generator(function*() { + /*#__PURE__*/ return /*#__PURE__*/ _async_to_generator(function*() { return _arguments.length; }); }); diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es5.1.normal.js index dff38994c2d3..7145001fcbc1 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es5.1.normal.js @@ -10,7 +10,7 @@ var C = /*#__PURE__*/ function() { var _proto = C.prototype; _proto.method = function method() { var _this = this; - var fn = function() { + var fn = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { switch(_state.label){ diff --git a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es6.1.normal.js b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es6.1.normal.js index 8a44b81634b8..f993a8765949 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es6.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunctionCapturesThis_es6.1.normal.js @@ -3,7 +3,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; class C { method() { var _this = this; - var fn = function() { + var fn = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return yield _this; }); diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5.1.normal.js index 5f4bcc3ee4ea..4417bd857d8d 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5.1.normal.js @@ -41,7 +41,7 @@ function _f3() { }); return _f3.apply(this, arguments); } -var f4 = function() { +var f4 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -53,7 +53,7 @@ var f4 = function() { return _ref.apply(this, arguments); }; }(); -var f5 = function() { +var f5 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -65,7 +65,7 @@ var f5 = function() { return _ref.apply(this, arguments); }; }(); -var f6 = function() { +var f6 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -77,7 +77,7 @@ var f6 = function() { return _ref.apply(this, arguments); }; }(); -var f7 = function() { +var f7 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -89,7 +89,7 @@ var f7 = function() { return _ref.apply(this, arguments); }; }(); -var f8 = function() { +var f8 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -101,7 +101,7 @@ var f8 = function() { return _ref.apply(this, arguments); }; }(); -var f9 = function() { +var f9 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -113,7 +113,7 @@ var f9 = function() { return _ref.apply(this, arguments); }; }(); -var f10 = function() { +var f10 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -126,7 +126,7 @@ var f10 = function() { return _ref.apply(this, arguments); }; }(); -var f11 = function() { +var f11 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -139,7 +139,7 @@ var f11 = function() { return _ref.apply(this, arguments); }; }(); -var f12 = function() { +var f12 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -152,7 +152,7 @@ var f12 = function() { return _ref.apply(this, arguments); }; }(); -var f13 = function() { +var f13 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5.2.minified.js index efcffa015520..e87ebe418182 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5.2.minified.js @@ -3,71 +3,7 @@ var M; import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -_async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); -}), function(M) { +!function(M) { function _f1() { return (_f1 = _async_to_generator(function() { return _ts_generator(this, function(_state) { diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6.1.normal.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6.1.normal.js index c2f66e457750..fc891b4d26ff 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6.1.normal.js @@ -21,43 +21,43 @@ function _f3() { _f3 = _async_to_generator(function*() {}); return _f3.apply(this, arguments); } -let f4 = function() { +let f4 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function f4() { return _ref.apply(this, arguments); }; }(); -let f5 = function() { +let f5 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function f5() { return _ref.apply(this, arguments); }; }(); -let f6 = function() { +let f6 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function f6() { return _ref.apply(this, arguments); }; }(); -let f7 = function() { +let f7 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function f7() { return _ref.apply(this, arguments); }; }(); -let f8 = function() { +let f8 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function f8() { return _ref.apply(this, arguments); }; }(); -let f9 = function() { +let f9 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function f9() { return _ref.apply(this, arguments); }; }(); -let f10 = function() { +let f10 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return p; }); @@ -65,7 +65,7 @@ let f10 = function() { return _ref.apply(this, arguments); }; }(); -let f11 = function() { +let f11 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return mp; }); @@ -73,7 +73,7 @@ let f11 = function() { return _ref.apply(this, arguments); }; }(); -let f12 = function() { +let f12 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return mp; }); @@ -81,7 +81,7 @@ let f12 = function() { return _ref.apply(this, arguments); }; }(); -let f13 = function() { +let f13 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return p; }); diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6.2.minified.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6.2.minified.js index 16c603790e70..26121be45d04 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6.2.minified.js @@ -1,15 +1,7 @@ //// [asyncAwaitIsolatedModules_es6.ts] var M; import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; -_async_to_generator(function*() {}), _async_to_generator(function*() {}), _async_to_generator(function*() {}), _async_to_generator(function*() {}), _async_to_generator(function*() {}), _async_to_generator(function*() {}), _async_to_generator(function*() { - return p; -}), _async_to_generator(function*() { - return mp; -}), _async_to_generator(function*() { - return mp; -}), _async_to_generator(function*() { - return p; -}), function(M) { +!function(M) { function _f1() { return (_f1 = _async_to_generator(function*() {})).apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncAwait_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwait_es5.1.normal.js index 774a25373f18..7328157a45ce 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es5.1.normal.js @@ -41,7 +41,7 @@ function _f3() { }); return _f3.apply(this, arguments); } -var f4 = function() { +var f4 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -53,7 +53,7 @@ var f4 = function() { return _ref.apply(this, arguments); }; }(); -var f5 = function() { +var f5 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -65,7 +65,7 @@ var f5 = function() { return _ref.apply(this, arguments); }; }(); -var f6 = function() { +var f6 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -77,7 +77,7 @@ var f6 = function() { return _ref.apply(this, arguments); }; }(); -var f7 = function() { +var f7 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -89,7 +89,7 @@ var f7 = function() { return _ref.apply(this, arguments); }; }(); -var f8 = function() { +var f8 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -101,7 +101,7 @@ var f8 = function() { return _ref.apply(this, arguments); }; }(); -var f9 = function() { +var f9 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -113,7 +113,7 @@ var f9 = function() { return _ref.apply(this, arguments); }; }(); -var f10 = function() { +var f10 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -126,7 +126,7 @@ var f10 = function() { return _ref.apply(this, arguments); }; }(); -var f11 = function() { +var f11 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -139,7 +139,7 @@ var f11 = function() { return _ref.apply(this, arguments); }; }(); -var f12 = function() { +var f12 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -152,7 +152,7 @@ var f12 = function() { return _ref.apply(this, arguments); }; }(); -var f13 = function() { +var f13 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { return _ts_generator(this, function(_state) { return [ diff --git a/crates/swc/tests/tsc-references/asyncAwait_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncAwait_es5.2.minified.js index 329c20b0d5c8..e4cf0ade0336 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es5.2.minified.js @@ -3,71 +3,7 @@ var M; import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -_async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - mp - ]; - }); -}), _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - p - ]; - }); -}), function(M) { +!function(M) { function _f1() { return (_f1 = _async_to_generator(function() { return _ts_generator(this, function(_state) { diff --git a/crates/swc/tests/tsc-references/asyncAwait_es6.1.normal.js b/crates/swc/tests/tsc-references/asyncAwait_es6.1.normal.js index 213aacecd858..8c5726d4287d 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es6.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es6.1.normal.js @@ -21,43 +21,43 @@ function _f3() { _f3 = _async_to_generator(function*() {}); return _f3.apply(this, arguments); } -let f4 = function() { +let f4 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function f4() { return _ref.apply(this, arguments); }; }(); -let f5 = function() { +let f5 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function f5() { return _ref.apply(this, arguments); }; }(); -let f6 = function() { +let f6 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function f6() { return _ref.apply(this, arguments); }; }(); -let f7 = function() { +let f7 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function f7() { return _ref.apply(this, arguments); }; }(); -let f8 = function() { +let f8 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function f8() { return _ref.apply(this, arguments); }; }(); -let f9 = function() { +let f9 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() {}); return function f9() { return _ref.apply(this, arguments); }; }(); -let f10 = function() { +let f10 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return p; }); @@ -65,7 +65,7 @@ let f10 = function() { return _ref.apply(this, arguments); }; }(); -let f11 = function() { +let f11 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return mp; }); @@ -73,7 +73,7 @@ let f11 = function() { return _ref.apply(this, arguments); }; }(); -let f12 = function() { +let f12 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return mp; }); @@ -81,7 +81,7 @@ let f12 = function() { return _ref.apply(this, arguments); }; }(); -let f13 = function() { +let f13 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return p; }); diff --git a/crates/swc/tests/tsc-references/asyncAwait_es6.2.minified.js b/crates/swc/tests/tsc-references/asyncAwait_es6.2.minified.js index 854a0c852f3f..b4acbcacb114 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es6.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es6.2.minified.js @@ -1,15 +1,7 @@ //// [asyncAwait_es6.ts] var M; import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; -_async_to_generator(function*() {}), _async_to_generator(function*() {}), _async_to_generator(function*() {}), _async_to_generator(function*() {}), _async_to_generator(function*() {}), _async_to_generator(function*() {}), _async_to_generator(function*() { - return p; -}), _async_to_generator(function*() { - return mp; -}), _async_to_generator(function*() { - return mp; -}), _async_to_generator(function*() { - return p; -}), function(M) { +!function(M) { function _f1() { return (_f1 = _async_to_generator(function*() {})).apply(this, arguments); } diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration16_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration16_es5.1.normal.js index bb09e741c6f2..ea68539d8a8e 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration16_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration16_es5.1.normal.js @@ -18,7 +18,7 @@ * @returns {string} */ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -var f1 = function() { +var f1 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(str) { return _ts_generator(this, function(_state) { return [ @@ -31,7 +31,7 @@ var f1 = function() { return _ref.apply(this, arguments); }; }(); -/** @type {T1} */ var f2 = function() { +/** @type {T1} */ var f2 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(str) { return _ts_generator(this, function(_state) { return [ @@ -47,7 +47,7 @@ var f1 = function() { /** * @param {string} str * @returns {Promise} - */ var f3 = function() { + */ var f3 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(str) { return _ts_generator(this, function(_state) { return [ @@ -60,7 +60,7 @@ var f1 = function() { return _ref.apply(this, arguments); }; }(); -/** @type {T2} */ var f4 = function() { +/** @type {T2} */ var f4 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(str) { return _ts_generator(this, function(_state) { return [ @@ -73,7 +73,7 @@ var f1 = function() { return _ref.apply(this, arguments); }; }(); -/** @type {T3} */ var f5 = function() { +/** @type {T3} */ var f5 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(str) { return _ts_generator(this, function(_state) { return [ diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclaration16_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncFunctionDeclaration16_es5.2.minified.js index fd6ec9e5a465..b2fc0f1b0661 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclaration16_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclaration16_es5.2.minified.js @@ -3,39 +3,3 @@ //// [/a.js] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -_async_to_generator(function(str) { - return _ts_generator(this, function(_state) { - return [ - 2, - str - ]; - }); -}), _async_to_generator(function(str) { - return _ts_generator(this, function(_state) { - return [ - 2, - str - ]; - }); -}), _async_to_generator(function(str) { - return _ts_generator(this, function(_state) { - return [ - 2, - str - ]; - }); -}), _async_to_generator(function(str) { - return _ts_generator(this, function(_state) { - return [ - 2, - str - ]; - }); -}), _async_to_generator(function(str) { - return _ts_generator(this, function(_state) { - return [ - 2, - str - ]; - }); -}); diff --git a/crates/swc/tests/tsc-references/asyncFunctionDeclarationParameterEvaluation(target=es2015).1.normal.js b/crates/swc/tests/tsc-references/asyncFunctionDeclarationParameterEvaluation(target=es2015).1.normal.js index 6aca44cf566b..edfc28ed2535 100644 --- a/crates/swc/tests/tsc-references/asyncFunctionDeclarationParameterEvaluation(target=es2015).1.normal.js +++ b/crates/swc/tests/tsc-references/asyncFunctionDeclarationParameterEvaluation(target=es2015).1.normal.js @@ -34,7 +34,7 @@ function _f4() { _f4 = _async_to_generator(function*(x = z) { var _arguments = arguments; return /*#__PURE__*/ _async_to_generator(function*() { - /*#__PURE__*/ return _async_to_generator(function*() { + /*#__PURE__*/ return /*#__PURE__*/ _async_to_generator(function*() { return _arguments; }); }); @@ -67,7 +67,7 @@ function _f7() { _f7 = _async_to_generator(function*(x = z, ...args) { var _arguments = arguments; return /*#__PURE__*/ _async_to_generator(function*() { - /*#__PURE__*/ return _async_to_generator(function*() { + /*#__PURE__*/ return /*#__PURE__*/ _async_to_generator(function*() { return _arguments; }); }); @@ -93,7 +93,7 @@ function _f9() { _f9 = _async_to_generator(function*() { var _arguments = arguments; return /*#__PURE__*/ _async_to_generator(function*(x = z) { - /*#__PURE__*/ return _async_to_generator(function*() { + /*#__PURE__*/ return /*#__PURE__*/ _async_to_generator(function*() { return _arguments; }); }); @@ -106,7 +106,7 @@ function f10() { function _f10() { _f10 = _async_to_generator(function*(x = z) { return /*#__PURE__*/ _async_to_generator(function*() { - /*#__PURE__*/ return _async_to_generator(function*() { + /*#__PURE__*/ return /*#__PURE__*/ _async_to_generator(function*() { var _arguments = arguments; return /*#__PURE__*/ _async_to_generator(function*() { return _arguments; @@ -125,26 +125,26 @@ function f11() { function f12() { var _arguments = arguments; return /*#__PURE__*/ _async_to_generator(function*(x = z) { - /*#__PURE__*/ return _async_to_generator(function*() { + /*#__PURE__*/ return /*#__PURE__*/ _async_to_generator(function*() { return _arguments; }); }); } function f() { - const a1 = function() { + const a1 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(x, y = z) {}); return function a1(x) { return _ref.apply(this, arguments); }; }(); - const a2 = function() { + const a2 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*({ [z]: x }) {}); return function a2(_) { return _ref.apply(this, arguments); }; }(); var _arguments = arguments; - const a3 = function() { + const a3 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(x = z) { return /*#__PURE__*/ _async_to_generator(function*() { return _arguments; @@ -155,10 +155,10 @@ function f() { }; }(); var _arguments1 = arguments; - const a4 = function() { + const a4 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(x = z) { return /*#__PURE__*/ _async_to_generator(function*() { - /*#__PURE__*/ return _async_to_generator(function*() { + /*#__PURE__*/ return /*#__PURE__*/ _async_to_generator(function*() { return _arguments1; }); }); @@ -167,14 +167,14 @@ function f() { return _ref.apply(this, arguments); }; }(); - const a5 = function() { + const a5 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(x = z, ...args) {}); return function a5() { return _ref.apply(this, arguments); }; }(); var _arguments2 = arguments; - const a6 = function() { + const a6 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(x = z, ...args) { return /*#__PURE__*/ _async_to_generator(function*() { return _arguments2; @@ -185,10 +185,10 @@ function f() { }; }(); var _arguments3 = arguments; - const a7 = function() { + const a7 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(x = z, ...args) { return /*#__PURE__*/ _async_to_generator(function*() { - /*#__PURE__*/ return _async_to_generator(function*() { + /*#__PURE__*/ return /*#__PURE__*/ _async_to_generator(function*() { return _arguments3; }); }); @@ -198,7 +198,7 @@ function f() { }; }(); var _arguments4 = arguments; - const a8 = function() { + const a8 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return /*#__PURE__*/ _async_to_generator(function*(x = z) { return _arguments4; @@ -209,10 +209,10 @@ function f() { }; }(); var _arguments5 = arguments; - const a9 = function() { + const a9 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return /*#__PURE__*/ _async_to_generator(function*(x = z) { - /*#__PURE__*/ return _async_to_generator(function*() { + /*#__PURE__*/ return /*#__PURE__*/ _async_to_generator(function*() { return _arguments5; }); }); @@ -221,10 +221,10 @@ function f() { return _ref.apply(this, arguments); }; }(); - const a10 = function() { + const a10 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(x = z) { return /*#__PURE__*/ _async_to_generator(function*() { - /*#__PURE__*/ return _async_to_generator(function*() { + /*#__PURE__*/ return /*#__PURE__*/ _async_to_generator(function*() { var _arguments = arguments; return /*#__PURE__*/ _async_to_generator(function*() { return _arguments; diff --git a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es6.1.normal.js b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es6.1.normal.js index f1a46e9dcd6d..b22f86e7cfe8 100644 --- a/crates/swc/tests/tsc-references/asyncMethodWithSuper_es6.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncMethodWithSuper_es6.1.normal.js @@ -65,12 +65,12 @@ class B extends A { ()=>_superprop_get_x().call(_this); // element access in arrow ()=>_superprop_get("x").call(_this); - // property access in async arrow - /*#__PURE__*/ _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(// property access in async arrow + function*() { return _superprop_get_x().call(_this); }); - // element access in async arrow - /*#__PURE__*/ _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(// element access in async arrow + function*() { return _superprop_get("x").call(_this); }); })(); @@ -84,8 +84,8 @@ class B extends A { const a = _superprop_get_x(); // property access in arrow ()=>_superprop_get_x().call(_this); - // property access in async arrow - /*#__PURE__*/ _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(// property access in async arrow + function*() { return _superprop_get_x().call(_this); }); })(); @@ -109,8 +109,8 @@ class B extends A { }); // property access (assign) in arrow ()=>_superprop_set_x(f); - // property access (assign) in async arrow - /*#__PURE__*/ _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(// property access (assign) in async arrow + function*() { return _superprop_set_x(f); }); })(); @@ -124,8 +124,8 @@ class B extends A { const a = _superprop_get("x"); // element access in arrow ()=>_superprop_get("x").call(_this); - // element access in async arrow - /*#__PURE__*/ _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(// element access in async arrow + function*() { return _superprop_get("x").call(_this); }); })(); @@ -149,8 +149,8 @@ class B extends A { }); // element access (assign) in arrow ()=>_superprop_set("x", f); - // element access (assign) in async arrow - /*#__PURE__*/ _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(// element access (assign) in async arrow + function*() { return _superprop_set("x", f); }); })(); @@ -164,8 +164,8 @@ class B extends A { const a = _superprop_get_x(); // property access in arrow ()=>_superprop_get_x().call(_this); - // property access in async arrow - /*#__PURE__*/ _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(// property access in async arrow + function*() { return _superprop_get_x().call(_this); }); })(); @@ -189,8 +189,8 @@ class B extends A { }); // property access (assign) in arrow ()=>_superprop_set_x(f); - // property access (assign) in async arrow - /*#__PURE__*/ _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(// property access (assign) in async arrow + function*() { return _superprop_set_x(f); }); })(); @@ -204,8 +204,8 @@ class B extends A { const a = _superprop_get("x"); // element access in arrow ()=>_superprop_get("x").call(_this); - // element access in async arrow - /*#__PURE__*/ _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(// element access in async arrow + function*() { return _superprop_get("x").call(_this); }); })(); @@ -229,8 +229,8 @@ class B extends A { }); // element access (assign) in arrow ()=>_superprop_set("x", f); - // element access (assign) in async arrow - /*#__PURE__*/ _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(// element access (assign) in async arrow + function*() { return _superprop_set("x", f); }); })(); diff --git a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5.1.normal.js index e64bbbf7e5e0..3bdc35c35e76 100644 --- a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5.1.normal.js @@ -1,7 +1,7 @@ //// [asyncUnParenthesizedArrowFunction_es5.ts] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -var x = function() { +var x = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(i) { return _ts_generator(this, function(_state) { switch(_state.label){ @@ -22,7 +22,7 @@ var x = function() { return _ref.apply(this, arguments); }; }(); -var x1 = function() { +var x1 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(i) { return _ts_generator(this, function(_state) { switch(_state.label){ diff --git a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5.2.minified.js index 1f70e9a31150..3b752dc096d0 100644 --- a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es5.2.minified.js @@ -1,34 +1,3 @@ //// [asyncUnParenthesizedArrowFunction_es5.ts] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -_async_to_generator(function(i) { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - someOtherFunction(i) - ]; - case 1: - return [ - 2, - _state.sent() - ]; - } - }); -}), _async_to_generator(function(i) { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - someOtherFunction(i) - ]; - case 1: - return [ - 2, - _state.sent() - ]; - } - }); -}); diff --git a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6.1.normal.js b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6.1.normal.js index 0779da1e8b65..7fe43aa6ce8c 100644 --- a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6.1.normal.js @@ -1,6 +1,6 @@ //// [asyncUnParenthesizedArrowFunction_es6.ts] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; -const x = function() { +const x = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(i) { return yield someOtherFunction(i); }); @@ -8,7 +8,7 @@ const x = function() { return _ref.apply(this, arguments); }; }(); -const x1 = function() { +const x1 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(i) { return yield someOtherFunction(i); }); diff --git a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6.2.minified.js b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6.2.minified.js index b4b4949af17d..895c164ec2ad 100644 --- a/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncUnParenthesizedArrowFunction_es6.2.minified.js @@ -1,7 +1,2 @@ //// [asyncUnParenthesizedArrowFunction_es6.ts] import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; -_async_to_generator(function*(i) { - return yield someOtherFunction(i); -}), _async_to_generator(function*(i) { - return yield someOtherFunction(i); -}); diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es2015).1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es2015).1.normal.js index d35d1106376d..d6cdfc7f1eda 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es2015).1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es2015).1.normal.js @@ -53,7 +53,7 @@ try { }); return _ag.apply(this, arguments); } - const a = function() { + const a = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { try { var _usingCtx = _using_ctx(); diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es2015).2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es2015).2.minified.js index 1e23f22187e2..e927492a1a0c 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es2015).2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es2015).2.minified.js @@ -7,17 +7,6 @@ try { var _usingCtx = _using_ctx(); _usingCtx.a({ [Symbol.asyncDispose]: ()=>_async_to_generator(function*() {})() - }), _async_to_generator(function*() { - try { - var _usingCtx = _using_ctx(); - _usingCtx.a({ - [Symbol.asyncDispose]: ()=>_async_to_generator(function*() {})() - }); - } catch (_) { - _usingCtx.e = _; - } finally{ - yield _usingCtx.d(); - } }); try { var _usingCtx1 = _using_ctx(); diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es5).1.normal.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es5).1.normal.js index ebf8514584d5..dd03b1149b1b 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es5).1.normal.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es5).1.normal.js @@ -144,7 +144,7 @@ try { }); return _ag.apply(this, arguments); } - var a = function() { + var a = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { var _usingCtx, d6, _; return _ts_generator(this, function(_state) { diff --git a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es5).2.minified.js b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es5).2.minified.js index f7e7ed4ef76b..64d976ae2176 100644 --- a/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es5).2.minified.js +++ b/crates/swc/tests/tsc-references/awaitUsingDeclarations.1(target=es5).2.minified.js @@ -16,49 +16,7 @@ try { ]; }); })(); - })), _async_to_generator(function() { - var _usingCtx, _; - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return _state.trys.push([ - 0, - 1, - 2, - 4 - ]), (_usingCtx = _using_ctx()).a(_define_property({}, Symbol.asyncDispose, function() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); - })(); - })), [ - 3, - 4 - ]; - case 1: - return _ = _state.sent(), _usingCtx.e = _, [ - 3, - 4 - ]; - case 2: - return [ - 4, - _usingCtx.d() - ]; - case 3: - return _state.sent(), [ - 7 - ]; - case 4: - return [ - 2 - ]; - } - }); - }); + })); try { var _usingCtx1 = _using_ctx(); _usingCtx1.a(_define_property({}, Symbol.asyncDispose, function() { diff --git a/crates/swc/tests/tsc-references/callGenericFunctionWithZeroTypeArguments.2.minified.js b/crates/swc/tests/tsc-references/callGenericFunctionWithZeroTypeArguments.2.minified.js index 9fd16b4979a0..2ed393fc265a 100644 --- a/crates/swc/tests/tsc-references/callGenericFunctionWithZeroTypeArguments.2.minified.js +++ b/crates/swc/tests/tsc-references/callGenericFunctionWithZeroTypeArguments.2.minified.js @@ -1,14 +1,14 @@ //// [callGenericFunctionWithZeroTypeArguments.ts] var i, i2; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(void 0)(1), new /*#__PURE__*/ (function() { +(void 0)(1), new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } return C.prototype.f = function(x) { return null; }, C; -}())().f(1), i.f(1), new /*#__PURE__*/ (function() { +}())().f(1), i.f(1), new (/*#__PURE__*/ function() { function C2() { _class_call_check(this, C2); } diff --git a/crates/swc/tests/tsc-references/callNonGenericFunctionWithTypeArguments.2.minified.js b/crates/swc/tests/tsc-references/callNonGenericFunctionWithTypeArguments.2.minified.js index 8b6a6f0079be..9c981a786ea3 100644 --- a/crates/swc/tests/tsc-references/callNonGenericFunctionWithTypeArguments.2.minified.js +++ b/crates/swc/tests/tsc-references/callNonGenericFunctionWithTypeArguments.2.minified.js @@ -1,14 +1,14 @@ //// [callNonGenericFunctionWithTypeArguments.ts] var i, i2, a, a2; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(void 0)(1), new /*#__PURE__*/ (function() { +(void 0)(1), new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } return C.prototype.f = function(x) { return null; }, C; -}())().f(1), i.f(1), new /*#__PURE__*/ (function() { +}())().f(1), i.f(1), new (/*#__PURE__*/ function() { function C2() { _class_call_check(this, C2); } diff --git a/crates/swc/tests/tsc-references/checkJsxIntersectionElementPropsType.2.minified.js b/crates/swc/tests/tsc-references/checkJsxIntersectionElementPropsType.2.minified.js index 2212182f006b..5ccfd00a8e24 100644 --- a/crates/swc/tests/tsc-references/checkJsxIntersectionElementPropsType.2.minified.js +++ b/crates/swc/tests/tsc-references/checkJsxIntersectionElementPropsType.2.minified.js @@ -2,7 +2,7 @@ import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; -new /*#__PURE__*/ (function(Component1) { +new (/*#__PURE__*/ function(Component1) { function C() { return _class_call_check(this, C), _call_super(this, C, arguments); } diff --git a/crates/swc/tests/tsc-references/classAbstractAsIdentifier.2.minified.js b/crates/swc/tests/tsc-references/classAbstractAsIdentifier.2.minified.js index 19c24ca06e85..67afcc9102e2 100644 --- a/crates/swc/tests/tsc-references/classAbstractAsIdentifier.2.minified.js +++ b/crates/swc/tests/tsc-references/classAbstractAsIdentifier.2.minified.js @@ -1,6 +1,6 @@ //// [classAbstractAsIdentifier.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -new /*#__PURE__*/ (function() { +new (/*#__PURE__*/ function() { function abstract() { _class_call_check(this, abstract); } diff --git a/crates/swc/tests/tsc-references/classCanExtendConstructorFunction.2.minified.js b/crates/swc/tests/tsc-references/classCanExtendConstructorFunction.2.minified.js index b8429897f5b6..e7826d57edb7 100644 --- a/crates/swc/tests/tsc-references/classCanExtendConstructorFunction.2.minified.js +++ b/crates/swc/tests/tsc-references/classCanExtendConstructorFunction.2.minified.js @@ -14,7 +14,7 @@ Wagon.circle = function(wagons) { }, Wagon.prototype.speed = function() { return this.numberOxen / this.weight(); }; -var db = new /*#__PURE__*/ (function(Wagon) { +var db = new (/*#__PURE__*/ function(Wagon) { function Sql() { var _this; return _class_call_check(this, Sql), (_this = _call_super(this, Sql)).foonly = 12, _this; @@ -29,7 +29,7 @@ db.numberOxen = db.foonly, /*#__PURE__*/ Dragon; import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; -var c = new /*#__PURE__*/ (function(Wagon1) { +var c = new (/*#__PURE__*/ function(Wagon1) { function Conestoga(drunkOO) { var _this; return _class_call_check(this, Conestoga), (_this = _call_super(this, Conestoga, [ diff --git a/crates/swc/tests/tsc-references/classExpression3.2.minified.js b/crates/swc/tests/tsc-references/classExpression3.2.minified.js index d5857ec6ae82..0b527d06846b 100644 --- a/crates/swc/tests/tsc-references/classExpression3.2.minified.js +++ b/crates/swc/tests/tsc-references/classExpression3.2.minified.js @@ -2,7 +2,7 @@ import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; -var c = new /*#__PURE__*/ (function(_superClass) { +var c = new (/*#__PURE__*/ function(_superClass) { function C() { var _this; return _class_call_check(this, C), _this = _call_super(this, C, arguments), _this.c = 3, _this; diff --git a/crates/swc/tests/tsc-references/classExpression5.1.normal.js b/crates/swc/tests/tsc-references/classExpression5.1.normal.js index da507f1faed5..f7db1357c1f4 100644 --- a/crates/swc/tests/tsc-references/classExpression5.1.normal.js +++ b/crates/swc/tests/tsc-references/classExpression5.1.normal.js @@ -1,6 +1,6 @@ //// [classExpression5.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -new /*#__PURE__*/ (function() { +new (/*#__PURE__*/ function() { "use strict"; function _class() { _class_call_check(this, _class); diff --git a/crates/swc/tests/tsc-references/classExpression5.2.minified.js b/crates/swc/tests/tsc-references/classExpression5.2.minified.js index 7d7aa832dec4..4d3adecc2d69 100644 --- a/crates/swc/tests/tsc-references/classExpression5.2.minified.js +++ b/crates/swc/tests/tsc-references/classExpression5.2.minified.js @@ -1,6 +1,6 @@ //// [classExpression5.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -new /*#__PURE__*/ (function() { +new (/*#__PURE__*/ function() { function _class() { _class_call_check(this, _class); } diff --git a/crates/swc/tests/tsc-references/classWithStaticFieldInParameterBindingPattern.2(target=es5).1.normal.js b/crates/swc/tests/tsc-references/classWithStaticFieldInParameterBindingPattern.2(target=es5).1.normal.js index 8742cf1cdf41..1d32423d4838 100644 --- a/crates/swc/tests/tsc-references/classWithStaticFieldInParameterBindingPattern.2(target=es5).1.normal.js +++ b/crates/swc/tests/tsc-references/classWithStaticFieldInParameterBindingPattern.2(target=es5).1.normal.js @@ -9,7 +9,7 @@ var C = function C() { _class_call_check(this, C); }; (function(param) { - var tmp = param[/*#__PURE__*/ (_class = function(C) { + var tmp = param[(_class = /*#__PURE__*/ function(C) { "use strict"; _inherits(_class, C); function _class() { @@ -22,7 +22,7 @@ var C = function C() { })(); var x = ""; (function(param) { - var tmp = param[/*#__PURE__*/ (_class1 = function(C) { + var tmp = param[(_class1 = /*#__PURE__*/ function(C) { "use strict"; _inherits(_class, C); function _class() { diff --git a/crates/swc/tests/tsc-references/classWithStaticFieldInParameterBindingPattern.2(target=es5).2.minified.js b/crates/swc/tests/tsc-references/classWithStaticFieldInParameterBindingPattern.2(target=es5).2.minified.js index 9a87c6ba43e9..c67b14a42abd 100644 --- a/crates/swc/tests/tsc-references/classWithStaticFieldInParameterBindingPattern.2(target=es5).2.minified.js +++ b/crates/swc/tests/tsc-references/classWithStaticFieldInParameterBindingPattern.2(target=es5).2.minified.js @@ -5,13 +5,13 @@ import { _ as _inherits } from "@swc/helpers/_/_inherits"; var _class, _class1, C = function C() { _class_call_check(this, C); }; -(void 0)[/*#__PURE__*/ ((_class = function(C) { +(void 0)[((_class = /*#__PURE__*/ function(C) { function _class() { return _class_call_check(this, _class), _call_super(this, _class, arguments); } return _inherits(_class, C), _class; }(C)).x = 1, _class).x], function(param) { - param[/*#__PURE__*/ ((_class1 = function(C) { + param[((_class1 = /*#__PURE__*/ function(C) { function _class() { return _class_call_check(this, _class), _call_super(this, _class, arguments); } diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015.1.normal.js index dc312ed9ec21..f2011b37d612 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015.1.normal.js @@ -1,6 +1,6 @@ //// [F1.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -const f1 = function() { +const f1 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function*() {}); return function f1() { return _ref.apply(this, arguments); @@ -8,7 +8,7 @@ const f1 = function() { }(); //// [F2.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -const f2 = function() { +const f2 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function*() { const x = yield; }); @@ -18,7 +18,7 @@ const f2 = function() { }(); //// [F3.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -const f3 = function() { +const f3 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function*() { const x = yield 1; }); @@ -31,7 +31,7 @@ import { _ as _async_generator_delegate } from "@swc/helpers/_/_async_generator_ import { _ as _async_iterator } from "@swc/helpers/_/_async_iterator"; import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generator"; import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -const f4 = function() { +const f4 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function*() { const x = yield* _async_generator_delegate(_async_iterator([ 1 @@ -46,7 +46,7 @@ import { _ as _async_generator_delegate } from "@swc/helpers/_/_async_generator_ import { _ as _async_iterator } from "@swc/helpers/_/_async_iterator"; import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generator"; import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -const f5 = function() { +const f5 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function*() { const x = yield* _async_generator_delegate(_async_iterator(_wrap_async_generator(function*() { yield 1; @@ -59,7 +59,7 @@ const f5 = function() { //// [F6.ts] import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generator"; import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -const f6 = function() { +const f6 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function*() { const x = yield _await_async_generator(1); }); @@ -69,7 +69,7 @@ const f6 = function() { }(); //// [F7.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -const f7 = function() { +const f7 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function*() { return 1; }); diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015.2.minified.js index 7e6cc9db62c5..1a21697b4ffa 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es2015.2.minified.js @@ -1,44 +1,21 @@ //// [F1.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -_wrap_async_generator(function*() {}); //// [F2.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -_wrap_async_generator(function*() { - yield; -}); //// [F3.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -_wrap_async_generator(function*() { - yield 1; -}); //// [F4.ts] import { _ as _async_generator_delegate } from "@swc/helpers/_/_async_generator_delegate"; import { _ as _async_iterator } from "@swc/helpers/_/_async_iterator"; import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generator"; import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -_wrap_async_generator(function*() { - yield* _async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator); -}); //// [F5.ts] import { _ as _async_generator_delegate } from "@swc/helpers/_/_async_generator_delegate"; import { _ as _async_iterator } from "@swc/helpers/_/_async_iterator"; import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generator"; import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -_wrap_async_generator(function*() { - yield* _async_generator_delegate(_async_iterator(_wrap_async_generator(function*() { - yield 1; - })()), _await_async_generator); -}); //// [F6.ts] import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generator"; import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -_wrap_async_generator(function*() { - yield _await_async_generator(1); -}); //// [F7.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; -_wrap_async_generator(function*() { - return 1; -}); diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5.1.normal.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5.1.normal.js index b4344515ff82..e3956d18b421 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5.1.normal.js @@ -1,7 +1,7 @@ //// [F1.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -var f1 = function() { +var f1 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function() { return _ts_generator(this, function(_state) { return [ @@ -16,7 +16,7 @@ var f1 = function() { //// [F2.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -var f2 = function() { +var f2 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function() { var x; return _ts_generator(this, function(_state) { @@ -40,7 +40,7 @@ var f2 = function() { //// [F3.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -var f3 = function() { +var f3 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function() { var x; return _ts_generator(this, function(_state) { @@ -69,7 +69,7 @@ import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generat import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; import { _ as _ts_values } from "@swc/helpers/_/_ts_values"; -var f4 = function() { +var f4 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function() { var x; return _ts_generator(this, function(_state) { @@ -100,7 +100,7 @@ import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generat import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; import { _ as _ts_values } from "@swc/helpers/_/_ts_values"; -var f5 = function() { +var f5 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function() { var x; return _ts_generator(this, function(_state) { @@ -141,7 +141,7 @@ var f5 = function() { import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generator"; import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -var f6 = function() { +var f6 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function() { var x; return _ts_generator(this, function(_state) { @@ -166,7 +166,7 @@ var f6 = function() { //// [F7.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -var f7 = function() { +var f7 = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function() { return _ts_generator(this, function(_state) { return [ diff --git a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5.2.minified.js b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5.2.minified.js index f75ef963c22d..eee397aee848 100644 --- a/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitter.asyncGenerators.functionExpressions.es5.2.minified.js @@ -1,48 +1,12 @@ //// [F1.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2 - ]; - }); -}); //// [F2.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4 - ]; - case 1: - return _state.sent(), [ - 2 - ]; - } - }); -}); //// [F3.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - 1 - ]; - case 1: - return _state.sent(), [ - 2 - ]; - } - }); -}); //// [F4.ts] import { _ as _async_generator_delegate } from "@swc/helpers/_/_async_generator_delegate"; import { _ as _async_iterator } from "@swc/helpers/_/_async_iterator"; @@ -50,23 +14,6 @@ import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generat import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; import { _ as _ts_values } from "@swc/helpers/_/_ts_values"; -_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 5, - _ts_values(_async_generator_delegate(_async_iterator([ - 1 - ]), _await_async_generator)) - ]; - case 1: - return _state.sent(), [ - 2 - ]; - } - }); -}); //// [F5.ts] import { _ as _async_generator_delegate } from "@swc/helpers/_/_async_generator_delegate"; import { _ as _async_iterator } from "@swc/helpers/_/_async_iterator"; @@ -74,62 +21,10 @@ import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generat import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; import { _ as _ts_values } from "@swc/helpers/_/_ts_values"; -_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - 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: - return _state.sent(), [ - 2 - ]; - } - }); - })()), _await_async_generator)) - ]; - case 1: - return _state.sent(), [ - 2 - ]; - } - }); -}); //// [F6.ts] import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generator"; import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - _await_async_generator(1) - ]; - case 1: - return _state.sent(), [ - 2 - ]; - } - }); -}); //// [F7.ts] import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -_wrap_async_generator(function() { - return _ts_generator(this, function(_state) { - return [ - 2, - 1 - ]; - }); -}); diff --git a/crates/swc/tests/tsc-references/genericCallTypeArgumentInference.2.minified.js b/crates/swc/tests/tsc-references/genericCallTypeArgumentInference.2.minified.js index 49a9a0dfaaa2..6e9359b089cc 100644 --- a/crates/swc/tests/tsc-references/genericCallTypeArgumentInference.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallTypeArgumentInference.2.minified.js @@ -1,6 +1,6 @@ //// [genericCallTypeArgumentInference.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var i, c = new /*#__PURE__*/ (function() { +var i, c = new (/*#__PURE__*/ function() { function C(t, u) { _class_call_check(this, C), this.t = t, this.u = u; } diff --git a/crates/swc/tests/tsc-references/genericCallWithConstraintsTypeArgumentInference.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithConstraintsTypeArgumentInference.2.minified.js index e285c87ce6d8..e33019874a34 100644 --- a/crates/swc/tests/tsc-references/genericCallWithConstraintsTypeArgumentInference.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithConstraintsTypeArgumentInference.2.minified.js @@ -2,7 +2,7 @@ import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; -var b, d1, d2, i, c = new /*#__PURE__*/ (function() { +var b, d1, d2, i, c = new (/*#__PURE__*/ function() { function C(t, u) { _class_call_check(this, C), this.t = t, this.u = u; } diff --git a/crates/swc/tests/tsc-references/genericClassWithFunctionTypedMemberArguments.2.minified.js b/crates/swc/tests/tsc-references/genericClassWithFunctionTypedMemberArguments.2.minified.js index 90ee92eeab3c..0ac7e75d7eb0 100644 --- a/crates/swc/tests/tsc-references/genericClassWithFunctionTypedMemberArguments.2.minified.js +++ b/crates/swc/tests/tsc-references/genericClassWithFunctionTypedMemberArguments.2.minified.js @@ -1,7 +1,7 @@ //// [genericClassWithFunctionTypedMemberArguments.ts] var ImmediatelyFix, WithCandidates, c, c2, c1, c21; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -ImmediatelyFix || (ImmediatelyFix = {}), (c = new /*#__PURE__*/ (function() { +ImmediatelyFix || (ImmediatelyFix = {}), (c = new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } @@ -14,7 +14,7 @@ ImmediatelyFix || (ImmediatelyFix = {}), (c = new /*#__PURE__*/ (function() { return ''; }), c.foo(function(x) { return ''; -}), (c2 = new /*#__PURE__*/ (function() { +}), (c2 = new (/*#__PURE__*/ function() { function C2() { _class_call_check(this, C2); } diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5AMD.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5AMD.1.normal.js index 3053f4c509bf..1b86053e3ede 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5AMD.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5AMD.1.normal.js @@ -150,7 +150,7 @@ define([ }) }; }; - var l = function() { + var l = /*#__PURE__*/ function() { var _ref = _async_to_generator._(function() { var req; return _ts_generator._(this, function(_state) { diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS.1.normal.js index 15f715390a78..70fea61a9203 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS.1.normal.js @@ -130,7 +130,7 @@ var cl2 = function cl2() { }) }; }; -var l = function() { +var l = /*#__PURE__*/ function() { var _ref = _async_to_generator._(function() { var req; return _ts_generator._(this, function(_state) { diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5System.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5System.1.normal.js index 459fea9d89a0..5dc0711115e7 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5System.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5System.1.normal.js @@ -112,7 +112,7 @@ System.register([ }) }; }); - _export("l", l = function() { + _export("l", l = /*#__PURE__*/ function() { var _ref = _async_to_generator(function() { var req; return _ts_generator(this, function(_state) { diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5UMD.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5UMD.1.normal.js index 70434d7df1ef..1e44f1c8a2cd 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5UMD.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5UMD.1.normal.js @@ -129,7 +129,7 @@ }) }; }; - var l = function() { + var l = /*#__PURE__*/ function() { var _ref = _async_to_generator._(function() { var req; return _ts_generator._(this, function(_state) { diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6AMD.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6AMD.1.normal.js index 92c2b5908500..1ce10cf35d1b 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6AMD.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6AMD.1.normal.js @@ -74,7 +74,7 @@ define([ }; } } - const l = function() { + const l = /*#__PURE__*/ function() { var _ref = _async_to_generator._(function*() { const req = yield new Promise((resolve, reject)=>require([ "./test" diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS.1.normal.js index 2af641624310..3b1240216037 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS.1.normal.js @@ -62,7 +62,7 @@ class cl2 { }; } } -const l = function() { +const l = /*#__PURE__*/ function() { var _ref = _async_to_generator._(function*() { const req = yield Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require("./test"))) // FIVE ; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6System.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6System.1.normal.js index 9b73dc9cf93f..c3ff93f51d46 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6System.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6System.1.normal.js @@ -50,7 +50,7 @@ System.register([ }; } }); - _export("l", l = function() { + _export("l", l = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { const req = yield _context.import('./test') // FIVE ; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6UMD.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6UMD.1.normal.js index cd66939f1746..c8dffe8731c0 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6UMD.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6UMD.1.normal.js @@ -69,7 +69,7 @@ }; } } - const l = function() { + const l = /*#__PURE__*/ function() { var _ref = _async_to_generator._(function*() { const req = yield import('./test') // FIVE ; diff --git a/crates/swc/tests/tsc-references/importCallExpressionNoModuleKindSpecified.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionNoModuleKindSpecified.1.normal.js index 60181656f507..b8a9881c288d 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionNoModuleKindSpecified.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionNoModuleKindSpecified.1.normal.js @@ -33,7 +33,7 @@ var C = /*#__PURE__*/ function() { var loadAsync = import("./0"); this.myModule.then(function(Zero) { console.log(Zero.foo()); - }, function() { + }, /*#__PURE__*/ function() { var _ref = _async_to_generator(function(err) { var one; return _ts_generator(this, function(_state) { diff --git a/crates/swc/tests/tsc-references/indexersInClassType.2.minified.js b/crates/swc/tests/tsc-references/indexersInClassType.2.minified.js index ad5f6bad32a4..2ff4b0c00a4b 100644 --- a/crates/swc/tests/tsc-references/indexersInClassType.2.minified.js +++ b/crates/swc/tests/tsc-references/indexersInClassType.2.minified.js @@ -1,6 +1,6 @@ //// [indexersInClassType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var r = new /*#__PURE__*/ (function() { +var r = new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/inferringClassMembersFromAssignments7.2.minified.js b/crates/swc/tests/tsc-references/inferringClassMembersFromAssignments7.2.minified.js index 46e6da6200fc..08b4fa73a0b9 100644 --- a/crates/swc/tests/tsc-references/inferringClassMembersFromAssignments7.2.minified.js +++ b/crates/swc/tests/tsc-references/inferringClassMembersFromAssignments7.2.minified.js @@ -1,6 +1,6 @@ //// [inferringClassMembersFromAssignments7.js] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var c = new /*#__PURE__*/ (function() { +var c = new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); var self = this; diff --git a/crates/swc/tests/tsc-references/instancePropertiesInheritedIntoClassType.2.minified.js b/crates/swc/tests/tsc-references/instancePropertiesInheritedIntoClassType.2.minified.js index 763be03f1f51..6afc7587e748 100644 --- a/crates/swc/tests/tsc-references/instancePropertiesInheritedIntoClassType.2.minified.js +++ b/crates/swc/tests/tsc-references/instancePropertiesInheritedIntoClassType.2.minified.js @@ -4,7 +4,7 @@ import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _create_class } from "@swc/helpers/_/_create_class"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; -NonGeneric || (NonGeneric = {}), (r = (d = new /*#__PURE__*/ (function(C) { +NonGeneric || (NonGeneric = {}), (r = (d = new (/*#__PURE__*/ function(C) { function D() { return _class_call_check(this, D), _call_super(this, D, arguments); } @@ -24,7 +24,7 @@ NonGeneric || (NonGeneric = {}), (r = (d = new /*#__PURE__*/ (function(C) { set: function(v) {} } ]), C; -}()))(1, 2)).fn()).x, r.y, r.y = 4, d.y(), Generic || (Generic = {}), (r1 = (d1 = new /*#__PURE__*/ (function(C) { +}()))(1, 2)).fn()).x, r.y, r.y = 4, d.y(), Generic || (Generic = {}), (r1 = (d1 = new (/*#__PURE__*/ function(C) { function D() { return _class_call_check(this, D), _call_super(this, D, arguments); } diff --git a/crates/swc/tests/tsc-references/instancePropertyInClassType.2.minified.js b/crates/swc/tests/tsc-references/instancePropertyInClassType.2.minified.js index 05c48d3c6848..14e8612e19ec 100644 --- a/crates/swc/tests/tsc-references/instancePropertyInClassType.2.minified.js +++ b/crates/swc/tests/tsc-references/instancePropertyInClassType.2.minified.js @@ -2,7 +2,7 @@ var NonGeneric, Generic, c, r, c1, r1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _create_class } from "@swc/helpers/_/_create_class"; -NonGeneric || (NonGeneric = {}), (r = (c = new /*#__PURE__*/ (function() { +NonGeneric || (NonGeneric = {}), (r = (c = new (/*#__PURE__*/ function() { function C(a, b) { _class_call_check(this, C), this.a = a, this.b = b; } @@ -17,7 +17,7 @@ NonGeneric || (NonGeneric = {}), (r = (c = new /*#__PURE__*/ (function() { set: function(v) {} } ]), C; -}())(1, 2)).fn()).x, r.y, r.y = 4, c.y(), Generic || (Generic = {}), (r1 = (c1 = new /*#__PURE__*/ (function() { +}())(1, 2)).fn()).x, r.y, r.y = 4, c.y(), Generic || (Generic = {}), (r1 = (c1 = new (/*#__PURE__*/ function() { function C(a, b) { _class_call_check(this, C), this.a = a, this.b = b; } diff --git a/crates/swc/tests/tsc-references/keyofAndIndexedAccess.2.minified.js b/crates/swc/tests/tsc-references/keyofAndIndexedAccess.2.minified.js index db3d278ffc4b..ad6732b4a3fb 100644 --- a/crates/swc/tests/tsc-references/keyofAndIndexedAccess.2.minified.js +++ b/crates/swc/tests/tsc-references/keyofAndIndexedAccess.2.minified.js @@ -14,7 +14,7 @@ one(function() {}), on({ }).get("hello"), dispatchMethod("someMethod", [ "hello", 35 -]), new /*#__PURE__*/ (function(SampleClass) { +]), new (/*#__PURE__*/ function(SampleClass) { function AnotherSampleClass(props) { return _class_call_check(this, AnotherSampleClass), _call_super(this, AnotherSampleClass, [ merge(props, { diff --git a/crates/swc/tests/tsc-references/localTypes5.2.minified.js b/crates/swc/tests/tsc-references/localTypes5.2.minified.js index e02da7166d9c..6bf6b3b4bbf0 100644 --- a/crates/swc/tests/tsc-references/localTypes5.2.minified.js +++ b/crates/swc/tests/tsc-references/localTypes5.2.minified.js @@ -1,6 +1,6 @@ //// [localTypes5.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -new /*#__PURE__*/ (function() { +new (/*#__PURE__*/ function() { function X() { _class_call_check(this, X); } diff --git a/crates/swc/tests/tsc-references/looseThisTypeInFunctions.2.minified.js b/crates/swc/tests/tsc-references/looseThisTypeInFunctions.2.minified.js index 638774b54fb1..afb4fedccfc8 100644 --- a/crates/swc/tests/tsc-references/looseThisTypeInFunctions.2.minified.js +++ b/crates/swc/tests/tsc-references/looseThisTypeInFunctions.2.minified.js @@ -1,6 +1,6 @@ //// [looseThisTypeInFunctions.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var u, c = new /*#__PURE__*/ (function() { +var u, c = new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/mappedTypeErrors.2.minified.js b/crates/swc/tests/tsc-references/mappedTypeErrors.2.minified.js index af883d2bb6d5..0a594e03871b 100644 --- a/crates/swc/tests/tsc-references/mappedTypeErrors.2.minified.js +++ b/crates/swc/tests/tsc-references/mappedTypeErrors.2.minified.js @@ -19,7 +19,7 @@ setState(foo, { }), setState(foo, { c: !0 }); -var c = new /*#__PURE__*/ (function() { +var c = new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/mergedInheritedMembersSatisfyAbstractBase.2.minified.js b/crates/swc/tests/tsc-references/mergedInheritedMembersSatisfyAbstractBase.2.minified.js index cc4e187df1f3..4f71e21a0696 100644 --- a/crates/swc/tests/tsc-references/mergedInheritedMembersSatisfyAbstractBase.2.minified.js +++ b/crates/swc/tests/tsc-references/mergedInheritedMembersSatisfyAbstractBase.2.minified.js @@ -2,7 +2,7 @@ import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; -new /*#__PURE__*/ (function(BaseClass) { +new (/*#__PURE__*/ function(BaseClass) { function Broken() { return _class_call_check(this, Broken), _call_super(this, Broken, arguments); } diff --git a/crates/swc/tests/tsc-references/moduleExportAssignment5.2.minified.js b/crates/swc/tests/tsc-references/moduleExportAssignment5.2.minified.js index 7d48c819145e..ec39af5765f6 100644 --- a/crates/swc/tests/tsc-references/moduleExportAssignment5.2.minified.js +++ b/crates/swc/tests/tsc-references/moduleExportAssignment5.2.minified.js @@ -1,6 +1,6 @@ //// [axios.js] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var axios = new /*#__PURE__*/ (function() { +var axios = new (/*#__PURE__*/ function() { function Axios() { _class_call_check(this, Axios); } diff --git a/crates/swc/tests/tsc-references/objectRest2.1.normal.js b/crates/swc/tests/tsc-references/objectRest2.1.normal.js index 3ee83cbd2b94..9f9efa726a30 100644 --- a/crates/swc/tests/tsc-references/objectRest2.1.normal.js +++ b/crates/swc/tests/tsc-references/objectRest2.1.normal.js @@ -4,7 +4,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; function rootConnection(name) { return { - resolve: function() { + resolve: /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(context, args) { const { objects } = yield { objects: 12 diff --git a/crates/swc/tests/tsc-references/objectSpread.2.minified.js b/crates/swc/tests/tsc-references/objectSpread.2.minified.js index 3dc91599c620..648d956275fb 100644 --- a/crates/swc/tests/tsc-references/objectSpread.2.minified.js +++ b/crates/swc/tests/tsc-references/objectSpread.2.minified.js @@ -39,7 +39,7 @@ _object_spread_props(_object_spread({}, o), { }), { c: 7 }).a = 12, _object_spread({}, function() {}), _object_spread({}, anything); -var c = new /*#__PURE__*/ (function() { +var c = new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C), this.p = 1; } diff --git a/crates/swc/tests/tsc-references/parserAstSpans1.2.minified.js b/crates/swc/tests/tsc-references/parserAstSpans1.2.minified.js index e89c0406a7a9..290813f0e565 100644 --- a/crates/swc/tests/tsc-references/parserAstSpans1.2.minified.js +++ b/crates/swc/tests/tsc-references/parserAstSpans1.2.minified.js @@ -71,7 +71,7 @@ var c2 = /*#__PURE__*/ function() { } ]), c3; }(c2), c2_i = new c2(10), c3_i = new c3(); -c2_i.c2_f1(), c2_i.c2_nc_f1(), c2_i.f1(), c2_i.nc_f1(), c3_i.c2_f1(), c3_i.c2_nc_f1(), c3_i.f1(), c3_i.nc_f1(), (c2_i = c3_i).c2_f1(), c2_i.c2_nc_f1(), c2_i.f1(), c2_i.nc_f1(), new /*#__PURE__*/ (function(c2) { +c2_i.c2_f1(), c2_i.c2_nc_f1(), c2_i.f1(), c2_i.nc_f1(), c3_i.c2_f1(), c3_i.c2_nc_f1(), c3_i.f1(), c3_i.nc_f1(), (c2_i = c3_i).c2_f1(), c2_i.c2_nc_f1(), c2_i.f1(), c2_i.nc_f1(), new (/*#__PURE__*/ function(c2) { function c4() { return _class_call_check(this, c4), _call_super(this, c4, arguments); } diff --git a/crates/swc/tests/tsc-references/privateProtectedMembersAreNotAccessibleDestructuring.2.minified.js b/crates/swc/tests/tsc-references/privateProtectedMembersAreNotAccessibleDestructuring.2.minified.js index aad2ebbfb7c0..c4ae36926837 100644 --- a/crates/swc/tests/tsc-references/privateProtectedMembersAreNotAccessibleDestructuring.2.minified.js +++ b/crates/swc/tests/tsc-references/privateProtectedMembersAreNotAccessibleDestructuring.2.minified.js @@ -2,7 +2,7 @@ import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; -var k = new /*#__PURE__*/ (function() { +var k = new (/*#__PURE__*/ function() { function K() { _class_call_check(this, K); } diff --git a/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithConstraints.2.minified.js b/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithConstraints.2.minified.js index 1d56361342c2..ecc720cbc28b 100644 --- a/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithConstraints.2.minified.js +++ b/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithConstraints.2.minified.js @@ -1,7 +1,7 @@ //// [propertyAccessOnTypeParameterWithConstraints.ts] var i, a; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -new /*#__PURE__*/ (function() { +new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithConstraints4.2.minified.js b/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithConstraints4.2.minified.js index d9b85f36a68e..79ab49f87669 100644 --- a/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithConstraints4.2.minified.js +++ b/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithConstraints4.2.minified.js @@ -1,6 +1,6 @@ //// [propertyAccessOnTypeParameterWithConstraints4.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -new /*#__PURE__*/ (function() { +new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithConstraints5.2.minified.js b/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithConstraints5.2.minified.js index 07114b2ecf16..87c938d5d438 100644 --- a/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithConstraints5.2.minified.js +++ b/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithConstraints5.2.minified.js @@ -17,7 +17,7 @@ var i, a, B = /*#__PURE__*/ function(A) { return ''; }, A; }()); -new /*#__PURE__*/ (function() { +new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithoutConstraints.2.minified.js b/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithoutConstraints.2.minified.js index 6fe94400ec9c..e83831d9ef9b 100644 --- a/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithoutConstraints.2.minified.js +++ b/crates/swc/tests/tsc-references/propertyAccessOnTypeParameterWithoutConstraints.2.minified.js @@ -1,7 +1,7 @@ //// [propertyAccessOnTypeParameterWithoutConstraints.ts] var i, a; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -new /*#__PURE__*/ (function() { +new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/superPropertyAccessNoError.2.minified.js b/crates/swc/tests/tsc-references/superPropertyAccessNoError.2.minified.js index e544ed3edc07..03c58b93fc83 100644 --- a/crates/swc/tests/tsc-references/superPropertyAccessNoError.2.minified.js +++ b/crates/swc/tests/tsc-references/superPropertyAccessNoError.2.minified.js @@ -6,7 +6,7 @@ import { _ as _create_class } from "@swc/helpers/_/_create_class"; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; -new /*#__PURE__*/ (function(SomeBaseClass) { +new (/*#__PURE__*/ function(SomeBaseClass) { function SomeDerivedClass() { var _this; return _class_call_check(this, SomeDerivedClass), _get((_assert_this_initialized(_this = _call_super(this, SomeDerivedClass)), _get_prototype_of(SomeDerivedClass.prototype)), "func", _this).call(_this), _this; diff --git a/crates/swc/tests/tsc-references/typeParametersAvailableInNestedScope.2.minified.js b/crates/swc/tests/tsc-references/typeParametersAvailableInNestedScope.2.minified.js index 84176802f195..34c0b1b8913d 100644 --- a/crates/swc/tests/tsc-references/typeParametersAvailableInNestedScope.2.minified.js +++ b/crates/swc/tests/tsc-references/typeParametersAvailableInNestedScope.2.minified.js @@ -1,6 +1,6 @@ //// [typeParametersAvailableInNestedScope.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var c = new /*#__PURE__*/ (function() { +var c = new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C), this.x = function(a) {}; } diff --git a/crates/swc/tests/tsc-references/typesWithSpecializedCallSignatures.2.minified.js b/crates/swc/tests/tsc-references/typesWithSpecializedCallSignatures.2.minified.js index 97401448b4c2..57d45a1efa32 100644 --- a/crates/swc/tests/tsc-references/typesWithSpecializedCallSignatures.2.minified.js +++ b/crates/swc/tests/tsc-references/typesWithSpecializedCallSignatures.2.minified.js @@ -2,7 +2,7 @@ import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; -var i, a, c = new /*#__PURE__*/ (function() { +var i, a, c = new (/*#__PURE__*/ function() { function C() { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/wrappedAndRecursiveConstraints.2.minified.js b/crates/swc/tests/tsc-references/wrappedAndRecursiveConstraints.2.minified.js index 276d68e6c60e..da44ffa153a8 100644 --- a/crates/swc/tests/tsc-references/wrappedAndRecursiveConstraints.2.minified.js +++ b/crates/swc/tests/tsc-references/wrappedAndRecursiveConstraints.2.minified.js @@ -1,6 +1,6 @@ //// [wrappedAndRecursiveConstraints.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -new /*#__PURE__*/ (function() { +new (/*#__PURE__*/ function() { function C(data) { _class_call_check(this, C), this.data = data; } diff --git a/crates/swc/tests/tsc-references/wrappedAndRecursiveConstraints3.2.minified.js b/crates/swc/tests/tsc-references/wrappedAndRecursiveConstraints3.2.minified.js index ad07d4c207b4..873f2d2ded20 100644 --- a/crates/swc/tests/tsc-references/wrappedAndRecursiveConstraints3.2.minified.js +++ b/crates/swc/tests/tsc-references/wrappedAndRecursiveConstraints3.2.minified.js @@ -1,6 +1,6 @@ //// [wrappedAndRecursiveConstraints3.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -new /*#__PURE__*/ (function() { +new (/*#__PURE__*/ function() { function C(x) { _class_call_check(this, C); } diff --git a/crates/swc/tests/tsc-references/wrappedAndRecursiveConstraints4.2.minified.js b/crates/swc/tests/tsc-references/wrappedAndRecursiveConstraints4.2.minified.js index be34730a9598..ab58dc5d5a21 100644 --- a/crates/swc/tests/tsc-references/wrappedAndRecursiveConstraints4.2.minified.js +++ b/crates/swc/tests/tsc-references/wrappedAndRecursiveConstraints4.2.minified.js @@ -1,6 +1,6 @@ //// [wrappedAndRecursiveConstraints4.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -new /*#__PURE__*/ (function() { +new (/*#__PURE__*/ function() { function C(x) { _class_call_check(this, C); } diff --git a/crates/swc/tests/vercel/full/react-autowhatever/1/output/index.js b/crates/swc/tests/vercel/full/react-autowhatever/1/output/index.js index 2987d868557d..9a378d832ef0 100644 --- a/crates/swc/tests/vercel/full/react-autowhatever/1/output/index.js +++ b/crates/swc/tests/vercel/full/react-autowhatever/1/output/index.js @@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", { }), Object.defineProperty(exports, "default", { enumerable: !0, get: function() { - return _; + return o; } }); -var e = require("@swc/helpers/_/_call_super"), t = require("@swc/helpers/_/_class_call_check"), r = require("@swc/helpers/_/_create_class"), i = require("@swc/helpers/_/_define_property"), n = require("@swc/helpers/_/_inherits"), s = require("@swc/helpers/_/_interop_require_default"), u = require("@swc/helpers/_/_interop_require_wildcard"), d = require("@swc/helpers/_/_object_spread"), c = require("@swc/helpers/_/_object_spread_props"), l = require("react/jsx-runtime"), a = /*#__PURE__*/ u._(require("react")), o = /*#__PURE__*/ s._(require("prop-types")), _ = /*#__PURE__*/ function(s) { +var e = require("@swc/helpers/_/_call_super"), t = require("@swc/helpers/_/_class_call_check"), r = require("@swc/helpers/_/_create_class"), i = require("@swc/helpers/_/_define_property"), n = require("@swc/helpers/_/_inherits"), s = require("@swc/helpers/_/_interop_require_default"), u = require("@swc/helpers/_/_interop_require_wildcard"), d = require("@swc/helpers/_/_object_spread"), c = require("@swc/helpers/_/_object_spread_props"), l = require("react/jsx-runtime"), _ = /*#__PURE__*/ u._(require("react")), a = /*#__PURE__*/ s._(require("prop-types")), o = /*#__PURE__*/ function(s) { "use strict"; function u() { var r; @@ -25,18 +25,18 @@ var e = require("@swc/helpers/_/_call_super"), t = require("@swc/helpers/_/_clas { key: "render", value: function() { - var e = this, t = this.props, r = t.items, i = t.itemProps, n = t.renderItem, s = t.renderItemData, u = t.sectionIndex, a = t.highlightedItemIndex, o = t.getItemId, _ = t.theme, p = t.keyPrefix, h = null === u ? p : "".concat(p, "section-").concat(u, "-"), f = "function" == typeof i; + var e = this, t = this.props, r = t.items, i = t.itemProps, n = t.renderItem, s = t.renderItemData, u = t.sectionIndex, _ = t.highlightedItemIndex, a = t.getItemId, o = t.theme, p = t.keyPrefix, h = null === u ? p : "".concat(p, "section-").concat(u, "-"), f = "function" == typeof i; return /*#__PURE__*/ (0, l.jsx)("ul", c._(d._({ role: "listbox" - }, _("".concat(h, "items-list"), "itemsList")), { + }, o("".concat(h, "items-list"), "itemsList")), { children: r.map(function(t, r) { - var p = 0 === r, m = r === a, I = "".concat(h, "item-").concat(r), g = f ? i({ + var p = 0 === r, m = r === _, I = "".concat(h, "item-").concat(r), g = f ? i({ sectionIndex: u, itemIndex: r }) : i, q = d._({ - id: o(u, r), + id: a(u, r), "aria-selected": m - }, _(I, "item", p && "itemFirst", m && "itemHighlighted"), g); + }, o(I, "item", p && "itemFirst", m && "itemHighlighted"), g); return m && (q.ref = e.storeHighlightedItemReference), /*#__PURE__*/ (0, l.jsx)(Item, c._(d._({}, q), { sectionIndex: u, isHighlighted: m, @@ -50,21 +50,21 @@ var e = require("@swc/helpers/_/_call_super"), t = require("@swc/helpers/_/_clas } } ]), u; -}(a.Component); -i._(_, "propTypes", { - items: o.default.array.isRequired, - itemProps: o.default.oneOfType([ - o.default.object, - o.default.func +}(_.Component); +i._(o, "propTypes", { + items: a.default.array.isRequired, + itemProps: a.default.oneOfType([ + a.default.object, + a.default.func ]), - renderItem: o.default.func.isRequired, - renderItemData: o.default.object.isRequired, - sectionIndex: o.default.number, - highlightedItemIndex: o.default.number, - onHighlightedItemChange: o.default.func.isRequired, - getItemId: o.default.func.isRequired, - theme: o.default.func.isRequired, - keyPrefix: o.default.string.isRequired -}), i._(_, "defaultProps", { + renderItem: a.default.func.isRequired, + renderItemData: a.default.object.isRequired, + sectionIndex: a.default.number, + highlightedItemIndex: a.default.number, + onHighlightedItemChange: a.default.func.isRequired, + getItemId: a.default.func.isRequired, + theme: a.default.func.isRequired, + keyPrefix: a.default.string.isRequired +}), i._(o, "defaultProps", { sectionIndex: null -}), new _(); +}), new o(); diff --git a/crates/swc/tests/vercel/full/react-autowhatever/2/output/index.js b/crates/swc/tests/vercel/full/react-autowhatever/2/output/index.js index 4e6de904f57c..c3476f6ff221 100644 --- a/crates/swc/tests/vercel/full/react-autowhatever/2/output/index.js +++ b/crates/swc/tests/vercel/full/react-autowhatever/2/output/index.js @@ -4,18 +4,18 @@ Object.defineProperty(exports, "__esModule", { }), Object.defineProperty(exports, "default", { enumerable: !0, get: function() { - return u; + return l; } }); -var e = require("@swc/helpers/_/_call_super"), t = require("@swc/helpers/_/_class_call_check"), r = require("@swc/helpers/_/_create_class"), i = require("@swc/helpers/_/_define_property"), s = require("@swc/helpers/_/_inherits"), n = require("@swc/helpers/_/_interop_require_wildcard"), c = require("@swc/helpers/_/_object_spread"), o = require("@swc/helpers/_/_object_spread_props"), l = require("react/jsx-runtime"), u = /*#__PURE__*/ function(n) { +var e = require("@swc/helpers/_/_call_super"), t = require("@swc/helpers/_/_class_call_check"), r = require("@swc/helpers/_/_create_class"), i = require("@swc/helpers/_/_define_property"), s = require("@swc/helpers/_/_inherits"), n = require("@swc/helpers/_/_interop_require_wildcard"), c = require("@swc/helpers/_/_object_spread"), _ = require("@swc/helpers/_/_object_spread_props"), o = require("react/jsx-runtime"), l = /*#__PURE__*/ function(n) { "use strict"; - function u() { + function l() { var r; - return t._(this, u), r = e._(this, u, arguments), i._(r, "storeHighlightedItemReference", function(e) { + return t._(this, l), r = e._(this, l, arguments), i._(r, "storeHighlightedItemReference", function(e) { r.props.onHighlightedItemChange(null === e ? null : e.item); }), r; } - return s._(u, n), r._(u, [ + return s._(l, n), r._(l, [ { key: "shouldComponentUpdate", value: function(e) { @@ -27,20 +27,20 @@ var e = require("@swc/helpers/_/_call_super"), t = require("@swc/helpers/_/_clas { key: "render", value: function() { - var e = this, t = this.props, r = t.items, i = t.itemProps, s = t.renderItem, n = t.renderItemData, u = t.sectionIndex, _ = t.highlightedItemIndex, p = t.getItemId, a = t.theme, d = t.keyPrefix, h = null === u ? d : "".concat(d, "section-").concat(u, "-"), m = "function" == typeof i; - return /*#__PURE__*/ (0, l.jsx)("ul", o._(c._({ + var e = this, t = this.props, r = t.items, i = t.itemProps, s = t.renderItem, n = t.renderItemData, l = t.sectionIndex, u = t.highlightedItemIndex, p = t.getItemId, a = t.theme, d = t.keyPrefix, h = null === l ? d : "".concat(d, "section-").concat(l, "-"), m = "function" == typeof i; + return /*#__PURE__*/ (0, o.jsx)("ul", _._(c._({ role: "listbox" }, a("".concat(h, "items-list"), "itemsList")), { children: r.map(function(t, r) { - var d = 0 === r, f = r === _, I = "".concat(h, "item-").concat(r), g = m ? i({ - sectionIndex: u, + var d = 0 === r, f = r === u, I = "".concat(h, "item-").concat(r), g = m ? i({ + sectionIndex: l, itemIndex: r }) : i, x = c._({ - id: p(u, r), + id: p(l, r), "aria-selected": f }, a(I, "item", d && "itemFirst", f && "itemHighlighted"), g); - return f && (x.ref = e.storeHighlightedItemReference), /*#__PURE__*/ (0, l.jsx)(Item, o._(c._({}, x), { - sectionIndex: u, + return f && (x.ref = e.storeHighlightedItemReference), /*#__PURE__*/ (0, o.jsx)(Item, _._(c._({}, x), { + sectionIndex: l, isHighlighted: f, itemIndex: r, item: t, @@ -51,10 +51,10 @@ var e = require("@swc/helpers/_/_call_super"), t = require("@swc/helpers/_/_clas })); } } - ]), u; + ]), l; }(/*#__PURE__*/ n._(require("react")).Component); -i._(u, "propTypes", { +i._(l, "propTypes", { items: 500 -}), i._(u, "defaultProps", { +}), i._(l, "defaultProps", { sectionIndex: null -}), new u(); +}), new l(); 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 72a651c9b935..0760c63e936d 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 @@ -8,7 +8,7 @@ var Test = function Test(name) { "use strict"; _class_call_check(this, Test); var _this = this; - _define_property(this, "print", function() { + _define_property(this, "print", /*#__PURE__*/ function() { var _ref = _async_to_generator(function(arg) { return _ts_generator(this, function(_state) { console.log(_this.name, arg); 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 b04e1b188476..729488476d79 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 @@ -6,7 +6,7 @@ var Test = function Test(name) { "use strict"; _class_call_check._(this, Test); var _this = this; - _define_property._(this, "print", function() { + _define_property._(this, "print", /*#__PURE__*/ function() { var _ref = _async_to_generator._(function(arg) { return _ts_generator._(this, function(_state) { console.log(_this.name, arg); diff --git a/crates/swc_common/src/syntax_pos.rs b/crates/swc_common/src/syntax_pos.rs index bc407a45f50f..3e9092403f0c 100644 --- a/crates/swc_common/src/syntax_pos.rs +++ b/crates/swc_common/src/syntax_pos.rs @@ -83,6 +83,11 @@ pub const DUMMY_SP: Span = Span { hi: BytePos::DUMMY, }; +pub const PURE_SP: Span = Span { + lo: BytePos::PURE, + hi: BytePos::PURE, +}; + pub struct Globals { hygiene_data: Mutex, #[allow(unused)] @@ -396,6 +401,11 @@ impl Span { self.lo.0 == 0 && self.hi.0 == 0 || self.lo.0 >= DUMMY_RESERVE } + #[inline] + pub fn is_pure(self) -> bool { + self.lo.is_pure() + } + /// Returns `true` if this is a dummy span with any hygienic context. #[inline] pub fn is_dummy_ignoring_cmt(self) -> bool { @@ -1020,6 +1030,7 @@ impl BytePos { /// Dummy position. This is reserved for synthesized spans. pub const DUMMY: Self = BytePos(0); const MIN_RESERVED: Self = BytePos(DUMMY_RESERVE); + pub const PURE: Self = BytePos(u32::MAX - 1); /// Synthesized, but should be stored in a source map. pub const SYNTHESIZED: Self = BytePos(u32::MAX); @@ -1033,6 +1044,10 @@ impl BytePos { self.0 == 0 } + pub const fn is_pure(self) -> bool { + self.0 == Self::PURE.0 + } + /// Returns `true`` if this is explicitly synthesized or has relevant input /// source so can have a comment. pub const fn can_have_comment(self) -> bool { diff --git a/crates/swc_ecma_codegen/src/comments.rs b/crates/swc_ecma_codegen/src/comments.rs index c37e842f914f..8f1768d21203 100644 --- a/crates/swc_ecma_codegen/src/comments.rs +++ b/crates/swc_ecma_codegen/src/comments.rs @@ -1,3 +1,5 @@ +use swc_common::comments::Comment; + use super::*; macro_rules! write_comments { @@ -82,6 +84,18 @@ where return Ok(()); } + if pos.is_pure() { + write_comments!( + self, + false, + Some(vec![Comment { + kind: CommentKind::Block, + span: DUMMY_SP, + text: "#__PURE__".into(), + }]) + ); + } + let comments = match self.comments { Some(ref comments) => comments, None => return Ok(()), diff --git a/crates/swc_ecma_codegen/src/lib.rs b/crates/swc_ecma_codegen/src/lib.rs index 6ec6d4af5a39..e219dba78784 100644 --- a/crates/swc_ecma_codegen/src/lib.rs +++ b/crates/swc_ecma_codegen/src/lib.rs @@ -2132,11 +2132,9 @@ where #[emitter] fn emit_expr_or_spread(&mut self, node: &ExprOrSpread) -> Result { - if self.comments.is_some() { - self.emit_leading_comments_of_span(node.span(), false)?; - } + if let Some(span) = node.spread { + self.emit_leading_comments_of_span(span, false)?; - if node.spread.is_some() { punct!("..."); } diff --git a/crates/swc_ecma_compat_es2015/src/classes/mod.rs b/crates/swc_ecma_compat_es2015/src/classes/mod.rs index b06ef7d3587c..bf6136881586 100644 --- a/crates/swc_ecma_compat_es2015/src/classes/mod.rs +++ b/crates/swc_ecma_compat_es2015/src/classes/mod.rs @@ -2,8 +2,8 @@ use std::iter; use serde::Deserialize; use swc_common::{ - collections::ARandomState, comments::Comments, util::take::Take, BytePos, Mark, Span, Spanned, - SyntaxContext, DUMMY_SP, + collections::ARandomState, util::take::Take, BytePos, Mark, Span, Spanned, SyntaxContext, + DUMMY_SP, }; use swc_ecma_ast::*; use swc_ecma_transforms_base::{helper, native::is_native, perf::Check}; @@ -27,13 +27,9 @@ use self::{ mod constructor; mod prop_name; -pub fn classes(comments: Option, config: Config) -> impl Fold + VisitMut -where - C: Comments, -{ +pub fn classes(config: Config) -> impl Fold + VisitMut { as_folder(Classes { in_strict: false, - comments, config, params: Default::default(), @@ -75,12 +71,8 @@ type IndexMap = indexmap::IndexMap; /// }(); /// ``` #[derive(Default, Clone)] -struct Classes -where - C: Comments, -{ +struct Classes { in_strict: bool, - comments: Option, config: Config, params: Vec, @@ -108,10 +100,7 @@ struct Data { } #[swc_trace] -impl Classes -where - C: Comments, -{ +impl Classes { fn visit_mut_stmt_like(&mut self, stmts: &mut Vec) where T: StmtLike + ModuleItemLike + VisitMutWith + Take, @@ -215,10 +204,7 @@ where #[swc_trace] #[fast_path(ClassFinder)] -impl VisitMut for Classes -where - C: Comments, -{ +impl VisitMut for Classes { noop_visit_mut_type!(fail); fn visit_mut_module_items(&mut self, items: &mut Vec) { @@ -343,18 +329,9 @@ where } #[swc_trace] -impl Classes -where - C: Comments, -{ +impl Classes { fn add_pure_comments(&mut self, start: &mut BytePos) { - if start.is_dummy() { - *start = Span::dummy_with_cmt().lo; - } - - if let Some(comments) = &self.comments { - comments.add_pure_comment(*start); - } + *start = BytePos::PURE; } fn fold_class_as_var_decl(&mut self, ident: Ident, class: Box) -> VarDecl { diff --git a/crates/swc_ecma_compat_es2015/src/generator.rs b/crates/swc_ecma_compat_es2015/src/generator.rs index 834c6b0d88a0..422224b5fb8e 100644 --- a/crates/swc_ecma_compat_es2015/src/generator.rs +++ b/crates/swc_ecma_compat_es2015/src/generator.rs @@ -783,7 +783,7 @@ impl VisitMut for Generator { let mut args = node.args.take().into_iter().map(Some).collect::>(); let arg = self.visit_elements(&mut args, None, None); - let apply = callee.make_member(IdentName::new("apply".into(), node.span)); + let apply = callee.make_member(quote_ident!("apply")); *node = CallExpr { span: node.span, diff --git a/crates/swc_ecma_compat_es2015/src/lib.rs b/crates/swc_ecma_compat_es2015/src/lib.rs index c2792adb6e8a..d1a10b3de8cc 100644 --- a/crates/swc_ecma_compat_es2015/src/lib.rs +++ b/crates/swc_ecma_compat_es2015/src/lib.rs @@ -72,7 +72,7 @@ where }), block_scoped_functions(), template_literal(c.template_literal), - classes(comments.clone(), c.classes), + classes(c.classes), new_target(), spread(c.spread), // https://github.com/Microsoft/TypeScript/issues/5441 diff --git a/crates/swc_ecma_compat_es2015/src/object_super.rs b/crates/swc_ecma_compat_es2015/src/object_super.rs index 47e2ede1702a..f182a5ecd617 100644 --- a/crates/swc_ecma_compat_es2015/src/object_super.rs +++ b/crates/swc_ecma_compat_es2015/src/object_super.rs @@ -234,7 +234,7 @@ impl SuperReplacer { callee: MemberExpr { span: DUMMY_SP, obj: Box::new(callee), - prop: MemberProp::Ident(quote_ident!("apply")), + prop: quote_ident!("apply").into(), } .as_callee(), args: iter::once(this) diff --git a/crates/swc_ecma_compat_es2015/src/spread.rs b/crates/swc_ecma_compat_es2015/src/spread.rs index 1810383df83f..f4276c53504a 100644 --- a/crates/swc_ecma_compat_es2015/src/spread.rs +++ b/crates/swc_ecma_compat_es2015/src/spread.rs @@ -156,7 +156,7 @@ impl VisitMut for Spread { let apply = MemberExpr { span: DUMMY_SP, obj: callee_updated.unwrap_or_else(|| callee.take()), - prop: MemberProp::Ident(IdentName::new("apply".into(), *span)), + prop: quote_ident!("apply").into(), }; *e = CallExpr { diff --git a/crates/swc_ecma_compat_es2017/src/async_to_generator.rs b/crates/swc_ecma_compat_es2017/src/async_to_generator.rs index 23436794f3d7..1c62f0d86172 100644 --- a/crates/swc_ecma_compat_es2017/src/async_to_generator.rs +++ b/crates/swc_ecma_compat_es2017/src/async_to_generator.rs @@ -1,9 +1,7 @@ use std::{iter, mem}; use serde::Deserialize; -use swc_common::{ - comments::Comments, util::take::Take, Mark, Span, Spanned, SyntaxContext, DUMMY_SP, -}; +use swc_common::{source_map::PURE_SP, util::take::Take, Mark, Spanned, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_transforms_base::{helper, helper_expr, perf::Check}; use swc_ecma_transforms_macros::fast_path; @@ -37,14 +35,9 @@ use swc_trace_macro::swc_trace; /// yield bar(); /// }); /// ``` -pub fn async_to_generator( - c: Config, - comments: Option, - unresolved_mark: Mark, -) -> impl Fold + VisitMut { +pub fn async_to_generator(c: Config, unresolved_mark: Mark) -> impl Fold + VisitMut { as_folder(AsyncToGenerator { c, - comments, in_subclass: false, unresolved_ctxt: SyntaxContext::empty().apply_mark(unresolved_mark), }) @@ -60,16 +53,15 @@ pub struct Config { } #[derive(Default, Clone)] -struct AsyncToGenerator { +struct AsyncToGenerator { c: Config, - comments: Option, + in_subclass: bool, unresolved_ctxt: SyntaxContext, } -struct Actual { +struct Actual { c: Config, - comments: Option, in_subclass: bool, hoister: FnEnvHoister, @@ -80,7 +72,7 @@ struct Actual { #[swc_trace] #[fast_path(ShouldWork)] -impl VisitMut for AsyncToGenerator { +impl VisitMut for AsyncToGenerator { noop_visit_mut_type!(fail); fn visit_mut_class(&mut self, c: &mut Class) { @@ -101,10 +93,10 @@ impl VisitMut for AsyncToGenerator { } #[swc_trace] -impl AsyncToGenerator { +impl AsyncToGenerator { fn visit_mut_stmt_like(&mut self, stmts: &mut Vec) where - T: StmtLike + VisitMutWith>, + T: StmtLike + VisitMutWith, Vec: VisitMutWith, { let mut stmts_updated = Vec::with_capacity(stmts.len()); @@ -114,7 +106,6 @@ impl AsyncToGenerator { let mut actual = Actual { c: self.c, - comments: self.comments.clone(), in_subclass: self.in_subclass, hoister, unresolved_ctxt: self.unresolved_ctxt, @@ -134,7 +125,7 @@ impl AsyncToGenerator { #[swc_trace] #[fast_path(ShouldWork)] -impl VisitMut for Actual { +impl VisitMut for Actual { noop_visit_mut_type!(fail); fn visit_mut_class(&mut self, c: &mut Class) { @@ -430,7 +421,7 @@ impl VisitMut for Actual { } #[swc_trace] -impl Actual { +impl Actual { fn visit_mut_expr_with_binding( &mut self, expr: &mut Expr, @@ -453,13 +444,7 @@ impl Actual { wrapper.function = make_fn_ref(fn_expr); *expr = wrapper.into(); if !in_iife { - if let Some(c) = &mut self.comments { - let mut lo = expr.span().lo; - if lo.is_dummy() { - lo = Span::dummy_with_cmt().lo; - } - c.add_pure_comment(lo); - } + expr.set_span(PURE_SP); } } @@ -475,13 +460,7 @@ impl Actual { *expr = wrapper.into(); if !in_iife { - if let Some(c) = &mut self.comments { - let mut lo = expr.span().lo; - if lo.is_dummy() { - lo = Span::dummy_with_cmt().lo; - } - c.add_pure_comment(lo) - } + expr.set_span(PURE_SP); } } diff --git a/crates/swc_ecma_compat_es2017/src/lib.rs b/crates/swc_ecma_compat_es2017/src/lib.rs index 0333e302adb3..bded16d95c0e 100644 --- a/crates/swc_ecma_compat_es2017/src/lib.rs +++ b/crates/swc_ecma_compat_es2017/src/lib.rs @@ -1,17 +1,13 @@ use serde::Deserialize; -use swc_common::{comments::Comments, Mark}; +use swc_common::Mark; use swc_ecma_visit::Fold; pub use self::async_to_generator::async_to_generator; pub mod async_to_generator; -pub fn es2017( - c: Config, - comments: Option, - unresolved_mark: Mark, -) -> impl Fold { - async_to_generator(c.async_to_generator, comments, unresolved_mark) +pub fn es2017(c: Config, unresolved_mark: Mark) -> impl Fold { + async_to_generator(c.async_to_generator, unresolved_mark) } #[derive(Debug, Clone, Copy, Default, Deserialize)] diff --git a/crates/swc_ecma_compat_es2022/src/class_properties/mod.rs b/crates/swc_ecma_compat_es2022/src/class_properties/mod.rs index ca937fd8f393..48ad1b8a2e2f 100644 --- a/crates/swc_ecma_compat_es2022/src/class_properties/mod.rs +++ b/crates/swc_ecma_compat_es2022/src/class_properties/mod.rs @@ -1,6 +1,6 @@ use swc_common::{ - collections::AHashMap, comments::Comments, errors::HANDLER, util::take::Take, Mark, Span, - Spanned, SyntaxContext, DUMMY_SP, + collections::AHashMap, errors::HANDLER, source_map::PURE_SP, util::take::Take, Mark, Spanned, + SyntaxContext, DUMMY_SP, }; use swc_ecma_ast::*; use swc_ecma_transforms_base::{helper, perf::Check}; @@ -40,14 +40,9 @@ mod used_name; /// # Impl note /// /// We use custom helper to handle export default class -pub fn class_properties( - cm: Option, - config: Config, - unresolved_mark: Mark, -) -> impl Fold + VisitMut { +pub fn class_properties(config: Config, unresolved_mark: Mark) -> impl Fold + VisitMut { as_folder(ClassProperties { c: config, - cm, private: PrivateRecord::new(), extra: ClassExtra::default(), unresolved_mark, @@ -77,10 +72,9 @@ impl Default for Config { } } -struct ClassProperties { +struct ClassProperties { extra: ClassExtra, c: Config, - cm: Option, private: PrivateRecord, unresolved_mark: Mark, } @@ -158,7 +152,7 @@ impl Take for ClassExtra { #[swc_trace] #[fast_path(ShouldWork)] -impl VisitMut for ClassProperties { +impl VisitMut for ClassProperties { noop_visit_mut_type!(fail); fn visit_mut_module_items(&mut self, n: &mut Vec) { @@ -329,7 +323,7 @@ impl VisitMut for ClassProperties { } #[swc_trace] -impl ClassProperties { +impl ClassProperties { fn visit_mut_stmt_like(&mut self, stmts: &mut Vec) where T: StmtLike + ModuleItemLike + VisitMutWith + From, @@ -438,7 +432,7 @@ impl ClassProperties { } #[swc_trace] -impl ClassProperties { +impl ClassProperties { fn visit_mut_class_as_decl( &mut self, class_ident: Ident, @@ -751,13 +745,7 @@ impl ClassProperties { name: ident.clone(), value, }); - let span = if let Some(cm) = &self.cm { - let span = Span::dummy_with_cmt(); - cm.add_pure_comment(span.lo); - span - } else { - DUMMY_SP - }; + let span = PURE_SP; if self.c.private_as_properties { vars.push(VarDeclarator { span: DUMMY_SP, @@ -906,13 +894,7 @@ impl ClassProperties { }; if let Some(extra) = extra_collect { - let span = if let Some(cm) = &self.cm { - let span = Span::dummy_with_cmt(); - cm.add_pure_comment(span.lo); - span - } else { - DUMMY_SP - }; + let span = PURE_SP; vars.push(VarDeclarator { span: DUMMY_SP, definite: false, diff --git a/crates/swc_ecma_compat_es2022/src/lib.rs b/crates/swc_ecma_compat_es2022/src/lib.rs index bfe0bf226af8..28b937f8d7be 100644 --- a/crates/swc_ecma_compat_es2022/src/lib.rs +++ b/crates/swc_ecma_compat_es2022/src/lib.rs @@ -1,6 +1,6 @@ #![allow(clippy::vec_box)] -use swc_common::{chain, comments::Comments, Mark}; +use swc_common::{chain, Mark}; use swc_ecma_compat_common::regexp::{self, regexp}; use swc_ecma_visit::Fold; @@ -14,7 +14,7 @@ pub mod optional_chaining_impl; pub mod private_in_object; pub mod static_blocks; -pub fn es2022(cm: Option, config: Config, unresolved_mark: Mark) -> impl Fold { +pub fn es2022(config: Config, unresolved_mark: Mark) -> impl Fold { chain!( regexp(regexp::Config { dot_all_regex: true, @@ -27,7 +27,7 @@ pub fn es2022(cm: Option, config: Config, unresolved_mark: Mark) unicode_sets_regex: false, }), static_blocks(config.class_properties.static_blocks_mark), - class_properties(cm, config.class_properties, unresolved_mark), + class_properties(config.class_properties, unresolved_mark), private_in_object(), ) } diff --git a/crates/swc_ecma_minifier/src/metadata/mod.rs b/crates/swc_ecma_minifier/src/metadata/mod.rs index f09c24dbb645..0143d8ef0724 100644 --- a/crates/swc_ecma_minifier/src/metadata/mod.rs +++ b/crates/swc_ecma_minifier/src/metadata/mod.rs @@ -307,7 +307,7 @@ pub(super) fn has_noinline(comments: Option<&dyn Comments>, span: Span) -> bool /// Check for `/*#__PURE__*/` pub(super) fn has_pure(comments: Option<&dyn Comments>, span: Span) -> bool { - has_flag(comments, span, "PURE") + span.is_pure() || has_flag(comments, span, "PURE") } fn find_comment(comments: Option<&dyn Comments>, span: Span, mut op: F) -> bool diff --git a/crates/swc_ecma_preset_env/src/lib.rs b/crates/swc_ecma_preset_env/src/lib.rs index bd733197f1f2..f36724930927 100644 --- a/crates/swc_ecma_preset_env/src/lib.rs +++ b/crates/swc_ecma_preset_env/src/lib.rs @@ -143,7 +143,6 @@ where pass, ClassProperties, es2022::class_properties( - comments.clone(), es2022::class_properties::Config { private_as_properties: loose || assumptions.private_fields_as_properties, set_public_fields: loose || assumptions.set_public_class_fields, @@ -210,7 +209,6 @@ where ignore_function_name: loose || assumptions.ignore_function_name, ignore_function_length: loose || assumptions.ignore_function_length, }, - comments.clone(), unresolved_mark ) ); @@ -232,15 +230,12 @@ where let pass = add!( pass, Classes, - es2015::classes( - comments.clone(), - es2015::classes::Config { - constant_super: loose || assumptions.constant_super, - no_class_calls: loose || assumptions.no_class_calls, - set_class_methods: loose || assumptions.set_class_methods, - super_is_callable_constructor: loose || assumptions.super_is_callable_constructor, - } - ) + es2015::classes(es2015::classes::Config { + constant_super: loose || assumptions.constant_super, + no_class_calls: loose || assumptions.no_class_calls, + set_class_methods: loose || assumptions.set_class_methods, + super_is_callable_constructor: loose || assumptions.super_is_callable_constructor, + }) ); let pass = add!( pass, diff --git a/crates/swc_ecma_transforms/tests/decorators.rs b/crates/swc_ecma_transforms/tests/decorators.rs index e128e5490d00..60061305e9ac 100644 --- a/crates/swc_ecma_transforms/tests/decorators.rs +++ b/crates/swc_ecma_transforms/tests/decorators.rs @@ -36,7 +36,7 @@ fn syntax(decorators_before_export: bool) -> Syntax { }) } -fn tr(t: &Tester) -> impl Fold { +fn tr(_: &Tester) -> impl Fold { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -44,11 +44,7 @@ fn tr(t: &Tester) -> impl Fold { resolver(unresolved_mark, top_level_mark, true), decorators(Default::default()), class_fields_use_set(true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) } @@ -62,7 +58,7 @@ fn ts_transform(t: &Tester) -> impl Fold { ) } -fn simple_strip(t: &Tester, config: Config) -> impl Fold { +fn simple_strip(_: &Tester, config: Config) -> impl Fold { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -79,7 +75,6 @@ fn simple_strip(t: &Tester, config: Config) -> impl Fold { ), class_fields_use_set(true), class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: true, ..Default::default() @@ -1622,7 +1617,7 @@ expect(el).toEqual(Object.defineProperty({ // legacy_class_constructors_return_new_constructor test_exec!( syntax(true), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -1632,11 +1627,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_constructors_return_new_constructor_exec, @@ -1661,7 +1652,7 @@ expect(typeof Parent.prototype.child).toBe("function"); // legacy_class_prototype_methods_numeric_props test_exec!( syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -1671,11 +1662,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_prototype_methods_numeric_props_exec, @@ -1699,7 +1686,7 @@ test_exec!( // I tested using typescript playground and node js ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -1709,11 +1696,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_static_properties_mutate_descriptor_exec, @@ -1824,7 +1807,7 @@ expect(Example._).toBe("__8__"); // legacy_class_static_methods_string_props test_exec!( syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -1834,11 +1817,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_static_methods_string_props_exec, @@ -1861,7 +1840,7 @@ class Example { test_exec!( ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -1871,11 +1850,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_prototype_properties_string_literal_properties_exec, @@ -1918,7 +1893,7 @@ test_exec!( // I tested on typescript playground ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -1928,11 +1903,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_prototype_methods_mutate_descriptor_exec, @@ -2061,7 +2032,7 @@ test_exec!( // Legacy decorator for object literals ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -2071,11 +2042,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_object_properties_numeric_props_exec, @@ -2098,7 +2065,7 @@ const inst = { test_exec!( ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -2108,11 +2075,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_prototype_properties_return_descriptor_exec, @@ -2225,7 +2188,7 @@ test_exec!( // Legacy decorator for object literals ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -2235,11 +2198,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_object_properties_string_props_exec, @@ -2263,7 +2222,7 @@ test_exec!( // Legacy decorator for object literals ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -2273,11 +2232,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_object_properties_return_descriptor_exec, @@ -2386,7 +2341,7 @@ expect(inst._).toBe("__8__"); // legacy_class_prototype_methods_string_props test_exec!( syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -2396,11 +2351,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_prototype_methods_string_props_exec, @@ -2422,7 +2373,7 @@ class Example { // legacy_class_prototype_methods_return_descriptor test_exec!( syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -2432,11 +2383,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_prototype_methods_return_descriptor_exec, @@ -2567,7 +2514,7 @@ test_exec!( // Legacy decorator for object literals ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -2577,11 +2524,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_object_ordering_reverse_order_exec, @@ -2621,7 +2564,7 @@ test_exec!( // Legacy decorator for object literals ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -2631,11 +2574,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_object_methods_numeric_props_exec, @@ -2660,7 +2599,7 @@ test_exec!( // I tested using typescript playground and node js ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -2670,11 +2609,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_static_properties_return_descriptor_exec, @@ -2790,7 +2725,7 @@ test_exec!( // below correctly. ignore, syntax(true), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -2800,11 +2735,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_export_default_exec, @@ -2830,7 +2761,7 @@ expect(calls).toEqual(["Foo"]); // legacy_class_ordering_reverse_order test_exec!( syntax(true), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -2840,11 +2771,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_ordering_reverse_order_exec, @@ -2887,7 +2814,7 @@ test_exec!( // Legacy decorator for object literals ignore, syntax(true), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -2897,11 +2824,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_object_methods_mutate_descriptor_exec, @@ -3026,7 +2949,7 @@ expect(inst._()).toBe("__8__"); // legacy_class_static_methods_return_descriptor test_exec!( syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -3036,11 +2959,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_static_methods_return_descriptor_exec, @@ -3168,7 +3087,7 @@ test_exec!( // Legacy decorator for object literals ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -3178,11 +3097,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_object_methods_return_descriptor_exec, @@ -3309,7 +3224,7 @@ test_exec!( // Legacy decorator for object literals ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -3319,11 +3234,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_object_methods_string_props_exec, @@ -3348,7 +3259,7 @@ const inst = { test_exec!( ignore, syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -3358,11 +3269,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_prototype_properties_child_classes_properties_exec, @@ -3401,7 +3308,7 @@ expect(inst.prop2).toBe("__4__"); // legacy_class_static_methods_mutate_descriptor test_exec!( syntax(false), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -3411,11 +3318,7 @@ test_exec!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, legacy_class_static_methods_mutate_descriptor_exec, @@ -3621,7 +3524,7 @@ test!( // See: https://github.com/swc-project/swc/issues/421 ignore, Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -3631,12 +3534,8 @@ test!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()) + class_properties(Default::default(), unresolved_mark), + classes(Default::default()) ) }, decorators_legacy_interop_local_define_property, @@ -3666,7 +3565,7 @@ fn issue_395_syntax() -> ::swc_ecma_parser::Syntax { test!( issue_395_syntax(), - |t| chain!( + |_| chain!( decorators(Default::default()), common_js( Mark::fresh(Mark::root()), @@ -3677,7 +3576,6 @@ test!( ..Default::default() }, Default::default(), - Some(t.comments.clone()) ), ), issue_395_1, @@ -3695,7 +3593,7 @@ class Demo { test!( issue_395_syntax(), - |t| chain!( + |_| chain!( decorators(Default::default()), common_js::common_js( Mark::fresh(Mark::root()), @@ -3706,7 +3604,6 @@ test!( ..Default::default() }, Default::default(), - Some(t.comments.clone()) ), ), issue_395_2, @@ -3725,7 +3622,7 @@ export default Test test!( ignore, Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -3735,7 +3632,7 @@ test!( legacy: true, ..Default::default() }), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), function_name(), ) }, @@ -3763,7 +3660,7 @@ test!( // not important ignore, Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -3773,7 +3670,7 @@ test!( legacy: true, ..Default::default() }), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), function_name(), ) }, @@ -3807,14 +3704,14 @@ var obj = { test!( ignore, Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), function_name(), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), decorators(decorators::Config { legacy: true, ..Default::default() @@ -3847,14 +3744,14 @@ test!( // not important ignore, Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), function_name(), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), decorators(decorators::Config { legacy: true, ..Default::default() @@ -3891,7 +3788,7 @@ test!( // Cost of development is too high. ignore, Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -3902,7 +3799,7 @@ test!( ..Default::default() }), function_name(), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), ) }, function_name_global, @@ -3919,7 +3816,7 @@ setInterval: function(fn, ms) { // function_name_modules test!( Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -3929,13 +3826,12 @@ test!( legacy: true, ..Default::default() }), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), function_name(), common_js( Mark::fresh(Mark::root()), Default::default(), Default::default(), - Some(t.comments.clone()) ), ) }, @@ -3957,14 +3853,14 @@ console.log(new Template().events()); // function_name_eval test!( Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), function_name(), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), decorators(decorators::Config { legacy: true, ..Default::default() diff --git a/crates/swc_ecma_transforms/tests/es2015_function_name.rs b/crates/swc_ecma_transforms/tests/es2015_function_name.rs index 619219de2c39..65428951c32a 100644 --- a/crates/swc_ecma_transforms/tests/es2015_function_name.rs +++ b/crates/swc_ecma_transforms/tests/es2015_function_name.rs @@ -211,24 +211,19 @@ const z = { z: () => y(x) }.z; // function_name_modules_3 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), function_name(), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), decorators(decorators::Config { legacy: true, ..Default::default() }), - common_js( - unresolved_mark, - Default::default(), - Default::default(), - Some(t.comments.clone()) - ) + common_js(unresolved_mark, Default::default(), Default::default(),) ) }, function_name_modules_3, @@ -247,7 +242,7 @@ export default class Login extends React.Component { // function_name_basic test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -257,7 +252,7 @@ test!( legacy: true, ..Default::default() }), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), function_name(), ) }, @@ -274,18 +269,13 @@ var g = function () { test!( ignore, syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); chain!( arrow(unresolved_mark), shorthand(), function_name(), - common_js( - unresolved_mark, - Default::default(), - Default::default(), - Some(t.comments.clone()) - ) + common_js(unresolved_mark, Default::default(), Default::default(),) ) }, function_name_export_default_arrow_renaming, @@ -386,7 +376,7 @@ test!( // not important ignore, syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -397,7 +387,7 @@ test!( ..Default::default() }), function_name(), - classes(Some(t.comments.clone()), Default::default()) + classes(Default::default()) ) }, function_name_self_reference, @@ -429,7 +419,7 @@ const z = { z: () => y(x) }.z; // function_name_method_definition test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -439,7 +429,7 @@ test!( legacy: true, ..Default::default() }), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), function_name(), ) }, @@ -490,7 +480,7 @@ test!( // not important ignore, syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -500,7 +490,7 @@ test!( legacy: true, ..Default::default() }), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), function_name(), ) }, @@ -528,7 +518,7 @@ test!( // See: https://github.com/swc-project/swc/issues/421 ignore, syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -538,12 +528,8 @@ test!( legacy: true, ..Default::default() }), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()), + class_properties(Default::default(), unresolved_mark), + classes(Default::default()), ) }, decorators_legacy_interop_strict, @@ -565,7 +551,7 @@ c = 456; test!( ignore, syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -575,7 +561,7 @@ test!( legacy: true, ..Default::default() }), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), function_name(), ) }, @@ -611,7 +597,7 @@ b(); // function_name_collisions test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -621,7 +607,7 @@ test!( legacy: true, ..Default::default() }), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), function_name(), ) }, @@ -644,7 +630,7 @@ function search({search}) { test!( ignore, Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -654,14 +640,9 @@ test!( legacy: true, ..Default::default() }), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), function_name(), - common_js( - unresolved_mark, - Default::default(), - Default::default(), - Some(t.comments.clone()) - ) + common_js(unresolved_mark, Default::default(), Default::default(),) ) }, function_name_modules_2, @@ -684,7 +665,7 @@ return last(this.tokens.get(key)) // function_name_await test!( Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -694,7 +675,7 @@ test!( legacy: true, ..Default::default() }), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), function_name(), ) }, diff --git a/crates/swc_ecma_transforms_base/src/fixer.rs b/crates/swc_ecma_transforms_base/src/fixer.rs index 1e8737a3468b..3b75ffa1f3f9 100644 --- a/crates/swc_ecma_transforms_base/src/fixer.rs +++ b/crates/swc_ecma_transforms_base/src/fixer.rs @@ -1025,13 +1025,15 @@ impl Fixer<'_> { return; } - let span = e.span(); + let mut span = e.span(); - let span = if let Some(span) = self.span_map.shift_remove(&span) { - span - } else { - span - }; + if let Some(new_span) = self.span_map.shift_remove(&span) { + span = new_span; + } + + if span.is_pure() { + span = DUMMY_SP; + } let expr = Box::new(e.take()); *e = ParenExpr { expr, span }.into(); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_block_scoping.rs/issue_1036_2.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_block_scoping.rs/issue_1036_2.js index 88422e9651ae..24264cedc2eb 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_block_scoping.rs/issue_1036_2.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_block_scoping.rs/issue_1036_2.js @@ -18,7 +18,7 @@ function _foo() { [ 3 ] - ].map(function() { + ].map(/*#__PURE__*/ function() { var _ref = _async_to_generator(function(param) { var _param, a; return _ts_generator(this, function(_state) { diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_1.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_1.js index 2dbb3e3e6b02..4c51e76cbc07 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_1.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_1.js @@ -1,5 +1,5 @@ export default function Foo() { - return call(function() { + return call(/*#__PURE__*/ function() { var _ref = _async_to_generator(function(e) { return _ts_generator(this, function(_state) { switch(_state.label){ diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_2.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_2.js index 2dbb3e3e6b02..4c51e76cbc07 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_2.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_2.js @@ -1,5 +1,5 @@ export default function Foo() { - return call(function() { + return call(/*#__PURE__*/ function() { var _ref = _async_to_generator(function(e) { return _ts_generator(this, function(_state) { switch(_state.label){ diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_3.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_3.js index 2dbb3e3e6b02..4c51e76cbc07 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_3.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_3.js @@ -1,5 +1,5 @@ export default function Foo() { - return call(function() { + return call(/*#__PURE__*/ function() { var _ref = _async_to_generator(function(e) { return _ts_generator(this, function(_state) { switch(_state.label){ diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_5.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_5.js index 2dbb3e3e6b02..4c51e76cbc07 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_5.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2015_generator.rs/issue_1799_5.js @@ -1,5 +1,5 @@ export default function Foo() { - return call(function() { + return call(/*#__PURE__*/ function() { var _ref = _async_to_generator(function(e) { return _ts_generator(this, function(_state) { switch(_state.label){ diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_arrow_in_method.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_arrow_in_method.js index 3fbd7810fe54..3d7c77c73da1 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_arrow_in_method.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_arrow_in_method.js @@ -2,7 +2,7 @@ let TestClass = { name: "John Doe", testMethodFailure () { var _this = this; - return new Promise(function() { + return new Promise(/*#__PURE__*/ function() { var _ref = _async_to_generator(function*(resolve) { console.log(_this); setTimeout(resolve, 1000); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_iife.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_iife.js index 09d83a2e4883..a4173fce74de 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_iife.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_iife.js @@ -4,7 +4,7 @@ _async_to_generator(function*() { _async_to_generator(function*() { yield 'ok'; })(); -(function() { +/*#__PURE__*/ (function() { var _notIIFE = _async_to_generator(function*() { yield 'ok'; }); @@ -13,6 +13,6 @@ _async_to_generator(function*() { } return notIIFE; })(); -_async_to_generator(function*() { +/*#__PURE__*/ _async_to_generator(function*() { yield 'not iife'; }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_async_arrow_in_method.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_async_arrow_in_method.js index 3fbd7810fe54..3d7c77c73da1 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_async_arrow_in_method.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_async_arrow_in_method.js @@ -2,7 +2,7 @@ let TestClass = { name: "John Doe", testMethodFailure () { var _this = this; - return new Promise(function() { + return new Promise(/*#__PURE__*/ function() { var _ref = _async_to_generator(function*(resolve) { console.log(_this); setTimeout(resolve, 1000); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_deeply_nested_asyncs.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_deeply_nested_asyncs.js index 44ad6b908fa5..90553c76df54 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_deeply_nested_asyncs.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_deeply_nested_asyncs.js @@ -4,9 +4,9 @@ function s(x) { function _s() { _s = _async_to_generator(function*(x, ...args) { var _this = this, _arguments = arguments; - let t = function() { + let t = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(y, a) { - let r = function() { + let r = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(z, b, ...innerArgs) { yield z; console.log(_this, innerArgs, _arguments); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_expression.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_expression.js index 306cacb95ebb..482d17f58ddf 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_expression.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_expression.js @@ -1,4 +1,4 @@ -var foo = function() { +var foo = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { var wat = yield bar(); }); @@ -6,14 +6,14 @@ var foo = function() { return _ref.apply(this, arguments); }; }(); -var foo2 = function() { +var foo2 = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { var wat = yield bar(); }); return function foo2() { return _ref.apply(this, arguments); }; -}(), bar = function() { +}(), bar = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { var wat = yield foo(); }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_named_expression.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_named_expression.js index 5ab016bde067..b085218a8cf3 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_named_expression.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_named_expression.js @@ -1,4 +1,4 @@ -var foo = function() { +var foo = /*#__PURE__*/ function() { var _bar = _async_to_generator(function*() { console.log(bar); }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_object_method_with_arrows.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_object_method_with_arrows.js index 6129814b810d..b503602298d2 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_object_method_with_arrows.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_to_generator_object_method_with_arrows.js @@ -13,7 +13,7 @@ class Class { this; }; var _this = this; - _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(function*() { _this; }); } @@ -24,7 +24,7 @@ class Class { this; }; var _this = this; - _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(function*() { _this; }); } diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_with_optional_params_2.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_with_optional_params_2.js index af49ebe360a6..b8fc36864aab 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_with_optional_params_2.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_with_optional_params_2.js @@ -1,4 +1,4 @@ const Z = (f)=>((x)=>f((y)=>x(x)(y)))((x)=>f((y)=>x(x)(y))); -const p = Z((f)=>_async_to_generator(function*(n = 0) { +const p = Z((f)=>/*#__PURE__*/ _async_to_generator(function*(n = 0) { return n <= 1 ? 1 : n * (yield f(n - 1)); }))(5); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_wrap_arguments.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_wrap_arguments.js index 1b3f7159edc3..4ce1387c1a68 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_wrap_arguments.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_wrap_arguments.js @@ -1,6 +1,6 @@ function foo() { var _arguments = arguments; - const bar = function() { + const bar = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return _arguments; }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_wrap_super_and_new_target.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_wrap_super_and_new_target.js index d34cde974aeb..c42a33d6c59d 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_wrap_super_and_new_target.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_wrap_super_and_new_target.js @@ -1,7 +1,7 @@ class Foo { constractur() { var _newtarget = new.target; - const foo = function() { + const foo = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return _newtarget; }); @@ -12,7 +12,7 @@ class Foo { } hello() { var _this = this, _superprop_get_hello = ()=>super.hello; - const world = function() { + const world = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { return _superprop_get_hello().call(_this); }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_wrap_this.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_wrap_this.js index 30f9e1863b7d..e83e56a9cb44 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_wrap_this.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/async_wrap_this.js @@ -1,5 +1,5 @@ var _this = this; -const foo = function() { +const foo = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(x, y, ...z) { return _this; }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/deeply_nested_asyncs.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/deeply_nested_asyncs.js index 0c1880379235..88391255fc9b 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/deeply_nested_asyncs.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/deeply_nested_asyncs.js @@ -7,9 +7,9 @@ function _s() { args[_key - 1] = arguments[_key]; } var _this = this, _arguments = arguments; - let t = function() { + let t = /*#__PURE__*/ function() { var _t = _async_to_generator(function*(y, a) { - let r = function() { + let r = /*#__PURE__*/ function() { var _r = _async_to_generator(function*(z, b) { for(var _len = arguments.length, innerArgs = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ innerArgs[_key - 2] = arguments[_key]; diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/expression.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/expression.js index 51dc4952795a..bb8c145a3b55 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/expression.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/expression.js @@ -1,4 +1,4 @@ -var foo = function() { +var foo = /*#__PURE__*/ function() { var _foo = _async_to_generator(function*() { var wat = yield bar(); }); @@ -7,7 +7,7 @@ var foo = function() { } return foo; }(); -var foo2 = function() { +var foo2 = /*#__PURE__*/ function() { var _foo2 = _async_to_generator(function*() { var wat = yield bar(); }); @@ -15,7 +15,7 @@ var foo2 = function() { return _foo2.apply(this, arguments); } return foo2; -}(), bar = function() { +}(), bar = /*#__PURE__*/ function() { var _bar = _async_to_generator(function*() { var wat = yield foo(); }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_3.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_3.js index 73d8e35a3538..48df40bc9db4 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_3.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_3.js @@ -1,4 +1,4 @@ -const foo = function() { +const foo = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(x, y, ...z) { return 42; }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_4.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_4.js index a932c10b6d9d..cbbc823009de 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_4.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_4.js @@ -1,4 +1,4 @@ -const foo = function() { +const foo = /*#__PURE__*/ function() { var _ref = _wrap_async_generator(function*(x, y, ...z) { return 42; }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_5.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_5.js index 34e9d6344156..bb02aa4b9596 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_5.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_5.js @@ -1,4 +1,4 @@ -const foo = function() { +const foo = /*#__PURE__*/ function() { var _foo = _async_to_generator(function*(x, y, ...z) { if (x) { return foo(0, y); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_6.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_6.js index 3988d3b18dc1..c2f46858788a 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_6.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_6.js @@ -1,4 +1,4 @@ -const foo = function() { +const foo = /*#__PURE__*/ function() { var _foo = _wrap_async_generator(function*(x, y, ...z) { if (x) { return foo(0, y); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_7.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_7.js index 30f9e1863b7d..e83e56a9cb44 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_7.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/function_length_issue_3135_7.js @@ -1,5 +1,5 @@ var _this = this; -const foo = function() { +const foo = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(x, y, ...z) { return _this; }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_1036_1.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_1036_1.js index a1509122d652..0e10ef6adba5 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_1036_1.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_1036_1.js @@ -1,4 +1,4 @@ -const x = function() { +const x = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*() { console.log((yield Promise.all([ [ @@ -10,7 +10,7 @@ const x = function() { [ 3 ] - ].map(function() { + ].map(/*#__PURE__*/ function() { var _ref = _async_to_generator(function*([a]) { return Promise.resolve().then(()=>a * 2); }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_1455_1.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_1455_1.js index 488b73fb8214..bc1f1b37ce47 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_1455_1.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_1455_1.js @@ -4,7 +4,7 @@ const obj = { platform }; }, - byPlatform: function() { + byPlatform: /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(platform) { const result = yield this.find({ platform: { diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_2305_2.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_2305_2.js index 1093315209c0..ea3e19651020 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_2305_2.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_2305_2.js @@ -2,7 +2,7 @@ function MyClass() {} MyClass.prototype.handle = function() { console.log('this is MyClass handle'); }; -MyClass.prototype.init = function() { +MyClass.prototype.init = /*#__PURE__*/ function() { var _ref = _async_to_generator(function(param1) { var a; return _ts_generator(this, function(_state) { diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_2402_2.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_2402_2.js index e8da9dbe55ba..d2d313220ba1 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_2402_2.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_2402_2.js @@ -2,7 +2,7 @@ function MyClass(item) { this.item = item; console.log('Constructor | this.item', this.item); } -MyClass.prototype.fun = function() { +MyClass.prototype.fun = /*#__PURE__*/ function() { var _fun = _async_to_generator(function() { return _ts_generator(this, function(_state) { console.log('fun | this.item', this.item); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_4208.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_4208.js index 8ef3d5fc94e3..4e3310d7e4ee 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_4208.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_4208.js @@ -1,6 +1,6 @@ function foo() { var _this = this; - const bar = function() { + const bar = /*#__PURE__*/ function() { var _ref = _async_to_generator(function*(baz = _this.baz) { console.log(_this); }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_8452.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_8452.js index 0ec40d025077..32e6dd707bc6 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_8452.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_8452.js @@ -3,7 +3,7 @@ class Test0 { class Test extends Test0 { constructor(){ var _this; - super(), _this = this, console.log(function() { + super(), _this = this, console.log(/*#__PURE__*/ function() { var _ref = _async_to_generator(function*(e) { yield _this.test(); }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_9432.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_9432.js index e0085be24cc4..22ff3409fce3 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_9432.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/issue_9432.js @@ -2,7 +2,7 @@ class Foo extends Bar { constructor(options){ var _this; super({ - callA: _async_to_generator(function*() { + callA: /*#__PURE__*/ _async_to_generator(function*() { _this.callA(); }) }), _this = this; diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/named_expression.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/named_expression.js index 5ab016bde067..b085218a8cf3 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/named_expression.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/named_expression.js @@ -1,4 +1,4 @@ -var foo = function() { +var foo = /*#__PURE__*/ function() { var _bar = _async_to_generator(function*() { console.log(bar); }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/no_parameters_and_no_id.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/no_parameters_and_no_id.js index 6a5b542cf21c..c784f4880478 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/no_parameters_and_no_id.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/no_parameters_and_no_id.js @@ -1 +1 @@ -foo(_async_to_generator(function*() {})); +foo(/*#__PURE__*/ _async_to_generator(function*() {})); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/object_method_with_arrows.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/object_method_with_arrows.js index aa44400957c8..271f79919b85 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/object_method_with_arrows.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/object_method_with_arrows.js @@ -18,7 +18,7 @@ class Class { (function() { _this; }); - _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(function*() { _this; }); } @@ -29,7 +29,7 @@ class Class { (function() { _this; }); - _async_to_generator(function*() { + /*#__PURE__*/ _async_to_generator(function*() { _this; }); } diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/regression_4599.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/regression_4599.js index 26f47541e24a..5227f50b0974 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/regression_4599.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/regression_4599.js @@ -1,6 +1,6 @@ -_async_to_generator(function*() { +/*#__PURE__*/ _async_to_generator(function*() { return yield promise; }); -_async_to_generator(function*() { +/*#__PURE__*/ _async_to_generator(function*() { yield promise; }); diff --git a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/regression_t7194.js b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/regression_t7194.js index b750e693e2fb..9826c8297ff9 100644 --- a/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/regression_t7194.js +++ b/crates/swc_ecma_transforms_compat/tests/__swc_snapshots__/tests/es2017_async_to_generator.rs/regression_t7194.js @@ -1,12 +1,12 @@ function f() { - g(_async_to_generator(function*() { + g(/*#__PURE__*/ _async_to_generator(function*() { var _this = this; c(function() { return _this; }); })); } -_async_to_generator(function*() { +/*#__PURE__*/ _async_to_generator(function*() { var _this = this; console.log('async wrapper:', this === 'foo'); (function() { diff --git a/crates/swc_ecma_transforms_compat/tests/es2015_block_scoping.rs b/crates/swc_ecma_transforms_compat/tests/es2015_block_scoping.rs index abf0ae909f39..26c553f591d1 100644 --- a/crates/swc_ecma_transforms_compat/tests/es2015_block_scoping.rs +++ b/crates/swc_ecma_transforms_compat/tests/es2015_block_scoping.rs @@ -1,6 +1,6 @@ use std::{fs::read_to_string, path::PathBuf}; -use swc_common::{chain, comments::SingleThreadedComments, Mark, SyntaxContext}; +use swc_common::{chain, Mark, SyntaxContext}; use swc_ecma_ast::{Ident, PropName, TsQualifiedName}; use swc_ecma_parser::Syntax; use swc_ecma_transforms_base::resolver; @@ -311,7 +311,7 @@ test!( |Tester { comments, .. }| { let mark = Mark::fresh(Mark::root()); chain!( - async_to_generator::(Default::default(), None, mark), + async_to_generator(Default::default(), mark), es2015::es2015(mark, Some(comments.clone()), Default::default(),) ) }, @@ -330,7 +330,7 @@ test_exec!( |Tester { comments, .. }| { let mark = Mark::fresh(Mark::root()); chain!( - async_to_generator(Default::default(), Some(comments.clone()), mark), + async_to_generator(Default::default(), mark), es2015::es2015(mark, Some(comments.clone()), Default::default(),) ) }, diff --git a/crates/swc_ecma_transforms_compat/tests/es2015_classes.rs b/crates/swc_ecma_transforms_compat/tests/es2015_classes.rs index f1bdc725205b..64df8c18bc5e 100644 --- a/crates/swc_ecma_transforms_compat/tests/es2015_classes.rs +++ b/crates/swc_ecma_transforms_compat/tests/es2015_classes.rs @@ -16,15 +16,15 @@ fn syntax() -> Syntax { Syntax::default() } -fn tr(tester: &Tester) -> impl Fold { - classes(Some(tester.comments.clone()), Default::default()) +fn tr(_: &Tester) -> impl Fold { + classes(Default::default()) } -fn spec_tr(tester: &Tester) -> impl Fold { +fn spec_tr(_: &Tester) -> impl Fold { let unresolved_mark = Mark::new(); chain!( resolver(unresolved_mark, Mark::new(), false), - classes(Some(tester.comments.clone()), Default::default()), + classes(Default::default()), spread(Default::default()), block_scoping(unresolved_mark), ) @@ -2602,9 +2602,9 @@ test!( test!( syntax(), - |t| chain!( + |_| chain!( resolver(Mark::new(), Mark::new(), false), - classes(Some(t.comments.clone()), Default::default()) + classes(Default::default()) ), duplicate_ident, r#" @@ -2725,10 +2725,7 @@ class List extends Array {} // extend_builtins_imported_babel_plugin_transform_builtin_classes test_exec!( syntax(), - |t| chain!( - classes(Some(t.comments.clone()), Default::default()), - block_scoping(Mark::new()) - ), + |_| chain!(classes(Default::default()), block_scoping(Mark::new())), extend_builtins_imported_babel_plugin_transform_builtin_classes_exec, r#" // Imported from @@ -3029,10 +3026,7 @@ expect(obj.test).toBe(3); // extend_builtins_spec test_exec!( syntax(), - |t| chain!( - classes(Some(t.comments.clone()), Default::default()), - block_scoping(Mark::new()) - ), + |_| chain!(classes(Default::default()), block_scoping(Mark::new())), extend_builtins_spec_exec, r#" class List extends Array {} @@ -3420,10 +3414,7 @@ expect(obj.test).toBe(3); // extend_builtins_builtin_objects_throw_when_wrapped test_exec!( syntax(), - |t| chain!( - classes(Some(t.comments.clone()), Default::default()), - block_scoping(Mark::new()) - ), + |_| chain!(classes(Default::default()), block_scoping(Mark::new())), extend_builtins_builtin_objects_throw_when_wrapped_exec, r#" // JSON is wrapped because it starts with an uppercase letter, but it @@ -3472,10 +3463,7 @@ test_exec!( // Just don't do this. ignore, syntax(), - |t| chain!( - classes(Some(t.comments.clone()), Default::default()), - block_scoping(Mark::new()) - ), + |_| chain!(classes(Default::default()), block_scoping(Mark::new())), extend_builtins_overwritten_null_exec, r#" var env = { @@ -3496,10 +3484,7 @@ test_exec!( // Just don't do this. With is evil. ignore, syntax(), - |t| chain!( - classes(Some(t.comments.clone()), Default::default()), - block_scoping(Mark::new()) - ), + |_| chain!(classes(Default::default()), block_scoping(Mark::new())), extend_builtins_super_called_exec, r#" var called = false; @@ -3523,7 +3508,7 @@ with (env) { test_exec!( syntax(), - |t| classes(Some(t.comments.clone()), Default::default()), + |_| classes(Default::default()), issue_846, r#" class SomeClass { @@ -3546,7 +3531,7 @@ expect(obj.anotherMethod()).toBe(2); test!( syntax(), - |t| classes(Some(t.comments.clone()), Default::default()), + |_| classes(Default::default()), issue_1490_1, " class ColouredCanvasElement extends CanvasElement { @@ -3559,7 +3544,7 @@ test!( test!( syntax(), - |t| classes(Some(t.comments.clone()), Default::default()), + |_| classes(Default::default()), issue_1490_2, " class ColouredCanvasElement extends CanvasElement { @@ -3572,7 +3557,7 @@ test!( test!( syntax(), - |t| classes(Some(t.comments.clone()), Default::default()), + |_| classes(Default::default()), super_binding, " class Foo {} @@ -3586,7 +3571,7 @@ test!( test_exec!( syntax(), - |t| classes(Some(t.comments.clone()), Default::default()), + |_| classes(Default::default()), super_binding_exec, " class Foo {} @@ -3602,7 +3587,7 @@ test_exec!( test!( syntax(), - |t| classes(Some(t.comments.clone()), Default::default()), + |_| classes(Default::default()), issue_1617_1, " class A extends B { @@ -3615,7 +3600,7 @@ test!( test!( syntax(), - |t| classes(Some(t.comments.clone()), Default::default()), + |_| classes(Default::default()), issue_1617_2, " class A extends B { @@ -3628,7 +3613,7 @@ test!( test!( syntax(), - |t| classes(Some(t.comments.clone()), Default::default()), + |_| classes(Default::default()), issue_1660_1, " class A { @@ -3639,7 +3624,7 @@ test!( test!( syntax(), - |t| classes(Some(t.comments.clone()), Default::default()), + |_| classes(Default::default()), constructor_super_update, " class A extends B { @@ -3655,7 +3640,7 @@ class A extends B { test!( syntax(), - |t| classes(Some(t.comments.clone()), Default::default()), + |_| classes(Default::default()), prefix_super_update, " class A extends B { @@ -3668,7 +3653,7 @@ class A extends B { test!( syntax(), - |t| classes(Some(t.comments.clone()), Default::default()), + |_| classes(Default::default()), issue_1660_2, " const foo = class {run(){}}; @@ -3677,7 +3662,7 @@ test!( test!( syntax(), - |t| classes(Some(t.comments.clone()), Default::default()), + |_| classes(Default::default()), issue_1660_3, " console.log(class { run() { } }); @@ -3692,17 +3677,9 @@ test!( chain!( resolver(unresolved_mark, top_level_mark, true), - es2022::es2022( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + es2022::es2022(Default::default(), unresolved_mark), es2018::es2018(Default::default()), - es2017::es2017( - Default::default(), - Some(t.comments.clone()), - unresolved_mark - ), + es2017::es2017(Default::default(), unresolved_mark), es2016::es2016(), es2015::es2015( unresolved_mark, @@ -3725,11 +3702,7 @@ test!( chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), es2015::es2015( unresolved_mark, Some(t.comments.clone()), @@ -3773,11 +3746,7 @@ test!( chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), es2015::es2015( unresolved_mark, Some(t.comments.clone()), @@ -3803,11 +3772,7 @@ test!( chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), es2015::es2015( unresolved_mark, Some(t.comments.clone()), @@ -3830,18 +3795,14 @@ fn exec(input: PathBuf) { let src = read_to_string(input).unwrap(); compare_stdout( Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()) + class_properties(Default::default(), unresolved_mark), + classes(Default::default()) ) }, &src, @@ -3854,18 +3815,14 @@ fn fixture(input: PathBuf) { test_fixture( Default::default(), - &|t| { + &|_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()) + class_properties(Default::default(), unresolved_mark), + classes(Default::default()) ) }, &input, @@ -3876,13 +3833,10 @@ fn fixture(input: PathBuf) { test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - constant_super: true, - ..Default::default() - } - ), + |_| classes(Config { + constant_super: true, + ..Default::default() + }), constant_super_class, r#" class Test extends Foo { @@ -3903,13 +3857,10 @@ class Test extends Foo { test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - constant_super: true, - ..Default::default() - } - ), + |_| classes(Config { + constant_super: true, + ..Default::default() + }), constant_super_property, r#" class Test extends Foo { @@ -3924,13 +3875,10 @@ class Test extends Foo { test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - constant_super: true, - ..Default::default() - } - ), + |_| classes(Config { + constant_super: true, + ..Default::default() + }), constant_super_call, r#" class Test extends Foo { @@ -3949,13 +3897,10 @@ class Test extends Foo { test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - constant_super: true, - ..Default::default() - } - ), + |_| classes(Config { + constant_super: true, + ..Default::default() + }), constant_super_default, r#" class Test { @@ -3973,13 +3918,10 @@ class Test { test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - constant_super: true, - ..Default::default() - } - ), + |_| classes(Config { + constant_super: true, + ..Default::default() + }), constant_super_update, r#" class A extends B { @@ -3995,26 +3937,20 @@ class A extends B { test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - no_class_calls: true, - ..Default::default() - } - ), + |_| classes(Config { + no_class_calls: true, + ..Default::default() + }), no_class_call, "class A {}" ); test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - no_class_calls: true, - ..Default::default() - } - ), + |_| classes(Config { + no_class_calls: true, + ..Default::default() + }), no_class_call_constructor, r#" class A { @@ -4033,13 +3969,10 @@ class B { test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - no_class_calls: true, - ..Default::default() - } - ), + |_| classes(Config { + no_class_calls: true, + ..Default::default() + }), no_class_call_super, r#" class B {} @@ -4055,13 +3988,10 @@ class A extends B { test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - set_class_methods: true, - ..Default::default() - } - ), + |_| classes(Config { + set_class_methods: true, + ..Default::default() + }), set_method_literal_key, r#" class Foo { @@ -4073,13 +4003,10 @@ class Foo { test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - set_class_methods: true, - ..Default::default() - } - ), + |_| classes(Config { + set_class_methods: true, + ..Default::default() + }), set_method_static, r#" class Test { @@ -4092,13 +4019,10 @@ class Test { test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - set_class_methods: true, - ..Default::default() - } - ), + |_| classes(Config { + set_class_methods: true, + ..Default::default() + }), set_method_getter_setter, r#" class Test extends Foo { @@ -4113,13 +4037,10 @@ class Test extends Foo { test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - super_is_callable_constructor: true, - ..Default::default() - } - ), + |_| classes(Config { + super_is_callable_constructor: true, + ..Default::default() + }), super_callable, r#" class BaseController extends Chaplin.Controller { } @@ -4130,26 +4051,20 @@ class BaseController2 extends Chaplin.Controller.Another { } test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - super_is_callable_constructor: true, - ..Default::default() - } - ), + |_| classes(Config { + super_is_callable_constructor: true, + ..Default::default() + }), super_callable_super, r#"class Test extends Foo { }"# ); test!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - super_is_callable_constructor: true, - ..Default::default() - } - ), + |_| classes(Config { + super_is_callable_constructor: true, + ..Default::default() + }), issue_3943, r#" class Thing extends B { @@ -4163,10 +4078,7 @@ class Thing extends B { test!( syntax(), - |t| chain!( - classes(Some(t.comments.clone()), Default::default()), - block_scoping(Mark::new()) - ), + |_| chain!(classes(Default::default()), block_scoping(Mark::new())), issue_5102, r#" let C = class {} @@ -4178,13 +4090,10 @@ D ??= class /* D */ {}; test_exec!( syntax(), - |t| classes( - Some(t.comments.clone()), - Config { - constant_super: true, - ..Default::default() - } - ), + |_| classes(Config { + constant_super: true, + ..Default::default() + }), issue_5936, " class Superclass { diff --git a/crates/swc_ecma_transforms_compat/tests/es2015_generator.rs b/crates/swc_ecma_transforms_compat/tests/es2015_generator.rs index 9ff3c3ecf1d7..69fac8cf95a4 100644 --- a/crates/swc_ecma_transforms_compat/tests/es2015_generator.rs +++ b/crates/swc_ecma_transforms_compat/tests/es2015_generator.rs @@ -32,7 +32,7 @@ fn tr_with_async() -> impl Fold { let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), generator(unresolved_mark, NoopComments) ) } @@ -911,11 +911,7 @@ test_exec!( |t| { let unresolved_mark = Mark::new(); chain!( - es2017( - Default::default(), - Some(t.comments.clone()), - unresolved_mark - ), + es2017(Default::default(), unresolved_mark), es2016(), es2015( unresolved_mark, @@ -937,7 +933,7 @@ test_exec!( |t| { let unresolved_mark = Mark::new(); chain!( - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), es2015::for_of(Default::default()), generator(unresolved_mark, t.comments.clone()), ) @@ -1373,7 +1369,7 @@ test!( |_| { let mark = Mark::fresh(Mark::root()); chain!( - async_to_generator::(Default::default(), None, mark), + async_to_generator(Default::default(), mark), es2015::(mark, None, Default::default()) ) }, @@ -1390,7 +1386,7 @@ test!( |_| { let mark = Mark::fresh(Mark::root()); chain!( - async_to_generator::(Default::default(), None, mark), + async_to_generator(Default::default(), mark), es2016(), es2015::(mark, None, Default::default()), ) @@ -1405,24 +1401,16 @@ test!( test!( Syntax::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - es2022( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + es2022(Default::default(), unresolved_mark), es2021(), es2018(Default::default()), - es2017( - Default::default(), - Some(t.comments.clone()), - unresolved_mark - ), + es2017(Default::default(), unresolved_mark), es2016(), es2015::(unresolved_mark, None, Default::default()), ) @@ -1456,7 +1444,7 @@ test_exec!( |t| { let mark = Mark::fresh(Mark::root()); chain!( - async_to_generator::(Default::default(), None, mark), + async_to_generator(Default::default(), mark), es2015::for_of(Default::default()), generator(mark, t.comments.clone()) ) diff --git a/crates/swc_ecma_transforms_compat/tests/es2015_new_target.rs b/crates/swc_ecma_transforms_compat/tests/es2015_new_target.rs index 544687340258..add83ff25d10 100644 --- a/crates/swc_ecma_transforms_compat/tests/es2015_new_target.rs +++ b/crates/swc_ecma_transforms_compat/tests/es2015_new_target.rs @@ -10,7 +10,7 @@ use swc_ecma_transforms_compat::{ use swc_ecma_transforms_testing::{exec_tr, parse_options, test, test_fixture, Tester}; use swc_ecma_visit::Fold; -fn get_passes(t: &Tester, plugins: &[PluginConfig]) -> Box { +fn get_passes(_: &Tester, plugins: &[PluginConfig]) -> Box { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -41,7 +41,6 @@ fn get_passes(t: &Tester, plugins: &[PluginConfig]) -> Box { pass = Box::new(chain!( pass, class_properties( - Some(t.comments.clone()), class_properties::Config { constant_super: loose, set_public_fields: loose, @@ -111,10 +110,7 @@ fn fixture(input: PathBuf) { test!( ::swc_ecma_parser::Syntax::default(), - |t| chain!( - classes(Some(t.comments.clone()), Default::default()), - new_target() - ), + |_| chain!(classes(Default::default()), new_target()), issue_6259, r#" (() => { diff --git a/crates/swc_ecma_transforms_compat/tests/es2015_parameters.rs b/crates/swc_ecma_transforms_compat/tests/es2015_parameters.rs index d0168e88f240..aec8c84f6d01 100644 --- a/crates/swc_ecma_transforms_compat/tests/es2015_parameters.rs +++ b/crates/swc_ecma_transforms_compat/tests/es2015_parameters.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use swc_common::{chain, comments::SingleThreadedComments, Mark}; +use swc_common::{chain, Mark}; use swc_ecma_parser::Syntax; use swc_ecma_transforms_base::resolver; use swc_ecma_transforms_compat::{ @@ -138,10 +138,7 @@ foo(1, 2, 3);"# test!( syntax(), - |t| chain!( - classes(Some(t.comments.clone()), Default::default()), - tr(Default::default()) - ), + |_| chain!(classes(Default::default()), tr(Default::default())), default_iife_4253, r#"class Ref { constructor(id = ++Ref.nextID) { @@ -170,10 +167,7 @@ expect(new Ref().id).toBe(2);"# test!( syntax(), - |t| chain!( - classes(Some(t.comments.clone()), Default::default()), - tr(Default::default()) - ), + |_| chain!(classes(Default::default()), tr(Default::default())), default_iife_self, r#"class Ref { constructor(ref = Ref) { @@ -728,9 +722,9 @@ function d(thing, ...args) { test!( syntax(), - |t| chain!( + |_| chain!( tr(Default::default()), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), spread(Default::default()) ), rest_nested_iife, @@ -799,7 +793,7 @@ test!( let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), arrow(unresolved_mark), parameters(Default::default(), unresolved_mark), ) @@ -823,7 +817,7 @@ test!( let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), arrow(unresolved_mark), parameters(Default::default(), unresolved_mark), ) diff --git a/crates/swc_ecma_transforms_compat/tests/es2017_async_to_generator.rs b/crates/swc_ecma_transforms_compat/tests/es2017_async_to_generator.rs index 7ac0cc6e50cb..6d3035dd6d7c 100644 --- a/crates/swc_ecma_transforms_compat/tests/es2017_async_to_generator.rs +++ b/crates/swc_ecma_transforms_compat/tests/es2017_async_to_generator.rs @@ -1,6 +1,6 @@ use std::{fs::read_to_string, path::PathBuf}; -use swc_common::{chain, comments::SingleThreadedComments, Mark, Spanned}; +use swc_common::{chain, Mark, Spanned}; use swc_ecma_ast::*; use swc_ecma_parser::Syntax; use swc_ecma_transforms_base::{fixer::fixer, resolver}; @@ -49,7 +49,7 @@ fn tr() -> impl Fold { parameters(Default::default(), unresolved_mark), destructuring(destructuring::Config { loose: false }), function_name(), - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), fixer(None) ) } @@ -59,7 +59,7 @@ fn with_resolver() -> impl Fold { let top_level = Mark::new(); chain!( resolver(unresolved, top_level, false), - async_to_generator::(Default::default(), None, unresolved) + async_to_generator(Default::default(), unresolved) ) } @@ -448,7 +448,7 @@ return (new B(20)).print().then(() => console.log('Done'));" test_exec!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_400_2, "class A { constructor() { @@ -481,11 +481,7 @@ test_exec!( |t| { let unresolved_mark = Mark::new(); chain!( - async_to_generator( - Default::default(), - Some(t.comments.clone()), - unresolved_mark - ), + async_to_generator(Default::default(), unresolved_mark), es2015( unresolved_mark, Some(t.comments.clone()), @@ -547,7 +543,7 @@ return (new A()).print();" test!( ignore, syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), bluebird_coroutines_named_expression, r#" var foo = async function bar() { @@ -562,7 +558,7 @@ test!( // TODO: Enable this test after implementing es6 module pass. ignore, syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), export_async_lone_export, r#" export async function foo () { } @@ -574,7 +570,7 @@ export async function foo () { } test!( ignore, syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), bluebird_coroutines_arrow_function, r#" (async () => { await foo(); })() @@ -591,7 +587,7 @@ test!( |_| { let unresolved_mark = Mark::new(); chain!( - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), arrow(unresolved_mark) ) }, @@ -633,7 +629,7 @@ async function foo() { // async_to_generator_object_method_with_arrows test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_to_generator_object_method_with_arrows, r#" class Class { @@ -662,7 +658,7 @@ class Class { // async_to_generator_object_method test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_to_generator_object_method, r#" let obj = { @@ -679,7 +675,7 @@ let obj = { test!( ignore, syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), bluebird_coroutines_class, r#" class Foo { @@ -698,7 +694,7 @@ test!( |_| { let unresolved_mark = Mark::new(); chain!( - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), //regenerator(), arrow(unresolved_mark), ) @@ -784,7 +780,7 @@ test!( // async_to_generator_named_expression test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_to_generator_named_expression, r#" var foo = async function bar() { @@ -890,7 +886,7 @@ var foo = async function bar() { // async_to_generator_async_arrow_in_method test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_to_generator_async_arrow_in_method, r#" let TestClass = { @@ -911,7 +907,7 @@ let TestClass = { test!( ignore, syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), bluebird_coroutines_statement, r#" async function foo() { @@ -930,7 +926,7 @@ test!( chain!( resolver(unresolved_mark, top_level_mark, false), - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), parameters(Default::default(), unresolved_mark), destructuring(destructuring::Config { loose: false }), ) @@ -955,7 +951,7 @@ test!( // TODO: Enable this test after implementing es6 module pass. ignore, syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), export_async_default_arrow_export, r#" export default async () => { return await foo(); } @@ -966,7 +962,7 @@ export default async () => { return await foo(); } // async_to_generator_function_arity test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_to_generator_function_arity, r#" async function one(a, b = 1) {} @@ -982,7 +978,7 @@ async function six(a, {b} = {}){} // async_to_generator_object_method_with_super test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_to_generator_object_method_with_super_caching, r#" class Foo extends class {} { @@ -1001,7 +997,7 @@ test!( // TODO: Enable this test after implementing es6 module pass. ignore, syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), export_async_default_export, r#" export default async function myFunc() {} @@ -1012,7 +1008,7 @@ export default async function myFunc() {} // async_to_generator_async test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_to_generator_async, r#" class Foo { @@ -1027,7 +1023,7 @@ class Foo { // regression_8783 test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), regression_8783, r#" (async function poll() { @@ -1068,7 +1064,7 @@ test!( // TODO: Enable this test after implementing es6 module pass. ignore, syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), export_async_import_and_export, r#" import bar from 'bar'; @@ -1108,7 +1104,7 @@ async function foo() { // regression_4599 test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), regression_4599, r#" async () => await promise @@ -1121,7 +1117,7 @@ async () => { await promise } // regression_4943_exec test_exec!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), regression_4943_exec, r#" "use strict"; @@ -1144,7 +1140,7 @@ return foo().then(() => { // regression_8783_exec test_exec!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), regression_8783_exec, r#" let log = []; @@ -1169,7 +1165,7 @@ return main.then(() => { test!( ignore, syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), bluebird_coroutines_expression, r#" var foo = async function () { @@ -1182,7 +1178,7 @@ var foo = async function () { // async_to_generator_expression test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_to_generator_expression, r#" var foo = async function () { @@ -1202,7 +1198,7 @@ bar = async function () { // async_to_generator_statement test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_to_generator_statement, r#" async function foo() { @@ -1232,7 +1228,7 @@ async function foo() { // async_to_generator_parameters test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_to_generator_parameters, r#" async function foo(bar) { @@ -1247,7 +1243,7 @@ async function foo(bar) { // regression_t6882_exec test_exec!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), regression_t6882_exec, r#" foo(); @@ -1260,7 +1256,7 @@ async function foo() {} // async_to_generator_parameters test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_600, r#" async function foo() { @@ -1272,7 +1268,7 @@ for (let a of b) { test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1036_1, " const x = async function() { @@ -1287,7 +1283,7 @@ test!( test_exec!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1036_2, " const x = async function() { @@ -1303,7 +1299,7 @@ test_exec!( test!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1216_1, " const source = Math.random() < 2 ? 'matilda' : 'fred'; @@ -1328,7 +1324,7 @@ test!( test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1125_1, " async function test() { @@ -1344,7 +1340,7 @@ test() test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1341_1, " class A { @@ -1362,18 +1358,14 @@ test!( test_exec!( Syntax::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - async_to_generator(Default::default(), Some(t.comments.clone()), Mark::new()) + class_properties(Default::default(), unresolved_mark), + async_to_generator(Default::default(), Mark::new()) ) }, issue_1341_1_exec, @@ -1396,7 +1388,7 @@ test_exec!( test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1341_2, " class A { @@ -1410,18 +1402,14 @@ test!( test_exec!( Syntax::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - async_to_generator(Default::default(), Some(t.comments.clone()), Mark::new()) + class_properties(Default::default(), unresolved_mark), + async_to_generator(Default::default(), Mark::new()) ) }, issue_1341_2_exec, @@ -1440,7 +1428,7 @@ test_exec!( test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1455_1, " const obj = { @@ -1459,7 +1447,7 @@ test!( test_exec!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1575_1, " const obj = { @@ -1477,7 +1465,7 @@ test_exec!( |t| { let mark = Mark::fresh(Mark::root()); chain!( - async_to_generator::(Default::default(), None, mark), + async_to_generator(Default::default(), mark), generator(mark, t.comments.clone()) ) }, @@ -1495,7 +1483,7 @@ test_exec!( test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1722_1, " (async function main() { @@ -1506,7 +1494,7 @@ test!( test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1721_1, " async function main() { @@ -1519,7 +1507,7 @@ test!( test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1721_2_async_generator, " async function* lol() { @@ -1531,7 +1519,7 @@ test!( test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1684_1, " const cache = {} @@ -1552,7 +1540,7 @@ test!( |t| { let unresolved_mark = Mark::fresh(Mark::root()); chain!( - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), generator(unresolved_mark, t.comments.clone()) ) }, @@ -1573,7 +1561,7 @@ test!( test_exec!( syntax(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1752_1, " async function* generate() { @@ -1601,7 +1589,7 @@ test_exec!( test_exec!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_1918_1, " let counter = 0; @@ -1641,7 +1629,7 @@ test_exec!( test_exec!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_2402_1, " function MyClass(item) { @@ -1665,7 +1653,7 @@ test!( |t| { let unresolved_mark = Mark::fresh(Mark::root()); chain!( - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), generator(unresolved_mark, t.comments.clone()) ) }, @@ -1691,7 +1679,7 @@ test!( test_exec!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_2305_1, " function MyClass () {} @@ -1726,7 +1714,7 @@ test!( |t| { let unresolved_mark = Mark::fresh(Mark::root()); chain!( - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), generator(unresolved_mark, t.comments.clone()) ) }, @@ -1763,7 +1751,7 @@ test!( |t| { let unresolved_mark = Mark::fresh(Mark::root()); chain!( - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), generator(unresolved_mark, t.comments.clone()) ) }, @@ -1787,7 +1775,7 @@ test!( |t| { let unresolved_mark = Mark::fresh(Mark::root()); chain!( - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), generator(unresolved_mark, t.comments.clone()) ) }, @@ -1804,7 +1792,7 @@ export default async function() { test_exec!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), function_parameters, " class A { @@ -1827,7 +1815,7 @@ expect(a.doTest()).resolves.toEqual(3); test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), function_length_issue_3135_1, r#" async function foo(x, y, ...z) { @@ -1838,7 +1826,7 @@ async function foo(x, y, ...z) { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), function_length_issue_3135_2, r#" async function* foo(x, y, ...z) { @@ -1849,7 +1837,7 @@ async function* foo(x, y, ...z) { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), function_length_issue_3135_3, r#" const foo = async function (x, y, ...z) { @@ -1860,7 +1848,7 @@ const foo = async function (x, y, ...z) { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), function_length_issue_3135_4, r#" const foo = async function* (x, y, ...z) { @@ -1871,7 +1859,7 @@ const foo = async function* (x, y, ...z) { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), function_length_issue_3135_5, r#" const foo = async function foo(x, y, ...z) { @@ -1885,7 +1873,7 @@ const foo = async function foo(x, y, ...z) { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), function_length_issue_3135_6, r#" const foo = async function* foo(x, y, ...z) { @@ -1899,7 +1887,7 @@ const foo = async function* foo(x, y, ...z) { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), function_length_issue_3135_7, r#" const foo = async (x, y, ...z) => { @@ -1910,7 +1898,7 @@ const foo = async (x, y, ...z) => { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_wrap_this, r#" const foo = async (x, y, ...z) => { @@ -1955,7 +1943,7 @@ class Foo { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), export_default_async_nested_1, " export default async function foo(x) { @@ -1968,7 +1956,7 @@ export default async function foo(x) { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), export_default_async_nested_2, " export default async function (x) { @@ -1981,7 +1969,7 @@ export default async function (x) { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_with_optional_params, " (async function (a = 10, ...rest) {})(); @@ -2006,7 +1994,7 @@ export class Quirk { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), super_field_update, " class Foo { @@ -2020,7 +2008,7 @@ class Foo { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), microbundle_835, " class A extends B { @@ -2035,7 +2023,7 @@ class A extends B { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), super_update, " class A extends B { @@ -2051,7 +2039,7 @@ class A extends B { test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), async_with_optional_params_2, " const Z = (f) => ((x) => f((y) => x(x)(y)))((x) => f((y) => x(x)(y))); @@ -2066,7 +2054,7 @@ const p = Z( test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_4208, " function foo() { @@ -2079,7 +2067,7 @@ test!( test!( Syntax::default(), - |_| async_to_generator::(Default::default(), None, Mark::new()), + |_| async_to_generator(Default::default(), Mark::new()), issue_8452, r#" class Test0 {} @@ -2120,22 +2108,14 @@ fn exec(input: PathBuf) { let input = read_to_string(input).unwrap(); compare_stdout( Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - async_to_generator( - Default::default(), - Some(t.comments.clone()), - unresolved_mark - ) + class_properties(Default::default(), unresolved_mark), + async_to_generator(Default::default(), unresolved_mark) ) }, &input, @@ -2153,16 +2133,8 @@ fn exec_regenerator(input: PathBuf) { chain!( resolver(unresolved_mark, top_level_mark, false), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - async_to_generator( - Default::default(), - Some(t.comments.clone()), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), es2015::for_of(Default::default()), block_scoping(unresolved_mark), generator(unresolved_mark, t.comments.clone()) diff --git a/crates/swc_ecma_transforms_compat/tests/es2020_optional_chaining.rs b/crates/swc_ecma_transforms_compat/tests/es2020_optional_chaining.rs index 3485ff5826f7..12d8f38d8e81 100644 --- a/crates/swc_ecma_transforms_compat/tests/es2020_optional_chaining.rs +++ b/crates/swc_ecma_transforms_compat/tests/es2020_optional_chaining.rs @@ -278,13 +278,12 @@ fn fixture(input: PathBuf) { test_fixture( Default::default(), - &|t| { + &|_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), swc_ecma_transforms_compat::es2022::class_properties::Config { private_as_properties: false, ..Default::default() @@ -306,13 +305,12 @@ fn fixture_loose(input: PathBuf) { test_fixture( Default::default(), - &|t| { + &|_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), swc_ecma_transforms_compat::es2022::class_properties::Config { private_as_properties: false, pure_getter: true, diff --git a/crates/swc_ecma_transforms_compat/tests/es2022_class_properties.rs b/crates/swc_ecma_transforms_compat/tests/es2022_class_properties.rs index 5ceb869d1f48..a16f09c9cfe7 100644 --- a/crates/swc_ecma_transforms_compat/tests/es2022_class_properties.rs +++ b/crates/swc_ecma_transforms_compat/tests/es2022_class_properties.rs @@ -20,19 +20,15 @@ fn syntax() -> Syntax { Syntax::Es(Default::default()) } -fn tr(t: &Tester) -> impl Fold { +fn tr(_: &Tester) -> impl Fold { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), function_name(), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()), + class_properties(Default::default(), unresolved_mark), + classes(Default::default()), block_scoping(unresolved_mark), reserved_words(false), ) @@ -114,18 +110,14 @@ class Foo extends Bar { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), function_name(), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), ) }, private_class_method, @@ -1760,17 +1752,13 @@ class Foo { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ) + class_properties(Default::default(), unresolved_mark) ) }, issue_308, @@ -1788,18 +1776,14 @@ class Foo { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()) + class_properties(Default::default(), unresolved_mark), + classes(Default::default()) ) }, issue_342, @@ -1816,17 +1800,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), block_scoping(unresolved_mark) ) }, @@ -1847,18 +1827,14 @@ class foo { // public_regression_t7364 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - async_to_generator(Default::default(), Some(t.comments.clone()), Mark::new()) + class_properties(Default::default(), unresolved_mark), + async_to_generator(Default::default(), Mark::new()) ) }, public_regression_t7364, @@ -1887,17 +1863,13 @@ export default class MyClass3 { // private_regression_t6719 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), block_scoping(Mark::new()) ) }, @@ -1924,17 +1896,13 @@ function withContext(ComposedComponent) { // private_reevaluated test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), block_scoping(Mark::new()) ) }, @@ -1969,17 +1937,13 @@ function classFactory() { // private_static test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), block_scoping(Mark::new()) ) }, @@ -2007,18 +1971,14 @@ expect(Foo.test()).toBe("foo") // private_destructuring_object_pattern_1 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()), + class_properties(Default::default(), unresolved_mark), + classes(Default::default()), block_scoping(Mark::new()) ) }, @@ -2038,17 +1998,13 @@ class Foo { // private_static_inherited test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), block_scoping(Mark::new()) ) }, @@ -2090,17 +2046,13 @@ class Sub2 extends Base {} // private_destructuring_object_pattern_1_exec test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, private_destructuring_object_pattern_1_exec, @@ -2129,17 +2081,13 @@ expect(foo.z).toBe('bar'); // private_static_undefined test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), block_scoping(Mark::new()) ) }, @@ -2163,18 +2111,14 @@ class Foo { // private_destructuring_array_pattern test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()), + class_properties(Default::default(), unresolved_mark), + classes(Default::default()), block_scoping(Mark::new()) ) }, @@ -2194,17 +2138,13 @@ class Foo { // private_regression_t2983 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), block_scoping(Mark::new()) ) }, @@ -2224,22 +2164,14 @@ export default class { // private_regression_t7364 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - async_to_generator( - Default::default(), - Some(t.comments.clone()), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), block_scoping(unresolved_mark) ) }, @@ -2269,18 +2201,14 @@ export default class MyClass3 { // private_destructuring_array_pattern_1 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()), + class_properties(Default::default(), unresolved_mark), + classes(Default::default()), block_scoping(Mark::new()) ) }, @@ -2300,17 +2228,13 @@ class Foo { // regression_8882_exec test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, regression_8882_exec, @@ -2343,17 +2267,13 @@ for(let i=0; i<= 10; ++i) { test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ), + class_properties(Default::default(), unresolved_mark,), ) }, regression_8882_exec_2, @@ -2386,17 +2306,13 @@ for(let i=0; i<= 10; ++i) { test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, private_field_reinitialized, @@ -2420,17 +2336,13 @@ expect(() => new Derived(foo)).toThrow() // private_static_export test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), block_scoping(Mark::new()) ) }, @@ -2450,18 +2362,14 @@ export default class MyClass2 { // static_property_tdz_edgest_case test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()) + class_properties(Default::default(), unresolved_mark), + classes(Default::default()) ) }, static_property_tdz_edgest_case, @@ -2475,18 +2383,14 @@ class A { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()) + class_properties(Default::default(), unresolved_mark), + classes(Default::default()) ) }, static_property_tdz_false_alarm, @@ -2500,17 +2404,13 @@ static A = 123; // regression_6153 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), arrow(Mark::new()) ) }, @@ -2551,17 +2451,13 @@ var qux = function() { // regression_7371 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), arrow(unresolved_mark), ) }, @@ -2672,17 +2568,13 @@ new ComputedField(); test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, private_optional_chain_call, @@ -2699,17 +2591,13 @@ class A { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, private_optional_chain_member, @@ -2726,18 +2614,14 @@ class MyClass { // private_canonical test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()), + class_properties(Default::default(), unresolved_mark), + classes(Default::default()), block_scoping(Mark::new()) ) }, @@ -2770,17 +2654,13 @@ class Point { // regression_8882 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, regression_8882, @@ -2812,18 +2692,14 @@ for(let i = 0; i <= 10; ++i){ // private_destructuring_array_pattern_3 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()), + class_properties(Default::default(), unresolved_mark), + classes(Default::default()), block_scoping(Mark::new()) ) }, @@ -2841,17 +2717,13 @@ class Foo { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, staic_private_destructuring_array_pattern, @@ -2868,17 +2740,13 @@ class A { // public_static_super_exec test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, public_static_super_exec, @@ -2905,18 +2773,14 @@ expect(getPropA()).toBe(1); // private_destructuring_array_pattern_2 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()), + class_properties(Default::default(), unresolved_mark), + classes(Default::default()), block_scoping(Mark::new()) ) }, @@ -2935,17 +2799,13 @@ class Foo { // private_non_block_arrow_func test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), block_scoping(Mark::new()) ) }, @@ -2969,17 +2829,13 @@ export default param => // regression_8110 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, regression_8110, @@ -2996,17 +2852,13 @@ class A { // public_computed_without_block_exec test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, public_computed_without_block_exec, @@ -3022,19 +2874,15 @@ expect(instance.foo).toBe(2); // private_instance test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), exponentiation(), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), block_scoping(Mark::new()), ) }, @@ -3050,18 +2898,14 @@ class Foo { // static_property_tdz_general test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()) + class_properties(Default::default(), unresolved_mark), + classes(Default::default()) ) }, static_property_tdz_general, @@ -3076,17 +2920,13 @@ class C { // public_native_classes test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), block_scoping(Mark::new()) ) }, @@ -3119,17 +2959,13 @@ test!( // Seems useless, while being hard to implement. ignore, syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), block_scoping(Mark::new()) ) }, @@ -3145,17 +2981,13 @@ var Foo = class { // regression_7951 test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ) + class_properties(Default::default(), unresolved_mark) ) }, regression_7951, @@ -3172,17 +3004,13 @@ export class Foo extends Bar { // private_native_classes test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), block_scoping(Mark::new()) ) }, @@ -3207,18 +3035,14 @@ class Foo { // public_computed_without_block test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()), + class_properties(Default::default(), unresolved_mark), + classes(Default::default()), block_scoping(Mark::new()) ) }, @@ -3232,17 +3056,13 @@ const createClass = (k) => class { [k()] = 2 }; // private_destructuring_array_pattern_2_exec test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, private_destructuring_array_pattern_2_exec, @@ -3269,18 +3089,14 @@ expect(foo.getClient()).toEqual(['bar', 'baz', 'quu']); // public_static_super test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - classes(Some(t.comments.clone()), Default::default()), + class_properties(Default::default(), unresolved_mark), + classes(Default::default()), block_scoping(Mark::new()) ) }, @@ -3302,17 +3118,13 @@ class B extends A { // private_destructuring_array_pattern_exec test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, private_destructuring_array_pattern_exec, @@ -3338,17 +3150,13 @@ expect(foo.getClient()).toBe('bar'); // private_destructuring_array_pattern_1_exec test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, private_destructuring_array_pattern_1_exec, @@ -3376,17 +3184,13 @@ expect(foo.y).toBe('bar'); test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1306_1, @@ -3407,17 +3211,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1306_2, @@ -3438,17 +3238,13 @@ class Animal { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1333_1, @@ -3465,17 +3261,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1333_2, @@ -3572,17 +3364,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1333_3, @@ -3613,17 +3401,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1333_4, @@ -3647,17 +3431,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1333_5, @@ -3673,17 +3453,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1333_6, @@ -3699,17 +3475,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1660_1, @@ -3720,17 +3492,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_3055_1, @@ -3752,17 +3520,13 @@ export class Node { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_3618, @@ -3778,18 +3542,14 @@ class MyClass { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - async_to_generator(Default::default(), Some(t.comments.clone()), Mark::new()) + class_properties(Default::default(), unresolved_mark), + async_to_generator(Default::default(), Mark::new()) ) }, issue_1694_1, @@ -3807,18 +3567,14 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - async_to_generator(Default::default(), Some(t.comments.clone()), Mark::new()) + class_properties(Default::default(), unresolved_mark), + async_to_generator(Default::default(), Mark::new()) ) }, issue_1694_2, @@ -3836,18 +3592,14 @@ class MyClass { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), - async_to_generator(Default::default(), Some(t.comments.clone()), Mark::new()) + class_properties(Default::default(), unresolved_mark), + async_to_generator(Default::default(), Mark::new()) ) }, issue_1702_1, @@ -3873,17 +3625,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1711_1, @@ -3903,17 +3651,13 @@ test!( test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1742_1, @@ -3939,17 +3683,13 @@ test_exec!( test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), template_literal(Default::default()) ) }, @@ -3976,17 +3716,13 @@ test_exec!( test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, new_target_in_class_prop, @@ -4005,17 +3741,13 @@ expect(foo.baz).toBe(undefined); test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, class_field_evalutaion_order, @@ -4034,17 +3766,13 @@ expect(() => new Foo()).not.toThrow(); test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1742_3, @@ -4070,17 +3798,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1869_1, @@ -4101,17 +3825,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_1869_2, @@ -4131,17 +3851,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_2021_1, @@ -4158,17 +3874,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_3229_1, @@ -4186,17 +3898,13 @@ class A { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_3229_2, @@ -4215,17 +3923,13 @@ class A { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_3368, @@ -4247,17 +3951,13 @@ class A { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, nested_class_in_arrow, @@ -4275,17 +3975,13 @@ const a = () => class { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_2481, @@ -4301,17 +3997,13 @@ class Foo { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_4473, @@ -4331,14 +4023,13 @@ function a() { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), class_properties::Config { constant_super: true, ..Default::default() @@ -4357,14 +4048,13 @@ class A extends class B {} { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), class_properties::Config { constant_super: true, ..Default::default() @@ -4384,14 +4074,13 @@ class A extends B { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), class_properties::Config { no_document_all: true, ..Default::default() @@ -4413,14 +4102,13 @@ class MyClass { test_exec!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: true, ..Default::default() @@ -4474,14 +4162,13 @@ expect(inst[9]).toBe(15); test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: true, ..Default::default() @@ -4522,14 +4209,13 @@ class MyClass { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: true, ..Default::default() @@ -4556,14 +4242,13 @@ class Foo { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: true, ..Default::default() @@ -4582,14 +4267,13 @@ class Foo { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), class_properties::Config { private_as_properties: true, ..Default::default() @@ -4628,14 +4312,13 @@ class Cl { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), class_properties::Config { private_as_properties: true, ..Default::default() @@ -4656,14 +4339,13 @@ class Cl { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), class_properties::Config { private_as_properties: true, ..Default::default() @@ -4691,14 +4373,13 @@ class Cl { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), class_properties::Config { private_as_properties: true, set_public_fields: true, @@ -4762,17 +4443,13 @@ class Cl { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, set_only_getter, @@ -4802,17 +4479,13 @@ const cl = new Cl(); test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, get_only_setter, @@ -4833,14 +4506,13 @@ class Cl { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), class_properties( - Some(t.comments.clone()), class_properties::Config { private_as_properties: true, ..Default::default() @@ -4876,17 +4548,13 @@ fn exec(input: PathBuf) { let src = read_to_string(input).unwrap(); compare_stdout( Default::default(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, &src, @@ -4897,17 +4565,13 @@ fn exec(input: PathBuf) { fn fixture(input: PathBuf) { test_fixture( Default::default(), - &|t| { + &|_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ) + class_properties(Default::default(), unresolved_mark) ) }, &input, @@ -4918,17 +4582,13 @@ fn fixture(input: PathBuf) { test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, true), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark, - ) + class_properties(Default::default(), unresolved_mark,) ) }, issue_6305, @@ -4937,17 +4597,13 @@ test!( test!( syntax(), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), optional_chaining(Default::default(), unresolved_mark) ) }, diff --git a/crates/swc_ecma_transforms_compat/tests/es2022_private_in_object.rs b/crates/swc_ecma_transforms_compat/tests/es2022_private_in_object.rs index 3d3c6ecf2eda..2d9d4b77a7a3 100644 --- a/crates/swc_ecma_transforms_compat/tests/es2022_private_in_object.rs +++ b/crates/swc_ecma_transforms_compat/tests/es2022_private_in_object.rs @@ -32,7 +32,7 @@ fn fixture(input: PathBuf) { let output = parent.join("output.js"); test_fixture( Default::default(), - &|t| { + &|_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -58,7 +58,6 @@ fn fixture(input: PathBuf) { pass = Box::new(chain!( pass, class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: loose, constant_super: loose, @@ -79,7 +78,6 @@ fn fixture(input: PathBuf) { pass = Box::new(chain!( pass, class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: loose, constant_super: loose, @@ -95,10 +93,7 @@ fn fixture(input: PathBuf) { } "transform-classes" => { - pass = Box::new(chain!( - pass, - classes(Some(t.comments.clone()), Default::default()) - )); + pass = Box::new(chain!(pass, classes(Default::default()))); } _ => { diff --git a/crates/swc_ecma_transforms_compat/tests/es2022_static_blocks.rs b/crates/swc_ecma_transforms_compat/tests/es2022_static_blocks.rs index 470db89d1fb3..e208c9e39fab 100644 --- a/crates/swc_ecma_transforms_compat/tests/es2022_static_blocks.rs +++ b/crates/swc_ecma_transforms_compat/tests/es2022_static_blocks.rs @@ -14,7 +14,7 @@ fn fixture(input: PathBuf) { let output = parent.join("output.js"); test_fixture( Syntax::Es(Default::default()), - &|t| { + &|_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -23,7 +23,7 @@ fn fixture(input: PathBuf) { Box::new(chain!( resolver(unresolved_mark, top_level_mark, false), static_blocks(config.static_blocks_mark), - class_properties(Some(t.comments.clone()), config, unresolved_mark) + class_properties(config, unresolved_mark) )) } else { Box::new(chain!( diff --git a/crates/swc_ecma_transforms_module/src/amd.rs b/crates/swc_ecma_transforms_module/src/amd.rs index fc139f75e530..bc2acb3fd54b 100644 --- a/crates/swc_ecma_transforms_module/src/amd.rs +++ b/crates/swc_ecma_transforms_module/src/amd.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; use swc_atoms::JsWord; use swc_common::{ comments::{CommentKind, Comments}, + source_map::PURE_SP, util::take::Take, FileName, Mark, Span, SyntaxContext, DUMMY_SP, }; @@ -312,7 +313,6 @@ where *n = amd_dynamic_import( *span, - self.pure_span(), args.take(), require, self.config.import_interop(), @@ -402,11 +402,11 @@ where } else { helper_expr!(interop_require_default) } - .as_call(self.pure_span(), vec![import_expr.as_arg()]), - ImportInterop::Node if link_flag.namespace() => helper_expr!( - interop_require_wildcard - ) - .as_call(self.pure_span(), vec![import_expr.as_arg(), true.as_arg()]), + .as_call(PURE_SP, vec![import_expr.as_arg()]), + ImportInterop::Node if link_flag.namespace() => { + helper_expr!(interop_require_wildcard) + .as_call(PURE_SP, vec![import_expr.as_arg(), true.as_arg()]) + } _ => import_expr, } }; @@ -455,20 +455,6 @@ where .clone() } - fn pure_span(&self) -> Span { - let mut span = DUMMY_SP; - - if self.config.import_interop().is_none() { - return span; - } - - if let Some(comments) = &self.comments { - span = Span::dummy_with_cmt(); - comments.add_pure_comment(span.lo); - } - span - } - fn get_amd_module_id_from_comments(&self, span: Span) -> Option { // https://github.com/microsoft/TypeScript/blob/1b9c8a15adc3c9a30e017a7048f98ef5acc0cada/src/compiler/parser.ts#L9648-L9658 let amd_module_re = @@ -497,7 +483,6 @@ where /// new Promise((resolve, reject) => require([arg], m => resolve(m), reject)) pub(crate) fn amd_dynamic_import( span: Span, - pure_span: Span, args: Vec, require: Ident, import_interop: ImportInterop, @@ -512,10 +497,10 @@ pub(crate) fn amd_dynamic_import( let resolved_module: Expr = match import_interop { ImportInterop::None => module.clone().into(), ImportInterop::Swc => { - helper_expr!(interop_require_wildcard).as_call(pure_span, vec![module.clone().as_arg()]) + helper_expr!(interop_require_wildcard).as_call(PURE_SP, vec![module.clone().as_arg()]) } ImportInterop::Node => helper_expr!(interop_require_wildcard) - .as_call(pure_span, vec![module.clone().as_arg(), true.as_arg()]), + .as_call(PURE_SP, vec![module.clone().as_arg(), true.as_arg()]), }; let resolve_callback = resolve diff --git a/crates/swc_ecma_transforms_module/src/common_js.rs b/crates/swc_ecma_transforms_module/src/common_js.rs index ed9289157c2f..3962c7dc3d1d 100644 --- a/crates/swc_ecma_transforms_module/src/common_js.rs +++ b/crates/swc_ecma_transforms_module/src/common_js.rs @@ -1,5 +1,5 @@ use swc_common::{ - collections::AHashSet, comments::Comments, util::take::Take, FileName, Mark, Span, + collections::AHashSet, source_map::PURE_SP, util::take::Take, FileName, Mark, Span, SyntaxContext, DUMMY_SP, }; use swc_ecma_ast::*; @@ -23,21 +23,16 @@ use crate::{ }, }; -pub fn common_js( +pub fn common_js( unresolved_mark: Mark, config: Config, available_features: FeatureFlag, - comments: Option, -) -> impl Fold + VisitMut -where - C: Comments, -{ +) -> impl Fold + VisitMut { as_folder(Cjs { config, resolver: Resolver::Default, unresolved_mark, available_features, - comments, support_arrow: caniuse!(available_features.ArrowFunctions), const_var_kind: if caniuse!(available_features.BlockScoping) { VarDeclKind::Const @@ -47,23 +42,18 @@ where }) } -pub fn common_js_with_resolver( +pub fn common_js_with_resolver( resolver: Box, base: FileName, unresolved_mark: Mark, config: Config, available_features: FeatureFlag, - comments: Option, -) -> impl Fold + VisitMut -where - C: Comments, -{ +) -> impl Fold + VisitMut { as_folder(Cjs { config, resolver: Resolver::Real { base, resolver }, unresolved_mark, available_features, - comments, support_arrow: caniuse!(available_features.ArrowFunctions), const_var_kind: if caniuse!(available_features.BlockScoping) { VarDeclKind::Const @@ -73,23 +63,16 @@ where }) } -pub struct Cjs -where - C: Comments, -{ +pub struct Cjs { config: Config, resolver: Resolver, unresolved_mark: Mark, available_features: FeatureFlag, - comments: Option, support_arrow: bool, const_var_kind: VarDeclKind, } -impl VisitMut for Cjs -where - C: Comments, -{ +impl VisitMut for Cjs { noop_visit_mut_type!(fail); fn visit_mut_module(&mut self, n: &mut Module) { @@ -231,7 +214,6 @@ where *n = cjs_dynamic_import( *span, - self.pure_span(), args.take(), quote_ident!(unresolved_ctxt, *import_span, "require"), self.config.import_interop(), @@ -260,10 +242,7 @@ where } } -impl Cjs -where - C: Comments, -{ +impl Cjs { fn handle_import_export( &mut self, import_map: &mut ImportMap, @@ -337,11 +316,11 @@ where } else { helper_expr!(interop_require_default) } - .as_call(self.pure_span(), vec![import_expr.as_arg()]), - ImportInterop::Node if link_flag.namespace() => helper_expr!( - interop_require_wildcard - ) - .as_call(self.pure_span(), vec![import_expr.as_arg(), true.as_arg()]), + .as_call(PURE_SP, vec![import_expr.as_arg()]), + ImportInterop::Node if link_flag.namespace() => { + helper_expr!(interop_require_wildcard) + .as_call(PURE_SP, vec![import_expr.as_arg(), true.as_arg()]) + } _ => import_expr, } }; @@ -558,20 +537,6 @@ where .into_stmt() }) } - - fn pure_span(&self) -> Span { - let mut span = DUMMY_SP; - - if self.config.import_interop().is_none() { - return span; - } - - if let Some(comments) = &self.comments { - span = Span::dummy_with_cmt(); - comments.add_pure_comment(span.lo); - } - span - } } /// ```javascript @@ -581,7 +546,6 @@ where /// ``` pub(crate) fn cjs_dynamic_import( span: Span, - pure_span: Span, args: Vec, require: Ident, import_interop: ImportInterop, @@ -607,10 +571,10 @@ pub(crate) fn cjs_dynamic_import( match import_interop { ImportInterop::None => require, ImportInterop::Swc => { - helper_expr!(interop_require_wildcard).as_call(pure_span, vec![require.as_arg()]) + helper_expr!(interop_require_wildcard).as_call(PURE_SP, vec![require.as_arg()]) } ImportInterop::Node => helper_expr!(interop_require_wildcard) - .as_call(pure_span, vec![require.as_arg(), true.as_arg()]), + .as_call(PURE_SP, vec![require.as_arg(), true.as_arg()]), } }; diff --git a/crates/swc_ecma_transforms_module/src/umd.rs b/crates/swc_ecma_transforms_module/src/umd.rs index d79d50a60fb8..b4bdfd40688d 100644 --- a/crates/swc_ecma_transforms_module/src/umd.rs +++ b/crates/swc_ecma_transforms_module/src/umd.rs @@ -1,7 +1,7 @@ use anyhow::Context; use swc_atoms::JsWord; use swc_common::{ - comments::Comments, sync::Lrc, util::take::Take, FileName, Mark, SourceMap, Span, + source_map::PURE_SP, sync::Lrc, util::take::Take, FileName, Mark, SourceMap, Span, SyntaxContext, DUMMY_SP, }; use swc_ecma_ast::*; @@ -27,22 +27,17 @@ use crate::{ mod config; -pub fn umd( +pub fn umd( cm: Lrc, unresolved_mark: Mark, config: Config, available_features: FeatureFlag, - comments: Option, -) -> impl Fold + VisitMut -where - C: Comments, -{ +) -> impl Fold + VisitMut { as_folder(Umd { config: config.build(cm.clone()), unresolved_mark, cm, resolver: Resolver::Default, - comments, const_var_kind: if caniuse!(available_features.BlockScoping) { VarDeclKind::Const @@ -56,24 +51,19 @@ where }) } -pub fn umd_with_resolver( +pub fn umd_with_resolver( cm: Lrc, resolver: Box, base: FileName, unresolved_mark: Mark, config: Config, available_features: FeatureFlag, - comments: Option, -) -> impl Fold + VisitMut -where - C: Comments, -{ +) -> impl Fold + VisitMut { as_folder(Umd { config: config.build(cm.clone()), unresolved_mark, cm, resolver: Resolver::Real { base, resolver }, - comments, const_var_kind: if caniuse!(available_features.BlockScoping) { VarDeclKind::Const @@ -86,15 +76,11 @@ where }) } -pub struct Umd -where - C: Comments, -{ +pub struct Umd { cm: Lrc, unresolved_mark: Mark, config: BuiltConfig, resolver: Resolver, - comments: Option, const_var_kind: VarDeclKind, @@ -103,10 +89,7 @@ where exports: Option, } -impl VisitMut for Umd -where - C: Comments, -{ +impl VisitMut for Umd { noop_visit_mut_type!(fail); fn visit_mut_module(&mut self, module: &mut Module) { @@ -207,10 +190,7 @@ where } } -impl Umd -where - C: Comments, -{ +impl Umd { fn handle_import_export( &mut self, import_map: &mut ImportMap, @@ -272,11 +252,11 @@ where } else { helper_expr!(interop_require_default) } - .as_call(self.pure_span(), vec![import_expr.as_arg()]), - ImportInterop::Node if link_flag.namespace() => helper_expr!( - interop_require_wildcard - ) - .as_call(self.pure_span(), vec![import_expr.as_arg(), true.as_arg()]), + .as_call(PURE_SP, vec![import_expr.as_arg()]), + ImportInterop::Node if link_flag.namespace() => { + helper_expr!(interop_require_wildcard) + .as_call(PURE_SP, vec![import_expr.as_arg(), true.as_arg()]) + } _ => import_expr, } }; @@ -532,18 +512,4 @@ where (adapter_fn_expr, factory_params) } - - fn pure_span(&self) -> Span { - let mut span = DUMMY_SP; - - if self.config.config.import_interop().is_none() { - return span; - } - - if let Some(comments) = &self.comments { - span = Span::dummy_with_cmt(); - comments.add_pure_comment(span.lo); - } - span - } } diff --git a/crates/swc_ecma_transforms_module/tests/common_js.rs b/crates/swc_ecma_transforms_module/tests/common_js.rs index 5b40ace2378e..2152b4fa15ed 100644 --- a/crates/swc_ecma_transforms_module/tests/common_js.rs +++ b/crates/swc_ecma_transforms_module/tests/common_js.rs @@ -1,6 +1,6 @@ -use std::{fs::File, path::PathBuf, rc::Rc}; +use std::{fs::File, path::PathBuf}; -use swc_common::{chain, comments::SingleThreadedComments, Mark}; +use swc_common::{chain, Mark}; use swc_ecma_parser::{Syntax, TsSyntax}; use swc_ecma_transforms_base::{feature::FeatureFlag, resolver}; use swc_ecma_transforms_compat::es2015::for_of; @@ -17,7 +17,7 @@ fn ts_syntax() -> Syntax { Syntax::Typescript(TsSyntax::default()) } -fn tr(config: common_js::Config, is_ts: bool, comments: Rc) -> impl Fold { +fn tr(config: common_js::Config, is_ts: bool) -> impl Fold { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -26,7 +26,7 @@ fn tr(config: common_js::Config, is_ts: bool, comments: Rc, config: Config, typescript: bool) -> impl Fold { chain!( resolver(unresolved_mark, top_level_mark, typescript), typescript::typescript(Default::default(), unresolved_mark, top_level_mark), - umd( - tester.cm.clone(), - unresolved_mark, - config, - avalible_set, - Some(tester.comments.clone()) - ), + umd(tester.cm.clone(), unresolved_mark, config, avalible_set,), ) } diff --git a/crates/swc_ecma_transforms_optimization/tests/simplify.rs b/crates/swc_ecma_transforms_optimization/tests/simplify.rs index 285c9f5d4278..fbd9ef4c7b77 100644 --- a/crates/swc_ecma_transforms_optimization/tests/simplify.rs +++ b/crates/swc_ecma_transforms_optimization/tests/simplify.rs @@ -494,7 +494,7 @@ test!( decorators: true, ..Default::default() }), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -502,7 +502,6 @@ test!( resolver(unresolved_mark, top_level_mark, false), strip(unresolved_mark, top_level_mark), class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: true, ..Default::default() @@ -554,11 +553,7 @@ test!( decorators(Default::default()), resolver(unresolved_mark, top_level_mark, false), strip(unresolved_mark, top_level_mark), - class_properties( - Some(t.comments.clone()), - Default::default(), - unresolved_mark - ), + class_properties(Default::default(), unresolved_mark), Repeat::new(chain!( expr_simplifier(unresolved_mark, Default::default()), inlining::inlining(Default::default()), @@ -566,11 +561,7 @@ test!( dce::dce(Default::default(), unresolved_mark) )), es2018(Default::default()), - es2017( - Default::default(), - Some(t.comments.clone()), - unresolved_mark - ), + es2017(Default::default(), unresolved_mark), es2016(), es2015( unresolved_mark, @@ -584,7 +575,6 @@ test!( Mark::fresh(Mark::root()), Default::default(), Default::default(), - Some(t.comments.clone()) ), ) }, diff --git a/crates/swc_ecma_transforms_optimization/tests/simplify_dce.rs b/crates/swc_ecma_transforms_optimization/tests/simplify_dce.rs index 064072a09500..9e5cce5180dd 100644 --- a/crates/swc_ecma_transforms_optimization/tests/simplify_dce.rs +++ b/crates/swc_ecma_transforms_optimization/tests/simplify_dce.rs @@ -465,7 +465,7 @@ test!( decorators: true, ..Default::default() }), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -473,7 +473,6 @@ test!( resolver(unresolved_mark, top_level_mark, false), strip(unresolved_mark, top_level_mark), class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: true, ..Default::default() @@ -505,7 +504,7 @@ test!( decorators: true, ..Default::default() }), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -513,7 +512,6 @@ test!( resolver(unresolved_mark, top_level_mark, false), strip(unresolved_mark, top_level_mark), class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: true, ..Default::default() @@ -588,7 +586,7 @@ test!( decorators: true, ..Default::default() }), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -596,7 +594,6 @@ test!( resolver(unresolved_mark, top_level_mark, false), strip(unresolved_mark, top_level_mark), class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: true, ..Default::default() diff --git a/crates/swc_ecma_transforms_optimization/tests/simplify_inlining.rs b/crates/swc_ecma_transforms_optimization/tests/simplify_inlining.rs index e98a6cc436ff..ad1f9e59ec53 100644 --- a/crates/swc_ecma_transforms_optimization/tests/simplify_inlining.rs +++ b/crates/swc_ecma_transforms_optimization/tests/simplify_inlining.rs @@ -2062,14 +2062,13 @@ test!( decorators: true, ..Default::default() }), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::fresh(Mark::root()); chain!( resolver(unresolved_mark, top_level_mark, false), simple_strip(unresolved_mark, top_level_mark), class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: true, ..Default::default() @@ -2101,14 +2100,13 @@ test!( decorators: true, ..Default::default() }), - |t| { + |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); chain!( resolver(unresolved_mark, top_level_mark, false), simple_strip(unresolved_mark, top_level_mark), class_properties( - Some(t.comments.clone()), class_properties::Config { set_public_fields: true, ..Default::default() diff --git a/crates/swc_ecma_transforms_proposal/tests/decorators.rs b/crates/swc_ecma_transforms_proposal/tests/decorators.rs index aec96d387679..fe10f8bbf0b6 100644 --- a/crates/swc_ecma_transforms_proposal/tests/decorators.rs +++ b/crates/swc_ecma_transforms_proposal/tests/decorators.rs @@ -135,7 +135,6 @@ fn create_pass(comments: Rc, input: &Path) -> Box, input: &Path) -> Box { add!(swc_ecma_transforms_compat::es2022::class_properties( - Some(comments.clone()), Default::default(), unresolved_mark )); diff --git a/crates/swc_ecma_transforms_react/src/jsx/tests.rs b/crates/swc_ecma_transforms_react/src/jsx/tests.rs index 11a26ebc5be6..c7461a3eba45 100644 --- a/crates/swc_ecma_transforms_react/src/jsx/tests.rs +++ b/crates/swc_ecma_transforms_react/src/jsx/tests.rs @@ -33,7 +33,7 @@ fn tr(t: &mut Tester, options: Options, top_level_mark: Mark) -> impl Fold { unresolved_mark ), display_name(), - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), arrow(unresolved_mark), ) } @@ -934,7 +934,7 @@ test!( let unresolved_mark = Mark::fresh(Mark::root()); chain!( - classes(Some(t.comments.clone()), Default::default()), + classes(Default::default()), jsx( t.cm.clone(), Some(t.comments.clone()), diff --git a/crates/swc_ecma_transforms_typescript/benches/compat.rs b/crates/swc_ecma_transforms_typescript/benches/compat.rs index fc043f9cd18d..b3df1af10146 100644 --- a/crates/swc_ecma_transforms_typescript/benches/compat.rs +++ b/crates/swc_ecma_transforms_typescript/benches/compat.rs @@ -137,11 +137,7 @@ fn single_tr_group(c: &mut Criterion) { fn es2020(b: &mut Bencher) { run(b, |unresolved_mark| { - swc_ecma_transforms_compat::es2022( - Some(SingleThreadedComments::default()), - Default::default(), - unresolved_mark, - ) + swc_ecma_transforms_compat::es2022(Default::default(), unresolved_mark) }); } @@ -163,11 +159,7 @@ fn es2020_optional_chaining(b: &mut Bencher) { fn es2022_class_properties(b: &mut Bencher) { run(b, |unresolved_mark| { - swc_ecma_transforms_compat::es2022::class_properties( - Some(SingleThreadedComments::default()), - Default::default(), - unresolved_mark, - ) + swc_ecma_transforms_compat::es2022::class_properties(Default::default(), unresolved_mark) }); } @@ -192,21 +184,13 @@ fn es2019_optional_catch_binding(b: &mut Bencher) { fn es2017(b: &mut Bencher) { run(b, |_| { - swc_ecma_transforms_compat::es2017( - Default::default(), - Some(SingleThreadedComments::default()), - Mark::new(), - ) + swc_ecma_transforms_compat::es2017(Default::default(), Mark::new()) }); } fn es2017_async_to_generator(b: &mut Bencher) { run(b, |_| { - swc_ecma_transforms_compat::es2017::async_to_generator( - Default::default(), - Some(SingleThreadedComments::default()), - Mark::new(), - ) + swc_ecma_transforms_compat::es2017::async_to_generator(Default::default(), Mark::new()) }); } @@ -249,10 +233,7 @@ fn es2015_block_scoping(b: &mut Bencher) { fn es2015_classes(b: &mut Bencher) { run(b, |_| { - swc_ecma_transforms_compat::es2015::classes( - Some(SingleThreadedComments::default()), - Default::default(), - ) + swc_ecma_transforms_compat::es2015::classes(Default::default()) }); } @@ -316,16 +297,11 @@ fn es3(b: &mut Bencher) { fn full_es2016(b: &mut Bencher) { run(b, |unresolved_mark| { - let cmt = SingleThreadedComments::default(); chain!( - swc_ecma_transforms_compat::es2022( - Some(cmt.clone()), - Default::default(), - unresolved_mark - ), + swc_ecma_transforms_compat::es2022(Default::default(), unresolved_mark), swc_ecma_transforms_compat::es2019(), swc_ecma_transforms_compat::es2018(Default::default()), - swc_ecma_transforms_compat::es2017(Default::default(), Some(cmt), Mark::new()), + swc_ecma_transforms_compat::es2017(Default::default(), Mark::new()), swc_ecma_transforms_compat::es2016(), ) }); @@ -333,16 +309,11 @@ fn full_es2016(b: &mut Bencher) { fn full_es2017(b: &mut Bencher) { run(b, |unresolved_mark| { - let cmt = SingleThreadedComments::default(); chain!( - swc_ecma_transforms_compat::es2022( - Some(cmt.clone()), - Default::default(), - unresolved_mark - ), + swc_ecma_transforms_compat::es2022(Default::default(), unresolved_mark), swc_ecma_transforms_compat::es2019(), swc_ecma_transforms_compat::es2018(Default::default()), - swc_ecma_transforms_compat::es2017(Default::default(), Some(cmt), Mark::new()), + swc_ecma_transforms_compat::es2017(Default::default(), Mark::new()), ) }); } @@ -350,11 +321,7 @@ fn full_es2017(b: &mut Bencher) { fn full_es2018(b: &mut Bencher) { run(b, |unresolved_mark| { chain!( - swc_ecma_transforms_compat::es2022( - Some(SingleThreadedComments::default()), - Default::default(), - unresolved_mark - ), + swc_ecma_transforms_compat::es2022(Default::default(), unresolved_mark), swc_ecma_transforms_compat::es2019(), swc_ecma_transforms_compat::es2018(Default::default()), ) diff --git a/crates/swc_ecma_transforms_typescript/tests/strip.rs b/crates/swc_ecma_transforms_typescript/tests/strip.rs index 18d1d62527fe..b0686311fbda 100644 --- a/crates/swc_ecma_transforms_typescript/tests/strip.rs +++ b/crates/swc_ecma_transforms_typescript/tests/strip.rs @@ -1,11 +1,6 @@ use std::path::PathBuf; -use swc_common::{ - chain, - comments::{NoopComments, SingleThreadedComments}, - pass::Optional, - Mark, -}; +use swc_common::{chain, comments::NoopComments, pass::Optional, Mark}; use swc_ecma_parser::{Syntax, TsSyntax}; use swc_ecma_transforms_base::resolver; use swc_ecma_transforms_compat::{ @@ -87,7 +82,7 @@ fn tsxr(t: &Tester) -> impl Fold { ) } -fn properties(t: &Tester, loose: bool) -> impl Fold { +fn properties(_: &Tester, loose: bool) -> impl Fold { let static_blocks_mark = Mark::new(); let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -96,7 +91,6 @@ fn properties(t: &Tester, loose: bool) -> impl Fold { resolver(unresolved_mark, top_level_mark, false), static_blocks(static_blocks_mark), class_properties( - Some(t.comments.clone()), class_properties::Config { static_blocks_mark, set_public_fields: loose, @@ -1868,7 +1862,7 @@ test!( Optional::new(decorators(Default::default()), false,), resolver(unresolved_mark, top_level_mark, true), typescript(config, unresolved_mark, top_level_mark), - async_to_generator::(Default::default(), None, unresolved_mark), + async_to_generator(Default::default(), unresolved_mark), ) }, issue_1235_1,