@coherent.js/performance 1.0.0-beta.3 → 1.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +505 -0
- package/package.json +3 -2
- package/types/index.d.ts +426 -29
package/README.md
ADDED
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
# @coherent.js/performance
|
|
2
|
+
|
|
3
|
+
Performance monitoring and optimization utilities for Coherent.js applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @coherent.js/performance
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @coherent.js/performance
|
|
11
|
+
# or
|
|
12
|
+
yarn add @coherent.js/performance
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
The `@coherent.js/performance` package provides comprehensive performance monitoring and optimization tools for Coherent.js applications, including:
|
|
18
|
+
|
|
19
|
+
- Real-time performance monitoring
|
|
20
|
+
- Rendering performance metrics
|
|
21
|
+
- Memory usage tracking
|
|
22
|
+
- Bundle size analysis
|
|
23
|
+
- Performance bottlenecks detection
|
|
24
|
+
- Optimization recommendations
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
import { createPerformanceMonitor } from '@coherent.js/performance';
|
|
30
|
+
|
|
31
|
+
// Create performance monitor
|
|
32
|
+
const monitor = createPerformanceMonitor({
|
|
33
|
+
// Optional configuration
|
|
34
|
+
logLevel: 'info',
|
|
35
|
+
sampleRate: 1.0, // Monitor all renders
|
|
36
|
+
thresholds: {
|
|
37
|
+
render: 50, // Warn if render takes >50ms
|
|
38
|
+
memory: 100 // Warn if memory usage >100MB
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Start monitoring
|
|
43
|
+
monitor.start();
|
|
44
|
+
|
|
45
|
+
// Your Coherent.js application
|
|
46
|
+
function App() {
|
|
47
|
+
return {
|
|
48
|
+
div: {
|
|
49
|
+
children: [
|
|
50
|
+
{ h1: { text: 'Performance Monitored App' } },
|
|
51
|
+
{ p: { text: 'Performance data is being collected...' } }
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Stop monitoring when needed
|
|
58
|
+
// monitor.stop();
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Features
|
|
62
|
+
|
|
63
|
+
### Real-time Monitoring
|
|
64
|
+
|
|
65
|
+
Monitor application performance in real-time:
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
import { createPerformanceMonitor } from '@coherent.js/performance';
|
|
69
|
+
|
|
70
|
+
const monitor = createPerformanceMonitor({
|
|
71
|
+
onMetrics: (metrics) => {
|
|
72
|
+
// Handle metrics in real-time
|
|
73
|
+
console.log('Render time:', metrics.renderTime, 'ms');
|
|
74
|
+
console.log('Memory usage:', metrics.memoryUsage, 'MB');
|
|
75
|
+
|
|
76
|
+
// Send to analytics
|
|
77
|
+
sendToAnalytics('performance', metrics);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
monitor.start();
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Rendering Performance
|
|
85
|
+
|
|
86
|
+
Track component rendering performance:
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
import { withPerformance } from '@coherent.js/performance';
|
|
90
|
+
|
|
91
|
+
const OptimizedComponent = withPerformance({
|
|
92
|
+
name: 'UserProfile',
|
|
93
|
+
threshold: 30 // Warn if rendering takes >30ms
|
|
94
|
+
})(function UserProfile({ user }) {
|
|
95
|
+
return {
|
|
96
|
+
div: {
|
|
97
|
+
className: 'user-profile',
|
|
98
|
+
children: [
|
|
99
|
+
{ img: { src: user.avatar, alt: user.name } },
|
|
100
|
+
{ h2: { text: user.name } },
|
|
101
|
+
{ p: { text: user.bio } }
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Memory Tracking
|
|
109
|
+
|
|
110
|
+
Monitor memory usage patterns:
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
import { createMemoryTracker } from '@coherent.js/performance';
|
|
114
|
+
|
|
115
|
+
const memoryTracker = createMemoryTracker({
|
|
116
|
+
interval: 5000, // Check every 5 seconds
|
|
117
|
+
onWarning: (usage) => {
|
|
118
|
+
console.warn('High memory usage detected:', usage);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
memoryTracker.start();
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Performance Metrics
|
|
126
|
+
|
|
127
|
+
### Core Metrics
|
|
128
|
+
|
|
129
|
+
Track essential performance metrics:
|
|
130
|
+
|
|
131
|
+
```javascript
|
|
132
|
+
const monitor = createPerformanceMonitor({
|
|
133
|
+
metrics: {
|
|
134
|
+
renderTime: true, // Component render time
|
|
135
|
+
totalTime: true, // Total render time
|
|
136
|
+
memoryUsage: true, // Memory consumption
|
|
137
|
+
gcEvents: true, // Garbage collection events
|
|
138
|
+
eventLoopDelay: true, // Event loop delay
|
|
139
|
+
bundleSize: true // Bundle size analysis
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Custom Metrics
|
|
145
|
+
|
|
146
|
+
Define custom performance metrics:
|
|
147
|
+
|
|
148
|
+
```javascript
|
|
149
|
+
const monitor = createPerformanceMonitor({
|
|
150
|
+
customMetrics: {
|
|
151
|
+
databaseQueries: () => getQueryCount(),
|
|
152
|
+
apiCalls: () => getApiCallCount(),
|
|
153
|
+
cacheHits: () => getCacheHitRate()
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Configuration Options
|
|
159
|
+
|
|
160
|
+
### Thresholds
|
|
161
|
+
|
|
162
|
+
Set performance thresholds for alerts:
|
|
163
|
+
|
|
164
|
+
```javascript
|
|
165
|
+
const monitor = createPerformanceMonitor({
|
|
166
|
+
thresholds: {
|
|
167
|
+
renderTime: 50, // ms
|
|
168
|
+
totalTime: 200, // ms
|
|
169
|
+
memoryUsage: 150, // MB
|
|
170
|
+
eventLoopDelay: 20, // ms
|
|
171
|
+
bundleSize: 500 // KB
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Sampling
|
|
177
|
+
|
|
178
|
+
Control monitoring sampling rate:
|
|
179
|
+
|
|
180
|
+
```javascript
|
|
181
|
+
const monitor = createPerformanceMonitor({
|
|
182
|
+
sampleRate: 0.1, // Only monitor 10% of renders
|
|
183
|
+
sampleStrategy: 'random' // or 'first' or 'last'
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Logging
|
|
188
|
+
|
|
189
|
+
Configure logging behavior:
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
const monitor = createPerformanceMonitor({
|
|
193
|
+
logLevel: 'warn', // 'debug', 'info', 'warn', 'error'
|
|
194
|
+
logFormat: 'json', // or 'text'
|
|
195
|
+
logDestination: 'console' // or 'file' or custom function
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Performance Optimization
|
|
200
|
+
|
|
201
|
+
### Bundle Analysis
|
|
202
|
+
|
|
203
|
+
Analyze and optimize bundle size:
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
import { analyzeBundle } from '@coherent.js/performance';
|
|
207
|
+
|
|
208
|
+
// Analyze your application bundle
|
|
209
|
+
const bundleAnalysis = await analyzeBundle({
|
|
210
|
+
entryPoints: ['./src/index.js'],
|
|
211
|
+
outputDir: './dist'
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
console.log('Bundle size:', bundleAnalysis.totalSize);
|
|
215
|
+
console.log('Largest modules:', bundleAnalysis.largestModules);
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Code Splitting Recommendations
|
|
219
|
+
|
|
220
|
+
Get code splitting recommendations:
|
|
221
|
+
|
|
222
|
+
```javascript
|
|
223
|
+
import { getCodeSplittingRecommendations } from '@coherent.js/performance';
|
|
224
|
+
|
|
225
|
+
const recommendations = getCodeSplittingRecommendations({
|
|
226
|
+
componentUsage: getComponentUsageData(),
|
|
227
|
+
routePatterns: getRoutePatterns()
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
recommendations.forEach(rec => {
|
|
231
|
+
console.log(`Split ${rec.component} into separate bundle`);
|
|
232
|
+
});
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Advanced Features
|
|
236
|
+
|
|
237
|
+
### Profiling
|
|
238
|
+
|
|
239
|
+
Detailed performance profiling:
|
|
240
|
+
|
|
241
|
+
```javascript
|
|
242
|
+
import { createProfiler } from '@coherent.js/performance';
|
|
243
|
+
|
|
244
|
+
const profiler = createProfiler({
|
|
245
|
+
detailLevel: 'high', // 'low', 'medium', 'high'
|
|
246
|
+
outputFormat: 'json' // or 'html'
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// Profile a specific operation
|
|
250
|
+
profiler.profile('render-dashboard', () => {
|
|
251
|
+
return renderDashboard(data);
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Comparison Reports
|
|
256
|
+
|
|
257
|
+
Generate performance comparison reports:
|
|
258
|
+
|
|
259
|
+
```javascript
|
|
260
|
+
import { createComparisonReport } from '@coherent.js/performance';
|
|
261
|
+
|
|
262
|
+
const beforeMetrics = getMetricsBeforeOptimization();
|
|
263
|
+
const afterMetrics = getMetricsAfterOptimization();
|
|
264
|
+
|
|
265
|
+
const report = createComparisonReport({
|
|
266
|
+
before: beforeMetrics,
|
|
267
|
+
after: afterMetrics,
|
|
268
|
+
improvementsOnly: true
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
console.log(report.summary);
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Integration with Monitoring Services
|
|
275
|
+
|
|
276
|
+
Integrate with external monitoring services:
|
|
277
|
+
|
|
278
|
+
```javascript
|
|
279
|
+
const monitor = createPerformanceMonitor({
|
|
280
|
+
integrations: {
|
|
281
|
+
newRelic: {
|
|
282
|
+
apiKey: process.env.NEW_RELIC_API_KEY,
|
|
283
|
+
accountId: process.env.NEW_RELIC_ACCOUNT_ID
|
|
284
|
+
},
|
|
285
|
+
datadog: {
|
|
286
|
+
apiKey: process.env.DATADOG_API_KEY,
|
|
287
|
+
site: 'datadoghq.com'
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## API Reference
|
|
294
|
+
|
|
295
|
+
### createPerformanceMonitor(options)
|
|
296
|
+
|
|
297
|
+
Create a new performance monitor instance.
|
|
298
|
+
|
|
299
|
+
**Parameters:**
|
|
300
|
+
- `options.logLevel` - Logging level ('debug', 'info', 'warn', 'error')
|
|
301
|
+
- `options.sampleRate` - Sampling rate (0.0 to 1.0)
|
|
302
|
+
- `options.thresholds` - Performance thresholds for alerts
|
|
303
|
+
- `options.metrics` - Which metrics to collect
|
|
304
|
+
- `options.onMetrics` - Callback for real-time metrics
|
|
305
|
+
|
|
306
|
+
**Returns:** Performance monitor instance
|
|
307
|
+
|
|
308
|
+
### withPerformance(options)
|
|
309
|
+
|
|
310
|
+
Higher-order component for performance monitoring.
|
|
311
|
+
|
|
312
|
+
**Parameters:**
|
|
313
|
+
- `options.name` - Component name for tracking
|
|
314
|
+
- `options.threshold` - Performance threshold in ms
|
|
315
|
+
- `options.onRender` - Callback after each render
|
|
316
|
+
|
|
317
|
+
**Returns:** Wrapped component function
|
|
318
|
+
|
|
319
|
+
### createMemoryTracker(options)
|
|
320
|
+
|
|
321
|
+
Create a memory usage tracker.
|
|
322
|
+
|
|
323
|
+
**Parameters:**
|
|
324
|
+
- `options.interval` - Check interval in ms
|
|
325
|
+
- `options.onWarning` - Callback for memory warnings
|
|
326
|
+
|
|
327
|
+
### Methods
|
|
328
|
+
|
|
329
|
+
- `monitor.start()` - Start performance monitoring
|
|
330
|
+
- `monitor.stop()` - Stop performance monitoring
|
|
331
|
+
- `monitor.getMetrics()` - Get current metrics
|
|
332
|
+
- `monitor.reset()` - Reset collected metrics
|
|
333
|
+
|
|
334
|
+
## Examples
|
|
335
|
+
|
|
336
|
+
### Full Application Monitoring
|
|
337
|
+
|
|
338
|
+
```javascript
|
|
339
|
+
import { createPerformanceMonitor, withPerformance } from '@coherent.js/performance';
|
|
340
|
+
import { render } from '@coherent.js/core';
|
|
341
|
+
|
|
342
|
+
// Create monitor
|
|
343
|
+
const monitor = createPerformanceMonitor({
|
|
344
|
+
logLevel: 'info',
|
|
345
|
+
thresholds: {
|
|
346
|
+
renderTime: 30,
|
|
347
|
+
memoryUsage: 100
|
|
348
|
+
},
|
|
349
|
+
onMetrics: (metrics) => {
|
|
350
|
+
// Send to analytics service
|
|
351
|
+
analytics.track('performance_metrics', metrics);
|
|
352
|
+
|
|
353
|
+
// Alert on issues
|
|
354
|
+
if (metrics.renderTime > 100) {
|
|
355
|
+
alertService.warn('High render time detected');
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
// Monitor specific components
|
|
361
|
+
const MonitoredDashboard = withPerformance({
|
|
362
|
+
name: 'Dashboard',
|
|
363
|
+
threshold: 25
|
|
364
|
+
})(function Dashboard({ data }) {
|
|
365
|
+
return {
|
|
366
|
+
div: {
|
|
367
|
+
className: 'dashboard',
|
|
368
|
+
children: data.widgets.map(widget => ({
|
|
369
|
+
div: {
|
|
370
|
+
className: 'widget',
|
|
371
|
+
children: [
|
|
372
|
+
{ h3: { text: widget.title } },
|
|
373
|
+
{ p: { text: widget.content } }
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
}))
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
// Start monitoring
|
|
382
|
+
monitor.start();
|
|
383
|
+
|
|
384
|
+
// Render application
|
|
385
|
+
render(MonitoredDashboard, { data: getDashboardData() });
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Production Performance Dashboard
|
|
389
|
+
|
|
390
|
+
```javascript
|
|
391
|
+
import { createPerformanceMonitor } from '@coherent.js/performance';
|
|
392
|
+
|
|
393
|
+
class PerformanceDashboard {
|
|
394
|
+
constructor() {
|
|
395
|
+
this.monitor = createPerformanceMonitor({
|
|
396
|
+
sampleRate: 0.05, // Only 5% in production
|
|
397
|
+
logLevel: 'warn',
|
|
398
|
+
thresholds: {
|
|
399
|
+
renderTime: 100,
|
|
400
|
+
memoryUsage: 200,
|
|
401
|
+
eventLoopDelay: 50
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
this.metricsHistory = [];
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
start() {
|
|
409
|
+
this.monitor.start();
|
|
410
|
+
|
|
411
|
+
// Collect metrics periodically
|
|
412
|
+
setInterval(() => {
|
|
413
|
+
const metrics = this.monitor.getMetrics();
|
|
414
|
+
this.metricsHistory.push({
|
|
415
|
+
timestamp: Date.now(),
|
|
416
|
+
...metrics
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
// Keep only last 100 entries
|
|
420
|
+
if (this.metricsHistory.length > 100) {
|
|
421
|
+
this.metricsHistory.shift();
|
|
422
|
+
}
|
|
423
|
+
}, 60000); // Every minute
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
getReport() {
|
|
427
|
+
return {
|
|
428
|
+
avgRenderTime: this.getAverage('renderTime'),
|
|
429
|
+
peakMemory: this.getPeak('memoryUsage'),
|
|
430
|
+
metricsHistory: this.metricsHistory
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
getAverage(metric) {
|
|
435
|
+
const values = this.metricsHistory.map(m => m[metric]).filter(Boolean);
|
|
436
|
+
return values.reduce((sum, val) => sum + val, 0) / values.length;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
getPeak(metric) {
|
|
440
|
+
return Math.max(...this.metricsHistory.map(m => m[metric]).filter(Boolean));
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// Usage
|
|
445
|
+
const dashboard = new PerformanceDashboard();
|
|
446
|
+
dashboard.start();
|
|
447
|
+
|
|
448
|
+
// Expose report endpoint
|
|
449
|
+
app.get('/performance-report', (req, res) => {
|
|
450
|
+
res.json(dashboard.getReport());
|
|
451
|
+
});
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
## Best Practices
|
|
455
|
+
|
|
456
|
+
### 1. Environment-Specific Configuration
|
|
457
|
+
|
|
458
|
+
```javascript
|
|
459
|
+
const config = process.env.NODE_ENV === 'production'
|
|
460
|
+
? {
|
|
461
|
+
sampleRate: 0.1,
|
|
462
|
+
logLevel: 'warn'
|
|
463
|
+
}
|
|
464
|
+
: {
|
|
465
|
+
sampleRate: 1.0,
|
|
466
|
+
logLevel: 'debug'
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
const monitor = createPerformanceMonitor(config);
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### 2. Selective Monitoring
|
|
473
|
+
|
|
474
|
+
```javascript
|
|
475
|
+
// Only monitor in production or staging
|
|
476
|
+
if (['production', 'staging'].includes(process.env.NODE_ENV)) {
|
|
477
|
+
monitor.start();
|
|
478
|
+
}
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
### 3. Resource-Efficient Monitoring
|
|
482
|
+
|
|
483
|
+
```javascript
|
|
484
|
+
const monitor = createPerformanceMonitor({
|
|
485
|
+
sampleRate: 0.1, // Only sample 10%
|
|
486
|
+
metrics: { // Only collect essential metrics
|
|
487
|
+
renderTime: true,
|
|
488
|
+
memoryUsage: true
|
|
489
|
+
},
|
|
490
|
+
thresholds: { // Conservative thresholds
|
|
491
|
+
renderTime: 100,
|
|
492
|
+
memoryUsage: 500
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
## Related Packages
|
|
498
|
+
|
|
499
|
+
- [@coherent.js/core](../core/README.md) - Core framework
|
|
500
|
+
- [@coherent.js/profiler](../profiler/README.md) - Detailed profiling tools
|
|
501
|
+
- [@coherent.js/devtools](../devtools/README.md) - Development tools
|
|
502
|
+
|
|
503
|
+
## License
|
|
504
|
+
|
|
505
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coherent.js/performance",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.6",
|
|
4
4
|
"description": "Performance optimization utilities for Coherent.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"author": "Coherent.js Team",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@coherent.js/core": "1.0.0-beta.
|
|
23
|
+
"@coherent.js/core": "1.0.0-beta.6"
|
|
24
24
|
},
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"README.md",
|
|
36
36
|
"types/"
|
|
37
37
|
],
|
|
38
|
+
"sideEffects": false,
|
|
38
39
|
"scripts": {
|
|
39
40
|
"build": "node build.mjs",
|
|
40
41
|
"clean": "rm -rf dist"
|
package/types/index.d.ts
CHANGED
|
@@ -3,164 +3,561 @@
|
|
|
3
3
|
* @module @coherent.js/performance
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import type { CoherentNode, CoherentComponent, ComponentProps } from '@coherent.js/core';
|
|
7
7
|
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Performance Metrics
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Comprehensive performance metrics
|
|
14
|
+
*/
|
|
15
|
+
export interface PerformanceMetrics {
|
|
16
|
+
/** Total render time (ms) */
|
|
17
|
+
renderTime: number;
|
|
18
|
+
/** Number of components rendered */
|
|
19
|
+
componentCount: number;
|
|
20
|
+
/** Total number of renders */
|
|
21
|
+
totalRenders: number;
|
|
22
|
+
/** Average render time */
|
|
23
|
+
avgRenderTime: number;
|
|
24
|
+
/** Slowest render information */
|
|
25
|
+
slowestRender: {
|
|
26
|
+
component: string;
|
|
27
|
+
time: number;
|
|
28
|
+
};
|
|
29
|
+
/** Memory usage (if available) */
|
|
30
|
+
memoryUsage?: number;
|
|
31
|
+
/** Cache hit rate */
|
|
32
|
+
cacheHitRate?: number;
|
|
33
|
+
/** Bundle size information */
|
|
34
|
+
bundleSize?: {
|
|
35
|
+
total: number;
|
|
36
|
+
gzipped: number;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Performance configuration
|
|
42
|
+
*/
|
|
43
|
+
export interface PerformanceConfig {
|
|
44
|
+
/** Enable performance tracking */
|
|
45
|
+
enabled?: boolean;
|
|
46
|
+
/** Sample rate (0-1) for measurement */
|
|
47
|
+
sampleRate?: number;
|
|
48
|
+
/** Threshold for slow render warning (ms) */
|
|
49
|
+
slowThreshold?: number;
|
|
50
|
+
/** Callback for slow renders */
|
|
51
|
+
onSlowRender?: (component: string, time: number) => void;
|
|
52
|
+
/** Enable detailed tracing */
|
|
53
|
+
tracing?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Profiler result for a single render
|
|
58
|
+
*/
|
|
59
|
+
export interface ProfilerResult {
|
|
60
|
+
/** Component name */
|
|
61
|
+
componentName: string;
|
|
62
|
+
/** Total duration (ms) */
|
|
63
|
+
duration: number;
|
|
64
|
+
/** Render phase */
|
|
65
|
+
phase: 'mount' | 'update';
|
|
66
|
+
/** Actual render duration */
|
|
67
|
+
actualDuration: number;
|
|
68
|
+
/** Base duration (without memoization) */
|
|
69
|
+
baseDuration: number;
|
|
70
|
+
/** Start time (relative to page load) */
|
|
71
|
+
startTime: number;
|
|
72
|
+
/** Commit time */
|
|
73
|
+
commitTime: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Create a performance profiler
|
|
78
|
+
*/
|
|
79
|
+
export function createProfiler(config?: PerformanceConfig): {
|
|
80
|
+
/** Start a measurement */
|
|
81
|
+
start(label: string): void;
|
|
82
|
+
/** End a measurement and return duration */
|
|
83
|
+
end(label: string): number;
|
|
84
|
+
/** Measure a synchronous function */
|
|
85
|
+
measure<T>(label: string, fn: () => T): T;
|
|
86
|
+
/** Measure an async function */
|
|
87
|
+
measureAsync<T>(label: string, fn: () => Promise<T>): Promise<T>;
|
|
88
|
+
/** Get current metrics */
|
|
89
|
+
getMetrics(): PerformanceMetrics;
|
|
90
|
+
/** Reset all measurements */
|
|
91
|
+
reset(): void;
|
|
92
|
+
/** Subscribe to render events */
|
|
93
|
+
onRender(callback: (result: ProfilerResult) => void): () => void;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* HOC to add profiling to a component
|
|
98
|
+
*/
|
|
99
|
+
export function withProfiling<P extends ComponentProps>(
|
|
100
|
+
component: CoherentComponent<P>,
|
|
101
|
+
name?: string
|
|
102
|
+
): CoherentComponent<P>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Memoize with metrics tracking
|
|
106
|
+
*/
|
|
107
|
+
export function memoWithMetrics<T extends (...args: unknown[]) => unknown>(
|
|
108
|
+
fn: T,
|
|
109
|
+
options?: {
|
|
110
|
+
name?: string;
|
|
111
|
+
maxSize?: number;
|
|
112
|
+
}
|
|
113
|
+
): T & {
|
|
114
|
+
hits: number;
|
|
115
|
+
misses: number;
|
|
116
|
+
hitRate: () => number;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// ============================================================================
|
|
120
|
+
// Code Splitting
|
|
121
|
+
// ============================================================================
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Split options for lazy loading
|
|
125
|
+
*/
|
|
8
126
|
export interface SplitOptions {
|
|
9
|
-
|
|
10
|
-
|
|
127
|
+
/** Loading component */
|
|
128
|
+
loading?: CoherentNode;
|
|
129
|
+
/** Error component */
|
|
130
|
+
error?: CoherentNode;
|
|
131
|
+
/** Delay before showing loading (ms) */
|
|
11
132
|
delay?: number;
|
|
133
|
+
/** Timeout for loading (ms) */
|
|
12
134
|
timeout?: number;
|
|
13
135
|
}
|
|
14
136
|
|
|
15
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Lazy component loader type
|
|
139
|
+
*/
|
|
140
|
+
export type LazyComponent = () => Promise<{ default: CoherentComponent }>;
|
|
16
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Code splitter class
|
|
144
|
+
*/
|
|
17
145
|
export class CodeSplitter {
|
|
18
146
|
constructor();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
147
|
+
|
|
148
|
+
/** Create a lazy-loaded component */
|
|
149
|
+
lazy(loader: LazyComponent, options?: SplitOptions): CoherentComponent;
|
|
150
|
+
|
|
151
|
+
/** Split a component into a separate chunk */
|
|
152
|
+
split(component: CoherentComponent, chunkName?: string): LazyComponent;
|
|
153
|
+
|
|
154
|
+
/** Preload a lazy component */
|
|
155
|
+
preload(loader: LazyComponent): Promise<CoherentComponent>;
|
|
156
|
+
|
|
157
|
+
/** Prefetch a lazy component (lower priority) */
|
|
22
158
|
prefetch(loader: LazyComponent): void;
|
|
23
159
|
}
|
|
24
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Create a code splitter instance
|
|
163
|
+
*/
|
|
25
164
|
export function createCodeSplitter(): CodeSplitter;
|
|
26
|
-
export function lazy(loader: LazyComponent, options?: SplitOptions): LazyComponent;
|
|
27
|
-
export function splitComponent(component: any, chunkName?: string): LazyComponent;
|
|
28
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Create a lazy-loaded component
|
|
168
|
+
*/
|
|
169
|
+
export function lazy(loader: LazyComponent, options?: SplitOptions): CoherentComponent;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Split a component into a separate chunk
|
|
173
|
+
*/
|
|
174
|
+
export function splitComponent(component: CoherentComponent, chunkName?: string): LazyComponent;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Route-based code splitting configuration
|
|
178
|
+
*/
|
|
29
179
|
export interface RouteConfig {
|
|
180
|
+
/** Route path */
|
|
30
181
|
path: string;
|
|
182
|
+
/** Lazy component loader */
|
|
31
183
|
component: LazyComponent;
|
|
184
|
+
/** Preload on route definition */
|
|
32
185
|
preload?: boolean;
|
|
186
|
+
/** Prefetch on idle */
|
|
33
187
|
prefetch?: boolean;
|
|
34
188
|
}
|
|
35
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Create a route-based code splitter
|
|
192
|
+
*/
|
|
36
193
|
export function createRouteSplitter(routes: RouteConfig[]): {
|
|
194
|
+
/** Get route configuration */
|
|
37
195
|
getRoute(path: string): RouteConfig | undefined;
|
|
196
|
+
/** Preload a route's component */
|
|
38
197
|
preloadRoute(path: string): Promise<void>;
|
|
198
|
+
/** Prefetch a route's component */
|
|
39
199
|
prefetchRoute(path: string): void;
|
|
40
200
|
};
|
|
41
201
|
|
|
42
|
-
//
|
|
202
|
+
// ============================================================================
|
|
203
|
+
// Caching
|
|
204
|
+
// ============================================================================
|
|
43
205
|
|
|
44
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Cache entry structure
|
|
208
|
+
*/
|
|
209
|
+
export interface CacheEntry<T = unknown> {
|
|
210
|
+
/** Cached value */
|
|
45
211
|
value: T;
|
|
212
|
+
/** Creation timestamp */
|
|
46
213
|
timestamp: number;
|
|
214
|
+
/** Hit count */
|
|
47
215
|
hits: number;
|
|
216
|
+
/** Size in bytes (estimated) */
|
|
48
217
|
size?: number;
|
|
49
218
|
}
|
|
50
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Cache options
|
|
222
|
+
*/
|
|
51
223
|
export interface CacheOptions {
|
|
224
|
+
/** Maximum cache size */
|
|
52
225
|
maxSize?: number;
|
|
226
|
+
/** Maximum age in ms */
|
|
53
227
|
maxAge?: number;
|
|
54
|
-
|
|
228
|
+
/** Callback when entry is evicted */
|
|
229
|
+
onEvict?: (key: string, value: unknown) => void;
|
|
55
230
|
}
|
|
56
231
|
|
|
57
|
-
|
|
232
|
+
/**
|
|
233
|
+
* LRU Cache class
|
|
234
|
+
*/
|
|
235
|
+
export class LRUCache<K = string, V = unknown> {
|
|
58
236
|
constructor(options?: CacheOptions);
|
|
237
|
+
|
|
238
|
+
/** Get a cached value */
|
|
59
239
|
get(key: K): V | undefined;
|
|
240
|
+
|
|
241
|
+
/** Set a cached value */
|
|
60
242
|
set(key: K, value: V): void;
|
|
243
|
+
|
|
244
|
+
/** Check if key exists */
|
|
61
245
|
has(key: K): boolean;
|
|
246
|
+
|
|
247
|
+
/** Delete a key */
|
|
62
248
|
delete(key: K): boolean;
|
|
249
|
+
|
|
250
|
+
/** Clear all entries */
|
|
63
251
|
clear(): void;
|
|
252
|
+
|
|
253
|
+
/** Get cache size */
|
|
64
254
|
size(): number;
|
|
255
|
+
|
|
256
|
+
/** Get all keys */
|
|
65
257
|
keys(): K[];
|
|
258
|
+
|
|
259
|
+
/** Get all values */
|
|
66
260
|
values(): V[];
|
|
261
|
+
|
|
262
|
+
/** Get all entries */
|
|
67
263
|
entries(): Array<[K, V]>;
|
|
68
264
|
}
|
|
69
265
|
|
|
70
|
-
|
|
266
|
+
/**
|
|
267
|
+
* Memory cache with TTL support
|
|
268
|
+
*/
|
|
269
|
+
export class MemoryCache<K = string, V = unknown> {
|
|
71
270
|
constructor(options?: CacheOptions);
|
|
271
|
+
|
|
272
|
+
/** Get a cached value */
|
|
72
273
|
get(key: K): V | undefined;
|
|
274
|
+
|
|
275
|
+
/** Set a cached value with optional TTL */
|
|
73
276
|
set(key: K, value: V, ttl?: number): void;
|
|
277
|
+
|
|
278
|
+
/** Check if key exists */
|
|
74
279
|
has(key: K): boolean;
|
|
280
|
+
|
|
281
|
+
/** Delete a key */
|
|
75
282
|
delete(key: K): boolean;
|
|
283
|
+
|
|
284
|
+
/** Clear all entries */
|
|
76
285
|
clear(): void;
|
|
286
|
+
|
|
287
|
+
/** Get cache size */
|
|
77
288
|
size(): number;
|
|
289
|
+
|
|
290
|
+
/** Clean up expired entries */
|
|
78
291
|
cleanup(): void;
|
|
79
292
|
}
|
|
80
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Memoization options
|
|
296
|
+
*/
|
|
81
297
|
export interface MemoOptions {
|
|
298
|
+
/** Maximum cache size */
|
|
82
299
|
maxSize?: number;
|
|
83
|
-
|
|
300
|
+
/** Custom key generator */
|
|
301
|
+
keyGenerator?: (...args: unknown[]) => string;
|
|
302
|
+
/** TTL in ms */
|
|
84
303
|
ttl?: number;
|
|
85
304
|
}
|
|
86
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Memoization cache class
|
|
308
|
+
*/
|
|
87
309
|
export class MemoCache {
|
|
88
310
|
constructor(options?: MemoOptions);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
311
|
+
|
|
312
|
+
/** Memoize a function */
|
|
313
|
+
memoize<T extends (...args: unknown[]) => unknown>(fn: T): T;
|
|
314
|
+
|
|
315
|
+
/** Clear cache for a function */
|
|
316
|
+
clear(fn?: (...args: unknown[]) => unknown): void;
|
|
317
|
+
|
|
318
|
+
/** Check if result is cached */
|
|
319
|
+
has(fn: (...args: unknown[]) => unknown, args: unknown[]): boolean;
|
|
320
|
+
|
|
321
|
+
/** Delete cached result */
|
|
322
|
+
delete(fn: (...args: unknown[]) => unknown, args?: unknown[]): boolean;
|
|
93
323
|
}
|
|
94
324
|
|
|
325
|
+
/**
|
|
326
|
+
* Render cache options
|
|
327
|
+
*/
|
|
95
328
|
export interface RenderCacheOptions extends CacheOptions {
|
|
96
|
-
|
|
329
|
+
/** Custom key generator */
|
|
330
|
+
keyGenerator?: (component: CoherentComponent, props: unknown) => string;
|
|
97
331
|
}
|
|
98
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Render cache for component output
|
|
335
|
+
*/
|
|
99
336
|
export class RenderCache {
|
|
100
337
|
constructor(options?: RenderCacheOptions);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
338
|
+
|
|
339
|
+
/** Get cached render */
|
|
340
|
+
get(component: CoherentComponent, props: unknown): string | undefined;
|
|
341
|
+
|
|
342
|
+
/** Set cached render */
|
|
343
|
+
set(component: CoherentComponent, props: unknown, html: string): void;
|
|
344
|
+
|
|
345
|
+
/** Clear cache for a component */
|
|
346
|
+
clear(component?: CoherentComponent): void;
|
|
347
|
+
|
|
348
|
+
/** Get cache size */
|
|
104
349
|
size(): number;
|
|
105
350
|
}
|
|
106
351
|
|
|
107
|
-
|
|
108
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Create a cache of specified type
|
|
354
|
+
*/
|
|
355
|
+
export function createCache<K = string, V = unknown>(
|
|
356
|
+
type: 'lru' | 'memory' | 'memo' | 'render',
|
|
357
|
+
options?: CacheOptions
|
|
358
|
+
): LRUCache<K, V> | MemoryCache<K, V> | MemoCache | RenderCache;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Memoize a function
|
|
362
|
+
*/
|
|
363
|
+
export function memoize<T extends (...args: unknown[]) => unknown>(
|
|
364
|
+
fn: T,
|
|
365
|
+
options?: MemoOptions
|
|
366
|
+
): T;
|
|
109
367
|
|
|
110
|
-
//
|
|
368
|
+
// ============================================================================
|
|
369
|
+
// Lazy Loading
|
|
370
|
+
// ============================================================================
|
|
111
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Lazy load options
|
|
374
|
+
*/
|
|
112
375
|
export interface LazyLoadOptions {
|
|
376
|
+
/** Intersection threshold (0-1) */
|
|
113
377
|
threshold?: number;
|
|
378
|
+
/** Root margin for intersection */
|
|
114
379
|
rootMargin?: string;
|
|
380
|
+
/** Root element for intersection */
|
|
115
381
|
root?: Element | null;
|
|
382
|
+
/** Callback when loaded */
|
|
116
383
|
onLoad?: () => void;
|
|
384
|
+
/** Callback on error */
|
|
117
385
|
onError?: (error: Error) => void;
|
|
118
386
|
}
|
|
119
387
|
|
|
388
|
+
/**
|
|
389
|
+
* Lazy loader class
|
|
390
|
+
*/
|
|
120
391
|
export class LazyLoader {
|
|
121
392
|
constructor(options?: LazyLoadOptions);
|
|
122
|
-
|
|
393
|
+
|
|
394
|
+
/** Start observing an element */
|
|
395
|
+
observe(element: Element, loader: () => Promise<unknown>): void;
|
|
396
|
+
|
|
397
|
+
/** Stop observing an element */
|
|
123
398
|
unobserve(element: Element): void;
|
|
399
|
+
|
|
400
|
+
/** Disconnect all observers */
|
|
124
401
|
disconnect(): void;
|
|
402
|
+
|
|
403
|
+
/** Load all observed elements */
|
|
125
404
|
loadAll(): Promise<void[]>;
|
|
126
405
|
}
|
|
127
406
|
|
|
407
|
+
/**
|
|
408
|
+
* Image lazy load options
|
|
409
|
+
*/
|
|
128
410
|
export interface ImageLazyLoadOptions extends LazyLoadOptions {
|
|
411
|
+
/** Placeholder image URL */
|
|
129
412
|
placeholder?: string;
|
|
413
|
+
/** Blur data URL for preview */
|
|
130
414
|
blurDataURL?: string;
|
|
415
|
+
/** Enable fade-in animation */
|
|
131
416
|
fadeIn?: boolean;
|
|
417
|
+
/** Fade-in duration (ms) */
|
|
132
418
|
fadeInDuration?: number;
|
|
133
419
|
}
|
|
134
420
|
|
|
421
|
+
/**
|
|
422
|
+
* Image lazy loader class
|
|
423
|
+
*/
|
|
135
424
|
export class ImageLazyLoader extends LazyLoader {
|
|
136
425
|
constructor(options?: ImageLazyLoadOptions);
|
|
426
|
+
|
|
427
|
+
/** Lazy load an image */
|
|
137
428
|
lazyImage(element: HTMLImageElement, src: string, options?: ImageLazyLoadOptions): void;
|
|
138
429
|
}
|
|
139
430
|
|
|
431
|
+
/**
|
|
432
|
+
* Preload options
|
|
433
|
+
*/
|
|
140
434
|
export interface PreloadOptions {
|
|
435
|
+
/** Resource type */
|
|
141
436
|
as?: 'script' | 'style' | 'image' | 'font' | 'fetch';
|
|
437
|
+
/** Cross-origin setting */
|
|
142
438
|
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
439
|
+
/** MIME type */
|
|
143
440
|
type?: string;
|
|
441
|
+
/** Media query */
|
|
144
442
|
media?: string;
|
|
145
443
|
}
|
|
146
444
|
|
|
445
|
+
/**
|
|
446
|
+
* Resource preloader class
|
|
447
|
+
*/
|
|
147
448
|
export class ResourcePreloader {
|
|
148
449
|
constructor();
|
|
450
|
+
|
|
451
|
+
/** Preload a resource (high priority) */
|
|
149
452
|
preload(url: string, options?: PreloadOptions): void;
|
|
453
|
+
|
|
454
|
+
/** Prefetch a resource (low priority) */
|
|
150
455
|
prefetch(url: string): void;
|
|
456
|
+
|
|
457
|
+
/** Preconnect to a domain */
|
|
151
458
|
preconnect(url: string, crossOrigin?: boolean): void;
|
|
459
|
+
|
|
460
|
+
/** DNS prefetch for a domain */
|
|
152
461
|
dnsPrefetch(url: string): void;
|
|
462
|
+
|
|
463
|
+
/** Check if resource is preloaded */
|
|
153
464
|
hasPreloaded(url: string): boolean;
|
|
154
465
|
}
|
|
155
466
|
|
|
467
|
+
/**
|
|
468
|
+
* Create a lazy loader
|
|
469
|
+
*/
|
|
156
470
|
export function createLazyLoader(options?: LazyLoadOptions): LazyLoader;
|
|
157
|
-
export function lazyImage(element: HTMLImageElement | string, src: string, options?: ImageLazyLoadOptions): void;
|
|
158
471
|
|
|
472
|
+
/**
|
|
473
|
+
* Lazy load an image
|
|
474
|
+
*/
|
|
475
|
+
export function lazyImage(
|
|
476
|
+
element: HTMLImageElement | string,
|
|
477
|
+
src: string,
|
|
478
|
+
options?: ImageLazyLoadOptions
|
|
479
|
+
): void;
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Progressive image loading options
|
|
483
|
+
*/
|
|
159
484
|
export interface ProgressiveImageOptions {
|
|
485
|
+
/** Low quality image source */
|
|
160
486
|
lowQualitySrc: string;
|
|
487
|
+
/** High quality image source */
|
|
161
488
|
highQualitySrc: string;
|
|
489
|
+
/** Placeholder while loading */
|
|
162
490
|
placeholder?: string;
|
|
491
|
+
/** Fade-in duration (ms) */
|
|
163
492
|
fadeInDuration?: number;
|
|
164
493
|
}
|
|
165
494
|
|
|
166
|
-
|
|
495
|
+
/**
|
|
496
|
+
* Load an image progressively (low quality first)
|
|
497
|
+
*/
|
|
498
|
+
export function progressiveImage(
|
|
499
|
+
element: HTMLImageElement | string,
|
|
500
|
+
options: ProgressiveImageOptions
|
|
501
|
+
): Promise<void>;
|
|
502
|
+
|
|
503
|
+
// ============================================================================
|
|
504
|
+
// Bundle Optimization
|
|
505
|
+
// ============================================================================
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Bundle analysis result
|
|
509
|
+
*/
|
|
510
|
+
export interface BundleAnalysis {
|
|
511
|
+
/** Total size in bytes */
|
|
512
|
+
totalSize: number;
|
|
513
|
+
/** Gzipped size */
|
|
514
|
+
gzippedSize: number;
|
|
515
|
+
/** Modules in bundle */
|
|
516
|
+
modules: Array<{
|
|
517
|
+
name: string;
|
|
518
|
+
size: number;
|
|
519
|
+
gzippedSize: number;
|
|
520
|
+
}>;
|
|
521
|
+
/** Duplicate modules */
|
|
522
|
+
duplicates: Array<{
|
|
523
|
+
name: string;
|
|
524
|
+
count: number;
|
|
525
|
+
totalSize: number;
|
|
526
|
+
}>;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Tree shaking result
|
|
531
|
+
*/
|
|
532
|
+
export interface TreeShakeResult {
|
|
533
|
+
/** Original size */
|
|
534
|
+
originalSize: number;
|
|
535
|
+
/** Size after tree shaking */
|
|
536
|
+
shakenSize: number;
|
|
537
|
+
/** Removed exports */
|
|
538
|
+
removed: string[];
|
|
539
|
+
/** Kept exports */
|
|
540
|
+
kept: string[];
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Bundle optimizer class
|
|
545
|
+
*/
|
|
546
|
+
export class BundleOptimizer {
|
|
547
|
+
/** Analyze a bundle */
|
|
548
|
+
analyze(bundle: unknown): BundleAnalysis;
|
|
549
|
+
|
|
550
|
+
/** Optimize a bundle */
|
|
551
|
+
optimize(bundle: unknown): unknown;
|
|
552
|
+
|
|
553
|
+
/** Split bundle into chunks */
|
|
554
|
+
splitChunks(bundle: unknown): unknown[];
|
|
555
|
+
|
|
556
|
+
/** Tree shake a bundle */
|
|
557
|
+
treeshake(bundle: unknown): TreeShakeResult;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Global bundle optimizer instance
|
|
562
|
+
*/
|
|
563
|
+
export const bundleOptimizer: BundleOptimizer;
|