-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/codegen): Fix wrong sourcemap when there are new lines in tpl (#…
…9578) **Description:** 1. split quasi by '\n' 2. add the mapping between the original string and the generated string one by one. <img width="873" alt="image" src="https://github.com/user-attachments/assets/8a03da7f-2d22-4dd5-9bac-220418b10911"> **Related issue:** - Closes #9567
- Loading branch information
Showing
8 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
swc_ecma_codegen: patch | ||
swc_core: patch | ||
--- | ||
|
||
fix(es/codegen): fix wrong sourcemap when there are new lines in tpl |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
crates/swc/tests/fixture/sourcemap/issue-9567/input/.swcrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"tsx": true | ||
}, | ||
"target": "es2015", | ||
"externalHelpers": true, | ||
"loose": false, | ||
"minify": { | ||
"compress": true, | ||
"mangle": { | ||
"toplevel": true | ||
} | ||
} | ||
}, | ||
"module": { | ||
"type": "es6" | ||
}, | ||
"minify": true, | ||
"sourceMaps": true | ||
} |
12 changes: 12 additions & 0 deletions
12
crates/swc/tests/fixture/sourcemap/issue-9567/input/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function foo(span, error) { | ||
span.setStatus({ | ||
message: `${error.message} ${ | ||
error.code | ||
? `\nMon\tgo\nos | ||
e Error\n C | ||
od\ne: ${error.code}` | ||
: "1\n23" | ||
}`, | ||
}); | ||
} | ||
foo(); |
7 changes: 7 additions & 0 deletions
7
crates/swc/tests/fixture/sourcemap/issue-9567/output/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function e(e,o){e.setStatus({message:`${o.message} ${o.code?` | ||
Mon go | ||
os | ||
e Error | ||
C | ||
od | ||
e: ${o.code}`:"1\n23"}`})}e(); |
18 changes: 18 additions & 0 deletions
18
crates/swc/tests/fixture/sourcemap/issue-9567/output/index.map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"mappings": "AAAA,SAASA,EAAIC,CAAI,CAAEC,CAAK,EACtBD,EAAKE,SAAS,CAAC,CACXC,QAAS,CAAC,EAAEF,EAAME,OAAO,CAAC,CAAC,EACvBF,EAAMG,IAAI,CACJ,CAAC;AAAE;AAAS;AAC5B;AAAS;AACT;AAAI,GAAG,EAAEH,EAAMG,IAAI,CAAC,CAAC,CACL,QACT,CAAC,AACN,EACF,CACAL", | ||
"names": [ | ||
"foo", | ||
"span", | ||
"error", | ||
"setStatus", | ||
"message", | ||
"code" | ||
], | ||
"sources": [ | ||
"../../input/index.js" | ||
], | ||
"sourcesContent": [ | ||
"function foo(span, error) {\n span.setStatus({\n message: `${error.message} ${\n error.code\n ? `\\nMon\\tgo\\nos\ne Error\\n C\nod\\ne: ${error.code}`\n : \"1\\n23\"\n }`,\n });\n}\nfoo();\n" | ||
], | ||
"version": 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters