fix(es/codegen): Fix sourcemap of comments (#3723)

This commit is contained in:
Donny/강동윤 2022-02-24 17:47:20 +09:00 committed by GitHub
parent 2ab88b5556
commit b8b0c920e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 4 deletions

View File

@ -1,5 +1,5 @@
{
"mappings": "AAAAA,CAAC,EAAG,CAA6B,AAA7B,EAA6B,AAA7B,yBAA6B,AAA7B,EAA6B",
"mappings": "AAAAA,CAAC,GAAG,EAA6B,AAA7B,yBAA6B,AAA7B,EAA6B",
"names": [
"a"
],

View File

@ -1,5 +1,5 @@
{
"mappings": "AAAAA,CAAC,EAAG,CAA6B,AAA7B,EAA6B,AAA7B,yBAA6B,AAA7B,EAA6B",
"mappings": "AAAAA,CAAC,GAAG,EAA6B,AAA7B,yBAA6B,AAA7B,EAA6B",
"names": [
"a"
],

View File

@ -0,0 +1,11 @@
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false,
"decorators": false,
"dynamicImport": false
}
},
"sourceMaps": true
}

View File

@ -0,0 +1,7 @@
a()/*?*/
a()//?
a();/*?*/
a();//?

View File

@ -0,0 +1,5 @@
a();
/*?*/ a() //?
;
a(); /*?*/
a(); //?

View File

@ -0,0 +1,13 @@
{
"mappings": "AAAAA,CAAC;AAAE,EAAK,AAAL,CAAK,AAAL,EAAK,CAERA,CAAC,GAAE,EAAG,AAAH,CAAG;;AAENA,CAAC,IAAG,EAAK,AAAL,CAAK,AAAL,EAAK;AAETA,CAAC,IAAG,EAAG,AAAH,CAAG",
"names": [
"a"
],
"sources": [
"../../input/index.js"
],
"sourcesContent": [
"a()/*?*/\n\na()//?\n\na();/*?*/\n\na();//?\n"
],
"version": 3
}

View File

@ -13,7 +13,7 @@ macro_rules! write_comments {
match cmt.kind {
CommentKind::Line => {
if $prefix_space {
$e.wr.write_comment(cmt.span, " ")?;
$e.wr.write_comment(swc_common::DUMMY_SP, " ")?;
}
$e.wr.write_comment(cmt.span, "//")?;
$e.wr.write_comment(cmt.span, &cmt.text)?;
@ -21,7 +21,7 @@ macro_rules! write_comments {
}
CommentKind::Block => {
if $prefix_space {
$e.wr.write_comment(cmt.span, " ")?;
$e.wr.write_comment(swc_common::DUMMY_SP, " ")?;
}
$e.wr.write_comment(cmt.span, "/*")?;
$e.wr.write_lit(cmt.span, &cmt.text)?;