3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-21 07:32:58 +01:00

Measure each package as a namespace so default exports count, add the loaded JavaScript to the WebAssembly row, drop the growth claim

This commit is contained in:
2026-11-15 13:57:35 +01:00
committed by Lillem4n
parent d3832a85b6
commit 14b5680304
5 changed files with 24 additions and 9 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ import { gzipSync } from "node:zlib";
const bytesPerKilobyte = 1000;
// A namespace export keeps default exports and same-named exports, which a star re-export drops.
// What a consumer's bundler ships for the whole of the packages: their code and dependencies, minified, gzipped.
export const minifiedGzippedBytes = async (resolveDir, specifiers) => {
const { outputFiles } = await build({
@@ -12,7 +13,7 @@ export const minifiedGzippedBytes = async (resolveDir, specifiers) => {
logLevel: "silent",
minify: true,
platform: "node",
stdin: { contents: specifiers.map((specifier) => `export * from ${JSON.stringify(specifier)};`).join("\n"), resolveDir },
stdin: { contents: specifiers.map((specifier, i) => `import * as m${i} from ${JSON.stringify(specifier)}; export { m${i} };`).join("\n"), resolveDir },
write: false,
});
return gzipSync(outputFiles[0].contents, { level: 9 }).length;