ReviewOS

stacks/bun-router

fix(build): remove obsolete distribution files before rebuilding

#889
Closed chris opened this 8 days ago ·
8 days ago

Release artifact preparation for #888 found that repeated builds retain obsolete generated files in dist. The build writes new hashed chunks and declarations without clearing prior output, and the package includes the entire dist directory.

On the current checkout the packed artifact has thirteen chunk-*.js files, while a fresh equivalent JavaScript build emits only four chunks. Existing dist occupies about 2.5 MiB including declarations; the fresh JavaScript output is about 576 KiB. Those are different file sets, so use a fresh complete build and packed archive comparison for the final size result.

Fix the owned build output lifecycle at the build entrypoint. Remove obsolete generated JavaScript and declaration files before emitting the new output, keep the existing entrypoint import smoke checks, and verify a seeded stale chunk and stale declaration do not survive a successful rebuild. Do not filter obsolete names only at packaging time or leave a manual clean step for releasers.

This prevents old compiled code and unnecessary bytes from accumulating in the published dependency used by Stacks.

8 days ago

Pushed 79f8ae8. The build now verifies its package working directory before deleting the generated output, removes stale chunks/declarations before both emitters run, and fails explicitly when bundling fails. Existing emitted-entrypoint smoke checks remain.

The real rebuild regression first failed with the obsolete chunk still present, then passed. Review found the wrong-cwd deletion risk; a second regression reproduced that risk and now verifies an unrelated temporary directory's dist survives. Separate Standards and Spec reviews pass after that correction.

Final source validation: 547 runtime tests, both TypeScript projects and pickier lint pass. An isolated installation of the clean tarball passes both CLI aliases, root/container imports and 30 native/generic HTTP checks.

The accumulated local 0.1.12 archive contained 163 files / 13 hashed chunks and measured 564,685 bytes. The clean archive contains 154 files / 4 chunks and measures 280,793 bytes, with identical current entrypoint behavior. This compares local rebuild output with stale files, not the registry's previous release; a fresh CI checkout would not necessarily have the stale accumulation.

Release preparation is tracked in #888. No tag or registry publication was performed.

Sign in to comment on this issue.