Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion crates/oxc_minifier/src/peephole/replace_known_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ impl<'a> PeepholeOptimizations {
return;
};

if matches!(ctx.parent(), Ancestor::StaticMemberExpressionObject(_)) {
if matches!(ctx.parent(), Ancestor::StaticMemberExpressionObject(member) if member.property().name == "concat")
{
return;
}

Expand Down Expand Up @@ -1389,15 +1390,22 @@ mod test {
// array
test("x = [1,2].concat(1).concat(2,['abc']).concat('abc')", "x = [1,2,1,2,'abc','abc']");
test("x = [].concat(['abc']).concat(1).concat([2,3])", "x = ['abc',1,2,3]");
test("x = [].concat(1).concat(2).join(',')", "x = [1,2].join(',')");

test("var x, y; [1].concat(x).concat(y)", "var x, y; [1].concat(x, y)");
test("var y; [1].concat(x).concat(y)", "var y; [1].concat(x, y)"); // x might have a getter that updates y, but that side effect is preserved correctly
test("var x; [1].concat(x.a).concat(x)", "var x; [1].concat(x.a, x)"); // x.a might have a getter that updates x, but that side effect is preserved correctly
test_same("x = [].map(a => a + 1).concat(1)");

// string
test("x = '1'.concat(1).concat(2,['abc']).concat('abc')", "x = '112abcabc'");
test("x = ''.concat(['abc']).concat(1).concat([2,3])", "x = 'abc12,3'");
test("x = ''.concat(1)", "x = '1'");
test(
"x = ''.concat('a', ' ').concat('b').split(/[\\s\\n]+/)",
"x = 'a b'.split(/[\\s\\n]+/)",
);
test_same("x = ''.split().concat(1)");

test("var x, y; v = ''.concat(x).concat(y)", "var x, y; v = `${x}${y}`");
test("var y; v = ''.concat(x).concat(y)", "var y; v = `${x}${y}`"); // x might have a getter that updates y, but that side effect is preserved correctly
Expand Down
2 changes: 1 addition & 1 deletion tasks/minsize/minsize.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Original | minified | minified | gzip | gzip | Iterations | Fi

3.20 MB | 1.00 MB | 1.01 MB | 323.10 kB | 331.56 kB | 3 | echarts.js

6.69 MB | 2.22 MB | 2.31 MB | 459.28 kB | 488.28 kB | 4 | antd.js
6.69 MB | 2.22 MB | 2.31 MB | 459.26 kB | 488.28 kB | 4 | antd.js

10.95 MB | 3.34 MB | 3.49 MB | 855.24 kB | 915.50 kB | 4 | typescript.js

4 changes: 2 additions & 2 deletions tasks/track_memory_allocations/allocs_minifier.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ File | File size || Sys allocs | Sys reallocs |
-------------------------------------------------------------------------------------------------------------------------------------------
checker.ts | 2.92 MB || 84074 | 14190 || 153691 | 29463 | 5.625 MB

cal.com.tsx | 1.06 MB || 40526 | 3033 || 37074 | 4733 | 1.654 MB
cal.com.tsx | 1.06 MB || 40526 | 3033 || 37077 | 4736 | 1.654 MB

RadixUIAdoptionSection.jsx | 2.52 kB || 83 | 8 || 30 | 6 | 992 B

pdf.mjs | 567.30 kB || 19823 | 2900 || 47400 | 7781 | 1.624 MB

antd.js | 6.69 MB || 99855 | 13518 || 331725 | 70117 | 17.407 MB
antd.js | 6.69 MB || 99862 | 13523 || 331767 | 70119 | 17.415 MB

binder.ts | 193.08 kB || 4769 | 974 || 7059 | 834 | 201.192 kB

Loading