mirror of
https://github.com/swc-project/swc.git
synced 2024-10-05 04:39:06 +03:00
fix(es/codegen): Fix codegen of arrow expressions. (#1452)
swc_ecma_codegen: - Fix codegen of arrow functions. (#1451)
This commit is contained in:
parent
dcdac2db6f
commit
9445c109f9
@ -648,9 +648,19 @@ impl<'a> Emitter<'a> {
|
||||
fn emit_arrow_expr(&mut self, node: &ArrowExpr) -> Result {
|
||||
self.emit_leading_comments_of_pos(node.span().lo())?;
|
||||
|
||||
let space = !self.cfg.minify
|
||||
|| match node.params.as_slice() {
|
||||
[Pat::Ident(_)] => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
if node.is_async {
|
||||
keyword!("async");
|
||||
formatting_space!();
|
||||
if space {
|
||||
space!();
|
||||
} else {
|
||||
formatting_space!();
|
||||
}
|
||||
}
|
||||
if node.is_generator {
|
||||
punct!("*")
|
||||
|
@ -556,6 +556,11 @@ fn deno_8541_2() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_1452_1() {
|
||||
assert_min("async foo => 0", "async foo=>0");
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct Buf(Arc<RwLock<Vec<u8>>>);
|
||||
impl Write for Buf {
|
||||
|
20
ecmascript/loader/Cargo.toml
Normal file
20
ecmascript/loader/Cargo.toml
Normal file
@ -0,0 +1,20 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
||||
description = "General ecmascript loader used for transforms"
|
||||
documentation = "https://swc.rs/rustdoc/swc_ecma_loader/"
|
||||
edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_loader"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.1.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
swc_atoms = {version = "0.2.3", path = "../../atoms"}
|
||||
swc_common = {version = "0.10.10", path = "../../common"}
|
||||
swc_ecma_ast = {version = "0.40.0", path = "../ast"}
|
||||
swc_ecma_visit = {version = "0.26.0", path = "../visit"}
|
||||
|
||||
[dev-dependencies]
|
||||
testing = {version = "0.10.3", path = "../../testing"}
|
7
ecmascript/loader/src/lib.rs
Normal file
7
ecmascript/loader/src/lib.rs
Normal file
@ -0,0 +1,7 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ all-features = true
|
||||
[features]
|
||||
compat = ["swc_ecma_transforms_compat"]
|
||||
module = ["swc_ecma_transforms_module"]
|
||||
multi-module-decorator = ["swc_ecma_transforms_proposal/multi-module"]
|
||||
optimization = ["swc_ecma_transforms_optimization"]
|
||||
proposal = ["swc_ecma_transforms_proposal"]
|
||||
react = ["swc_ecma_transforms_react"]
|
||||
|
@ -10,6 +10,10 @@ version = "0.8.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[features]
|
||||
default = []
|
||||
multi-module = ["swc_ecma_loader"]
|
||||
|
||||
[dependencies]
|
||||
either = "1.6.1"
|
||||
fxhash = "0.2.1"
|
||||
@ -18,6 +22,7 @@ smallvec = "1.6.0"
|
||||
swc_atoms = {version = "0.2", path = "../../../atoms"}
|
||||
swc_common = {version = "0.10.10", path = "../../../common"}
|
||||
swc_ecma_ast = {version = "0.40.0", path = "../../ast"}
|
||||
swc_ecma_loader = {version = "0.1.0", path = "../../loader", optional = true}
|
||||
swc_ecma_parser = {version = "0.50.0", path = "../../parser"}
|
||||
swc_ecma_transforms_base = {version = "0.7.0", path = "../base"}
|
||||
swc_ecma_utils = {version = "0.30.0", path = "../../utils"}
|
||||
|
0
ecmascript/utils/src/loader.rs
Normal file
0
ecmascript/utils/src/loader.rs
Normal file
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@swc/core",
|
||||
"version": "1.2.50",
|
||||
"version": "1.2.51",
|
||||
"description": "Super-fast alternative for babel",
|
||||
"homepage": "https://swc.rs",
|
||||
"main": "./index.js",
|
||||
|
@ -5,7 +5,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "wasm"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "1.2.50"
|
||||
version = "1.2.51"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
Loading…
Reference in New Issue
Block a user