Skip to content

Comments

feat(rspack_core): dump swc ast with ctxt #742

Merged
IWANABETHATGUY merged 3 commits intonextfrom
chore/dump-swc-ctxt
Sep 19, 2022
Merged

feat(rspack_core): dump swc ast with ctxt #742
IWANABETHATGUY merged 3 commits intonextfrom
chore/dump-swc-ctxt

Conversation

@IWANABETHATGUY
Copy link
Contributor

Summary

  1. dump swc ast with ctxt

Test Plan

  1. Checking the newly added assertion test

Related issue (if exists)

Further reading

}b /*#1*/ ;
// err = 3;
let a /*#1*/ = 10;
function another() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice that another is not dumped correctly, the identifier should have #1 ctxt, this is a bug of swc codegen .

@IWANABETHATGUY IWANABETHATGUY changed the title feat(rspack_core): dump swc ast with ctxt #732 feat(rspack_core): dump swc ast with ctxt Sep 16, 2022
GLOBALS.set(global, || {
module.visit_mut_with(&mut resolver(Mark::new(), Mark::new(), false));
let mut noop = Noop {
trailing: comment.trailing.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I think the code could be much cleaner if SwcComments was passed directly, thus, it's not necessary for us to introduce crate ahash .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds great

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@IWANABETHATGUY IWANABETHATGUY merged commit 5b32da5 into next Sep 19, 2022
@IWANABETHATGUY IWANABETHATGUY deleted the chore/dump-swc-ctxt branch September 19, 2022 06:52
@h-a-n-a
Copy link
Contributor

h-a-n-a commented Sep 19, 2022

It could be even cleaner with trait Comments, but LGTM :-)

@IWANABETHATGUY
Copy link
Contributor Author

I review the Comments triait, it doesn't not have the ability to insert the comment in the front of the Vec<comments, you need to take the comments array at specific pos, modify it, and then re-insert it back to comments XXmap

@IWANABETHATGUY
Copy link
Contributor Author

It is mainly used in debugging, will change it if we need the scaleability

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants