Skip to content

Commit 6f29236

Browse files
authored
Packager/compressor.js -- minor fixes + improvements [format]
1 parent db081af commit 6f29236

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/packager/compressor.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ export const optiCompress = (code, options) => {
9898

9999
const convLoaderInd = code.indexOf('t.r(e),t.d(e,"ConvexGeometry",(function(){') - 29;
100100
const convLoaderRegex = /this\.setAttribute\("([^"]+)",\s*new\s+([a-zA-Z_$][\w$]*)\.Float32BufferAttribute\(\s*([a-zA-Z_$][\w$]*),\s*3\s*\)\)/;
101-
const convLoaderEnd = (convLoaderRegex.exec(code)?.index ?? -999) + 128;
101+
const match = convLoaderRegex.exec(code);
102+
const convLoaderEnd = (match ? match.index : -999) + 128;
102103
if (convLoaderInd > 0 && convLoaderEnd > 0) {
103104
code = code.replace(code.substring(convLoaderInd, convLoaderEnd), BLANK_PACK);
104105
}
@@ -117,7 +118,8 @@ export const optiCompress = (code, options) => {
117118
if (!builtIns.includes('jwNum')) {
118119
const expNumInd = code.indexOf('serializeMode:0,debug:0},o="[ExpantaNumError]') - 66;
119120
const expRegex = /for\(var\s+([a-zA-Z_$][\w$]*)\s+in\s+([a-zA-Z_$][\w$]*)\.prototype=([a-zA-Z_$][\w$]*),\2\.JSON=0,\2\.STRING=1,\2\.NONE=0,\2\.NORMAL=1,\2\.ALL=2,\2\.clone=([a-zA-Z_$][\w$]*),\2\.config=\2\.set=/;
120-
const expNumEnd = (expRegex.exec(code)?.index ?? -999) + 378;
121+
const match = expRegex.exec(code);
122+
const expNumEnd = (match ? match.index : -999) + 378;
121123
if (expNumInd > 0 && expNumEnd > 0) {
122124
code = code.replace(code.substring(expNumInd, expNumEnd), BLANK_PACK);
123125
}

0 commit comments

Comments
 (0)