* refactor(agents): move prescriptive content from knowledge-base to rules - Create architecture-page-level-auth.md for Next.js auth checks - Create data-prefer-select-over-include.md for Prisma query optimization - Create performance-dayjs-usage.md for Day.js performance guidelines - Create quality-avoid-barrel-imports.md for import best practices - Update knowledge-base.md to reference rules directory - Remove duplicated prescriptive content from knowledge-base.md Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * chore(agents): remove redundant rules reference from knowledge-base Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * docs: add agents/rules reference to AGENTS.md extended documentation Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
36 lines
1.0 KiB
Markdown
36 lines
1.0 KiB
Markdown
---
|
|
title: Avoid Barrel Imports
|
|
impact: MEDIUM
|
|
impactDescription: Improves tree-shaking and reduces bundle size
|
|
tags: imports, performance, bundling
|
|
---
|
|
|
|
## Avoid Barrel Imports
|
|
|
|
**Impact: MEDIUM (Improves tree-shaking and reduces bundle size)**
|
|
|
|
Barrel files (index.ts that re-export from multiple modules) can hurt tree-shaking and increase bundle sizes. Import directly from source files instead.
|
|
|
|
**Incorrect (importing from barrel files):**
|
|
|
|
```typescript
|
|
// Importing from index.ts barrel files
|
|
import { BookingService, UserService } from "./services";
|
|
|
|
// Importing from @calcom/ui barrel
|
|
import { Button } from "@calcom/ui";
|
|
```
|
|
|
|
**Correct (importing directly from source):**
|
|
|
|
```typescript
|
|
// Import directly from source files
|
|
import { BookingService } from "./services/BookingService";
|
|
import { UserService } from "./services/UserService";
|
|
|
|
// Import directly from component path
|
|
import { Button } from "@calcom/ui/components/button";
|
|
```
|
|
|
|
Reference: [Cal.com Engineering Standards](https://cal.com/blog/engineering-in-2026-and-beyond)
|