Skip to content

Commit

Permalink
Change file-sizes.json to only have .wasm files, but to also have the…
Browse files Browse the repository at this point in the history
… gzipped size
  • Loading branch information
curiousdannii committed Dec 12, 2024
1 parent c5642b9 commit ba9b1f4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion remglk
22 changes: 15 additions & 7 deletions tools/write-file-sizes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,26 @@
import * as fs from 'fs'
import {dirname, resolve} from 'path'
import {fileURLToPath} from 'url'
import {gzipSync} from 'zlib'

const results = {
files: {},
files_gz: {},
};
const results = {};

function add_file(name, path) {
const data = fs.readFileSync(path)
const data_gz = gzipSync(data)
results[name] = {
size: data.length,
gz: data_gz.length,
}
}

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.files[file] = fs.statSync(resolve(build_path, file)).size
// TODO: gzipped size
if (file.endsWith('.wasm')) {
add_file(file, resolve(build_path, file))
}
}

add_file('glkaudio_bg.wasm', resolve(build_path, '../asyncglk/src/glkaudio/pkg/glkaudio_bg.wasm'))

fs.writeFileSync(resolve(build_path, 'file-sizes.json'), JSON.stringify(results))

0 comments on commit ba9b1f4

Please sign in to comment.