Skip to content

fix(build): skip unhelpful precompressed variants#2712

Open
Boyeep wants to merge 1 commit into
cloudflare:mainfrom
Boyeep:fix/precompress-beneficial-variants
Open

fix(build): skip unhelpful precompressed variants#2712
Boyeep wants to merge 1 commit into
cloudflare:mainfrom
Boyeep:fix/precompress-beneficial-variants

Conversation

@Boyeep

@Boyeep Boyeep commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

What changed

  • emit Brotli, gzip, and zstd variants independently only when smaller than identity
  • remove obsolete variants when content becomes incompressible or falls below the threshold
  • replace compressed files atomically
  • make the startup static cache reject oversized encoded variants as defense in depth

Why

Precompression previously wrote every encoding result regardless of size. High-entropy assets could therefore produce representations larger than the original, which the production server would still prefer during content negotiation. Reruns could also retain variants that were no longer useful.

Impact

Precompressed assets cannot increase transferred bytes, stale variants are cleaned up, and partially written variants are not exposed to the production server.

Validation

  • vp test run tests/precompress.test.ts tests/static-file-cache.test.ts
  • vp check packages/vinext/src/build/precompress.ts packages/vinext/src/server/static-file-cache.ts tests/precompress.test.ts tests/static-file-cache.test.ts

@pkg-pr-new

pkg-pr-new Bot commented Jul 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vinext/cloudflare@2712
npm i https://pkg.pr.new/create-vinext-app@2712
npm i https://pkg.pr.new/@vinext/types@2712
npm i https://pkg.pr.new/vinext@2712

commit: b1ebedd

@github-actions

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared b1ebedd against base 05eee9f using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 6 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 132.4 KB 132.4 KB ⚫ +0.0%
Client entry size (gzip) vinext 119.7 KB 119.7 KB ⚫ 0.0%
Dev server cold start vinext 2.79 s 2.81 s ⚫ +0.7%
Production build time vinext 2.95 s 2.93 s ⚫ -0.7%
RSC entry closure size (gzip) vinext 103.3 KB 103.3 KB ⚫ -0.0%
Server bundle size (gzip) vinext 177.8 KB 177.8 KB ⚫ -0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

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