From e0aaca5069e4a60fbbfbe5e090e963dc3b6e1506 Mon Sep 17 00:00:00 2001 From: nullbyze Date: Mon, 9 Feb 2026 16:34:48 +0100 Subject: [PATCH] Update build.js to incorporate changes from build.sh # Pull Request ## Summary Update build.js to incorporate changes from build.sh ## Related Issues - Closes # - Fixes # - Related to #47 ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Refactor - [ ] Performance improvement - [ ] UI/UX update - [ ] Documentation update - [x] Build/CI change - [ ] Other (describe): ## Changes Made List the key changes included in this PR. - Update build.js to incorporate changes from build.sh ## Testing "npm run build" completes successfully, files deleted as expected - [ ] Tested on emulator - [ ] Tested on physical device - [x] Manual testing completed - [ ] Not tested (explain why): ## Checklist - [x] Code builds successfully - [x] Code follows project style and conventions - [x] No unnecessary commented-out code - [x] No new warnings introduced - [x] Documentation updated (if needed) --- build.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/build.js b/build.js index 758fe82..f8bab3f 100644 --- a/build.js +++ b/build.js @@ -18,6 +18,15 @@ const removeDirs = (base, filterFn) => { } }; +const deleteFiles = (basePath, filenames) => { + filenames.forEach(filename => { + const filePath = path.join(basePath, filename); + if (fs.existsSync(filePath)) { + fs.unlinkSync(filePath); + } + }); +}; + try { console.log(' Building Moonfin for webOS...\n'); @@ -43,6 +52,50 @@ try { const localeDir = path.join('dist', 'node_modules', 'ilib', 'locale'); removeDirs(localeDir, (name) => !name.startsWith('en')); + // Root-level files: phone, currency, unit, address, astronomy data + console.log('\n Removing unused ilib data files...'); + const nonEngLocalefiles = ([ + 'currency.json', + 'numplan.json', + 'emergency.json', + 'unitfmt.json', + 'phoneloc.json', + 'phonefmt.json', + 'iddarea.json', + 'idd.json', + 'mnc.json', + 'address.json', + 'addressres.json', + 'astro.json', + 'pseudomap.json', + 'collation.json', + 'countries.json', + 'nativecountries.json', + 'ctrynames.json', + 'ctryreverse.json', + 'name.json', + 'lang2charset.json', + 'ccc.json' + ]); + deleteFiles(path.join('dist', 'node_modules', 'ilib', 'locale'), nonEngLocalefiles); + + // Remove Deseret script locale (historic/obsolete) + fs.rmSync(path.join('dist', 'node_modules', 'ilib', 'locale', 'en', 'Dsrt'), {recursive: true, force: true}); + + // Strip bulky files from en/ regional subdirs (keep only sysres, dateformats, list, localeinfo, plurals) + console.log('\n Removing non-essential files from en/ regional locale dirs...'); + deleteFiles(path.join('dist', 'node_modules', 'ilib', 'locale', 'en'), nonEngLocalefiles); + + // Remove unused font weights to reduce size + console.log('\n Removing unused font weights...'); + const fontFiles = ([ + 'MuseoSans-Thin.ttf', + 'MuseoSans-BlackItalic.ttf', + 'MuseoSans-BoldItalic.ttf', + 'MuseoSans-MediumItalic.ttf' + ]); + deleteFiles(path.join('dist', 'node_modules', '@enact', 'sandstone', 'fonts', 'MuseoSans'), fontFiles); + // Package into IPK console.log('\n Creating IPK package...'); fs.mkdirSync('build', {recursive: true});