diff --git a/newIDE/electron-app/scripts/app-build.js b/newIDE/electron-app/scripts/app-build.js index 028f57dc20..763d76a4e0 100755 --- a/newIDE/electron-app/scripts/app-build.js +++ b/newIDE/electron-app/scripts/app-build.js @@ -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( diff --git a/newIDE/web-app/scripts/deploy.js b/newIDE/web-app/scripts/deploy.js index 3b00fb3a4c..0723418257 100644 --- a/newIDE/web-app/scripts/deploy.js +++ b/newIDE/web-app/scripts/deploy.js @@ -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'))) {