Skip to content

Commit a06d5b2

Browse files
authoredDec 21, 2023
fix(es/compat): Use correct span.lo in class transforms (#8439)
**Related issue:** - Closes #8435
1 parent dc26f0f commit a06d5b2

File tree

6 files changed

+41
-3
lines changed

6 files changed

+41
-3
lines changed
 

‎crates/swc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ concurrent = [
2424
"swc_ecma_minifier/concurrent",
2525
]
2626

27-
debug = ["swc_ecma_visit/debug"]
27+
debug = ["swc_ecma_visit/debug", "swc_ecma_minifier/debug"]
2828
default = ["es3"]
2929
es3 = []
3030
node = ["napi", "napi-derive", "swc_compiler_base/node"]

‎crates/swc/tests/fixture/issues-5xxx/5272/1/output/a.map

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"mappings": ";;;+BACaA;;;eAAAA;;;;;;;oBADQ;AACd,IAAA,AAAMA,oBAAN;;gBAAMA;iCAAAA;aAAAA;kCAAAA;;;oBAAAA;;YACTC,KAAAA;mBAAAA,SAAAA;gBACI,OAAO,IAAI,IAAI,CAACC,GAAG;YACvB;;;WAHSF;EAAYG,UAAI",
2+
"mappings": ";;;+BACaA;;;eAAAA;;;;;;;oBADQ;AACd,IAAA,AAAMA,oBAAD,AAAL;;gBAAMA;iCAAAA;aAAAA;kCAAAA;;;oBAAAA;;YACTC,KAAAA;mBAAAA,SAAAA;gBACI,OAAO,IAAI,IAAI,CAACC,GAAG;YACvB;;;WAHSF;EAAYG,UAAI",
33
"names": [
44
"Foo",
55
"bar",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"jsc": {
3+
"parser": {
4+
"syntax": "typescript",
5+
"dynamicImport": true,
6+
"tsx": true,
7+
"jsx": true
8+
},
9+
"minify": {
10+
"compress": true,
11+
"mangle": false
12+
},
13+
"loose": false
14+
},
15+
"env": {
16+
"targets": "> 0.25%, not dead, Safari >=8",
17+
"mode": "entry",
18+
"coreJs": "3.27"
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const init = () => {
2+
var e = window.parcelRequire;
3+
e.register('module1', function () {
4+
class Hello {
5+
world() {}
6+
}
7+
}), e.register('module2', function () {
8+
console.log('test')
9+
});
10+
};
11+
12+
init();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var e;
2+
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
3+
import { _ as _create_class } from "@swc/helpers/_/_create_class";
4+
(e = window.parcelRequire).register("module1", function() {}), e.register("module2", function() {
5+
console.log("test");
6+
});

‎crates/swc_ecma_compat_es2015/src/classes/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ where
381381
if let Expr::Call(call) = &mut rhs {
382382
let mut span = Span {
383383
// after class
384-
lo: span.hi + BytePos(5),
384+
lo: span.lo + BytePos(5),
385385
..span
386386
};
387387
self.add_pure_comments(&mut span.lo);

0 commit comments

Comments
 (0)
Please sign in to comment.