Skip to content

Commit 1932cb3

Browse files
feat: enable inlineConst by default
1 parent d1f7e79 commit 1932cb3

File tree

195 files changed

+834
-1476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+834
-1476
lines changed

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
AGENTS.md
1+
AGENTS.md

crates/rolldown/tests/esbuild/dce/const_value_inlining_bundle/artifacts.snap

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ console.log(bar());
1313
//#region circular-import-constants.js
1414
const foo = 123;
1515
function bar() {
16-
return foo;
16+
return 123;
1717
}
1818
1919
//#endregion
@@ -23,19 +23,18 @@ function bar() {
2323

2424
```js
2525
//#region circular-re-export-cycle.js
26-
const baz = 0;
2726
console.log(bar());
2827
2928
//#endregion
3029
//#region circular-re-export-constants.js
3130
const foo = 123;
3231
function bar() {
33-
return foo;
32+
return 123;
3433
}
3534
3635
//#endregion
3736
//#region circular-re-export-entry.js
38-
console.log(baz);
37+
console.log(0);
3938
4039
//#endregion
4140
```
@@ -50,7 +49,7 @@ console.log(bar());
5049
//#region circular-re-export-star-constants.js
5150
const foo = 123;
5251
function bar() {
53-
return foo;
52+
return 123;
5453
}
5554
5655
//#endregion
@@ -64,12 +63,12 @@ const x_REMOVE = 1;
6463
foo();
6564
const y_keep = 1;
6665
function foo() {
67-
return [x_REMOVE, y_keep];
66+
return [1, 1];
6867
}
6968
7069
//#endregion
7170
//#region cross-module-entry.js
72-
console.log(x_REMOVE, y_keep);
71+
console.log(1, 1);
7372
7473
//#endregion
7574
```
@@ -80,7 +79,7 @@ console.log(x_REMOVE, y_keep);
8079
//#region exported-entry.js
8180
const x_REMOVE = 1;
8281
const y_keep = 2;
83-
console.log(x_REMOVE, y_keep);
82+
console.log(x_REMOVE, 2);
8483
8584
//#endregion
8685
export { y_keep };
@@ -92,12 +91,12 @@ export { y_keep };
9291
//#region non-circular-export-constants.js
9392
const foo = 123;
9493
function bar() {
95-
return foo;
94+
return 123;
9695
}
9796
9897
//#endregion
9998
//#region non-circular-export-entry.js
100-
console.log(foo, bar());
99+
console.log(123, bar());
101100
102101
//#endregion
103102
```
@@ -106,13 +105,12 @@ console.log(foo, bar());
106105

107106
```js
108107
//#region print-shorthand-constants.js
109-
const foo = 123;
110108
const _bar = -321;
111109
112110
//#endregion
113111
//#region print-shorthand-entry.js
114112
console.log({
115-
foo,
113+
foo: 123,
116114
_bar
117115
});
118116
@@ -133,12 +131,11 @@ export { y_keep };
133131

134132
```js
135133
//#region re-exported-constants.js
136-
const x_REMOVE = 1;
137134
const y_keep = 2;
138135
139136
//#endregion
140137
//#region re-exported-entry.js
141-
console.log(x_REMOVE, y_keep);
138+
console.log(1, 2);
142139
143140
//#endregion
144141
export { y_keep };

crates/rolldown/tests/esbuild/dce/cross_module_constant_folding_computed_property_name/artifacts.snap

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ source: crates/rolldown_testing/src/integration_test.rs
66
## const-entry_js.js
77

88
```js
9-
//#region const-constants.js
10-
const a = 456;
11-
const b = "xyz";
12-
13-
//#endregion
149
//#region const-entry.js
1510
console.log({
16-
[a]: a,
17-
[b]: b
11+
[456]: 456,
12+
["xyz"]: "xyz"
1813
});
1914
2015
//#endregion

crates/rolldown/tests/esbuild/dce/cross_module_constant_folding_number/artifacts.snap

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,43 @@ source: crates/rolldown_testing/src/integration_test.rs
66
## const-entry.js
77

88
```js
9-
//#region const-constants.js
10-
const a = 3;
11-
const b = 6;
12-
13-
//#endregion
149
//#region const-entry.js
1510
console.log([
16-
+b,
17-
-b,
18-
~b,
19-
!b,
20-
typeof b
11+
+6,
12+
-6,
13+
~6,
14+
!6,
15+
typeof 6
2116
], [
22-
a + b,
23-
a - b,
24-
a * b,
25-
a / b,
26-
a % b,
27-
a ** b
17+
3 + 6,
18+
3 - 6,
19+
3 * 6,
20+
3 / 6,
21+
3 % 6,
22+
3 ** 6
2823
], [
29-
a < b,
30-
a > b,
31-
a <= b,
32-
a >= b,
33-
a == b,
34-
a != b,
35-
a === b,
36-
a !== b
24+
3 < 6,
25+
3 > 6,
26+
3 <= 6,
27+
3 >= 6,
28+
3 == 6,
29+
3 != 6,
30+
3 === 6,
31+
3 !== 6
3732
], [
38-
b << 1,
39-
b >> 1,
40-
b >>> 1
33+
6 << 1,
34+
6 >> 1,
35+
6 >>> 1
4136
], [
42-
a & b,
43-
a | b,
44-
a ^ b
37+
3 & 6,
38+
3 | 6,
39+
3 ^ 6
4540
], [
46-
a && b,
47-
a || b,
48-
a ?? b,
49-
a ? "y" : "n",
50-
!b ? "y" : "n"
41+
3 && 6,
42+
3 || 6,
43+
3 ?? 6,
44+
3 ? "y" : "n",
45+
!6 ? "y" : "n"
5146
]);
5247
5348
//#endregion
@@ -110,9 +105,6 @@ console.log([
110105

111106
```js
112107
//#region nested-constants.ts
113-
const a = 2;
114-
const b = 4;
115-
const c = 8;
116108
let x = /* @__PURE__ */ function(x) {
117109
x[x["a"] = 16] = "a";
118110
x[x["b"] = 32] = "b";
@@ -123,7 +115,7 @@ let x = /* @__PURE__ */ function(x) {
123115
//#endregion
124116
//#region nested-entry.ts
125117
console.log({
126-
"should be 4": ~(~a & ~b) & (b | c),
118+
"should be 4": ~(~2 & ~4) & (4 | 8),
127119
"should be 32": ~(~x.a & ~x.b) & (x.b | x.c)
128120
});
129121

crates/rolldown/tests/esbuild/dce/cross_module_constant_folding_string/artifacts.snap

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,22 @@ source: crates/rolldown_testing/src/integration_test.rs
66
## const-entry.js
77

88
```js
9-
//#region const-constants.js
10-
const a = "foo";
11-
const b = "bar";
12-
13-
//#endregion
149
//#region const-entry.js
15-
console.log([typeof b], [a + b], [
16-
a < b,
17-
a > b,
18-
a <= b,
19-
a >= b,
20-
a == b,
21-
a != b,
22-
a === b,
23-
a !== b
10+
console.log([typeof "bar"], ["foo" + "bar"], [
11+
"foo" < "bar",
12+
"foo" > "bar",
13+
"foo" <= "bar",
14+
"foo" >= "bar",
15+
"foo" == "bar",
16+
"foo" != "bar",
17+
"foo" === "bar",
18+
"foo" !== "bar"
2419
], [
25-
a && b,
26-
a || b,
27-
a ?? b,
28-
a ? "y" : "n",
29-
!b ? "y" : "n"
20+
"foo" && "bar",
21+
"foo" || "bar",
22+
"foo" ?? "bar",
23+
"foo" ? "y" : "n",
24+
!"bar" ? "y" : "n"
3025
]);
3126
3227
//#endregion
@@ -68,9 +63,6 @@ console.log([typeof x.b], [x.a + x.b], [
6863

6964
```js
7065
//#region nested-constants.ts
71-
const a = "foo";
72-
const b = "bar";
73-
const c = "baz";
7466
let x = /* @__PURE__ */ function(x) {
7567
x["a"] = "FOO";
7668
x["b"] = "BAR";
@@ -81,7 +73,7 @@ let x = /* @__PURE__ */ function(x) {
8173
//#endregion
8274
//#region nested-entry.ts
8375
console.log({
84-
"should be foobarbaz": a + b + c,
76+
"should be foobarbaz": "foo" + "bar" + "baz",
8577
"should be FOOBARBAZ": x.a + x.b + x.c
8678
});
8779

crates/rolldown/tests/esbuild/dce/package_json_side_effects_false_intermediate_files_chain_all/artifacts.snap

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ source: crates/rolldown_testing/src/integration_test.rs
66
## src_entry.js
77

88
```js
9-
//#region node_modules/d/index.js
10-
const foo = 123;
11-
12-
//#endregion
139
//#region src/entry.js
14-
console.log(foo);
10+
console.log(123);
1511
1612
//#endregion
1713
```

crates/rolldown/tests/esbuild/dce/package_json_side_effects_false_intermediate_files_chain_one/artifacts.snap

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ source: crates/rolldown_testing/src/integration_test.rs
66
## src_entry.js
77

88
```js
9-
//#region node_modules/d/index.js
10-
const foo = 123;
11-
12-
//#endregion
139
//#region src/entry.js
14-
console.log(foo);
10+
console.log(123);
1511
1612
//#endregion
1713
```

crates/rolldown/tests/esbuild/dce/package_json_side_effects_false_intermediate_files_diamond/artifacts.snap

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ source: crates/rolldown_testing/src/integration_test.rs
66
## src_entry.js
77

88
```js
9-
//#region node_modules/d/index.js
10-
const foo = 123;
11-
12-
//#endregion
139
//#region src/entry.js
14-
console.log(foo);
10+
console.log(123);
1511
1612
//#endregion
1713
```

crates/rolldown/tests/esbuild/dce/package_json_side_effects_false_intermediate_files_used/artifacts.snap

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ source: crates/rolldown_testing/src/integration_test.rs
66
## src_entry.js
77

88
```js
9-
//#region node_modules/demo-pkg/foo.js
10-
const foo = 123;
11-
12-
//#endregion
139
//#region src/entry.js
14-
console.log(foo);
10+
console.log(123);
1511
1612
//#endregion
1713
```

crates/rolldown/tests/esbuild/dce/package_json_side_effects_false_keep_bare_import_and_require_es6/artifacts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source: crates/rolldown_testing/src/integration_test.rs
88
```js
99
// HIDDEN [\0rolldown/runtime.js]
1010
//#region node_modules/demo-pkg/index.js
11-
var demo_pkg_exports = /* @__PURE__ */ __exportAll({ foo: () => foo });
11+
var demo_pkg_exports = /* @__PURE__ */ __exportAll({ foo: () => 123 });
1212
var foo;
1313
var init_demo_pkg = __esmMin((() => {
1414
foo = 123;

0 commit comments

Comments
 (0)