handxr

bundle-import-auditor

Audit JavaScript/TypeScript imports for bundle size bloat, heavy dependencies with lighter alternatives, wildcard imports that break tree-shaking, barrel file re-exports, duplicate imports, code-splitting opportunities, and import hygiene issues. Use when reviewing frontend bundle size, debugging slow page loads, auditing import patterns, or when a user asks to check their imports, find heavy dependencies, optimize bundle size, detect tree-shaking blockers, or clean up import statements. Triggers on tasks involving .js/.jsx/.ts/.tsx/.mjs/.mts files with ES module imports or require() calls.

handxr 0 Updated 3mo ago
GitHub

Install

npx skillscat add handxr/bundle-import-auditor

Install via the SkillsCat registry.

SKILL.md

Bundle Import Auditor

Static analysis tool that scans JS/TS imports for patterns that bloat production bundles.

Running the Audit

# Single file
python3 scripts/bundle_import_auditor.py <file>

# Entire project
python3 scripts/bundle_import_auditor.py <directory>

# Include low-severity hints (deep imports, code-splitting opportunities)
python3 scripts/bundle_import_auditor.py <target> --strict

# Machine-readable JSON
python3 scripts/bundle_import_auditor.py <target> --json

No dependencies — uses only Python 3 standard library.

Detection Categories

Category Detects Severity
Heavy dependencies 20+ known packages with lighter alternatives (moment, lodash, jquery, axios, uuid...) Error (100KB+) / Warning
Tree-shaking blockers import * as X wildcards, barrel file re-exports Warning
Duplicate imports Same module imported multiple times in one file Warning
Code-splitting Route/page/modal components that could be lazy-loaded Info
Import hygiene Deep internal imports, heavy CSS frameworks Info
Lodash patterns Full lodash import vs per-function or lodash-es Error / Warning

Severity Levels

  • !! Error: Large impact (100KB+) or broken tree-shaking — fix immediately
  • !~ Warning: Moderate impact or suboptimal patterns — fix in hot paths
  • ~~ Info: Improvement opportunities (only shown with --strict)

Fix Priority

  1. Heavy dependencies — swap moment/lodash/jquery for modern alternatives (biggest wins)
  2. Lodash full imports — switch to per-function imports or lodash-es
  3. Wildcard imports — convert import * to named imports for tree-shaking
  4. Barrel files — import directly from source modules instead of index files
  5. Code-splitting — lazy-load route/page components

Detailed Rules

For complete detection rules, edge cases, and configuration tips, see references/bundle-rules.md.