Skip to content

Commit d10858d

Browse files
chore(minifier): Update fixture outputs for syntax context fix
The fix to not ignore syntax context when comparing if statement consequences causes different minifier output in some cases where previously incorrect merging was happening. Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
1 parent 006bb01 commit d10858d

6 files changed

Lines changed: 54 additions & 14 deletions

File tree

crates/swc_ecma_minifier/tests/benches-full/echarts.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,7 +2383,11 @@
23832383
var keyframes = this.keyframes, len = keyframes.length;
23842384
if (this.interpolable) if (isArrayLike(value)) {
23852385
var value1, arrayDim = isArrayLike((value1 = value) && value1[0]) ? 2 : 1;
2386-
if (len > 0 && this.arrDim !== arrayDim || 1 === arrayDim && 'number' != typeof value[0] || 2 === arrayDim && 'number' != typeof value[0][0]) {
2386+
if (len > 0 && this.arrDim !== arrayDim) {
2387+
this.interpolable = !1;
2388+
return;
2389+
}
2390+
if (1 === arrayDim && 'number' != typeof value[0] || 2 === arrayDim && 'number' != typeof value[0][0]) {
23872391
this.interpolable = !1;
23882392
return;
23892393
}
@@ -13072,12 +13076,18 @@
1307213076
globalRect.copy(labelItem.rect), globalRect.width -= 0.1, globalRect.height -= 0.1, globalRect.x += 0.05, globalRect.y += 0.05;
1307313077
for(var obb = labelItem.obb, overlapped = !1, j = 0; j < displayedLabels.length; j++){
1307413078
var existsTextCfg = displayedLabels[j]; // Fast rejection.
13075-
if (globalRect.intersect(existsTextCfg.rect) && (isAxisAligned && existsTextCfg.axisAligned || (existsTextCfg.obb || // If self is not axis aligned. But other is.
13076-
(existsTextCfg.obb = new OrientedBoundingRect(existsTextCfg.localRect, existsTextCfg.transform)), obb || // If self is axis aligned. But other is not.
13077-
(obb = new OrientedBoundingRect(localRect, transform)), obb.intersect(existsTextCfg.obb)))) {
13078-
// Is overlapped
13079-
overlapped = !0;
13080-
break;
13079+
if (globalRect.intersect(existsTextCfg.rect)) {
13080+
if (isAxisAligned && existsTextCfg.axisAligned) {
13081+
// Is overlapped
13082+
overlapped = !0;
13083+
break;
13084+
}
13085+
if (existsTextCfg.obb || // If self is not axis aligned. But other is.
13086+
(existsTextCfg.obb = new OrientedBoundingRect(existsTextCfg.localRect, existsTextCfg.transform)), obb || // If self is axis aligned. But other is not.
13087+
(obb = new OrientedBoundingRect(localRect, transform)), obb.intersect(existsTextCfg.obb)) {
13088+
overlapped = !0;
13089+
break;
13090+
}
1308113091
}
1308213092
} // TODO Callback to determine if this overlap should be handled?
1308313093
overlapped ? (hideEl(label), labelLine && hideEl(labelLine)) : (label.attr('ignore', labelItem.defaultAttr.ignore), labelLine && labelLine.attr('ignore', labelItem.defaultAttr.labelGuideIgnore), displayedLabels.push(labelItem));

crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16479,7 +16479,9 @@
1647916479
var type = (0, _videojs_vhs_utils_es_containers__WEBPACK_IMPORTED_MODULE_12__ /* .detectContainerForBytes */ .Xm)(bytes); // if this looks like a ts segment but we don't have enough data
1648016480
return(// to see the second sync byte, wait until we have enough data
1648116481
// before declaring it ts
16482-
"ts" === type && bytes.length < 188 || !type && bytes.length < 376 ? callbackOnCompleted(request, function() {
16482+
"ts" === type && bytes.length < 188 ? callbackOnCompleted(request, function() {
16483+
return endRequestAndCallback(error, request, "", bytes);
16484+
}) : !type && bytes.length < 376 ? callbackOnCompleted(request, function() {
1648316485
return endRequestAndCallback(error, request, "", bytes);
1648416486
}) : endRequestAndCallback(null, request, type, bytes) // this may be an unsynced ts segment
1648516487
);
@@ -20853,7 +20855,12 @@
2085320855
case "timed-metadata":
2085420856
// Exit early because we don't have enough to parse
2085520857
// the ID3 tag header
20856-
if (bytes.length - byteIndex < 10 || (frameSize = probe.aac.parseId3TagSize(bytes, byteIndex)) > bytes.length) {
20858+
if (bytes.length - byteIndex < 10) {
20859+
endLoop = !0;
20860+
break;
20861+
}
20862+
// to emit a full packet
20863+
if ((frameSize = probe.aac.parseId3TagSize(bytes, byteIndex)) > bytes.length) {
2085720864
endLoop = !0;
2085820865
break;
2085920866
}
@@ -20862,7 +20869,12 @@
2086220869
case "audio":
2086320870
// Exit early because we don't have enough to parse
2086420871
// the ADTS frame header
20865-
if (bytes.length - byteIndex < 7 || (frameSize = probe.aac.parseAdtsSize(bytes, byteIndex)) > bytes.length) {
20872+
if (bytes.length - byteIndex < 7) {
20873+
endLoop = !0;
20874+
break;
20875+
}
20876+
// to emit a full packet
20877+
if ((frameSize = probe.aac.parseAdtsSize(bytes, byteIndex)) > bytes.length) {
2086620878
endLoop = !0;
2086720879
break;
2086820880
}

crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6889,11 +6889,16 @@
68896889
// last char was a lead
68906890
if (!leadSurrogate) {
68916891
// no lead yet
6892-
if (codePoint > 0xdbff || i + 1 === length) {
6892+
if (codePoint > 0xdbff) {
68936893
// unexpected trail
68946894
(units -= 3) > -1 && bytes.push(0xef, 0xbf, 0xbd);
68956895
continue;
68966896
}
6897+
if (i + 1 === length) {
6898+
// unpaired lead
6899+
(units -= 3) > -1 && bytes.push(0xef, 0xbf, 0xbd);
6900+
continue;
6901+
}
68976902
// valid lead
68986903
leadSurrogate = codePoint;
68996904
continue;

crates/swc_ecma_minifier/tests/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/output.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,11 @@
665665
for(var t, f = e.length, n = null, i = [], o = 0; o < f; ++o){
666666
if ((t = e.charCodeAt(o)) > 55295 && t < 57344) {
667667
if (!n) {
668-
if (t > 56319 || o + 1 === f) {
668+
if (t > 56319) {
669+
(r -= 3) > -1 && i.push(239, 191, 189);
670+
continue;
671+
}
672+
if (o + 1 === f) {
669673
(r -= 3) > -1 && i.push(239, 191, 189);
670674
continue;
671675
}

crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20898,7 +20898,11 @@
2089820898
for(var r, n = t.length, i = null, o = [], a = 0; a < n; ++a){
2089920899
if ((r = t.charCodeAt(a)) > 55295 && r < 57344) {
2090020900
if (!i) {
20901-
if (r > 56319 || a + 1 === n) {
20901+
if (r > 56319) {
20902+
(e -= 3) > -1 && o.push(239, 191, 189);
20903+
continue;
20904+
}
20905+
if (a + 1 === n) {
2090220906
(e -= 3) > -1 && o.push(239, 191, 189);
2090320907
continue;
2090420908
}

crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11462,11 +11462,16 @@
1146211462
// last char was a lead
1146311463
if (!leadSurrogate) {
1146411464
// no lead yet
11465-
if (codePoint > 0xDBFF || i + 1 === length) {
11465+
if (codePoint > 0xDBFF) {
1146611466
// unexpected trail
1146711467
(units -= 3) > -1 && bytes.push(0xEF, 0xBF, 0xBD);
1146811468
continue;
1146911469
}
11470+
if (i + 1 === length) {
11471+
// unpaired lead
11472+
(units -= 3) > -1 && bytes.push(0xEF, 0xBF, 0xBD);
11473+
continue;
11474+
}
1147011475
// valid lead
1147111476
leadSurrogate = codePoint;
1147211477
continue;

0 commit comments

Comments
 (0)