Initial work towards benchmarking bundle size over time
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
28
scripts/benchmark-bundle.ts
Executable file
28
scripts/benchmark-bundle.ts
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env -S yarn --silent tsx
|
||||
|
||||
import { glob } from "glob";
|
||||
import path from "node:path";
|
||||
import { stat } from "node:fs/promises";
|
||||
|
||||
async function main() {
|
||||
const cwd = path.join(__dirname, "..", "webapp");
|
||||
const jsfiles = await glob("**/*.js", { cwd });
|
||||
const sizes = await Promise.all(
|
||||
jsfiles.map(async (file) => {
|
||||
const data = await stat(path.join(cwd, file));
|
||||
return data.size;
|
||||
}),
|
||||
);
|
||||
|
||||
const totalBytes = sizes.reduce((acc, size) => acc + size, 0);
|
||||
|
||||
console.log([
|
||||
{
|
||||
name: "Total JS bundle size",
|
||||
unit: "Megabytes",
|
||||
value: totalBytes / 1024 / 1024,
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env -S npx ts-node
|
||||
#!/usr/bin/env -S yarn --silent tsx
|
||||
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
Reference in New Issue
Block a user