Skip to content

Commit 0d130f8

Browse files
authored
fix(bundler): Prevent hanging (#1369)
swc_bundler: - Prevent infinite loop.
1 parent af25a88 commit 0d130f8

File tree

32 files changed

+232
-85
lines changed

32 files changed

+232
-85
lines changed

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2018"
99
license = "Apache-2.0/MIT"
1010
name = "swc"
1111
repository = "https://github.com/swc-project/swc.git"
12-
version = "0.2.6"
12+
version = "0.2.7"
1313

1414
[lib]
1515
name = "swc"
@@ -28,11 +28,11 @@ sourcemap = "6"
2828
swc_atoms = {version = "0.2", path = "./atoms"}
2929
swc_common = {version = "0.10", path = "./common", features = ["sourcemap", "concurrent"]}
3030
swc_ecma_ast = {version = "0.37.3", path = "./ecmascript/ast"}
31-
swc_ecma_codegen = {version = "0.43.5", path = "./ecmascript/codegen"}
32-
swc_ecma_ext_transforms = {version = "0.2.4", path = "./ecmascript/ext-transforms"}
33-
swc_ecma_parser = {version = "0.45.4", path = "./ecmascript/parser"}
34-
swc_ecma_preset_env = {version = "0.3.6", path = "./ecmascript/preset_env"}
35-
swc_ecma_transforms = {version = "0.33.7", path = "./ecmascript/transforms", features = [
31+
swc_ecma_codegen = {version = "0.43.7", path = "./ecmascript/codegen"}
32+
swc_ecma_ext_transforms = {version = "0.2.5", path = "./ecmascript/ext-transforms"}
33+
swc_ecma_parser = {version = "0.45.6", path = "./ecmascript/parser"}
34+
swc_ecma_preset_env = {version = "0.3.7", path = "./ecmascript/preset_env"}
35+
swc_ecma_transforms = {version = "0.33.8", path = "./ecmascript/transforms", features = [
3636
"compat",
3737
"module",
3838
"optimization",

bundler/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/**/*.js"]
99
license = "Apache-2.0/MIT"
1010
name = "swc_bundler"
1111
repository = "https://github.com/swc-project/swc.git"
12-
version = "0.20.7"
12+
version = "0.20.8"
1313

1414
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1515
[features]
@@ -32,9 +32,9 @@ retain_mut = "0.1.2"
3232
swc_atoms = {version = "0.2.4", path = "../atoms"}
3333
swc_common = {version = "0.10.0", path = "../common"}
3434
swc_ecma_ast = {version = "0.37.3", path = "../ecmascript/ast"}
35-
swc_ecma_codegen = {version = "0.43.5", path = "../ecmascript/codegen"}
36-
swc_ecma_parser = {version = "0.45.4", path = "../ecmascript/parser"}
37-
swc_ecma_transforms = {version = "0.33.7", path = "../ecmascript/transforms", features = ["optimization"]}
35+
swc_ecma_codegen = {version = "0.43.7", path = "../ecmascript/codegen"}
36+
swc_ecma_parser = {version = "0.45.6", path = "../ecmascript/parser"}
37+
swc_ecma_transforms = {version = "0.33.8", path = "../ecmascript/transforms", features = ["optimization"]}
3838
swc_ecma_utils = {version = "0.27.3", path = "../ecmascript/utils"}
3939
swc_ecma_visit = {version = "0.23.3", path = "../ecmascript/visit"}
4040

@@ -43,7 +43,7 @@ hex = "0.4"
4343
ntest = "0.7.2"
4444
reqwest = {version = "0.10.8", features = ["blocking"]}
4545
sha-1 = "0.9"
46-
swc_ecma_transforms = {version = "0.33.7", path = "../ecmascript/transforms", features = ["react", "typescript"]}
46+
swc_ecma_transforms = {version = "0.33.8", path = "../ecmascript/transforms", features = ["react", "typescript"]}
4747
tempfile = "3.1.0"
4848
testing = {version = "0.10.0", path = "../testing"}
4949
url = "2.1.1"

bundler/src/bundler/modules/sort/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ fn iter<'a>(
246246
return false;
247247
}
248248

249+
if !free.contains(&idx) && graph.has_a_path(*dep, idx) {
250+
if !moves.insert((idx, *dep)) {
251+
return false;
252+
}
253+
}
254+
249255
// Exlcude emitted items
250256
!done.contains(dep)
251257
})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { showList } from "./b";
2+
3+
export const showValue = (v: number): string => {
4+
if (v === 0) {
5+
return showList([v]);
6+
}
7+
8+
return `${v}`;
9+
};
10+
11+
console.log(showList([1, 2, 3]));
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { showValue } from "./a";
2+
3+
export const showList = (v: number[]): string => {
4+
return `[${v.map(showValue).join(', ')}]`;
5+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as a from './a';
2+
import * as b from './b';
3+
4+
console.log(a, b)
5+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { showList } from "./b";
2+
3+
export const showValue = (v: number): string => {
4+
if (v === 0) {
5+
return showList([v]);
6+
}
7+
8+
return `${v}`;
9+
};
10+
11+
console.log(showList([1, 2, 3]));
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { showValue } from "./a";
2+
3+
export const showList = (v: number[]): string => {
4+
return `[${v.map(showValue).join(', ')}]`;
5+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './a';
2+
3+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const showValue1 = (v)=>{
2+
if (v === 0) {
3+
return showList1([
4+
v
5+
]);
6+
}
7+
return `${v}`;
8+
};
9+
export { showValue1 as showValue };
10+
const showList = (v)=>{
11+
return `[${v.map(showValue1).join(', ')}]`;
12+
};
13+
const showList1 = showList;
14+
console.log(showList([
15+
1,
16+
2,
17+
3
18+
]));
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const showValue1 = (v)=>{
2+
if (v === 0) {
3+
return showList2([
4+
v
5+
]);
6+
}
7+
return `${v}`;
8+
};
9+
export { showValue1 as showValue };
10+
const showValue2 = showValue1;
11+
const showValue3 = showValue2;
12+
const showList = (v)=>{
13+
return `[${v.map(showValue3).join(', ')}]`;
14+
};
15+
const showList1 = showList;
16+
const showList2 = showList1;
17+
console.log(showList2([
18+
1,
19+
2,
20+
3
21+
]));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { showList } from "./b";
2+
3+
export const showValue = (v: number): string => {
4+
if (v === 0) {
5+
return showList([v]);
6+
}
7+
8+
return `${v}`;
9+
};
10+
11+
console.log(showList([1, 2, 3]));
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { showValue } from "./a";
2+
3+
export const showList = (v: number[]): string => {
4+
return `[${v.map(showValue).join(', ')}]`;
5+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { showValue } from './a';
2+
import { showList } from './b';
3+
4+
console.log(showValue, showList)
5+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const showValue = (v)=>{
2+
if (v === 0) {
3+
return showList1([
4+
v
5+
]);
6+
}
7+
return `${v}`;
8+
};
9+
const showList = (v)=>{
10+
return `[${v.map(showValue).join(', ')}]`;
11+
};
12+
const showList1 = showList;
13+
console.log(showList([
14+
1,
15+
2,
16+
3
17+
]));
18+
console.log(showValue, showList);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const showValue = (v)=>{
2+
if (v === 0) {
3+
return showList3([
4+
v
5+
]);
6+
}
7+
return `${v}`;
8+
};
9+
const showValue1 = showValue;
10+
const showValue2 = showValue1;
11+
const showValue3 = showValue1;
12+
const showList = (v)=>{
13+
return `[${v.map(showValue3).join(', ')}]`;
14+
};
15+
const showList1 = showList;
16+
const showList2 = showList1;
17+
const showList3 = showList1;
18+
console.log(showList3([
19+
1,
20+
2,
21+
3
22+
]));
23+
console.log(showValue2, showList2);

ecmascript/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
license = "Apache-2.0/MIT"
77
name = "swc_ecmascript"
88
repository = "https://github.com/swc-project/swc.git"
9-
version = "0.18.7"
9+
version = "0.18.8"
1010

1111
[features]
1212
codegen = ["swc_ecma_codegen"]
@@ -25,10 +25,10 @@ typescript = ["swc_ecma_transforms/typescript"]
2525

2626
[dependencies]
2727
swc_ecma_ast = {version = "0.37.3", path = "./ast"}
28-
swc_ecma_codegen = {version = "0.43.5", path = "./codegen", optional = true}
29-
swc_ecma_dep_graph = {version = "0.12.4", path = "./dep-graph", optional = true}
30-
swc_ecma_parser = {version = "0.45.4", path = "./parser", optional = true}
31-
swc_ecma_transforms = {version = "0.33.7", path = "./transforms", optional = true}
28+
swc_ecma_codegen = {version = "0.43.7", path = "./codegen", optional = true}
29+
swc_ecma_dep_graph = {version = "0.12.5", path = "./dep-graph", optional = true}
30+
swc_ecma_parser = {version = "0.45.6", path = "./parser", optional = true}
31+
swc_ecma_transforms = {version = "0.33.8", path = "./transforms", optional = true}
3232
swc_ecma_utils = {version = "0.27.3", path = "./utils", optional = true}
3333
swc_ecma_visit = {version = "0.23.3", path = "./visit", optional = true}
3434

ecmascript/codegen/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
77
license = "Apache-2.0/MIT"
88
name = "swc_ecma_codegen"
99
repository = "https://github.com/swc-project/swc.git"
10-
version = "0.43.6"
10+
version = "0.43.7"
1111

1212
[dependencies]
1313
bitflags = "1"
@@ -17,7 +17,7 @@ swc_atoms = {version = "0.2", path = "../../atoms"}
1717
swc_common = {version = "0.10.0", path = "../../common"}
1818
swc_ecma_ast = {version = "0.37.3", path = "../ast"}
1919
swc_ecma_codegen_macros = {version = "0.5", path = "./macros"}
20-
swc_ecma_parser = {version = "0.45.4", path = "../parser"}
20+
swc_ecma_parser = {version = "0.45.6", path = "../parser"}
2121

2222
[dev-dependencies]
2323
swc_common = {version = "0.10.0", path = "../../common", features = ["sourcemap"]}

ecmascript/dep-graph/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
license = "Apache-2.0/MIT"
77
name = "swc_ecma_dep_graph"
88
repository = "https://github.com/swc-project/swc.git"
9-
version = "0.12.4"
9+
version = "0.12.5"
1010

1111
[dependencies]
1212
swc_atoms = {version = "0.2", path = "../../atoms"}
@@ -15,5 +15,5 @@ swc_ecma_ast = {version = "0.37.3", path = "../ast"}
1515
swc_ecma_visit = {version = "0.23.3", path = "../visit"}
1616

1717
[dev-dependencies]
18-
swc_ecma_parser = {version = "0.45.4", path = "../parser"}
18+
swc_ecma_parser = {version = "0.45.6", path = "../parser"}
1919
testing = {version = "0.10.0", path = "../../testing"}

ecmascript/ext-transforms/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ documentation = "https://swc.rs/rustdoc/swc_ecma_ext_transforms/"
55
edition = "2018"
66
license = "Apache-2.0/MIT"
77
name = "swc_ecma_ext_transforms"
8-
version = "0.2.4"
8+
version = "0.2.5"
99

1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

@@ -14,6 +14,6 @@ phf = {version = "0.8.0", features = ["macros"]}
1414
swc_atoms = {version = "0.2", path = "../../atoms"}
1515
swc_common = {version = "0.10", path = "../../common"}
1616
swc_ecma_ast = {version = "0.37.3", path = "../ast"}
17-
swc_ecma_parser = {version = "0.45.4", path = "../parser"}
17+
swc_ecma_parser = {version = "0.45.6", path = "../parser"}
1818
swc_ecma_utils = {version = "0.27.3", path = "../utils"}
1919
swc_ecma_visit = {version = "0.23.3", path = "../visit"}

ecmascript/jsdoc/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ documentation = "https://swc.rs/rustdoc/jsdoc/"
55
edition = "2018"
66
license = "Apache-2.0/MIT"
77
name = "jsdoc"
8-
version = "0.13.4"
8+
version = "0.13.5"
99

1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

@@ -19,6 +19,6 @@ swc_common = {version = "0.10.0", path = "../../common"}
1919
anyhow = "1"
2020
dashmap = "3"
2121
swc_ecma_ast = {version = "0.37.3", path = "../ast"}
22-
swc_ecma_parser = {version = "0.45.4", path = "../parser"}
22+
swc_ecma_parser = {version = "0.45.6", path = "../parser"}
2323
testing = {version = "0.10.0", path = "../../testing"}
2424
walkdir = "2"

ecmascript/parser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "examples/**/*.rs"]
77
license = "Apache-2.0/MIT"
88
name = "swc_ecma_parser"
99
repository = "https://github.com/swc-project/swc.git"
10-
version = "0.45.5"
10+
version = "0.45.6"
1111

1212
[features]
1313
default = []

ecmascript/preset_env/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ documentation = "https://swc.rs/rustdoc/swc_ecma_preset_env/"
55
edition = "2018"
66
license = "Apache-2.0/MIT"
77
name = "swc_ecma_preset_env"
8-
version = "0.3.6"
8+
version = "0.3.7"
99

1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

@@ -21,13 +21,13 @@ string_enum = {version = "0.3", path = "../../macros/string_enum"}
2121
swc_atoms = {version = "0.2", path = "../../atoms"}
2222
swc_common = {version = "0.10", path = "../../common"}
2323
swc_ecma_ast = {version = "0.37.3", path = "../ast"}
24-
swc_ecma_transforms = {version = "0.33.7", path = "../transforms", features = ["compat", "proposal"]}
24+
swc_ecma_transforms = {version = "0.33.8", path = "../transforms", features = ["compat", "proposal"]}
2525
swc_ecma_utils = {version = "0.27.3", path = "../utils"}
2626
swc_ecma_visit = {version = "0.23.3", path = "../visit"}
2727
walkdir = "2"
2828

2929
[dev-dependencies]
3030
pretty_assertions = "0.6"
31-
swc_ecma_codegen = {version = "0.43.5", path = "../codegen"}
32-
swc_ecma_parser = {version = "0.45.4", path = "../parser"}
31+
swc_ecma_codegen = {version = "0.43.7", path = "../codegen"}
32+
swc_ecma_parser = {version = "0.45.6", path = "../parser"}
3333
testing = {version = "0.10", path = "../../testing"}

ecmascript/transforms/Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
license = "Apache-2.0/MIT"
77
name = "swc_ecma_transforms"
88
repository = "https://github.com/swc-project/swc.git"
9-
version = "0.33.7"
9+
version = "0.33.8"
1010

1111
[features]
1212
compat = ["swc_ecma_transforms_compat"]
@@ -20,23 +20,23 @@ typescript = ["swc_ecma_transforms_typescript"]
2020
swc_atoms = {version = "0.2.0", path = "../../atoms"}
2121
swc_common = {version = "0.10.0", path = "../../common"}
2222
swc_ecma_ast = {version = "0.37.3", path = "../ast"}
23-
swc_ecma_parser = {version = "0.45.4", path = "../parser"}
24-
swc_ecma_transforms_base = {version = "0.2.6", path = "./base"}
25-
swc_ecma_transforms_compat = {version = "0.3.6", path = "./compat", optional = true}
26-
swc_ecma_transforms_module = {version = "0.3.6", path = "./module", optional = true}
27-
swc_ecma_transforms_optimization = {version = "0.3.7", path = "./optimization", optional = true}
28-
swc_ecma_transforms_proposal = {version = "0.3.6", path = "./proposal", optional = true}
29-
swc_ecma_transforms_react = {version = "0.3.6", path = "./react", optional = true}
30-
swc_ecma_transforms_typescript = {version = "0.3.7", path = "./typescript", optional = true}
23+
swc_ecma_parser = {version = "0.45.6", path = "../parser"}
24+
swc_ecma_transforms_base = {version = "0.2.8", path = "./base"}
25+
swc_ecma_transforms_compat = {version = "0.3.7", path = "./compat", optional = true}
26+
swc_ecma_transforms_module = {version = "0.3.7", path = "./module", optional = true}
27+
swc_ecma_transforms_optimization = {version = "0.3.8", path = "./optimization", optional = true}
28+
swc_ecma_transforms_proposal = {version = "0.3.7", path = "./proposal", optional = true}
29+
swc_ecma_transforms_react = {version = "0.3.7", path = "./react", optional = true}
30+
swc_ecma_transforms_typescript = {version = "0.3.9", path = "./typescript", optional = true}
3131
swc_ecma_utils = {version = "0.27.3", path = "../utils"}
3232
swc_ecma_visit = {version = "0.23.3", path = "../visit"}
3333
unicode-xid = "0.2"
3434

3535
[dev-dependencies]
3636
pretty_assertions = "0.6"
3737
sourcemap = "6"
38-
swc_ecma_codegen = {version = "0.43.5", path = "../codegen"}
39-
swc_ecma_transforms_testing = {version = "0.2.5", path = "./testing"}
38+
swc_ecma_codegen = {version = "0.43.7", path = "../codegen"}
39+
swc_ecma_transforms_testing = {version = "0.2.6", path = "./testing"}
4040
tempfile = "3"
4141
testing = {version = "0.10.0", path = "../../testing"}
4242
walkdir = "2"

0 commit comments

Comments
 (0)