Skip to content

Commit 7e8ff1d

Browse files
authored
codegen: Fix for jsx (#1097)
1 parent 5cf1371 commit 7e8ff1d

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

ecmascript/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
license = "Apache-2.0/MIT"
77
name = "swc_ecmascript"
88
repository = "https://github.com/swc-project/swc.git"
9-
version = "0.7.10"
9+
version = "0.7.11"
1010

1111
[features]
1212
codegen = ["swc_ecma_codegen"]

ecmascript/codegen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
77
license = "Apache-2.0/MIT"
88
name = "swc_ecma_codegen"
99
repository = "https://github.com/swc-project/swc.git"
10-
version = "0.35.2"
10+
version = "0.35.3"
1111

1212
[dependencies]
1313
bitflags = "1"

ecmascript/codegen/src/jsx.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ impl<'a> Emitter<'a> {
2323
punct!("<");
2424
emit!(node.name);
2525

26+
space!();
27+
2628
self.emit_list(
2729
node.span(),
2830
Some(&node.attrs),
@@ -49,7 +51,10 @@ impl<'a> Emitter<'a> {
4951
emit!(node.name);
5052

5153
if let Some(ref value) = node.value {
52-
punct!(" ");
54+
space!();
55+
punct!("=");
56+
space!();
57+
5358
emit!(value);
5459
}
5560
}

ecmascript/codegen/src/tests.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,19 @@ fn issue_915_4() {
418418
test_identical(r#"`\\r\\n--${this.boundary}`;"#);
419419
}
420420

421+
#[test]
422+
fn jsx_1() {
423+
test_from_to_custom_config(
424+
"<Foo title=\"name\" desc=\"<empty>\" bool it>foo</Foo>;",
425+
"<Foo title = \"name\" desc = \"<empty>\" bool it>foo</Foo>;",
426+
Default::default(),
427+
Syntax::Es(EsConfig {
428+
jsx: true,
429+
..Default::default()
430+
}),
431+
);
432+
}
433+
421434
#[derive(Debug, Clone)]
422435
struct Buf(Arc<RwLock<Vec<u8>>>);
423436
impl Write for Buf {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@swc/core",
3-
"version": "1.2.31",
3+
"version": "1.2.32",
44
"description": "Super-fast alternative for babel",
55
"homepage": "https://swc.rs",
66
"main": "./index.js",

0 commit comments

Comments
 (0)