proomt

Search

Search posts, papers, and topics

All posts

SitePoint14 min readtutorialintermediate

Fixing Server Component Bundle Leaks in Next.js with AST Linting

Summary

Server‑only code can silently inflate client bundles in Next.js 15+ apps. The article shows how to spot leaks with @next/bundle-analyzer, prevent them by removing shared barrel files or adding the `server-only` guard, and enforce a deny‑list of server modules via a custom ESLint rule that scans the AST of files with a `'use client'` directive. The rule is wired into a CI bundle‑budget check using…

  • A single transitive import from a client component pulls the whole server‑only module (e.g. @prisma/client) into the browser, adding ~180 KB per leak.
  • Barrel files (`utils/index.ts`) are the most common leak vector because they re‑export server utilities alongside client‑safe helpers.
  • Use `@next/bundle-analyzer` (Webpack only) to visualize unexpected node_modules in client chunks.
  • Add `import 'server-only'` to any server‑only file to cause a build‑time failure if it ends up in a client bundle.

Undetected server‑module leaks degrade Time to Interactive and LCP, waste bandwidth, and increase bundle size without any compile‑time warning. Early static detection (lint) and architectural isolation prevent performance regressions before they ship.

7/10

Related reading

  1. Next.js 16.3 support on Vercel

    Vercel added full support for Next.js 16.3, bringing leaner prefetching, immutable static assets, and faster route metadata handling. Early adopters see up to 45% fewer prefetches, 24% less static traffic, and roughly 2× faster routing at scale.

    Vercelvercel.com4 min
  2. App Hardening: One Obfuscation Pipeline Across Every Port

    Codename One adds a cloud‑side hardening step that runs on the merged JAR before it is split into Android, iOS, JavaScript, and desktop binaries. It can rename symbols, encrypt string literals, and insert opaque‑predicate control‑flow guards at configurable levels (off → standard → aggressive → paranoid). The transforms are selective per platform to avoid breaking optimizers, and a mapping is kep…

    CodeName Onecodenameone.com6 min
  3. Migrating the GitHub Copilot runtime to Rust, using Copilot

    The Copilot agent runtime was rewritten from a 130‑k‑line TypeScript/Node.js codebase into a native Rust library (~830 k lines of Rust) to reduce startup latency, memory use, and improve reliability. The migration was done incrementally (in‑place) across 128 PRs, with AI‑generated code handling most of the work. The new runtime exposes a C ABI for in‑process embedding by all six Copilot SDK langu…

    GitHub Oldgithub.blog65 minHN188
  4. Preventing Destructive Actions with Step-up Authentication

    A step‑by‑step tutorial showing how to protect a high‑impact admin action (resetting all scores) in a Next.js app with Auth0 by combining role checks and a fresh MFA step‑up flow, including helper utilities, session claim preservation, and a hardened API endpoint.

    Auth0auth0.com14 min