Skip to content

build: fail the build on legacy Svelte components and clsx - #503

Merged
chhoumann merged 4 commits into
masterfrom
chore/size-guards
Oct 15, 2026
Merged

chhoumann merged 4 commits into
masterfrom
chore/size-guards

Conversation

@chhoumann

@chhoumann chhoumann commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Set runes: true in the Svelte compiler options and reject clsx code retained in the bundle. This guards the size wins from #501.

Verification

  • Node 22.23.2. npm run lint, npm run format:check, npm run typecheck, npm run build, npm run test (2,774 tests), npm run test:tooling (41 tests), npm run docs:build, and npm run size pass.
  • main.js is byte-identical to master 791912f. Both are 313,717 raw bytes and 101,332 gzip bytes at level 9. Both have SHA-256 d994a6ba6f1d8d681e9f366ef8f82cb48b1903c2f0ca655f25ce9da758d04787. No additional E2E run was needed.
  • Two deliberate violations each exit 1. A component using export let reports "Cannot use export let in runes mode". A dynamic class reports "main.js includes clsx" and directs the author to a class directive or string template. The tooling tests assert these failures and accept plain markup, string classes, and class directives.

Release impact

None. Plugin behavior and bundle bytes are unchanged.

Note

Add Vite plugin to guard Svelte bundle size and enable runes mode

  • Adds svelteSizeGuards in svelte-size-guards.ts, a Vite plugin that fails a build when an emitted chunk contains a non-empty clsx module. Chunks where clsx renders to zero length are allowed.
  • Registers the plugin in vite.config.ts and turns on Svelte runes compilation.
  • Adds acceptance and rejection tests in svelteSizeGuards.test.ts covering plain components, class directives, legacy prop syntax, and retained clsx imports.
  • Risk: production builds now fail whenever clsx survives tree-shaking in any chunk; check components using dynamic class expressions.

Macroscope summarized 7b3198d.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Deploying podnotes with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7b3198d
Status: ✅  Deploy successful!
Preview URL: https://add8d043.podnotes.pages.dev
Branch Preview URL: https://chore-size-guards.podnotes.pages.dev

View logs

@chhoumann chhoumann changed the title chore: guard Svelte bundle size and tidy size follow-ups chore: guard Svelte bundle size Oct 15, 2026
@chhoumann chhoumann changed the title chore: guard Svelte bundle size build: fail the build on legacy Svelte components and clsx Oct 15, 2026
@chhoumann
chhoumann merged commit 36a6fc3 into master Oct 15, 2026
21 checks passed
@chhoumann
chhoumann deleted the chore/size-guards branch October 15, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant