Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(swc): Fix bugs #1529

Merged
merged 56 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
d5f68a8
Add a test for #1477
kdy1 Apr 1, 2021
69c7606
Bump version (related to other prs)
kdy1 Apr 1, 2021
e6210f0
Fix lints
kdy1 Apr 1, 2021
975c3e3
Move the test for #1477
kdy1 Apr 1, 2021
3a33b18
Add a test for #1477
kdy1 Apr 1, 2021
af847a7
One more
kdy1 Apr 1, 2021
20df84e
Add a test for #1477
kdy1 Apr 1, 2021
9d2312d
Update test refs for #1477
kdy1 Apr 1, 2021
eff5f5b
Add a test for #1477
kdy1 Apr 1, 2021
c8d0c48
Fix #1477
kdy1 Apr 1, 2021
b372b38
Update test refs for #1477
kdy1 Apr 1, 2021
e468546
Update test refs
kdy1 Apr 1, 2021
4a2643e
Add a test for #1449
kdy1 Apr 1, 2021
5c7dfba
Move
kdy1 Apr 1, 2021
e7ab44e
Update test refs
kdy1 Apr 1, 2021
e5082dc
Add a test for #1448
kdy1 Apr 1, 2021
a79ed66
Add a test for #1448
kdy1 Apr 1, 2021
19e018f
Fix #1448
kdy1 Apr 1, 2021
9061a32
Update test refsx
kdy1 Apr 1, 2021
e77debd
Add a test for #1455
kdy1 Apr 1, 2021
ab8073d
Add a test for #1455
kdy1 Apr 1, 2021
e56c0bb
One more
kdy1 Apr 1, 2021
66a13a2
Update test refs
kdy1 Apr 1, 2021
1600308
Update a test for #1455
kdy1 Apr 1, 2021
8ad8350
Update test refs
kdy1 Apr 1, 2021
f995bda
Fix #1455?
kdy1 Apr 1, 2021
f4463ab
Update test refs
kdy1 Apr 1, 2021
33f2d01
Remove wrong test for #1455
kdy1 Apr 1, 2021
5ba0b04
Update test refs
kdy1 Apr 1, 2021
f72220e
Add a test for #1455
kdy1 Apr 1, 2021
1394c6f
WIP
kdy1 Apr 2, 2021
9e1d9ea
Implement comment test suitre
kdy1 Apr 2, 2021
b080917
fixup
kdy1 Apr 2, 2021
e6defd5
Add a test
kdy1 Apr 2, 2021
2a390b5
Add a test
kdy1 Apr 2, 2021
a477521
Improve tester
kdy1 Apr 2, 2021
2b3babd
Add a test for span
kdy1 Apr 2, 2021
05d338f
Update test refs
kdy1 Apr 2, 2021
9ecf985
Fix #1530
kdy1 Apr 2, 2021
9df37b5
Update test refs
kdy1 Apr 2, 2021
2a11d1d
Bump version
kdy1 Apr 2, 2021
3adc413
fixup
kdy1 Apr 2, 2021
884ef15
WIP: Fix codegen
kdy1 Apr 2, 2021
4b99645
fixup
kdy1 Apr 2, 2021
1bf4725
Fix codegen
kdy1 Apr 2, 2021
946227e
fixup
kdy1 Apr 2, 2021
ddb96cc
Fix fast refresh
kdy1 Apr 2, 2021
afdd681
Update test refs
kdy1 Apr 2, 2021
ca8645f
Make test for #532 fixture
kdy1 Apr 2, 2021
3a18115
Bump version
kdy1 Apr 2, 2021
b05d604
fixup
kdy1 Apr 2, 2021
494963d
Add a test
kdy1 Apr 2, 2021
7a21149
Fix coment bug
kdy1 Apr 2, 2021
f5fb742
Update test refs
kdy1 Apr 2, 2021
992d077
Fix codegen
kdy1 Apr 2, 2021
822dcd1
Update test refs
kdy1 Apr 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ecmascript/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecmascript"
repository = "https://github.com/swc-project/swc.git"
version = "0.29.0"
version = "0.29.1"

[package.metadata.docs.rs]
all-features = true
Expand All @@ -30,7 +30,7 @@ typescript = ["swc_ecma_transforms/typescript"]
swc_ecma_ast = {version = "0.42.0", path = "./ast"}
swc_ecma_codegen = {version = "0.50.0", path = "./codegen", optional = true}
swc_ecma_dep_graph = {version = "0.20.0", path = "./dep-graph", optional = true}
swc_ecma_parser = {version = "0.52.0", path = "./parser", optional = true}
swc_ecma_parser = {version = "0.52.1", path = "./parser", optional = true}
swc_ecma_transforms = {version = "0.43.0", path = "./transforms", optional = true}
swc_ecma_utils = {version = "0.33.0", path = "./utils", optional = true}
swc_ecma_visit = {version = "0.28.0", path = "./visit", optional = true}
Expand Down
2 changes: 1 addition & 1 deletion ecmascript/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.50.2"
version = "0.50.3"

[dependencies]
bitflags = "1"
Expand Down
7 changes: 6 additions & 1 deletion ecmascript/codegen/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl<'a> Emitter<'a> {
&mut self,
pos: BytePos,
prefix_space: bool,
_is_hi: bool,
) -> Result {
if pos == BytePos(0) {
return Ok(());
Expand All @@ -54,11 +55,15 @@ impl<'a> Emitter<'a> {
write_comments!(self, prefix_space, &cmts)
}

pub(super) fn emit_leading_comments_of_pos(&mut self, pos: BytePos) -> Result {
pub(super) fn emit_leading_comments_of_pos(&mut self, mut pos: BytePos, is_hi: bool) -> Result {
if pos == BytePos(0) {
return Ok(());
}

if is_hi {
pos = pos - BytePos(1)
}

let comments = match self.comments {
Some(ref comments) => comments,
None => return Ok(()),
Expand Down
8 changes: 4 additions & 4 deletions ecmascript/codegen/src/decl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<'a> Emitter<'a> {

#[emitter]
fn emit_class_decl(&mut self, node: &ClassDecl) -> Result {
self.emit_leading_comments_of_pos(node.span().lo())?;
self.emit_leading_comments_of_pos(node.span().lo(), false)?;

if node.declare {
keyword!("declare");
Expand All @@ -44,7 +44,7 @@ impl<'a> Emitter<'a> {

#[emitter]
fn emit_fn_decl(&mut self, node: &FnDecl) -> Result {
self.emit_leading_comments_of_pos(node.span().lo())?;
self.emit_leading_comments_of_pos(node.span().lo(), false)?;

if node.declare {
keyword!("declare");
Expand All @@ -71,7 +71,7 @@ impl<'a> Emitter<'a> {

#[emitter]
fn emit_var_decl(&mut self, node: &VarDecl) -> Result {
self.emit_leading_comments_of_pos(node.span.lo())?;
self.emit_leading_comments_of_pos(node.span.lo(), false)?;

if node.declare {
keyword!("declare");
Expand All @@ -90,7 +90,7 @@ impl<'a> Emitter<'a> {

#[emitter]
fn emit_var_declarator(&mut self, node: &VarDeclarator) -> Result {
self.emit_leading_comments_of_pos(node.span().lo())?;
self.emit_leading_comments_of_pos(node.span().lo(), false)?;

emit!(node.name);

Expand Down
Loading