diff --git a/.cargo/config b/.cargo/config index e04d86c3700..1758b307412 100644 --- a/.cargo/config +++ b/.cargo/config @@ -2,7 +2,7 @@ [build] rustflags = [ "--cfg", "procmacro2_semver_exempt", - "-C", "target-feature=+sse2,+aes", + "-C", "target-feature=+sse2", ] rustdocflags = [ diff --git a/Cargo.toml b/Cargo.toml index 3e5304405bf..691d81863c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc" repository = "https://github.com/swc-project/swc.git" -version = "0.15.2" +version = "0.15.3" [lib] name = "swc" @@ -30,11 +30,11 @@ sourcemap = "6" swc_atoms = {version = "0.2", path = "./atoms"} swc_common = {version = "0.10.16", path = "./common", features = ["sourcemap", "concurrent"]} swc_ecma_ast = {version = "0.43.1", path = "./ecmascript/ast"} -swc_ecma_codegen = {version = "0.52.2", path = "./ecmascript/codegen"} -swc_ecma_ext_transforms = {version = "0.12.1", path = "./ecmascript/ext-transforms"} -swc_ecma_parser = {version = "0.54.2", path = "./ecmascript/parser"} -swc_ecma_preset_env = {version = "0.15.2", path = "./ecmascript/preset_env"} -swc_ecma_transforms = {version = "0.45.2", path = "./ecmascript/transforms", features = [ +swc_ecma_codegen = {version = "0.52.3", path = "./ecmascript/codegen"} +swc_ecma_ext_transforms = {version = "0.12.2", path = "./ecmascript/ext-transforms"} +swc_ecma_parser = {version = "0.54.3", path = "./ecmascript/parser"} +swc_ecma_preset_env = {version = "0.15.3", path = "./ecmascript/preset_env"} +swc_ecma_transforms = {version = "0.45.3", path = "./ecmascript/transforms", features = [ "compat", "module", "optimization", diff --git a/bundler/Cargo.toml b/bundler/Cargo.toml index 93d9b7b2bf6..267ff7eaa46 100644 --- a/bundler/Cargo.toml +++ b/bundler/Cargo.toml @@ -9,7 +9,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/**/*.js"] license = "Apache-2.0/MIT" name = "swc_bundler" repository = "https://github.com/swc-project/swc.git" -version = "0.32.3" +version = "0.32.4" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] @@ -33,9 +33,9 @@ retain_mut = "0.1.2" swc_atoms = {version = "0.2.4", path = "../atoms"} swc_common = {version = "0.10.16", path = "../common"} swc_ecma_ast = {version = "0.43.1", path = "../ecmascript/ast"} -swc_ecma_codegen = {version = "0.52.2", path = "../ecmascript/codegen"} -swc_ecma_parser = {version = "0.54.2", path = "../ecmascript/parser"} -swc_ecma_transforms = {version = "0.45.2", path = "../ecmascript/transforms", features = ["optimization"]} +swc_ecma_codegen = {version = "0.52.3", path = "../ecmascript/codegen"} +swc_ecma_parser = {version = "0.54.3", path = "../ecmascript/parser"} +swc_ecma_transforms = {version = "0.45.3", path = "../ecmascript/transforms", features = ["optimization"]} swc_ecma_utils = {version = "0.34.1", path = "../ecmascript/utils"} swc_ecma_visit = {version = "0.29.1", path = "../ecmascript/visit"} @@ -44,7 +44,7 @@ hex = "0.4" ntest = "0.7.2" reqwest = {version = "0.10.8", features = ["blocking"]} sha-1 = "0.9" -swc_ecma_transforms = {version = "0.45.2", path = "../ecmascript/transforms", features = ["react", "typescript"]} +swc_ecma_transforms = {version = "0.45.3", path = "../ecmascript/transforms", features = ["react", "typescript"]} tempfile = "3.1.0" testing = {version = "0.10.5", path = "../testing"} url = "2.1.1" diff --git a/ecmascript/Cargo.toml b/ecmascript/Cargo.toml index 97dc4a9c64e..1a0b043fe2d 100644 --- a/ecmascript/Cargo.toml +++ b/ecmascript/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecmascript" repository = "https://github.com/swc-project/swc.git" -version = "0.31.2" +version = "0.31.3" [package.metadata.docs.rs] all-features = true @@ -28,10 +28,10 @@ typescript = ["swc_ecma_transforms/typescript"] [dependencies] swc_ecma_ast = {version = "0.43.1", path = "./ast"} -swc_ecma_codegen = {version = "0.52.2", path = "./codegen", optional = true} -swc_ecma_dep_graph = {version = "0.22.1", path = "./dep-graph", optional = true} -swc_ecma_parser = {version = "0.54.2", path = "./parser", optional = true} -swc_ecma_transforms = {version = "0.45.2", path = "./transforms", optional = true} +swc_ecma_codegen = {version = "0.52.3", path = "./codegen", optional = true} +swc_ecma_dep_graph = {version = "0.22.2", path = "./dep-graph", optional = true} +swc_ecma_parser = {version = "0.54.3", path = "./parser", optional = true} +swc_ecma_transforms = {version = "0.45.3", path = "./transforms", optional = true} swc_ecma_utils = {version = "0.34.1", path = "./utils", optional = true} swc_ecma_visit = {version = "0.29.1", path = "./visit", optional = true} diff --git a/ecmascript/codegen/Cargo.toml b/ecmascript/codegen/Cargo.toml index 9f6fedbb21c..fd56dcb79ba 100644 --- a/ecmascript/codegen/Cargo.toml +++ b/ecmascript/codegen/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = "Apache-2.0/MIT" name = "swc_ecma_codegen" repository = "https://github.com/swc-project/swc.git" -version = "0.52.2" +version = "0.52.3" [dependencies] bitflags = "1" @@ -17,7 +17,7 @@ swc_atoms = {version = "0.2", path = "../../atoms"} swc_common = {version = "0.10.16", path = "../../common"} swc_ecma_ast = {version = "0.43.1", path = "../ast"} swc_ecma_codegen_macros = {version = "0.5.2", path = "./macros"} -swc_ecma_parser = {version = "0.54.2", path = "../parser"} +swc_ecma_parser = {version = "0.54.3", path = "../parser"} [dev-dependencies] swc_common = {version = "0.10.16", path = "../../common", features = ["sourcemap"]} diff --git a/ecmascript/dep-graph/Cargo.toml b/ecmascript/dep-graph/Cargo.toml index 563ad6fc168..2e2028c0887 100644 --- a/ecmascript/dep-graph/Cargo.toml +++ b/ecmascript/dep-graph/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_dep_graph" repository = "https://github.com/swc-project/swc.git" -version = "0.22.1" +version = "0.22.2" [dependencies] swc_atoms = {version = "0.2", path = "../../atoms"} @@ -15,5 +15,5 @@ swc_ecma_ast = {version = "0.43.1", path = "../ast"} swc_ecma_visit = {version = "0.29.1", path = "../visit"} [dev-dependencies] -swc_ecma_parser = {version = "0.54.2", path = "../parser"} +swc_ecma_parser = {version = "0.54.3", path = "../parser"} testing = {version = "0.10.5", path = "../../testing"} diff --git a/ecmascript/ext-transforms/Cargo.toml b/ecmascript/ext-transforms/Cargo.toml index b123c760cb7..b9b149e825b 100644 --- a/ecmascript/ext-transforms/Cargo.toml +++ b/ecmascript/ext-transforms/Cargo.toml @@ -5,7 +5,7 @@ documentation = "https://rustdoc.swc.rs/swc_ecma_ext_transforms/" edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_ext_transforms" -version = "0.12.1" +version = "0.12.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -14,6 +14,6 @@ phf = {version = "0.8.0", features = ["macros"]} swc_atoms = {version = "0.2", path = "../../atoms"} swc_common = {version = "0.10.16", path = "../../common"} swc_ecma_ast = {version = "0.43.1", path = "../ast"} -swc_ecma_parser = {version = "0.54.2", path = "../parser"} +swc_ecma_parser = {version = "0.54.3", path = "../parser"} swc_ecma_utils = {version = "0.34.1", path = "../utils"} swc_ecma_visit = {version = "0.29.1", path = "../visit"} diff --git a/ecmascript/jsdoc/Cargo.toml b/ecmascript/jsdoc/Cargo.toml index 7a83650fc9b..cc0fd4e1507 100644 --- a/ecmascript/jsdoc/Cargo.toml +++ b/ecmascript/jsdoc/Cargo.toml @@ -5,7 +5,7 @@ documentation = "https://rustdoc.swc.rs/jsdoc/" edition = "2018" license = "Apache-2.0/MIT" name = "jsdoc" -version = "0.22.1" +version = "0.22.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -19,6 +19,6 @@ swc_common = {version = "0.10.16", path = "../../common"} anyhow = "1" dashmap = "3" swc_ecma_ast = {version = "0.43.1", path = "../ast"} -swc_ecma_parser = {version = "0.54.2", path = "../parser"} +swc_ecma_parser = {version = "0.54.3", path = "../parser"} testing = {version = "0.10.5", path = "../../testing"} walkdir = "2" diff --git a/ecmascript/parser/Cargo.toml b/ecmascript/parser/Cargo.toml index 69d976fc935..9395c51ae92 100644 --- a/ecmascript/parser/Cargo.toml +++ b/ecmascript/parser/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "examples/**/*.rs"] license = "Apache-2.0/MIT" name = "swc_ecma_parser" repository = "https://github.com/swc-project/swc.git" -version = "0.54.2" +version = "0.54.3" [features] default = [] diff --git a/ecmascript/parser/src/parser/class_and_fn.rs b/ecmascript/parser/src/parser/class_and_fn.rs index 1cb27e7c526..425c7200dc6 100644 --- a/ecmascript/parser/src/parser/class_and_fn.rs +++ b/ecmascript/parser/src/parser/class_and_fn.rs @@ -706,6 +706,8 @@ impl<'a, I: Tokens> Parser { { // handle async foo(){} + let is_override = is_override || self.parse_ts_modifier(&["override"])?.is_some(); + let is_generator = eat!(self, '*'); let key = self.parse_class_prop_name()?; if is_constructor(&key) { diff --git a/ecmascript/parser/tests/typescript/issue-1558/case1/input.ts b/ecmascript/parser/tests/typescript/issue-1558/case1/input.ts new file mode 100644 index 00000000000..d949c6fa67d --- /dev/null +++ b/ecmascript/parser/tests/typescript/issue-1558/case1/input.ts @@ -0,0 +1,14 @@ +class Base { + method1() { } + method2() { } +} + +class Test extends Base { + public override async method1() { + return Promise.resolve(1); + } + + public async override method2() { + return Promise.resolve(1); + } +} \ No newline at end of file diff --git a/ecmascript/parser/tests/typescript/issue-1558/case1/input.ts.json b/ecmascript/parser/tests/typescript/issue-1558/case1/input.ts.json new file mode 100644 index 00000000000..2574551eae1 --- /dev/null +++ b/ecmascript/parser/tests/typescript/issue-1558/case1/input.ts.json @@ -0,0 +1,380 @@ +{ + "type": "Script", + "span": { + "start": 0, + "end": 238, + "ctxt": 0 + }, + "body": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 6, + "end": 10, + "ctxt": 0 + }, + "value": "Base", + "optional": false + }, + "declare": false, + "span": { + "start": 0, + "end": 50, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 17, + "end": 30, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 17, + "end": 24, + "ctxt": 0 + }, + "value": "method1", + "optional": false + }, + "function": { + "params": [], + "decorators": [], + "span": { + "start": 17, + "end": 30, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 27, + "end": 30, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + }, + { + "type": "ClassMethod", + "span": { + "start": 35, + "end": 48, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 42, + "ctxt": 0 + }, + "value": "method2", + "optional": false + }, + "function": { + "params": [], + "decorators": [], + "span": { + "start": 35, + "end": 48, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 45, + "end": 48, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + }, + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 58, + "end": 62, + "ctxt": 0 + }, + "value": "Test", + "optional": false + }, + "declare": false, + "span": { + "start": 52, + "end": 238, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 82, + "end": 156, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 104, + "end": 111, + "ctxt": 0 + }, + "value": "method1", + "optional": false + }, + "function": { + "params": [], + "decorators": [], + "span": { + "start": 82, + "end": 156, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 114, + "end": 156, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ReturnStatement", + "span": { + "start": 124, + "end": 150, + "ctxt": 0 + }, + "argument": { + "type": "CallExpression", + "span": { + "start": 131, + "end": 149, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 131, + "end": 146, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 131, + "end": 138, + "ctxt": 0 + }, + "value": "Promise", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 139, + "end": 146, + "ctxt": 0 + }, + "value": "resolve", + "optional": false + }, + "computed": false + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 147, + "end": 148, + "ctxt": 0 + }, + "value": 1.0 + } + } + ], + "typeArguments": null + } + } + ] + }, + "generator": false, + "async": true, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": "public", + "isAbstract": false, + "isOptional": false, + "isOverride": true + }, + { + "type": "ClassMethod", + "span": { + "start": 162, + "end": 236, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 184, + "end": 191, + "ctxt": 0 + }, + "value": "method2", + "optional": false + }, + "function": { + "params": [], + "decorators": [], + "span": { + "start": 162, + "end": 236, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 194, + "end": 236, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ReturnStatement", + "span": { + "start": 204, + "end": 230, + "ctxt": 0 + }, + "argument": { + "type": "CallExpression", + "span": { + "start": 211, + "end": 229, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 211, + "end": 226, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 211, + "end": 218, + "ctxt": 0 + }, + "value": "Promise", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 219, + "end": 226, + "ctxt": 0 + }, + "value": "resolve", + "optional": false + }, + "computed": false + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 227, + "end": 228, + "ctxt": 0 + }, + "value": 1.0 + } + } + ], + "typeArguments": null + } + } + ] + }, + "generator": false, + "async": true, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": "public", + "isAbstract": false, + "isOptional": false, + "isOverride": true + } + ], + "superClass": { + "type": "Identifier", + "span": { + "start": 71, + "end": 75, + "ctxt": 0 + }, + "value": "Base", + "optional": false + }, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ], + "interpreter": null +} diff --git a/ecmascript/preset_env/Cargo.toml b/ecmascript/preset_env/Cargo.toml index 57e960f9174..2abe70eca2a 100644 --- a/ecmascript/preset_env/Cargo.toml +++ b/ecmascript/preset_env/Cargo.toml @@ -5,7 +5,7 @@ documentation = "https://rustdoc.swc.rs/swc_ecma_preset_env/" edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_preset_env" -version = "0.15.2" +version = "0.15.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -21,13 +21,13 @@ string_enum = {version = "0.3.1", path = "../../macros/string_enum"} swc_atoms = {version = "0.2", path = "../../atoms"} swc_common = {version = "0.10.16", path = "../../common"} swc_ecma_ast = {version = "0.43.1", path = "../ast"} -swc_ecma_transforms = {version = "0.45.2", path = "../transforms", features = ["compat", "proposal"]} +swc_ecma_transforms = {version = "0.45.3", path = "../transforms", features = ["compat", "proposal"]} swc_ecma_utils = {version = "0.34.1", path = "../utils"} swc_ecma_visit = {version = "0.29.1", path = "../visit"} walkdir = "2" [dev-dependencies] pretty_assertions = "0.6" -swc_ecma_codegen = {version = "0.52.2", path = "../codegen"} -swc_ecma_parser = {version = "0.54.2", path = "../parser"} +swc_ecma_codegen = {version = "0.52.3", path = "../codegen"} +swc_ecma_parser = {version = "0.54.3", path = "../parser"} testing = {version = "0.10.5", path = "../../testing"} diff --git a/ecmascript/transforms/Cargo.toml b/ecmascript/transforms/Cargo.toml index 655da3f1842..c45c78c54b7 100644 --- a/ecmascript/transforms/Cargo.toml +++ b/ecmascript/transforms/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms" repository = "https://github.com/swc-project/swc.git" -version = "0.45.2" +version = "0.45.3" [package.metadata.docs.rs] all-features = true @@ -24,14 +24,14 @@ typescript = ["swc_ecma_transforms_typescript"] swc_atoms = {version = "0.2.0", path = "../../atoms"} swc_common = {version = "0.10.16", path = "../../common"} swc_ecma_ast = {version = "0.43.1", path = "../ast"} -swc_ecma_parser = {version = "0.54.2", path = "../parser"} -swc_ecma_transforms_base = {version = "0.12.4", path = "./base"} -swc_ecma_transforms_compat = {version = "0.13.2", path = "./compat", optional = true} -swc_ecma_transforms_module = {version = "0.13.2", path = "./module", optional = true} -swc_ecma_transforms_optimization = {version = "0.15.4", path = "./optimization", optional = true} -swc_ecma_transforms_proposal = {version = "0.13.2", path = "./proposal", optional = true} -swc_ecma_transforms_react = {version = "0.14.2", path = "./react", optional = true} -swc_ecma_transforms_typescript = {version = "0.14.3", path = "./typescript", optional = true} +swc_ecma_parser = {version = "0.54.3", path = "../parser"} +swc_ecma_transforms_base = {version = "0.12.6", path = "./base"} +swc_ecma_transforms_compat = {version = "0.13.3", path = "./compat", optional = true} +swc_ecma_transforms_module = {version = "0.13.3", path = "./module", optional = true} +swc_ecma_transforms_optimization = {version = "0.15.5", path = "./optimization", optional = true} +swc_ecma_transforms_proposal = {version = "0.13.3", path = "./proposal", optional = true} +swc_ecma_transforms_react = {version = "0.14.3", path = "./react", optional = true} +swc_ecma_transforms_typescript = {version = "0.14.4", path = "./typescript", optional = true} swc_ecma_utils = {version = "0.34.1", path = "../utils"} swc_ecma_visit = {version = "0.29.1", path = "../visit"} unicode-xid = "0.2" @@ -39,8 +39,8 @@ unicode-xid = "0.2" [dev-dependencies] pretty_assertions = "0.6" sourcemap = "6" -swc_ecma_codegen = {version = "0.52.2", path = "../codegen"} -swc_ecma_transforms_testing = {version = "0.12.2", path = "./testing"} +swc_ecma_codegen = {version = "0.52.3", path = "../codegen"} +swc_ecma_transforms_testing = {version = "0.12.3", path = "./testing"} tempfile = "3" testing = {version = "0.10.5", path = "../../testing"} walkdir = "2" diff --git a/ecmascript/transforms/base/Cargo.toml b/ecmascript/transforms/base/Cargo.toml index ae511df38a9..ceb646d0c15 100644 --- a/ecmascript/transforms/base/Cargo.toml +++ b/ecmascript/transforms/base/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_base" repository = "https://github.com/swc-project/swc.git" -version = "0.12.5" +version = "0.12.6" [dependencies] fxhash = "0.2.1" @@ -17,10 +17,10 @@ smallvec = "1.6.0" swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.10.16", path = "../../../common"} swc_ecma_ast = {version = "0.43.1", path = "../../ast"} -swc_ecma_parser = {version = "0.54.2", path = "../../parser"} +swc_ecma_parser = {version = "0.54.3", path = "../../parser"} swc_ecma_utils = {version = "0.34.1", path = "../../utils"} swc_ecma_visit = {version = "0.29.1", path = "../../visit"} [dev-dependencies] -swc_ecma_codegen = {version = "0.52.2", path = "../../codegen"} +swc_ecma_codegen = {version = "0.52.3", path = "../../codegen"} testing = {version = "0.10.5", path = "../../../testing"} diff --git a/ecmascript/transforms/compat/Cargo.toml b/ecmascript/transforms/compat/Cargo.toml index b9d87c4183c..ed9ccf55741 100644 --- a/ecmascript/transforms/compat/Cargo.toml +++ b/ecmascript/transforms/compat/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_compat" repository = "https://github.com/swc-project/swc.git" -version = "0.13.2" +version = "0.13.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -21,12 +21,12 @@ smallvec = "1.6.0" swc_atoms = {version = "0.2.5", path = "../../../atoms"} swc_common = {version = "0.10.16", path = "../../../common"} swc_ecma_ast = {version = "0.43.1", path = "../../ast"} -swc_ecma_transforms_base = {version = "0.12.4", path = "../base"} +swc_ecma_transforms_base = {version = "0.12.6", path = "../base"} swc_ecma_transforms_macros = {version = "0.2.1", path = "../macros"} swc_ecma_utils = {version = "0.34.1", path = "../../utils"} swc_ecma_visit = {version = "0.29.1", path = "../../visit"} [dev-dependencies] -swc_ecma_parser = {version = "0.54.2", path = "../../parser"} -swc_ecma_transforms_testing = {version = "0.12.2", path = "../testing"} +swc_ecma_parser = {version = "0.54.3", path = "../../parser"} +swc_ecma_transforms_testing = {version = "0.12.3", path = "../testing"} testing = {version = "0.10.5", path = "../../../testing"} diff --git a/ecmascript/transforms/compat/src/es2017/async_to_generator.rs b/ecmascript/transforms/compat/src/es2017/async_to_generator.rs index 0d8f4038c1e..6f1b7c70c32 100644 --- a/ecmascript/transforms/compat/src/es2017/async_to_generator.rs +++ b/ecmascript/transforms/compat/src/es2017/async_to_generator.rs @@ -349,6 +349,8 @@ impl Fold for Actual { } let params = prop.function.params; + let is_this_used = contains_this_expr(&prop.function.body); + let fn_ref = make_fn_ref( FnExpr { ident: None, @@ -359,12 +361,20 @@ impl Fold for Actual { }, true, ); - let fn_ref = Expr::Call(CallExpr { - span: DUMMY_SP, - callee: fn_ref.as_callee(), - args: vec![], - type_args: Default::default(), - }); + let fn_ref = if is_this_used { + fn_ref.apply( + DUMMY_SP, + Box::new(Expr::This(ThisExpr { span: DUMMY_SP })), + vec![], + ) + } else { + Expr::Call(CallExpr { + span: DUMMY_SP, + callee: fn_ref.as_callee(), + args: vec![], + type_args: Default::default(), + }) + }; MethodProp { function: Function { diff --git a/ecmascript/transforms/compat/src/es2020/export_namespace_from.rs b/ecmascript/transforms/compat/src/es2020/export_namespace_from.rs index 0ce2c8c067d..d05d9c57e4b 100644 --- a/ecmascript/transforms/compat/src/es2020/export_namespace_from.rs +++ b/ecmascript/transforms/compat/src/es2020/export_namespace_from.rs @@ -73,7 +73,7 @@ impl Fold for ExportNamespaceFrom { extra_stmts.push(ModuleItem::ModuleDecl(ModuleDecl::ExportNamed(export))); } } - ModuleItem::ModuleDecl(ModuleDecl::Import(..)) => stmts.push(item), + ModuleItem::ModuleDecl(ModuleDecl::Import(..)) => extra_stmts.push(item), _ => extra_stmts.push(item), } } diff --git a/ecmascript/transforms/compat/src/es2020/nullish_coalescing/mod.rs b/ecmascript/transforms/compat/src/es2020/nullish_coalescing/mod.rs index 67efb38f848..3fcfeca97a7 100644 --- a/ecmascript/transforms/compat/src/es2020/nullish_coalescing/mod.rs +++ b/ecmascript/transforms/compat/src/es2020/nullish_coalescing/mod.rs @@ -116,6 +116,18 @@ impl Fold for NullishCoalescing { }); } + // TODO: Check for computed. + let right_expr = if aliased { + Box::new(Expr::Assign(AssignExpr { + span: assign.span, + left: PatOrExpr::Expr(left.clone()), + op: op!("="), + right: assign.right.take(), + })) + } else { + assign.right.take() + }; + let var_expr = if aliased { Expr::Assign(AssignExpr { span: DUMMY_SP, @@ -131,12 +143,7 @@ impl Fold for NullishCoalescing { span: assign.span, op: op!("="), left: PatOrExpr::Pat(Box::new(Pat::Ident(alias.clone().into()))), - right: Box::new(make_cond( - assign.span, - &alias, - var_expr, - assign.right.take(), - )), + right: Box::new(make_cond(assign.span, &alias, var_expr, right_expr)), }); } PatOrExpr::Pat(left) => match &mut **left { diff --git a/ecmascript/transforms/compat/src/es2020/nullish_coalescing/tests.rs b/ecmascript/transforms/compat/src/es2020/nullish_coalescing/tests.rs index 12cfa433292..74f85c3be2a 100644 --- a/ecmascript/transforms/compat/src/es2020/nullish_coalescing/tests.rs +++ b/ecmascript/transforms/compat/src/es2020/nullish_coalescing/tests.rs @@ -120,3 +120,30 @@ test!( a = a !== null && a !== void 0 ? a : b; " ); + +test!( + Default::default(), + |_| tr(()), + issue_1570_1, + " + const a = {} + a.b ??= '1' + ", + " + const a = { + }; + var _b; + _b = (_b = a.b) !== null && _b !== void 0 ? _b : a.b = '1'; + " +); + +test_exec!( + Default::default(), + |_| tr(()), + issue_1570_2, + " + const a = {} + a.b ??= '1' + expect(a.b).toBe('1') + " +); diff --git a/ecmascript/transforms/compat/tests/es2017_async_to_generator.rs b/ecmascript/transforms/compat/tests/es2017_async_to_generator.rs index 58bbb038c21..dcb5b6ec377 100644 --- a/ecmascript/transforms/compat/tests/es2017_async_to_generator.rs +++ b/ecmascript/transforms/compat/tests/es2017_async_to_generator.rs @@ -15,6 +15,8 @@ use swc_ecma_transforms_testing::test; use swc_ecma_transforms_testing::test_exec; use swc_ecma_visit::{Fold, FoldWith}; +use crate::es2015::regenerator; + struct ParenRemover; impl Fold for ParenRemover { fn fold_expr(&mut self, expr: Expr) -> Expr { @@ -2377,3 +2379,36 @@ test!( ); " ); + +test_exec!( + Syntax::default(), + |_| async_to_generator(), + issue_1575_1, + " + const obj = { + foo: 5, + async method() { + return this.foo; + } + } + return obj.method().then((res) => expect(res).toBe(5)) +" +); + +test_exec!( + Syntax::default(), + |_| { + let mark = Mark::fresh(Mark::root()); + chain!(async_to_generator(), regenerator(mark)) + }, + issue_1575_2, + " + const obj = { + foo: 5, + async method() { + return this.foo; + } + } + return obj.method().then((res) => expect(res).toBe(5)) +" +); diff --git a/ecmascript/transforms/module/Cargo.toml b/ecmascript/transforms/module/Cargo.toml index 7d6088b4827..6de01dabd38 100644 --- a/ecmascript/transforms/module/Cargo.toml +++ b/ecmascript/transforms/module/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_module" repository = "https://github.com/swc-project/swc.git" -version = "0.13.2" +version = "0.13.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -17,12 +17,12 @@ serde = {version = "1.0.118", features = ["derive"]} swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.10.16", path = "../../../common"} swc_ecma_ast = {version = "0.43.1", path = "../../ast"} -swc_ecma_parser = {version = "0.54.2", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.12.4", path = "../base"} +swc_ecma_parser = {version = "0.54.3", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.12.6", path = "../base"} swc_ecma_utils = {version = "0.34.1", path = "../../utils"} swc_ecma_visit = {version = "0.29.1", path = "../../visit"} [dev-dependencies] -swc_ecma_transforms_compat = {version = "0.13.2", path = "../compat"} -swc_ecma_transforms_testing = {version = "0.12.2", path = "../testing/"} +swc_ecma_transforms_compat = {version = "0.13.3", path = "../compat"} +swc_ecma_transforms_testing = {version = "0.12.3", path = "../testing/"} testing = {version = "0.10.5", path = "../../../testing/"} diff --git a/ecmascript/transforms/module/tests/common_js.rs b/ecmascript/transforms/module/tests/common_js.rs index 36623a0559c..e511750c94d 100644 --- a/ecmascript/transforms/module/tests/common_js.rs +++ b/ecmascript/transforms/module/tests/common_js.rs @@ -4619,3 +4619,54 @@ test!( var ora = _interopRequireWildcard(require('ora')); " ); + +test!( + syntax(), + |_| tr(Default::default()), + issue_1568_1, + " + export default function get(key) { + console.log(key); + } + ", + " + 'use strict'; + Object.defineProperty(exports, '__esModule', { + value: true + }); + + function get(key) { + console.log(key); + } + + exports.default = get; + " +); + +test!( + syntax(), + |_| tr(Default::default()), + issue_1568_2, + " + export function get(key) { + console.log(key); + } + + export default a; + ", + " + 'use strict'; + Object.defineProperty(exports, '__esModule', { + value: true + }); + exports.get = get; + exports.default = void 0; + + function get(key) { + console.log(key); + } + + var _default = a; + exports.default = _default; + " +); diff --git a/ecmascript/transforms/optimization/Cargo.toml b/ecmascript/transforms/optimization/Cargo.toml index f4c9d107e88..c64ac104b58 100644 --- a/ecmascript/transforms/optimization/Cargo.toml +++ b/ecmascript/transforms/optimization/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_optimization" repository = "https://github.com/swc-project/swc.git" -version = "0.15.4" +version = "0.15.5" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -20,16 +20,16 @@ serde_json = "1.0.61" swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.10.16", path = "../../../common"} swc_ecma_ast = {version = "0.43.1", path = "../../ast"} -swc_ecma_parser = {version = "0.54.2", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.12.4", path = "../base"} +swc_ecma_parser = {version = "0.54.3", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.12.6", path = "../base"} swc_ecma_utils = {version = "0.34.1", path = "../../utils"} swc_ecma_visit = {version = "0.29.1", path = "../../visit"} [dev-dependencies] -swc_ecma_transforms_compat = {version = "0.13.2", path = "../compat"} -swc_ecma_transforms_module = {version = "0.13.2", path = "../module"} -swc_ecma_transforms_proposal = {version = "0.13.2", path = "../proposal"} -swc_ecma_transforms_react = {version = "0.14.2", path = "../react"} -swc_ecma_transforms_testing = {version = "0.12.2", path = "../testing"} -swc_ecma_transforms_typescript = {version = "0.14.3", path = "../typescript"} +swc_ecma_transforms_compat = {version = "0.13.3", path = "../compat"} +swc_ecma_transforms_module = {version = "0.13.3", path = "../module"} +swc_ecma_transforms_proposal = {version = "0.13.3", path = "../proposal"} +swc_ecma_transforms_react = {version = "0.14.3", path = "../react"} +swc_ecma_transforms_testing = {version = "0.12.3", path = "../testing"} +swc_ecma_transforms_typescript = {version = "0.14.4", path = "../typescript"} testing = {version = "0.10.5", path = "../../../testing"} diff --git a/ecmascript/transforms/proposal/Cargo.toml b/ecmascript/transforms/proposal/Cargo.toml index d122f0c0e82..812e449d23b 100644 --- a/ecmascript/transforms/proposal/Cargo.toml +++ b/ecmascript/transforms/proposal/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_proposal" repository = "https://github.com/swc-project/swc.git" -version = "0.13.2" +version = "0.13.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -23,12 +23,12 @@ swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.10.16", path = "../../../common"} swc_ecma_ast = {version = "0.43.1", path = "../../ast"} swc_ecma_loader = {version = "0.4.1", path = "../../loader", optional = true} -swc_ecma_parser = {version = "0.54.2", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.12.4", path = "../base"} +swc_ecma_parser = {version = "0.54.3", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.12.6", path = "../base"} swc_ecma_utils = {version = "0.34.1", path = "../../utils"} swc_ecma_visit = {version = "0.29.1", path = "../../visit"} [dev-dependencies] -swc_ecma_transforms_compat = {version = "0.13.2", path = "../compat"} -swc_ecma_transforms_module = {version = "0.13.2", path = "../module"} -swc_ecma_transforms_testing = {version = "0.12.2", path = "../testing"} +swc_ecma_transforms_compat = {version = "0.13.3", path = "../compat"} +swc_ecma_transforms_module = {version = "0.13.3", path = "../module"} +swc_ecma_transforms_testing = {version = "0.12.3", path = "../testing"} diff --git a/ecmascript/transforms/react/Cargo.toml b/ecmascript/transforms/react/Cargo.toml index eff0d4637c6..8e3fcb7031e 100644 --- a/ecmascript/transforms/react/Cargo.toml +++ b/ecmascript/transforms/react/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = "Apache-2.0/MIT" name = "swc_ecma_transforms_react" repository = "https://github.com/swc-project/swc.git" -version = "0.14.2" +version = "0.14.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -22,14 +22,14 @@ string_enum = {version = "0.3.1", path = "../../../macros/string_enum"} swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.10.16", path = "../../../common"} swc_ecma_ast = {version = "0.43.1", path = "../../ast"} -swc_ecma_parser = {version = "0.54.2", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.12.4", path = "../base"} +swc_ecma_parser = {version = "0.54.3", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.12.6", path = "../base"} swc_ecma_utils = {version = "0.34.1", path = "../../utils"} swc_ecma_visit = {version = "0.29.1", path = "../../visit"} [dev-dependencies] -swc_ecma_transforms_compat = {version = "0.13.2", path = "../compat/"} -swc_ecma_transforms_module = {version = "0.13.2", path = "../module"} -swc_ecma_transforms_testing = {version = "0.12.2", path = "../testing/"} -swc_ecma_codegen = {version = "0.52.2", path = "../../codegen/"} +swc_ecma_transforms_compat = {version = "0.13.3", path = "../compat/"} +swc_ecma_transforms_module = {version = "0.13.3", path = "../module"} +swc_ecma_transforms_testing = {version = "0.12.3", path = "../testing/"} +swc_ecma_codegen = {version = "0.52.3", path = "../../codegen/"} testing = {version = "0.10.5", path = "../../../testing"} diff --git a/ecmascript/transforms/testing/Cargo.toml b/ecmascript/transforms/testing/Cargo.toml index bae40ab5d14..ab8ab048dfa 100644 --- a/ecmascript/transforms/testing/Cargo.toml +++ b/ecmascript/transforms/testing/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_testing" repository = "https://github.com/swc-project/swc.git" -version = "0.12.2" +version = "0.12.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,9 +16,9 @@ serde = "1" serde_json = "1" swc_common = {version = "0.10.16", path = "../../../common"} swc_ecma_ast = {version = "0.43.1", path = "../../ast"} -swc_ecma_codegen = {version = "0.52.2", path = "../../codegen"} -swc_ecma_parser = {version = "0.54.2", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.12.4", path = "../base"} +swc_ecma_codegen = {version = "0.52.3", path = "../../codegen"} +swc_ecma_parser = {version = "0.54.3", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.12.6", path = "../base"} swc_ecma_utils = {version = "0.34.1", path = "../../utils"} swc_ecma_visit = {version = "0.29.1", path = "../../visit"} tempfile = "3.1.0" diff --git a/ecmascript/transforms/typescript/Cargo.toml b/ecmascript/transforms/typescript/Cargo.toml index c8bbda5f778..59c3e9dee82 100644 --- a/ecmascript/transforms/typescript/Cargo.toml +++ b/ecmascript/transforms/typescript/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_typescript" repository = "https://github.com/swc-project/swc.git" -version = "0.14.3" +version = "0.14.4" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -15,16 +15,16 @@ serde = {version = "1.0.118", features = ["derive"]} swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.10.16", path = "../../../common"} swc_ecma_ast = {version = "0.43.1", path = "../../ast"} -swc_ecma_parser = {version = "0.54.2", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.12.4", path = "../base"} +swc_ecma_parser = {version = "0.54.3", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.12.6", path = "../base"} swc_ecma_utils = {version = "0.34.1", path = "../../utils"} swc_ecma_visit = {version = "0.29.1", path = "../../visit"} [dev-dependencies] -swc_ecma_codegen = {version = "0.52.2", path = "../../codegen"} -swc_ecma_transforms_compat = {version = "0.13.2", path = "../compat"} -swc_ecma_transforms_module = {version = "0.13.2", path = "../module"} -swc_ecma_transforms_proposal = {version = "0.13.2", path = "../proposal/"} -swc_ecma_transforms_testing = {version = "0.12.2", path = "../testing"} +swc_ecma_codegen = {version = "0.52.3", path = "../../codegen"} +swc_ecma_transforms_compat = {version = "0.13.3", path = "../compat"} +swc_ecma_transforms_module = {version = "0.13.3", path = "../module"} +swc_ecma_transforms_proposal = {version = "0.13.3", path = "../proposal/"} +swc_ecma_transforms_testing = {version = "0.12.3", path = "../testing"} testing = {version = "0.10.5", path = "../../../testing"} walkdir = "2.3.1" diff --git a/package.json b/package.json index 8156fda3d7b..b3e2d165f1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@swc/core", - "version": "1.2.52", + "version": "1.2.54", "description": "Super-fast alternative for babel", "homepage": "https://swc.rs", "main": "./index.js", diff --git a/spack/tests/pass/issue-1533/case1/input/entry.js b/spack/tests/pass/issue-1533/case1/input/entry.js new file mode 100644 index 00000000000..9cc4dc6d87f --- /dev/null +++ b/spack/tests/pass/issue-1533/case1/input/entry.js @@ -0,0 +1,9 @@ +var this_will_disappear; // <-- this variable declaration disappears +function a(x) { + switch (this_will_disappear) { + case x: return; + } +} +function b() { c(); } +function c() { b(); d(); } +function d() { a(); } \ No newline at end of file diff --git a/spack/tests/pass/issue-1533/case1/output/entry.js b/spack/tests/pass/issue-1533/case1/output/entry.js new file mode 100644 index 00000000000..c00ad3c0ec2 --- /dev/null +++ b/spack/tests/pass/issue-1533/case1/output/entry.js @@ -0,0 +1,17 @@ +var this_will_disappear; // <-- this variable declaration disappears +function a(x) { + switch(this_will_disappear){ + case x: + return; + } +} +function b() { + c(); +} +function c() { + b(); + d(); +} +function d() { + a(); +} diff --git a/tests/fixture/issue-1457/case1/input/index.ts b/tests/fixture/issue-1457/case1/input/index.ts new file mode 100644 index 00000000000..9003f8ef8d2 --- /dev/null +++ b/tests/fixture/issue-1457/case1/input/index.ts @@ -0,0 +1,23 @@ +import { + setGlobalOptions, + plugin, + buildSchema, + addModelToTypegoose, + deleteModel, +} from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW, + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at', + }, + }, +}); +import { schemas } from './schemas'; + +console.log(schemas) \ No newline at end of file diff --git a/tests/fixture/issue-1457/case1/output/index.ts b/tests/fixture/issue-1457/case1/output/index.ts new file mode 100644 index 00000000000..360d94087cd --- /dev/null +++ b/tests/fixture/issue-1457/case1/output/index.ts @@ -0,0 +1,16 @@ +import { setGlobalOptions } from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at' + } + } +}); +import { schemas } from './schemas'; +console.log(schemas); diff --git a/tests/fixture/issue-1457/case2-es2020/input/.swcrc b/tests/fixture/issue-1457/case2-es2020/input/.swcrc new file mode 100644 index 00000000000..cbb2cffff9a --- /dev/null +++ b/tests/fixture/issue-1457/case2-es2020/input/.swcrc @@ -0,0 +1,8 @@ +{ + "jsc": { + "target": "es2020", + "parser": { + "syntax": "typescript" + } + } +} diff --git a/tests/fixture/issue-1457/case2-es2020/input/index.ts b/tests/fixture/issue-1457/case2-es2020/input/index.ts new file mode 100644 index 00000000000..9003f8ef8d2 --- /dev/null +++ b/tests/fixture/issue-1457/case2-es2020/input/index.ts @@ -0,0 +1,23 @@ +import { + setGlobalOptions, + plugin, + buildSchema, + addModelToTypegoose, + deleteModel, +} from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW, + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at', + }, + }, +}); +import { schemas } from './schemas'; + +console.log(schemas) \ No newline at end of file diff --git a/tests/fixture/issue-1457/case2-es2020/output/index.ts b/tests/fixture/issue-1457/case2-es2020/output/index.ts new file mode 100644 index 00000000000..360d94087cd --- /dev/null +++ b/tests/fixture/issue-1457/case2-es2020/output/index.ts @@ -0,0 +1,16 @@ +import { setGlobalOptions } from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at' + } + } +}); +import { schemas } from './schemas'; +console.log(schemas); diff --git a/tests/fixture/issue-1457/case3-es2019/input/.swcrc b/tests/fixture/issue-1457/case3-es2019/input/.swcrc new file mode 100644 index 00000000000..d14f1259e0e --- /dev/null +++ b/tests/fixture/issue-1457/case3-es2019/input/.swcrc @@ -0,0 +1,8 @@ +{ + "jsc": { + "target": "es2019", + "parser": { + "syntax": "typescript" + } + } +} diff --git a/tests/fixture/issue-1457/case3-es2019/input/index.ts b/tests/fixture/issue-1457/case3-es2019/input/index.ts new file mode 100644 index 00000000000..9003f8ef8d2 --- /dev/null +++ b/tests/fixture/issue-1457/case3-es2019/input/index.ts @@ -0,0 +1,23 @@ +import { + setGlobalOptions, + plugin, + buildSchema, + addModelToTypegoose, + deleteModel, +} from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW, + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at', + }, + }, +}); +import { schemas } from './schemas'; + +console.log(schemas) \ No newline at end of file diff --git a/tests/fixture/issue-1457/case3-es2019/output/index.ts b/tests/fixture/issue-1457/case3-es2019/output/index.ts new file mode 100644 index 00000000000..360d94087cd --- /dev/null +++ b/tests/fixture/issue-1457/case3-es2019/output/index.ts @@ -0,0 +1,16 @@ +import { setGlobalOptions } from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at' + } + } +}); +import { schemas } from './schemas'; +console.log(schemas); diff --git a/tests/fixture/issue-1457/case4-es2018/input/.swcrc b/tests/fixture/issue-1457/case4-es2018/input/.swcrc new file mode 100644 index 00000000000..b43c5d7c3fb --- /dev/null +++ b/tests/fixture/issue-1457/case4-es2018/input/.swcrc @@ -0,0 +1,8 @@ +{ + "jsc": { + "target": "es2018", + "parser": { + "syntax": "typescript" + } + } +} diff --git a/tests/fixture/issue-1457/case4-es2018/input/index.ts b/tests/fixture/issue-1457/case4-es2018/input/index.ts new file mode 100644 index 00000000000..9003f8ef8d2 --- /dev/null +++ b/tests/fixture/issue-1457/case4-es2018/input/index.ts @@ -0,0 +1,23 @@ +import { + setGlobalOptions, + plugin, + buildSchema, + addModelToTypegoose, + deleteModel, +} from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW, + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at', + }, + }, +}); +import { schemas } from './schemas'; + +console.log(schemas) \ No newline at end of file diff --git a/tests/fixture/issue-1457/case4-es2018/output/index.ts b/tests/fixture/issue-1457/case4-es2018/output/index.ts new file mode 100644 index 00000000000..360d94087cd --- /dev/null +++ b/tests/fixture/issue-1457/case4-es2018/output/index.ts @@ -0,0 +1,16 @@ +import { setGlobalOptions } from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at' + } + } +}); +import { schemas } from './schemas'; +console.log(schemas); diff --git a/tests/fixture/issue-1457/case5-es2017/input/.swcrc b/tests/fixture/issue-1457/case5-es2017/input/.swcrc new file mode 100644 index 00000000000..4bf7d8d805c --- /dev/null +++ b/tests/fixture/issue-1457/case5-es2017/input/.swcrc @@ -0,0 +1,8 @@ +{ + "jsc": { + "target": "es2017", + "parser": { + "syntax": "typescript" + } + } +} diff --git a/tests/fixture/issue-1457/case5-es2017/input/index.ts b/tests/fixture/issue-1457/case5-es2017/input/index.ts new file mode 100644 index 00000000000..9003f8ef8d2 --- /dev/null +++ b/tests/fixture/issue-1457/case5-es2017/input/index.ts @@ -0,0 +1,23 @@ +import { + setGlobalOptions, + plugin, + buildSchema, + addModelToTypegoose, + deleteModel, +} from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW, + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at', + }, + }, +}); +import { schemas } from './schemas'; + +console.log(schemas) \ No newline at end of file diff --git a/tests/fixture/issue-1457/case5-es2017/output/index.ts b/tests/fixture/issue-1457/case5-es2017/output/index.ts new file mode 100644 index 00000000000..360d94087cd --- /dev/null +++ b/tests/fixture/issue-1457/case5-es2017/output/index.ts @@ -0,0 +1,16 @@ +import { setGlobalOptions } from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at' + } + } +}); +import { schemas } from './schemas'; +console.log(schemas); diff --git a/tests/fixture/issue-1457/case6-es2016/input/.swcrc b/tests/fixture/issue-1457/case6-es2016/input/.swcrc new file mode 100644 index 00000000000..5773ccbe28b --- /dev/null +++ b/tests/fixture/issue-1457/case6-es2016/input/.swcrc @@ -0,0 +1,8 @@ +{ + "jsc": { + "target": "es2016", + "parser": { + "syntax": "typescript" + } + } +} diff --git a/tests/fixture/issue-1457/case6-es2016/input/index.ts b/tests/fixture/issue-1457/case6-es2016/input/index.ts new file mode 100644 index 00000000000..9003f8ef8d2 --- /dev/null +++ b/tests/fixture/issue-1457/case6-es2016/input/index.ts @@ -0,0 +1,23 @@ +import { + setGlobalOptions, + plugin, + buildSchema, + addModelToTypegoose, + deleteModel, +} from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW, + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at', + }, + }, +}); +import { schemas } from './schemas'; + +console.log(schemas) \ No newline at end of file diff --git a/tests/fixture/issue-1457/case6-es2016/output/index.ts b/tests/fixture/issue-1457/case6-es2016/output/index.ts new file mode 100644 index 00000000000..360d94087cd --- /dev/null +++ b/tests/fixture/issue-1457/case6-es2016/output/index.ts @@ -0,0 +1,16 @@ +import { setGlobalOptions } from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at' + } + } +}); +import { schemas } from './schemas'; +console.log(schemas); diff --git a/tests/fixture/issue-1457/case7-es2015/input/.swcrc b/tests/fixture/issue-1457/case7-es2015/input/.swcrc new file mode 100644 index 00000000000..477983ec3a2 --- /dev/null +++ b/tests/fixture/issue-1457/case7-es2015/input/.swcrc @@ -0,0 +1,8 @@ +{ + "jsc": { + "target": "es2015", + "parser": { + "syntax": "typescript" + } + } +} diff --git a/tests/fixture/issue-1457/case7-es2015/input/index.ts b/tests/fixture/issue-1457/case7-es2015/input/index.ts new file mode 100644 index 00000000000..9003f8ef8d2 --- /dev/null +++ b/tests/fixture/issue-1457/case7-es2015/input/index.ts @@ -0,0 +1,23 @@ +import { + setGlobalOptions, + plugin, + buildSchema, + addModelToTypegoose, + deleteModel, +} from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW, + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at', + }, + }, +}); +import { schemas } from './schemas'; + +console.log(schemas) \ No newline at end of file diff --git a/tests/fixture/issue-1457/case7-es2015/output/index.ts b/tests/fixture/issue-1457/case7-es2015/output/index.ts new file mode 100644 index 00000000000..360d94087cd --- /dev/null +++ b/tests/fixture/issue-1457/case7-es2015/output/index.ts @@ -0,0 +1,16 @@ +import { setGlobalOptions } from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at' + } + } +}); +import { schemas } from './schemas'; +console.log(schemas); diff --git a/tests/fixture/issue-1457/case8-es5/input/.swcrc b/tests/fixture/issue-1457/case8-es5/input/.swcrc new file mode 100644 index 00000000000..9d103d8e7eb --- /dev/null +++ b/tests/fixture/issue-1457/case8-es5/input/.swcrc @@ -0,0 +1,8 @@ +{ + "jsc": { + "target": "es5", + "parser": { + "syntax": "typescript" + } + } +} diff --git a/tests/fixture/issue-1457/case8-es5/input/index.ts b/tests/fixture/issue-1457/case8-es5/input/index.ts new file mode 100644 index 00000000000..9003f8ef8d2 --- /dev/null +++ b/tests/fixture/issue-1457/case8-es5/input/index.ts @@ -0,0 +1,23 @@ +import { + setGlobalOptions, + plugin, + buildSchema, + addModelToTypegoose, + deleteModel, +} from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW, + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at', + }, + }, +}); +import { schemas } from './schemas'; + +console.log(schemas) \ No newline at end of file diff --git a/tests/fixture/issue-1457/case8-es5/output/index.ts b/tests/fixture/issue-1457/case8-es5/output/index.ts new file mode 100644 index 00000000000..360d94087cd --- /dev/null +++ b/tests/fixture/issue-1457/case8-es5/output/index.ts @@ -0,0 +1,16 @@ +import { setGlobalOptions } from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at' + } + } +}); +import { schemas } from './schemas'; +console.log(schemas); diff --git a/tests/fixture/issue-1457/case9-es3/input/.swcrc b/tests/fixture/issue-1457/case9-es3/input/.swcrc new file mode 100644 index 00000000000..b2ad7c147cd --- /dev/null +++ b/tests/fixture/issue-1457/case9-es3/input/.swcrc @@ -0,0 +1,8 @@ +{ + "jsc": { + "target": "es3", + "parser": { + "syntax": "typescript" + } + } +} diff --git a/tests/fixture/issue-1457/case9-es3/input/index.ts b/tests/fixture/issue-1457/case9-es3/input/index.ts new file mode 100644 index 00000000000..9003f8ef8d2 --- /dev/null +++ b/tests/fixture/issue-1457/case9-es3/input/index.ts @@ -0,0 +1,23 @@ +import { + setGlobalOptions, + plugin, + buildSchema, + addModelToTypegoose, + deleteModel, +} from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW, + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at', + }, + }, +}); +import { schemas } from './schemas'; + +console.log(schemas) \ No newline at end of file diff --git a/tests/fixture/issue-1457/case9-es3/output/index.ts b/tests/fixture/issue-1457/case9-es3/output/index.ts new file mode 100644 index 00000000000..360d94087cd --- /dev/null +++ b/tests/fixture/issue-1457/case9-es3/output/index.ts @@ -0,0 +1,16 @@ +import { setGlobalOptions } from '@typegoose/typegoose'; +import * as typegoose from '@typegoose/typegoose'; +// typegoose.mongoose.set('debug', true); +setGlobalOptions({ + options: { + allowMixed: typegoose.Severity.ALLOW + }, + schemaOptions: { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at' + } + } +}); +import { schemas } from './schemas'; +console.log(schemas); diff --git a/tests/fixture/issue-1545/case1/input/.swcrc b/tests/fixture/issue-1545/case1/input/.swcrc new file mode 100644 index 00000000000..66e2a7dca33 --- /dev/null +++ b/tests/fixture/issue-1545/case1/input/.swcrc @@ -0,0 +1,9 @@ +{ + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": true, + "decorators": true + } + } +} diff --git a/tests/fixture/issue-1545/case1/input/index.js b/tests/fixture/issue-1545/case1/input/index.js new file mode 100644 index 00000000000..8d00abe4e22 --- /dev/null +++ b/tests/fixture/issue-1545/case1/input/index.js @@ -0,0 +1,4 @@ +import { createHash, createHmac } from 'crypto-browserify'; + +let hash = createHash(algorithm); +let hmac = createHmac(fn, key); \ No newline at end of file diff --git a/tests/fixture/issue-1545/case1/output/index.js b/tests/fixture/issue-1545/case1/output/index.js new file mode 100644 index 00000000000..402b9cd5143 --- /dev/null +++ b/tests/fixture/issue-1545/case1/output/index.js @@ -0,0 +1,3 @@ +import { createHash, createHmac } from 'crypto-browserify'; +var hash = createHash(algorithm); +var hmac = createHmac(fn, key); diff --git a/tests/fixture/issue-1575/case1/input/index.js b/tests/fixture/issue-1575/case1/input/index.js new file mode 100644 index 00000000000..648c7995abb --- /dev/null +++ b/tests/fixture/issue-1575/case1/input/index.js @@ -0,0 +1,8 @@ +Vue.component('test', { + methods: { + async onSend() { + if (this.msg === '') { + } + }, + }, +}); \ No newline at end of file diff --git a/tests/fixture/issue-1575/case1/output/index.js b/tests/fixture/issue-1575/case1/output/index.js new file mode 100644 index 00000000000..c3d6f2bdd9d --- /dev/null +++ b/tests/fixture/issue-1575/case1/output/index.js @@ -0,0 +1,48 @@ +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} +function _asyncToGenerator(fn) { + return function() { + var self = this, args = arguments; + return new Promise(function(resolve, reject) { + var gen = fn.apply(self, args); + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + _next(undefined); + }); + }; +} +var regeneratorRuntime = require("regenerator-runtime"); +Vue.component('test', { + methods: { + onSend: function() { + return _asyncToGenerator(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + if (this.msg === '') { + } + case 1: + case "end": + return _ctx.stop(); + } + }, _callee, this); + })).apply(this); + } + } +}); diff --git a/tests/fixture/issue-1575/case2/input/index.js b/tests/fixture/issue-1575/case2/input/index.js new file mode 100644 index 00000000000..7c97dcc4f07 --- /dev/null +++ b/tests/fixture/issue-1575/case2/input/index.js @@ -0,0 +1,8 @@ +const obj = { + foo: 5, + async method() { + return this.foo; + } +} + +obj.method().then((v) => console.log(v)) \ No newline at end of file diff --git a/tests/fixture/issue-1575/case2/output/index.js b/tests/fixture/issue-1575/case2/output/index.js new file mode 100644 index 00000000000..536cb6655da --- /dev/null +++ b/tests/fixture/issue-1575/case2/output/index.js @@ -0,0 +1,49 @@ +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} +function _asyncToGenerator(fn) { + return function() { + var self = this, args = arguments; + return new Promise(function(resolve, reject) { + var gen = fn.apply(self, args); + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + _next(undefined); + }); + }; +} +var regeneratorRuntime = require("regenerator-runtime"); +var obj = { + foo: 5, + method: function() { + return _asyncToGenerator(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", this.foo); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee, this); + })).apply(this); + } +}; +obj.method().then(function(v) { + return console.log(v); +}); diff --git a/tests/fixture/issue-1581/.case1/input/.swcrc b/tests/fixture/issue-1581/.case1/input/.swcrc new file mode 100644 index 00000000000..1ec209a8e37 --- /dev/null +++ b/tests/fixture/issue-1581/.case1/input/.swcrc @@ -0,0 +1,3 @@ +{ + "sourceMaps": "inline" +} diff --git a/tests/fixture/issue-1581/.case1/input/index.js b/tests/fixture/issue-1581/.case1/input/index.js new file mode 100644 index 00000000000..af35a914cb2 --- /dev/null +++ b/tests/fixture/issue-1581/.case1/input/index.js @@ -0,0 +1,3 @@ +export const foo = () => { + return 2; +}; \ No newline at end of file diff --git a/tests/fixture/issue-1581/.case1/output/index.js b/tests/fixture/issue-1581/.case1/output/index.js new file mode 100644 index 00000000000..01078497754 --- /dev/null +++ b/tests/fixture/issue-1581/.case1/output/index.js @@ -0,0 +1,5 @@ +export var foo = function() { + return 2; +}; + +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9rZHkxL3Byb2plY3RzL3N3Yy1idWdzL3Rlc3RzL2ZpeHR1cmUvaXNzdWUtMTU4MS9jYXNlMS9pbnB1dC9pbmRleC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY29uc3QgZm9vID0gKCkgPT4ge1xuICAgIHJldHVybiAyO1xufTsiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IldBQWEsR0FBRztXQUNMLENBQUMifQ== diff --git a/tests/fixture/issue-1581/case2/input/.swcrc b/tests/fixture/issue-1581/case2/input/.swcrc new file mode 100644 index 00000000000..219de99ead2 --- /dev/null +++ b/tests/fixture/issue-1581/case2/input/.swcrc @@ -0,0 +1,3 @@ +{ + "sourceMaps": true +} diff --git a/tests/fixture/issue-1581/case2/input/index.js b/tests/fixture/issue-1581/case2/input/index.js new file mode 100644 index 00000000000..af35a914cb2 --- /dev/null +++ b/tests/fixture/issue-1581/case2/input/index.js @@ -0,0 +1,3 @@ +export const foo = () => { + return 2; +}; \ No newline at end of file diff --git a/tests/fixture/issue-1581/case2/output/index.js b/tests/fixture/issue-1581/case2/output/index.js new file mode 100644 index 00000000000..1007ec597b6 --- /dev/null +++ b/tests/fixture/issue-1581/case2/output/index.js @@ -0,0 +1,3 @@ +export var foo = function() { + return 2; +}; diff --git a/tests/fixture/issue-1581/case2/output/index.map b/tests/fixture/issue-1581/case2/output/index.map new file mode 100644 index 00000000000..9c4fc7f4378 --- /dev/null +++ b/tests/fixture/issue-1581/case2/output/index.map @@ -0,0 +1,11 @@ +{ + "mappings": "WAAa,GAAG;WACL,CAAC", + "names": [], + "sources": [ + "$DIR/tests/fixture/issue-1581/case2/input/index.js" + ], + "sourcesContent": [ + "export const foo = () => {\n return 2;\n};" + ], + "version": 3 +} diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index 952cc47322b..e298f3dab20 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -5,7 +5,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "wasm" repository = "https://github.com/swc-project/swc.git" -version = "1.2.52" +version = "1.2.54" [lib] crate-type = ["cdylib"]