Skip to content

Commit 2054d34

Browse files
authored
Merge pull request #17 from avixiii-dev/develop
Develop
2 parents 7831616 + ccd33d6 commit 2054d34

File tree

8 files changed

+577
-194
lines changed

8 files changed

+577
-194
lines changed

README.md

+62-186
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,27 @@ A powerful and flexible tool to track and analyze JavaScript bundle sizes across
4848
- Historical trend analysis
4949
- Size comparison across builds
5050

51-
### Performance Features ⚡️
52-
- Preact compatibility layer for React apps
53-
- Optimized chunk splitting strategies
54-
- Advanced tree shaking configuration
55-
- Styled-components optimization
56-
- Dynamic imports and code splitting
57-
- Bundle size reduction up to 50%
51+
### Real User Monitoring 📈 (New in v0.1.4)
52+
- Track real-world performance metrics:
53+
- Load time
54+
- First Contentful Paint (FCP)
55+
- Largest Contentful Paint (LCP)
56+
- First Input Delay (FID)
57+
- Cumulative Layout Shift (CLS)
58+
- Time to Interactive (TTI)
59+
- Total Blocking Time (TBT)
60+
- Device and network analysis:
61+
- Device type detection
62+
- Network connection speed
63+
- Hardware capabilities
64+
- Performance recommendations:
65+
- Automated performance insights
66+
- Device-specific optimizations
67+
- Network-based suggestions
68+
- Customizable data collection:
69+
- Configurable sampling rate
70+
- Pattern-based URL filtering
71+
- Custom endpoint support
5872

5973
## Installation
6074

