fix(swc): Fix bugs (#1560)

spack:
 - Ensure that #1533 is fixed. (#1533) 

swc_ecma_parser:
 - Support `async override` in classes. (#1558)

swc_ecma_transforms_compat:
 - `async_to_generator`: Preserve this in async object methods. (#1575)
 - `nullish_coaelscing`: Fix assignments. (#1570)
 - `export_namespace_from`: Preserve order of statements. (#1457)

swc:
 - Disable aes. (#1583)
This commit is contained in:
강동윤 2021-04-17 15:00:14 +09:00 committed by GitHub
parent 1178686a4c
commit 46c3d62ebd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 1229 additions and 102 deletions

View File

@ -2,7 +2,7 @@
[build]
rustflags = [
"--cfg", "procmacro2_semver_exempt",
"-C", "target-feature=+sse2,+aes",
"-C", "target-feature=+sse2",
]
rustdocflags = [

View File

@ -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",

View File

@ -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"

View File

@ -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}

View File

@ -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"]}

View File

@ -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"}

View File

@ -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"}

View File

@ -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"

View File

@ -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 = []

View File

@ -706,6 +706,8 @@ impl<'a, I: Tokens> Parser<I> {
{
// 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) {

View File

@ -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);
}
}

View File

@ -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
}

View File

@ -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"}

View File

@ -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"

View File

@ -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"}

View File

@ -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"}

View File

@ -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 {

View File

@ -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),
}
}

View File

@ -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 {

View File

@ -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')
"
);

View File

@ -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))
"
);

View File

@ -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/"}

View File

@ -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;
"
);

View File

@ -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"}

View File

@ -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"}

View File

@ -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"}

View File

@ -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"

View File

@ -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"

View File

@ -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",

View File

@ -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(); }

View File

@ -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();
}

View File

@ -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)

View File

@ -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);

View File

@ -0,0 +1,8 @@
{
"jsc": {
"target": "es2020",
"parser": {
"syntax": "typescript"
}
}
}

View File

@ -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)

View File

@ -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);

View File

@ -0,0 +1,8 @@
{
"jsc": {
"target": "es2019",
"parser": {
"syntax": "typescript"
}
}
}

View File

@ -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)

View File

@ -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);

View File

@ -0,0 +1,8 @@
{
"jsc": {
"target": "es2018",
"parser": {
"syntax": "typescript"
}
}
}

View File

@ -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)

View File

@ -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);

View File

@ -0,0 +1,8 @@
{
"jsc": {
"target": "es2017",
"parser": {
"syntax": "typescript"
}
}
}

View File

@ -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)

View File

@ -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);

View File

@ -0,0 +1,8 @@
{
"jsc": {
"target": "es2016",
"parser": {
"syntax": "typescript"
}
}
}

View File

@ -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)

View File

@ -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);

View File

@ -0,0 +1,8 @@
{
"jsc": {
"target": "es2015",
"parser": {
"syntax": "typescript"
}
}
}

View File

@ -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)

View File

@ -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);

View File

@ -0,0 +1,8 @@
{
"jsc": {
"target": "es5",
"parser": {
"syntax": "typescript"
}
}
}

View File

@ -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)

View File

@ -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);

View File

@ -0,0 +1,8 @@
{
"jsc": {
"target": "es3",
"parser": {
"syntax": "typescript"
}
}
}

View File

@ -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)

View File

@ -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);

View File

@ -0,0 +1,9 @@
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": true
}
}
}

View File

@ -0,0 +1,4 @@
import { createHash, createHmac } from 'crypto-browserify';
let hash = createHash(algorithm);
let hmac = createHmac(fn, key);

View File

@ -0,0 +1,3 @@
import { createHash, createHmac } from 'crypto-browserify';
var hash = createHash(algorithm);
var hmac = createHmac(fn, key);

View File

@ -0,0 +1,8 @@
Vue.component('test', {
methods: {
async onSend() {
if (this.msg === '') {
}
},
},
});

View File

@ -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);
}
}
});

View File

@ -0,0 +1,8 @@
const obj = {
foo: 5,
async method() {
return this.foo;
}
}
obj.method().then((v) => console.log(v))

View File

@ -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);
});

View File

@ -0,0 +1,3 @@
{
"sourceMaps": "inline"
}

View File

@ -0,0 +1,3 @@
export const foo = () => {
return 2;
};

View File

@ -0,0 +1,5 @@
export var foo = function() {
return 2;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9rZHkxL3Byb2plY3RzL3N3Yy1idWdzL3Rlc3RzL2ZpeHR1cmUvaXNzdWUtMTU4MS9jYXNlMS9pbnB1dC9pbmRleC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY29uc3QgZm9vID0gKCkgPT4ge1xuICAgIHJldHVybiAyO1xufTsiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IldBQWEsR0FBRztXQUNMLENBQUMifQ==

View File

@ -0,0 +1,3 @@
{
"sourceMaps": true
}

View File

@ -0,0 +1,3 @@
export const foo = () => {
return 2;
};

View File

@ -0,0 +1,3 @@
export var foo = function() {
return 2;
};

View File

@ -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
}

View File

@ -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"]