avoid-barrel-file-imports

Replace barrel file imports with direct module imports to reduce bundle size.

Updated Feb 10, 2026
One-click install
npx skills add https://github.com/ihj04982/my-cursor-settings --skill avoid-barrel-file-imports
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: avoid-barrel-file-imports
Source: https://github.com/ihj04982/my-cursor-settings/tree/main/skills/avoid-barrel-file-imports
Command: npx skills add https://github.com/ihj04982/my-cursor-settings --skill avoid-barrel-file-imports

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the performance degradation caused by importing entire libraries through barrel files, which can lead to significant increases in bundle size and slower application load times.

Core Features & Use Cases

  • Direct Imports: Replaces barrel file imports with direct imports from individual module files.
  • Performance Improvement: Significantly reduces initial load times, build times, and cold start performance.
  • Use Case: Refactor a project to import specific components like Button and TextField directly from @mui/material/Button and @mui/material/TextField instead of @mui/material.

Quick Start

Refactor the imports in the current project to use direct imports from source files instead of barrel files.

Frequently Asked Questions about avoid-barrel-file-imports

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

FAQPage Schema
Why do barrel file imports increase bundle size in JavaScript applications?

To optimize barrel file imports, replace them with direct imports from individual source files. For example, import from `@mui/material/Button` instead of `@mui/material` to ensure effective tree-shaking and reduce bundle size.

How do I refactor barrel file imports to direct imports in TypeScript?

To optimize barrel file imports, replace them with direct imports from individual source files. For example, import from `@mui/material/Button` instead of `@mui/material` to ensure effective tree-shaking and reduce bundle size.

What is tree-shaking and how does it relate to barrel files?

Yes, this refactoring targets large component and icon libraries like MUI. Replacing their barrel file imports with direct module referencing significantly reduces cold start performance issues and build times.

Does replacing barrel file imports improve cold start performance for large component libraries?

Yes, this refactoring targets large component and icon libraries like MUI. Replacing their barrel file imports with direct module referencing significantly reduces cold start performance issues and build times.

When should I avoid using barrel files for module exports?

Avoid barrel files when an application imports from large libraries suffering from slow load times. Excessive module re-exports in these files prevent effective tree-shaking, so direct imports are needed to reduce bundle size.