mirror of
https://github.com/swc-project/swc.git
synced 2024-09-11 16:55:27 +03:00
fix(es/codegen): Fix sourcemap of multiline comments (#5299)
This commit is contained in:
parent
0ddeb749f6
commit
3100bf8c62
@ -1,5 +1,5 @@
|
||||
{
|
||||
"mappings": "AAAAA,CAAC,EAAE,CAAC,6BAA6B,CAA9B,CAA+B",
|
||||
"mappings": "AAAAA,CAAC,EAAE,CAAC,2BAA2B,GAA5B,CAA+B",
|
||||
"names": [
|
||||
"a"
|
||||
],
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"mappings": "AAAAA,CAAC,EAAE,CAAC,6BAA6B,CAA9B,CAA+B",
|
||||
"mappings": "AAAAA,CAAC,EAAE,CAAC,2BAA2B,GAA5B,CAA+B",
|
||||
"names": [
|
||||
"a"
|
||||
],
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"mappings": "AAAAA,CAAC,EAAE,CAAC,CAAC,KAAK;AAEVA,CAAC,EAAE,CAAC,CAAC,GAAG;AAERA,CAAC,EAAE,CAAC,CAAC,KAAK;AAEVA,CAAC,EAAE,CAAC,CAAC,GAAG",
|
||||
"mappings": "AAAAA,CAAC,EAAE,CAAC,CAAC,GAAG;AAERA,CAAC,EAAE,CAAC,CAAC,GAAG;AAERA,CAAC,EAAE,CAAC,CAAC,GAAG;AAERA,CAAC,EAAE,CAAC,CAAC,GAAG",
|
||||
"names": [
|
||||
"a"
|
||||
],
|
||||
|
3
crates/swc/tests/fixture/issues-4xxx/4876/input/.swcrc
Normal file
3
crates/swc/tests/fixture/issues-4xxx/4876/input/.swcrc
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"sourceMaps": true
|
||||
}
|
11
crates/swc/tests/fixture/issues-4xxx/4876/input/index.js
Normal file
11
crates/swc/tests/fixture/issues-4xxx/4876/input/index.js
Normal file
@ -0,0 +1,11 @@
|
||||
/*!
|
||||
|
||||
something v5.1.0
|
||||
|
||||
more
|
||||
|
||||
else
|
||||
*/
|
||||
// a
|
||||
console.log(1);
|
||||
// b
|
@ -0,0 +1,9 @@
|
||||
/*!
|
||||
|
||||
something v5.1.0
|
||||
|
||||
more
|
||||
|
||||
else
|
||||
*/ // a
|
||||
console.log(1); // b
|
14
crates/swc/tests/fixture/issues-4xxx/4876/output/index.map
Normal file
14
crates/swc/tests/fixture/issues-4xxx/4876/output/index.map
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"mappings": "AAAA;;;;;;;AAOA,GACA,IAAI;AACJA,OAAO,CAACC,GAAG,CAAC,CAAC,CAAC,CAAC,CACf,IAAI",
|
||||
"names": [
|
||||
"console",
|
||||
"log"
|
||||
],
|
||||
"sources": [
|
||||
"../../input/index.js"
|
||||
],
|
||||
"sourcesContent": [
|
||||
"/*!\n\n something v5.1.0\n\nmore\n\nelse\n*/\n// a\nconsole.log(1);\n// b"
|
||||
],
|
||||
"version": 3
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"mappings": "AAAA;;GAEG,CACH,OAAO,IAAMA,WAAW,GAAG,SAACC,IAAI,EAAK;IACjCC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;IAClBC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;IAClBC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;IAClBC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;CACrB,CAAC",
|
||||
"mappings": "AAAA;;CAEC,GACD,OAAO,IAAMA,WAAW,GAAG,SAACC,IAAI,EAAK;IACjCC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;IAClBC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;IAClBC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;IAClBC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;CACrB,CAAC",
|
||||
"names": [
|
||||
"LogSomeText",
|
||||
"text",
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||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5 +1,5 @@
|
||||
{
|
||||
"mappings": "AAAA;;;;;GAKG,CACHA;AAAAA,OAAO,CAACC,GAAG,CAAC,IAAIC,KAAK,EAAE,CAACC,KAAK,CAAC,CAAC",
|
||||
"mappings": "AAAA;;;;;CAKC,GACDA;AAAAA,OAAO,CAACC,GAAG,CAAC,IAAIC,KAAK,EAAE,CAACC,KAAK,CAAC,CAAC",
|
||||
"names": [
|
||||
"console",
|
||||
"log",
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"mappings": "AAAAA,CAAC,EAAE,CAAC,CAAC,KAAK",
|
||||
"mappings": "AAAAA,CAAC,EAAE,CAAC,CAAC,GAAG",
|
||||
"names": [
|
||||
"a"
|
||||
],
|
||||
|
@ -29,10 +29,16 @@ macro_rules! write_comments {
|
||||
srcmap!($e, cmt, true);
|
||||
|
||||
$e.wr.write_comment("/*")?;
|
||||
$e.wr.write_lit(DUMMY_SP, &cmt.text)?;
|
||||
$e.wr.write_comment(&cmt.text)?;
|
||||
|
||||
{
|
||||
let hi = cmt.span_hi();
|
||||
if !hi.is_dummy() && hi.0 > 2 {
|
||||
$e.wr.add_srcmap(hi - swc_common::BytePos(2))?;
|
||||
}
|
||||
}
|
||||
$e.wr.write_comment("*/")?;
|
||||
|
||||
srcmap!($e, cmt, false);
|
||||
$e.wr.write_space()?;
|
||||
}
|
||||
}
|
||||
|
11
crates/swc_ecma_parser/tests/comments/issue-4876/input.js
Normal file
11
crates/swc_ecma_parser/tests/comments/issue-4876/input.js
Normal file
@ -0,0 +1,11 @@
|
||||
/*!
|
||||
|
||||
something v5.1.0
|
||||
|
||||
more
|
||||
|
||||
else
|
||||
*/
|
||||
// a
|
||||
console.log(1);
|
||||
// b
|
@ -0,0 +1,34 @@
|
||||
|
||||
> Leading (lo)
|
||||
|
||||
Error:
|
||||
> !
|
||||
|
|
||||
| something v5.1.0
|
||||
|
|
||||
| more
|
||||
|
|
||||
| else
|
||||
|
|
||||
,-[$DIR/tests/comments/issue-4876/input.js:10:1]
|
||||
10 | console.log(1);
|
||||
: ^
|
||||
`----
|
||||
|
||||
> Leading (lo)
|
||||
|
||||
Error:
|
||||
> a
|
||||
,-[$DIR/tests/comments/issue-4876/input.js:10:1]
|
||||
10 | console.log(1);
|
||||
: ^
|
||||
`----
|
||||
|
||||
> Trailing (hi)
|
||||
|
||||
Error:
|
||||
> b
|
||||
,-[$DIR/tests/comments/issue-4876/input.js:10:1]
|
||||
10 | console.log(1);
|
||||
: ^
|
||||
`----
|
@ -4,13 +4,22 @@ set -u
|
||||
export UPDATE=1
|
||||
export DIFF=0
|
||||
|
||||
function up(){
|
||||
cargo test -p swc -p swc_ecma_codegen -p swc_ecma_parser -p swc_bundler -p swc_node_bundler --no-fail-fast
|
||||
function crate() {
|
||||
until cargo test -p $1 --no-fail-fast
|
||||
do
|
||||
git add -A
|
||||
git commit -m 'Update test refs'
|
||||
done
|
||||
|
||||
git add -A
|
||||
git commit -m 'Update test refs'
|
||||
}
|
||||
|
||||
up
|
||||
crate swc
|
||||
crate swc_ecma_codegen
|
||||
crate swc_ecma_parser
|
||||
crate swc_bundler
|
||||
crate swc_node_bundler
|
||||
crate swc_ecma_transforms_react
|
||||
|
||||
|
||||
git add -A
|
||||
git commit -m 'Update test refs'
|
||||
git push -u origin "$(git rev-parse --abbrev-ref HEAD)" --no-verify
|
Loading…
Reference in New Issue
Block a user