Fix libGD size check (#8911)

Do not show in changelog
This commit is contained in:
Clément Pasteau
2026-07-31 09:15:54 +02:00
committed by GitHub
parent 97102aeaf5
commit b1e60169e4
2 changed files with 41 additions and 9 deletions
+23 -6
View File
@@ -21,17 +21,34 @@ const checkLibGDjsSize = () => {
shell.exit(1);
}
const sizeInMiB = stats.size / 1024 / 1024;
if (sizeInMiB > 2) {
// A release build is minified into a handful of very long lines, while a
// 'dev' or 'debug' build is not minified at all (tens of thousands of lines).
// Their sizes are too close to tell them apart, so check the line count.
const lineCount = fs
.readFileSync(path.join(appPublicPath, 'libGD.js'), 'utf8')
.split('\n').length;
if (lineCount > 1000) {
shell.echo(
`❌ libGD.js size is too big (${sizeInMiB.toFixed(
2
)}MiB) - are you sure you're not trying to deploy the development version?`
`❌ libGD.js does not look minified (${lineCount} lines) - are you sure you're not trying to deploy the development version?`
);
shell.exit(1);
}
shell.echo(`✅ libGD.js size seems correct (${sizeInMiB.toFixed(2)}MiB)`);
const sizeInMiB = stats.size / 1024 / 1024;
if (sizeInMiB > 4) {
shell.echo(
`❌ libGD.js size is too big (${sizeInMiB.toFixed(
2
)}MiB) - are you sure it was built properly?`
);
shell.exit(1);
}
shell.echo(
`✅ libGD.js seems correct (${sizeInMiB.toFixed(
2
)}MiB, ${lineCount} lines)`
);
if (!fs.existsSync(path.join(appPublicPath, 'libGD.wasm'))) {
shell.echo(
+18 -3
View File
@@ -42,18 +42,33 @@ isGitClean()
shell.exit(1);
}
// A release build is minified into a handful of very long lines, while a
// 'dev' or 'debug' build is not minified at all (tens of thousands of lines).
// Their sizes are too close to tell them apart, so check the line count.
const lineCount = fs
.readFileSync(path.join(appPublicPath, 'libGD.js'), 'utf8')
.split('\n').length;
if (lineCount > 1000) {
shell.echo(
`❌ libGD.js does not look minified (${lineCount} lines) - are you sure you're not trying to deploy the development version?`
);
shell.exit(1);
}
const sizeInMiB = stats.size / 1024 / 1024;
if (sizeInMiB > 2) {
if (sizeInMiB > 4) {
shell.echo(
`❌ libGD.js size is too big (${sizeInMiB.toFixed(
2
)}MiB) - are you sure you're not trying to deploy the development version?`
)}MiB) - are you sure it was built properly?`
);
shell.exit(1);
}
shell.echo(
`✅ libGD.js size seems correct (${sizeInMiB.toFixed(2)}MiB)`
`✅ libGD.js seems correct (${sizeInMiB.toFixed(
2
)}MiB, ${lineCount} lines)`
);
if (!fs.existsSync(path.join(appPublicPath, 'libGD.wasm'))) {