fleet-trimming-bundle

Stub unused modules in built bundles to reduce size with rolldown.

125|42|Updated May 19, 2025
One-click install
npx skills add https://github.com/SocketDev/socket-mcp --skill fleet-trimming-bundle
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: fleet-trimming-bundle
Source: https://github.com/SocketDev/socket-mcp/tree/main/.agents/skills/fleet-trimming-bundle
Command: npx skills add https://github.com/SocketDev/socket-mcp --skill fleet-trimming-bundle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Iteratively stub heavyweight modules that the bundler statically pulls in but the runtime never reaches, shrinking the final bundle size after a build.

Core Features & Use Cases

  • Baseline dist measurement and heaviest-file analysis to identify dead-weight imports.
  • Phase-driven stub loop using rolldown and the fleet lib-stub to replace unused modules without breaking runtime.
  • Clear guidance on when to apply (post-migration, pre-release, or during bundle-size optimizations).

Quick Start

Run the trimming workflow on a repo with a built bundle to begin identifying and stubbing unused modules.

Frequently Asked Questions about fleet-trimming-bundle

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce bundle size by stubbing unused modules in a rolldown build?▼

Stubbing unused modules in a rolldown build replaces statically imported but runtime-unreached modules with lightweight stubs to shrink the final bundle. This process uses a phase-driven loop to ensure runtime correctness while reducing dead-weight imports.

What is the best way to trim dead-weight imports from a published JavaScript bundle?▼

Trimming dead-weight imports from a published JavaScript bundle involves measuring the baseline dist directory and analyzing the heaviest files. Stubbing these unused modules iteratively reduces the published artifact size without breaking runtime functionality.

Do I need a pristine dist directory and rolldown config to use bundle trimming?▼

Yes, bundle trimming requires a pristine dist directory and a valid .config/repo/rolldown.config.mts importing createLibStubPlugin from lib-stub.mts. The test suite must also pass to verify that stubbing unused modules does not break runtime correctness.

When should I apply bundle trimming to optimize JavaScript build performance?▼

Apply bundle trimming to optimize JavaScript build performance after a bundler migration, pre-release, or when bundle size grows. It targets repos that ship a built bundle and rely on rolldown to keep the published artifact lean.

Why does bundle trimming require passing the test suite after stubbing modules?▼

Bundle trimming requires passing the test suite after stubbing modules to verify correctness and ensure the runtime behavior remains intact. Replacing statically pulled-in modules with stubs risks breaking functionality if the runtime actually reaches those code paths.