diff --git a/package.json b/package.json index 48a6a9b..481edd1 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "files": [ "bin/emglken.js", "build/*.js", + "build/*.json", "build/*.wasm", "src/*.js" ] diff --git a/src/build.sh b/src/build.sh index d76f5ee..490c447 100755 --- a/src/build.sh +++ b/src/build.sh @@ -15,4 +15,6 @@ docker run --rm -t \ /bin/bash -c " \\ emcmake cmake -DCMAKE_BUILD_TYPE=Release -S . -B build; \\ emmake make -j$(nproc) --no-print-directory -C build \\ - " \ No newline at end of file + " + +./tools/write-file-sizes.js \ No newline at end of file diff --git a/tools/write-file-sizes.js b/tools/write-file-sizes.js new file mode 100755 index 0000000..60a31c8 --- /dev/null +++ b/tools/write-file-sizes.js @@ -0,0 +1,18 @@ +#!/usr/bin/env node + +// Write build/file-sizes.json + +import * as fs from 'fs' +import {dirname, resolve} from 'path' +import {fileURLToPath} from 'url' + +const results = {}; + +const build_path = resolve(dirname(fileURLToPath(import.meta.url)), '../build') +for (const file of fs.readdirSync(build_path)) { + if (file.endsWith('.js') || file.endsWith('.wasm')) { + results[file] = fs.statSync(resolve(build_path, file)).size + } +} + +fs.writeFileSync(resolve(build_path, 'file-sizes.json'), JSON.stringify(results)) \ No newline at end of file