Skip to content

Commit

Permalink
Write the VM file sizes to build/file-sizes.json, for potential use i…
Browse files Browse the repository at this point in the history
…n Parchment
  • Loading branch information
curiousdannii committed Feb 12, 2024
1 parent af5a353 commit 9e6374e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"files": [
"bin/emglken.js",
"build/*.js",
"build/*.json",
"build/*.wasm",
"src/*.js"
]
Expand Down
4 changes: 3 additions & 1 deletion src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \\
"
"

./tools/write-file-sizes.js
18 changes: 18 additions & 0 deletions tools/write-file-sizes.js
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 9e6374e

Please sign in to comment.