Packages renamed to the @uhhm scope (@uhhm/buuh, @uhhm/buuh-html, @uhhm/buuh-component, @uhhm/buuh-devtools, @uhhm/buuh-migrate, @uhhm/bankai). Scoping is load-bearing twice over: npm routes registries per scope so @uhhm/* resolves against project.uhhm.no while everything else stays on npmjs, and it means this fork never squats upstream's names anywhere. The codemod now migrates choo v7 apps to the @uhhm names. README rewritten with the fork framing and full upstream credit; the choojs RFC moves to docs/upstream-rfc-draft.md, in the drawer for if this work ever goes home. API unchanged — choo() is still choo(). Also: Gitea Actions CI + release workflows (npm publish to the uhhm registry on tag push, CDN bundle uploaded as a generic package), npm run bundle producing dist-cdn/buuh.js (the whole framework as one minified ES module for import-map use), docs/publishing.md explaining what Gitea Packages is (a real npm registry) and is not (a CDN — serve the bundle from a static host with module-safe MIME instead), and onload.js constructing window.MutationObserver to match its own guard (surfaced by smoke-testing the bundle outside a full browser). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014NgfSjHE11oFpoSnLVKLXd
65 lines
2.3 KiB
JavaScript
65 lines
2.3 KiB
JavaScript
// The size budget: what does the framework itself cost on the wire?
|
|
// Bundles @uhhm/buuh + @uhhm/buuh-html (browser condition) minified via
|
|
// the same Vite/Rolldown pipeline apps use, then reports min+gzip and
|
|
// min+brotli. CI fails if min+gzip exceeds the budget.
|
|
//
|
|
// npm run size
|
|
|
|
import { build } from 'vite'
|
|
import { readFile, readdir, rm, mkdtemp } from 'node:fs/promises'
|
|
import { join } from 'node:path'
|
|
import { tmpdir } from 'node:os'
|
|
import { gzipSync, brotliCompressSync, constants } from 'node:zlib'
|
|
|
|
// The promise the README makes; raise only with a paper trail.
|
|
// Context: v7's "4kb" was choo alone — nanohtml lived in the browserify
|
|
// transform. This number is the whole framework: core, html engine,
|
|
// morph, hydrate, router, bus. Currently ~7.97 kB gzip; the headroom is
|
|
// margin, not license.
|
|
const BUDGET_GZIP = 8.5 * 1024
|
|
|
|
const VIRTUAL = '\0size:entry'
|
|
|
|
const outDir = await mkdtemp(join(tmpdir(), 'choo-size-'))
|
|
await build({
|
|
appType: 'custom',
|
|
logLevel: 'error',
|
|
plugins: [{
|
|
name: 'size-entry',
|
|
resolveId: (id) => id === 'size:entry' ? VIRTUAL : undefined,
|
|
load: (id) => id === VIRTUAL
|
|
? "import choo, { Choo, lazy } from '@uhhm/buuh'\n" +
|
|
"import html from '@uhhm/buuh-html'\n" +
|
|
"import raw from '@uhhm/buuh-html/raw'\n" +
|
|
'window.__keep = { choo, Choo, lazy, html, raw }\n'
|
|
: undefined
|
|
}],
|
|
build: {
|
|
outDir,
|
|
emptyOutDir: true,
|
|
rollupOptions: { input: { framework: 'size:entry' } }
|
|
}
|
|
})
|
|
|
|
const assets = await readdir(join(outDir, 'assets'))
|
|
const file = assets.find((name) => name.endsWith('.js'))
|
|
const code = await readFile(join(outDir, 'assets', file))
|
|
await rm(outDir, { recursive: true, force: true })
|
|
|
|
const gz = gzipSync(code, { level: constants.Z_BEST_COMPRESSION }).length
|
|
const br = brotliCompressSync(code, {
|
|
params: { [constants.BROTLI_PARAM_QUALITY]: constants.BROTLI_MAX_QUALITY }
|
|
}).length
|
|
|
|
const kb = (n) => (n / 1024).toFixed(2) + ' kB'
|
|
console.log(`@uhhm/buuh + @uhhm/buuh-html (browser, minified)`)
|
|
console.log(` raw: ${kb(code.length)}`)
|
|
console.log(` gzip: ${kb(gz)} (budget ${kb(BUDGET_GZIP)})`)
|
|
console.log(` brotli: ${kb(br)}`)
|
|
|
|
if (gz > BUDGET_GZIP) {
|
|
console.error(`\nsize budget exceeded: ${kb(gz)} > ${kb(BUDGET_GZIP)} min+gzip`)
|
|
process.exit(1)
|
|
}
|
|
console.log('\nwithin budget ✔')
|