@@ -87,6 +101,12 @@ module.exports = {
87101
totalSizeIncreaseThreshold: 10, // 10% increase warning
88102
maxTotalSize: 5 * 1024 * 1024 // 5MB limit
89103
}
104+
},
105+
rum: {
106+
enabled: true,
107+
sampleRate: 0.1, // Sample 10% of users
108+
endpoint: '/api/rum', // Optional custom endpoint
109+
excludePatterns: ['/api/*', '/static/*'] // Optional URL patterns to exclude
90110
}
91111
})
92112
]
@@ -110,6 +130,10 @@ export default {
110130
thresholds: {
111131
chunkSizeIncreaseThreshold: 15 // 15% chunk size increase warning
112132
}
133+
},
134+
rum: {
135+
enabled: true,
136+
sampleRate: 0.5 // Sample 50% of users
113137
}
114138
})
115139
]
@@ -129,6 +153,11 @@ export default {
129153
history: {
130154
enabled: true,
131155
exportPath: './bundle-history'
156+
},
157+
rum: {
158+
enabled: true,
159+
sampleRate: 1, // Monitor all users
160+
excludePatterns: ['/admin/*'] // Exclude admin pages
132161
}
133162
})
134163
]
@@ -148,6 +177,15 @@ export default {
148177
| `history.thresholds.maxTotalSize` | number | `5242880` | Maximum allowed total size in bytes (5MB) |
149178
| `history.thresholds.maxChunkSize` | number | `2097152` | Maximum allowed chunk size in bytes (2MB) |
150179

180+
### RUM Configuration
181+
182+
| Option | Type | Default | Description |
183+
|--------|------|---------|-------------|
184+
| `rum.enabled` | boolean | `false` | Enable Real User Monitoring |
185+
| `rum.sampleRate` | number | `1` | Percentage of users to monitor (0 to 1) |
186+
| `rum.endpoint` | string | undefined | Custom endpoint for sending RUM data |
187+
| `rum.excludePatterns` | string[] | `[]` | URL patterns to exclude from monitoring |
188+
151189
### AI Configuration
152190

153191
| Option | Type | Default | Description |
@@ -194,192 +232,30 @@ You can set specific size limits for different bundles:
194232
```
195233
Bundle Size Report
196234
197-
Generated: 2025-01-02T04:12:22.777Z
235+
Generated: 2025-01-13T15:52:18+07:00
198236
Status: PASS
199237
Total Size: 264.09 KB
200238
201239
main.js
202-
Size: 58.94 KB
203-
Limit: 400KB
204-
Status: Within limit
240+
Raw: 120.5 KB
241+
Gzip: 45.2 KB
242+
Brotli: 40.1 KB
243+
Status: PASS
205244
206245
vendor.js
207-
Size: 204.58 KB
208-
Limit: 400KB
209-
Status: Within limit
210-
211-
AI Suggestions:
212-
- Split vendor chunks for better caching
213-
- Remove unused moment.js locales
214-
- Implement dynamic imports for route components
215-
```
216-
217-
### HTML Report Features
218-
- Visual representation of bundle sizes
219-
- Size trends over time
220-
- AI optimization suggestions
221-
- Interactive charts and graphs
222-
- Detailed bundle breakdown
223-
- Color-coding for bundles exceeding limits
224-
- Performance metrics and trends
225-
- Dependency analysis visualization
226-
227-
### JSON Report Example
228-
```json
229-
{
230-
"timestamp": "2025-01-02T04:12:13.436Z",
231-
"bundles": [
232-
{
233-
"name": "main.js",
234-
"size": 169160,
235-
"exceedsLimit": false,
236-
"sizeLimit": 300,
237-
"compression": {
238-
"gzip": 45200,
239-
"brotli": 40100
240-
}
241-
}
242-
],
243-
"status": "pass",
244-
"totalSize": 169160,
245-
"aiSuggestions": [
246-
"Split vendor chunks for better caching",
247-
"Remove unused exports",
248-
"Use dynamic imports for routes"
249-
],
250-
"performance": {
251-
"loadTime": "1.2s",
252-
"firstContentfulPaint": "0.8s"
253-
}
254-
}
255-
```
256-
257-
## Test Project
258-
259-
The repository includes a test project that demonstrates all features:
260-
261-
```bash
262-
cd test-projects/ai-test
263-
npm install
264-
npm run build
265-
```
266-
267-
The test project showcases:
268-
- React/Preact compatibility
269-
- MUI components optimization
270-
- Dynamic imports
271-
- Tree shaking
272-
- Code splitting
273-
- Bundle size optimization
274-
- AI-powered suggestions
275-
- Custom rules implementation
276-
- Multiple output formats
277-
278-
## Contributing
279-
280-
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
281-
282-
1. Fork the repository
283-
2. Create your feature branch
284-
3. Commit your changes
285-
4. Push to the branch
286-
5. Create a Pull Request
287-
288-
### Development Setup
289-
290-
```bash
291-
# Clone the repository
292-
git clone https://github.com/avixiii-dev/bundle-size-tracker.git
293-
294-
# Install dependencies
295-
npm install
296-
297-
# Build
298-
npm run build
299-
300-
# Run tests
301-
npm test
302-
303-
# Run tests with coverage
304-
npm test -- --coverage
305-
306-
# Run linter
307-
npm run lint
308-
309-
# Generate documentation
310-
npm run docs
246+
Raw: 143.59 KB
247+
Gzip: 52.8 KB
248+
Brotli: 48.3 KB
249+
Status: PASS
250+
251+
Performance Metrics (RUM):
252+
Load Time (median): 1.2s
253+
First Contentful Paint: 0.8s
254+
Largest Contentful Paint: 2.1s
255+
First Input Delay: 45ms
256+
Cumulative Layout Shift: 0.05
311257
```
312258

313-
### Running Tests
314-
315-
```bash
316-
# Run all tests
317-
npm test
318-
319-
# Run specific test
320-
npm test -- -t "test name"
321-
322-
# Watch mode
323-
npm test -- --watch
324-
325-
# Coverage report
326-
npm test -- --coverage
327-
```
328-
329-
## Changelog
330-
331-
### v0.1.3 (2025-01-02)
332-
- Added history tracking feature
333-
- Added alerts for total size increases and chunk size changes
334-
- Improved HTML reports with interactive charts
335-
- Enhanced AI-powered optimization suggestions
336-
- Added new CLI options for history and alerts
337-
- Improved error handling and reporting
338-
- Updated dependencies to latest versions
339-
340-
### v0.1.2 (2025-01-02)
341-
- Added AI-powered bundle analysis
342-
- Added Preact compatibility layer
343-
- Improved code splitting strategies
344-
- Added styled-components optimization
345-
- Added tree shaking improvements
346-
- Added test project with optimization examples
347-
- Reduced bundle sizes by up to 50%
348-
- Enhanced HTML reports with interactive features
349-
- Added new CLI options for AI analysis
350-
- Improved error handling and reporting
351-
- Added TypeScript type definitions
352-
- Updated dependencies to latest versions
353-
354-
### v0.1.1
355-
- Initial release
356-
- Basic bundle size tracking
357-
- Size limits and warnings
358-
- Compression format support
359-
- Basic reporting features
360-
- Command-line interface
361-
- Configuration options
362-
- Documentation
363-
364-
## Support
365-
366-
- Create an [Issue](https://github.com/avixiii-dev/bundle-size-tracker/issues) for bug reports and feature requests
367-
- Star the project if you find it useful
368-
- Follow [@avixiii-dev](https://github.com/avixiii-dev) for updates
369-
<!-- - Join our [Discord community](https://discord.gg/bundlesize) for help -->
370-
<!-- - Read our [blog posts](https://dev.to/avixiii) for tips and tutorials -->
371-
372-
## Security
373-
374-
Please report security vulnerabilities to [email protected]. We take security seriously and will respond promptly.
375-
376259
## License
377260

378-
MIT [Tuan](https://github.com/avixiii-dev)
379-
380-
See [LICENSE](LICENSE) for more details.
381-
382-
<!-- ## Acknowledgments
383-
384-
- Thanks to all contributors
385-
- Inspired by [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) -->
261+
MIT [avixiii](https://github.com/avixiii-dev)

package-lock.json

+14-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@avixiii/bundle-size-tracker",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "A powerful tool to track and optimize your JavaScript bundle sizes with AI-powered suggestions",
55
"type": "module",
66
"main": "dist/index.js",
@@ -68,8 +68,9 @@
6868
},
6969
"devDependencies": {
7070
"@types/jest": "^29.5.14",
71-
"@types/node": "^20.10.5",
71+
"@types/node": "^20.17.12",
7272
"@types/rollup": "^0.54.0",
73+
"@types/web": "^0.0.193",
7374
"@typescript-eslint/eslint-plugin": "^6.15.0",
7475
"@typescript-eslint/parser": "^6.15.0",
7576
"eslint": "^8.56.0",

0 commit comments

Comments
 (0)