@@ -22,6 +22,8 @@ yarn add kr-corekit
2222
2323## Usage
2424
25+ ### Full Import (All utilities)
26+
2527``` typescript
2628import {
2729 stringUtil ,
@@ -90,6 +92,33 @@ const theme = cookieUtil.getCookie("theme");
9092const 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