trimming-bundle

Analyze built JavaScript bundles to detect and stub unused code paths.

56|20|Updated Aug 26, 2022
One-click install
npx skills add https://github.com/SocketDev/socket-sdk-js --skill trimming-bundle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: trimming-bundle
Source: https://github.com/SocketDev/socket-sdk-js/tree/main/.claude/skills/trimming-bundle
Command: npx skills add https://github.com/SocketDev/socket-sdk-js --skill trimming-bundle

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires node, pnpm, and includes references (resource) components.

What problem does it solve?

This Skill helps developers identify and eliminate unused code in their bundled JavaScript files, optimizing performance and reducing package size.

Core Features & Use Cases

  • Unused Code Detection: Analyzes built bundles to find code paths that are loaded but never executed.
  • Iterative Stubbing: Replaces heavy or dead modules with stub implementations to streamline the bundle.
  • Use Case: When releasing an npm package, reduce its size by removing large, unused dependencies and code paths, ensuring faster load times.

Quick Start

Use the trimming-bundle skill after building your project to analyze dist/ and iteratively stub unused modules, then rebuild and test to verify improvements.

Frequently Asked Questions about trimming-bundle

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

FAQPage Schema
How do I remove unused code paths from a JavaScript bundle?

To remove unused code paths from a JavaScript bundle, analyze your built dist files to identify loaded but unexecuted modules, then iteratively stub or eliminate those dead-code paths and rebuild to verify size reduction.

What is stubbing dependencies and how does it reduce bundle size?

Stubbing dependencies replaces heavy or unused modules with lightweight implementations to reduce bundle size. This streamlines the final package by eliminating dead-code paths while ensuring dependencies are safely stubbed without breaking runtime behavior.

Does this bundle optimization approach work with Node and pnpm?

Yes, this bundle optimization approach works with Node and pnpm environments. It analyzes built JavaScript bundles to find dead-code paths, ensuring dependencies are safely stubbed without breaking runtime behavior during package size audits.

When do I need to perform a bundle size audit for npm package releases?

You need to perform a bundle size audit when releasing an npm package to ensure faster load times. This process identifies unused code paths and large dependencies in your built files, allowing you to iteratively stub them for optimization.

What is the best way to safely eliminate dead-code in bundled JavaScript?

The best way to safely eliminate dead-code in bundled JavaScript is to analyze the built dist directory, identify unexecuted code paths, and replace heavy modules with stubs iteratively. Rebuild and test after each stubbing step to verify runtime behavior.