Skip to content

Commit 8c2e70f

Browse files
authored
Merge pull request #54 from klmhyeonwoo/copilot/fix-070ade3d-1f2a-44ed-972b-2d533af70514
Package size optimization: Added support for tree-shaking and fixed missing utility modules.
2 parents b7f0a28 + a04a2dd commit 8c2e70f

8 files changed

Lines changed: 3190 additions & 148 deletions

File tree

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ yarn add kr-corekit
2222

2323
## Usage
2424

25+
### Full Import (All utilities)
26+
2527
```typescript
2628
import {
2729
stringUtil,
@@ -90,6 +92,33 @@ const theme = cookieUtil.getCookie("theme");
9092
const formattedPhone = formatUtil.formatPhoneNumber("01012345678"); // "010-1234-5678"
9193
```
9294

95+
### Tree-Shaking Optimized Import (Recommended)
96+
97+
For optimal bundle size, import only the functions you need:
98+
99+
```typescript
100+
// Option 1: Import specific functions (best tree-shaking)
101+
import { escapeHtml, unescapeHtml } from "kr-corekit";
102+
import { sum, multiply } from "kr-corekit";
103+
import { clearNullProperties, deepFreeze } from "kr-corekit";
104+
105+
// Option 2: Import from specific utility modules (good tree-shaking)
106+
import { escapeHtml } from "kr-corekit/stringUtil";
107+
import { sum } from "kr-corekit/numberUtil";
108+
import { clearNullProperties } from "kr-corekit/objectUtil";
109+
110+
// Usage remains the same
111+
const escaped = escapeHtml("<div>Hello</div>");
112+
const total = sum(1, 2, 3, 4, 5);
113+
const cleaned = clearNullProperties({ a: 1, b: null, c: 3 });
114+
```
115+
116+
### Bundle Size Comparison
117+
118+
- **Full import**: ~8.3KB (2.9KB gzipped)
119+
- **Tree-shaken import**: Only includes functions you use
120+
- **Individual module import**: Further optimized for specific utilities
121+
93122
## API Reference
94123

95124
### StringUtil

0 commit comments

Comments
 (0)