packlyze 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Your Name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
package/README.md ADDED
@@ -0,0 +1,219 @@
1
+ # Packlyze
2
+
3
+ Advanced bundle analyzer with insights, recommendations, and historical tracking.
4
+
5
+ ## 📊 Features
6
+
7
+ - **Package Analysis**: Parse and analyze webpack, rollup, and esbuild stats files
8
+ - **Smart Recommendations**: AI-powered suggestions to optimize your bundle
9
+ - **Tree-Shaking Detection**: Identify modules preventing tree-shaking
10
+ - **Duplicate Detection**: Find and quantify duplicate modules
11
+ - **Beautiful Reports**: Generate interactive HTML reports
12
+ - **CLI Tool**: Easy-to-use command-line interface
13
+ - **TypeScript Ready**: Full TypeScript support with type definitions
14
+
15
+ ## 🚀 Installation
16
+
17
+ ```bash
18
+ npm install -g packlyze
19
+ # or
20
+ npx packlyze
21
+ ```
22
+
23
+ ## 📖 Usage
24
+
25
+ ### Basic Analysis
26
+
27
+ ```bash
28
+ # Generate webpack stats
29
+ webpack --profile --json > stats.json
30
+
31
+ # Analyze with packlyze
32
+ packlyze analyze stats.json
33
+
34
+ # Output HTML report to custom location
35
+ packlyze analyze stats.json -o ./reports/bundle-report.html
36
+ ```
37
+
38
+ ### JSON Output
39
+
40
+ ```bash
41
+ packlyze analyze stats.json --json
42
+ ```
43
+
44
+ ### As a Library
45
+
46
+ ```typescript
47
+ import { Packlyze } from 'packlyze';
48
+
49
+ const analyzer = new Packlyze('./dist/stats.json');
50
+ const result = await analyzer.analyze();
51
+
52
+ console.log(result.recommendations);
53
+ console.log(result.metrics);
54
+ console.log(result.bundleStats.modules);
55
+ ```
56
+
57
+ ## 📁 Project Structure
58
+
59
+ ```
60
+ Packlyze-plus/
61
+ ├── src/
62
+ │ ├── types.ts # TypeScript interfaces
63
+ │ ├── index.ts # Main entry point
64
+ │ ├── cli.ts # CLI interface
65
+ │ ├── analyzer/
66
+ │ │ └── packlyze.ts # Core analysis logic
67
+ │ └── visualization/
68
+ │ └── reports.ts # HTML report generation
69
+ ├── tests/
70
+ │ └── analyzer.test.ts
71
+ ├── dist/ # Compiled output
72
+ ├── package.json
73
+ ├── tsconfig.json
74
+ ├── .eslintrc.json
75
+ ├── .prettierrc
76
+ ├── .gitignore
77
+ └── README.md
78
+ ```
79
+
80
+ ## 🔧 Development
81
+
82
+ ### Setup
83
+
84
+ ```bash
85
+ npm install
86
+ npm run dev # Watch mode TypeScript compilation
87
+ ```
88
+
89
+ ### Build
90
+
91
+ ```bash
92
+ npm run build # Compile TypeScript to JavaScript
93
+ ```
94
+
95
+ ### Testing
96
+
97
+ ```bash
98
+ npm run test # Run all tests
99
+ npm run test:coverage # Generate coverage report
100
+ ```
101
+
102
+ ### Code Quality
103
+
104
+ ```bash
105
+ npm run lint # ESLint check and fix
106
+ npm run format # Prettier formatting
107
+ ```
108
+
109
+ ## 📊 Analysis Output
110
+
111
+ The analyzer provides:
112
+
113
+ ### Metrics
114
+ - Total bundle size
115
+ - Gzip size
116
+ - Number of modules and chunks
117
+ - Largest module
118
+ - Average module size
119
+
120
+ ### Recommendations
121
+ - Critical: Address immediately
122
+ - Warning: Consider optimizing
123
+ - Info: Monitor for growth
124
+
125
+ ### Insights
126
+ - Tree-shaking issues
127
+ - Duplicate modules
128
+ - Large modules (>5% of bundle)
129
+ - Module count analysis
130
+
131
+ ## 🎯 Use Cases
132
+
133
+ - **Performance Optimization**: Identify and reduce bundle bloat
134
+ - **Code Splitting**: Find optimal splitting points
135
+ - **Dependency Analysis**: Detect unused or duplicate packages
136
+ - **Tree-Shaking Audit**: Ensure modules support ES6 imports
137
+ - **CI/CD Integration**: Monitor bundle size over time
138
+
139
+ ## 📝 Examples
140
+
141
+ ### Webpack Project
142
+
143
+ ```bash
144
+ # In your webpack config
145
+ const path = require('path');
146
+
147
+ module.exports = {
148
+ // ... your config
149
+ plugins: [
150
+ // Add BundleAnalyzerPlugin if available
151
+ ],
152
+ // Generate stats.json
153
+ profile: true,
154
+ };
155
+
156
+ # Command
157
+ npx packlyze analyze stats.json
158
+ ```
159
+
160
+ ### Next.js Project
161
+
162
+ ```bash
163
+ # Build and analyze
164
+ ANALYZE=true npm run build
165
+ ```
166
+
167
+ ### Vue/Nuxt Project
168
+
169
+ ```bash
170
+ # Generate stats
171
+ npm run build -- --report
172
+
173
+ # Analyze
174
+ packlyze analyze dist/stats.json
175
+ ```
176
+
177
+ ## 🐛 Troubleshooting
178
+
179
+ ### "Stats file not found"
180
+ Ensure your stats.json path is correct and the file exists.
181
+
182
+ ### "Invalid JSON"
183
+ Verify your stats file is valid JSON. Generate it using your bundler's profiling mode.
184
+
185
+ ### Large bundle warnings
186
+ Consider:
187
+ - Code splitting with dynamic imports
188
+ - Tree-shaking verification
189
+ - Removing unused dependencies
190
+ - Using lighter alternatives
191
+
192
+ ## 📄 License
193
+
194
+ MIT
195
+
196
+ ## 🤝 Contributing
197
+
198
+ Contributions welcome! Please:
199
+
200
+ 1. Fork the repository
201
+ 2. Create a feature branch
202
+ 3. Make your changes
203
+ 4. Add tests
204
+ 5. Submit a pull request
205
+
206
+ ## 📞 Support
207
+
208
+ For issues and questions:
209
+ - GitHub Issues: [link]
210
+ - Email: [your-email]
211
+ - Twitter: [@yourhandle]
212
+
213
+ ## 🙏 Acknowledgments
214
+
215
+ Built with TypeScript, Commander.js, and Chalk
216
+
217
+ ---
218
+
219
+ **Made with ❤️ by [Your Name]**
@@ -0,0 +1,18 @@
1
+ import { AnalysisResult } from '../types.js';
2
+ export declare class Packlyze {
3
+ private statsData;
4
+ private baseDir;
5
+ constructor(statsPath: string);
6
+ private loadStats;
7
+ analyze(): Promise<AnalysisResult>;
8
+ private extractBundleStats;
9
+ private getTotalSize;
10
+ private getTotalGzipSize;
11
+ private extractChunks;
12
+ private getInitialBundleSize;
13
+ private generateRecommendations;
14
+ private detectTreeshakingIssues;
15
+ private findDuplicates;
16
+ private calculateMetrics;
17
+ }
18
+ //# sourceMappingURL=packlyze.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packlyze.d.ts","sourceRoot":"","sources":["../../src/analyzer/packlyze.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,cAAc,EACf,MAAM,aAAa,CAAC;AAErB,qBAAa,QAAQ;IACnB,OAAO,CAAC,SAAS,CAcV;IACP,OAAO,CAAC,OAAO,CAAS;gBAEZ,SAAS,EAAE,MAAM;IAQ7B,OAAO,CAAC,SAAS;IASX,OAAO,IAAI,OAAO,CAAC,cAAc,CAAC;IAiBxC,OAAO,CAAC,kBAAkB;IAwB1B,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,uBAAuB;IAkD/B,OAAO,CAAC,uBAAuB;IAY/B,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,gBAAgB;CAkBzB"}
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Packlyze = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ class Packlyze {
10
+ constructor(statsPath) {
11
+ this.statsData = {};
12
+ if (!fs_1.default.existsSync(statsPath)) {
13
+ throw new Error(`Stats file not found: ${statsPath}`);
14
+ }
15
+ this.baseDir = path_1.default.dirname(statsPath);
16
+ this.loadStats(statsPath);
17
+ }
18
+ loadStats(statsPath) {
19
+ const content = fs_1.default.readFileSync(statsPath, 'utf-8');
20
+ try {
21
+ this.statsData = JSON.parse(content);
22
+ }
23
+ catch (e) {
24
+ throw new Error(`Invalid JSON in stats file: ${e}`);
25
+ }
26
+ }
27
+ async analyze() {
28
+ const bundleStats = this.extractBundleStats();
29
+ const recommendations = this.generateRecommendations(bundleStats);
30
+ const treeshakingIssues = this.detectTreeshakingIssues();
31
+ const duplicates = this.findDuplicates();
32
+ const metrics = this.calculateMetrics(bundleStats);
33
+ return {
34
+ bundleStats,
35
+ recommendations,
36
+ treeshakingIssues,
37
+ duplicates,
38
+ metrics,
39
+ timestamp: new Date().toISOString()
40
+ };
41
+ }
42
+ extractBundleStats() {
43
+ const assets = this.statsData.assets || [];
44
+ const modules = (this.statsData.modules || []).map((m) => ({
45
+ name: m.name || 'unknown',
46
+ size: m.size || 0,
47
+ gzipSize: m.gzipSize,
48
+ percentage: (m.size || 0) / this.getTotalSize() * 100,
49
+ reasons: Array.isArray(m.reasons)
50
+ ? m.reasons.map((r) => typeof r === 'string' ? r : r.moduleName ?? '')
51
+ : []
52
+ }));
53
+ return {
54
+ name: this.statsData.name || 'bundle',
55
+ size: this.getTotalSize(),
56
+ gzipSize: this.getTotalGzipSize(),
57
+ modules: modules.sort((a, b) => b.size - a.size),
58
+ chunks: this.extractChunks(),
59
+ isInitialBySize: this.getInitialBundleSize(),
60
+ isInitialByCount: assets.length,
61
+ parsedSize: this.statsData.parsedSize || 0
62
+ };
63
+ }
64
+ getTotalSize() {
65
+ const assets = this.statsData.assets || [];
66
+ return assets.reduce((sum, asset) => sum + (asset.size || 0), 0);
67
+ }
68
+ getTotalGzipSize() {
69
+ const assets = this.statsData.assets || [];
70
+ return assets.reduce((sum, asset) => sum + (asset.gzipSize || 0), 0);
71
+ }
72
+ extractChunks() {
73
+ return (this.statsData.chunks || []).map((chunk) => ({
74
+ id: chunk.id,
75
+ name: chunk.name || `chunk-${chunk.id}`,
76
+ size: chunk.size || 0,
77
+ gzipSize: chunk.gzipSize,
78
+ modules: Array.isArray(chunk.modules) ? chunk.modules.map((m) => m.name) : []
79
+ }));
80
+ }
81
+ getInitialBundleSize() {
82
+ return (this.statsData.chunks || [])
83
+ .filter((c) => c.initial === true)
84
+ .reduce((sum, c) => sum + (c.size || 0), 0);
85
+ }
86
+ generateRecommendations(stats) {
87
+ const recommendations = [];
88
+ // Large bundle check
89
+ if (stats.gzipSize && stats.gzipSize > 500000) {
90
+ recommendations.push({
91
+ severity: 'critical',
92
+ message: `Bundle size is ${(stats.gzipSize / 1024 / 1024).toFixed(2)}MB (gzipped)`,
93
+ action: 'Implement aggressive code-splitting or consider alternative libraries'
94
+ });
95
+ }
96
+ else if (stats.gzipSize && stats.gzipSize > 250000) {
97
+ recommendations.push({
98
+ severity: 'warning',
99
+ message: `Bundle size is ${(stats.gzipSize / 1024 / 1024).toFixed(2)}MB (gzipped)`,
100
+ action: 'Consider code-splitting frequently used features'
101
+ });
102
+ }
103
+ // Large modules check
104
+ const largeModules = stats.modules.filter(m => m.percentage > 5);
105
+ if (largeModules.length > 0) {
106
+ recommendations.push({
107
+ severity: 'warning',
108
+ message: `Found ${largeModules.length} modules exceeding 5% of bundle size`,
109
+ action: 'Consider extracting to separate chunk or lazy-loading'
110
+ });
111
+ }
112
+ // Duplicate check
113
+ const duplicates = this.findDuplicates();
114
+ if (duplicates.length > 0) {
115
+ recommendations.push({
116
+ severity: 'warning',
117
+ message: `Found ${duplicates.length} duplicate modules totaling ${(duplicates.reduce((s, d) => s + d.totalSize, 0) / 1024).toFixed(2)}KB`,
118
+ action: 'Use npm dedupe or resolve version conflicts'
119
+ });
120
+ }
121
+ // Module count check
122
+ if (stats.modules.length > 500) {
123
+ recommendations.push({
124
+ severity: 'info',
125
+ message: `High module count (${stats.modules.length}) - may impact build performance`,
126
+ action: 'Monitor module growth and consider monorepo approach'
127
+ });
128
+ }
129
+ return recommendations;
130
+ }
131
+ detectTreeshakingIssues() {
132
+ const issues = [];
133
+ const modules = this.statsData.modules || [];
134
+ modules.forEach((m) => {
135
+ if (typeof m.source === 'string' && (m.source.includes('module.exports') || m.source.includes('require('))) {
136
+ issues.push(`${m.name}: Uses CommonJS - reduces tree-shaking effectiveness`);
137
+ }
138
+ });
139
+ return issues.slice(0, 10); // Limit to top 10
140
+ }
141
+ findDuplicates() {
142
+ const moduleMap = new Map();
143
+ const duplicates = [];
144
+ (this.statsData.modules || []).forEach((module) => {
145
+ const baseName = path_1.default.basename(module.name || '');
146
+ if (!moduleMap.has(baseName)) {
147
+ moduleMap.set(baseName, []);
148
+ }
149
+ moduleMap.get(baseName).push(module);
150
+ });
151
+ moduleMap.forEach((modules) => {
152
+ if (modules.length > 1) {
153
+ const totalSize = modules.reduce((s, m) => s + (m.size || 0), 0);
154
+ const minSize = Math.min(...modules.map(m => m.size || 0));
155
+ duplicates.push({
156
+ names: modules.map(m => m.name),
157
+ totalSize,
158
+ savings: totalSize - minSize
159
+ });
160
+ }
161
+ });
162
+ return duplicates.sort((a, b) => b.totalSize - a.totalSize).slice(0, 10);
163
+ }
164
+ calculateMetrics(stats) {
165
+ const sizes = stats.modules.map(m => m.size);
166
+ const averageSize = sizes.length > 0 ? sizes.reduce((a, b) => a + b, 0) / sizes.length : 0;
167
+ return {
168
+ totalSize: stats.size,
169
+ totalGzipSize: stats.gzipSize || 0,
170
+ moduleCount: stats.modules.length,
171
+ chunkCount: stats.chunks.length,
172
+ largestModule: stats.modules[0] || {
173
+ name: 'N/A',
174
+ size: 0,
175
+ percentage: 0,
176
+ reasons: [],
177
+ gzipSize: 0
178
+ },
179
+ averageModuleSize: averageSize
180
+ };
181
+ }
182
+ }
183
+ exports.Packlyze = Packlyze;
184
+ //# sourceMappingURL=packlyze.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packlyze.js","sourceRoot":"","sources":["../../src/analyzer/packlyze.ts"],"names":[],"mappings":";;;;;;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":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const commander_1 = require("commander");
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const ora_1 = __importDefault(require("ora"));
10
+ const packlyze_1 = require("./analyzer/packlyze");
11
+ const reports_1 = require("./visualization/reports");
12
+ const fs_1 = __importDefault(require("fs"));
13
+ const program = new commander_1.Command();
14
+ program
15
+ .name('packlyze')
16
+ .description('Advanced package analyzer with insights and recommendations')
17
+ .version('1.0.0')
18
+ .helpOption('-h, --help', 'Show help');
19
+ program
20
+ .command('analyze <statsFile>')
21
+ .description('Analyze a webpack/rollup/esbuild stats.json file')
22
+ .option('-o, --output <path>', 'Output HTML report path', './bundle-report.html')
23
+ .option('-j, --json', 'Output as JSON')
24
+ .option('-v, --verbose', 'Verbose output')
25
+ .action(async (statsFile, options) => {
26
+ const spinner = (0, ora_1.default)('Analyzing package...').start();
27
+ try {
28
+ // Validate file exists
29
+ if (!fs_1.default.existsSync(statsFile)) {
30
+ throw new Error(`File not found: ${statsFile}`);
31
+ }
32
+ const analyzer = new packlyze_1.Packlyze(statsFile);
33
+ const result = await analyzer.analyze();
34
+ spinner.succeed('Analysis complete!');
35
+ if (options.json) {
36
+ console.log(JSON.stringify(result, null, 2));
37
+ }
38
+ else {
39
+ // Display formatted results
40
+ console.log(chalk_1.default.bold.cyan('\n📊 Package Analysis Results\n'));
41
+ console.log(chalk_1.default.bold('Metrics:'));
42
+ console.log(` Total Size: ${chalk_1.default.red((result.metrics.totalSize / 1024 / 1024).toFixed(2))}MB`);
43
+ console.log(` Gzip Size: ${chalk_1.default.yellow((result.metrics.totalGzipSize / 1024 / 1024).toFixed(2))}MB`);
44
+ console.log(` Modules: ${chalk_1.default.blue(result.metrics.moduleCount)}`);
45
+ console.log(` Chunks: ${chalk_1.default.blue(result.metrics.chunkCount)}`);
46
+ console.log(` Avg Module: ${chalk_1.default.green((result.metrics.averageModuleSize / 1024).toFixed(2))}KB\n`);
47
+ // Top modules
48
+ console.log(chalk_1.default.bold('Top 5 Modules:'));
49
+ result.bundleStats.modules.slice(0, 5).forEach((m, i) => {
50
+ const bar = '█'.repeat(Math.round(m.percentage / 2));
51
+ console.log(` ${i + 1}. ${m.name.slice(-30).padEnd(30)} ${(m.size / 1024).toFixed(2)}KB ${bar}`);
52
+ });
53
+ // Recommendations
54
+ if (result.recommendations.length > 0) {
55
+ console.log(chalk_1.default.bold.cyan('\n💡 Recommendations\n'));
56
+ result.recommendations.forEach(rec => {
57
+ const icon = rec.severity === 'critical' ? '🔴' : rec.severity === 'warning' ? '🟡' : '🟢';
58
+ console.log(`${icon} ${rec.message}`);
59
+ console.log(` → ${rec.action}\n`);
60
+ });
61
+ }
62
+ // Tree-shaking issues
63
+ if (result.treeshakingIssues.length > 0) {
64
+ console.log(chalk_1.default.bold.yellow('\n🌳 Tree-Shaking Issues\n'));
65
+ result.treeshakingIssues.slice(0, 3).forEach(issue => {
66
+ console.log(` • ${issue}`);
67
+ });
68
+ if (result.treeshakingIssues.length > 3) {
69
+ console.log(` ... and ${result.treeshakingIssues.length - 3} more`);
70
+ }
71
+ console.log();
72
+ }
73
+ // Generate HTML report
74
+ (0, reports_1.generateHTMLReport)(result, options.output);
75
+ console.log(chalk_1.default.green(`✅ Report saved to ${options.output}`));
76
+ }
77
+ }
78
+ catch (error) {
79
+ spinner.fail('Analysis failed');
80
+ console.error(chalk_1.default.red(`Error: ${String(error)}`));
81
+ process.exit(1);
82
+ }
83
+ });
84
+ program.parse();
85
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,8CAAsB;AACt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AAC,CAAC;gBACH,IAAI,MAAM,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACxC,OAAO,CAAC,GAAG,CAAC,aAAa,MAAM,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC;gBACvE,CAAC;gBACD,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,CAAC;YAED,uBAAuB;YACvB,IAAA,4BAAkB,EAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,qBAAqB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,UAAU,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { Packlyze } from './analyzer/packlyze.js';
2
+ export * from './types.js';
3
+ export { generateHTMLReport } from './visualization/reports.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.generateHTMLReport = exports.Packlyze = void 0;
18
+ var packlyze_js_1 = require("./analyzer/packlyze.js");
19
+ Object.defineProperty(exports, "Packlyze", { enumerable: true, get: function () { return packlyze_js_1.Packlyze; } });
20
+ __exportStar(require("./types.js"), exports);
21
+ var reports_js_1 = require("./visualization/reports.js");
22
+ Object.defineProperty(exports, "generateHTMLReport", { enumerable: true, get: function () { return reports_js_1.generateHTMLReport; } });
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,sDAAkD;AAAzC,uGAAA,QAAQ,OAAA;AACjB,6CAA2B;AAC3B,yDAAgE;AAAvD,gHAAA,kBAAkB,OAAA"}
@@ -0,0 +1,51 @@
1
+ export interface BundleStats {
2
+ name: string;
3
+ size: number;
4
+ gzipSize?: number;
5
+ modules: ModuleInfo[];
6
+ chunks: ChunkInfo[];
7
+ isInitialBySize: number;
8
+ isInitialByCount: number;
9
+ parsedSize: number;
10
+ }
11
+ export interface ModuleInfo {
12
+ name: string;
13
+ size: number;
14
+ gzipSize?: number;
15
+ percentage: number;
16
+ reasons: string[];
17
+ }
18
+ export interface ChunkInfo {
19
+ id: string | number;
20
+ name: string;
21
+ size: number;
22
+ gzipSize?: number;
23
+ modules: string[];
24
+ }
25
+ export interface Recommendation {
26
+ severity: 'critical' | 'warning' | 'info';
27
+ message: string;
28
+ action: string;
29
+ }
30
+ export interface BundleMetrics {
31
+ totalSize: number;
32
+ totalGzipSize: number;
33
+ moduleCount: number;
34
+ chunkCount: number;
35
+ largestModule: ModuleInfo;
36
+ averageModuleSize: number;
37
+ }
38
+ export interface DuplicateModule {
39
+ names: string[];
40
+ totalSize: number;
41
+ savings: number;
42
+ }
43
+ export interface AnalysisResult {
44
+ bundleStats: BundleStats;
45
+ recommendations: Recommendation[];
46
+ treeshakingIssues: string[];
47
+ duplicates: DuplicateModule[];
48
+ metrics: BundleMetrics;
49
+ timestamp: string;
50
+ }
51
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,UAAU,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,OAAO,EAAE,aAAa,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB"}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { AnalysisResult } from '../types.js';
2
+ export declare function generateHTMLReport(result: AnalysisResult, outputPath: string): void;
3
+ //# sourceMappingURL=reports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../src/visualization/reports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAGnF"}
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateHTMLReport = generateHTMLReport;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ function generateHTMLReport(result, outputPath) {
9
+ const html = generateHTML(result);
10
+ fs_1.default.writeFileSync(outputPath, html);
11
+ }
12
+ function generateHTML(result) {
13
+ const recommendations = result.recommendations
14
+ .map(rec => `
15
+ <div class="recommendation ${rec.severity}">
16
+ <div class="rec-icon">${rec.severity === 'critical' ? '🔴' : rec.severity === 'warning' ? '🟡' : '🟢'}</div>
17
+ <div class="rec-content">
18
+ <div class="rec-message">${escapeHtml(rec.message)}</div>
19
+ <div class="rec-action">Action: ${escapeHtml(rec.action)}</div>
20
+ </div>
21
+ </div>
22
+ `)
23
+ .join('');
24
+ const topModules = result.bundleStats.modules
25
+ .slice(0, 10)
26
+ .map(m => `
27
+ <tr>
28
+ <td>${escapeHtml(m.name.slice(-50))}</td>
29
+ <td>${(m.size / 1024).toFixed(2)} KB</td>
30
+ <td>${m.percentage.toFixed(2)}%</td>
31
+ </tr>
32
+ `)
33
+ .join('');
34
+ return `
35
+ <!DOCTYPE html>
36
+ <html lang="en">
37
+ <head>
38
+ <meta charset="UTF-8">
39
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
40
+ <title>Package Analysis Report</title>
41
+ <style>
42
+ * { margin: 0; padding: 0; box-sizing: border-box; }
43
+ body {
44
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
45
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
46
+ color: #333;
47
+ min-height: 100vh;
48
+ padding: 20px;
49
+ }
50
+ .container { max-width: 1200px; margin: 0 auto; }
51
+ header {
52
+ background: white;
53
+ padding: 30px;
54
+ border-radius: 8px;
55
+ margin-bottom: 20px;
56
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
57
+ }
58
+ h1 { color: #667eea; font-size: 28px; margin-bottom: 10px; }
59
+ .timestamp { color: #999; font-size: 12px; }
60
+
61
+ .metrics-grid {
62
+ display: grid;
63
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
64
+ gap: 15px;
65
+ margin-bottom: 20px;
66
+ }
67
+ .metric-card {
68
+ background: white;
69
+ padding: 20px;
70
+ border-radius: 8px;
71
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
72
+ }
73
+ .metric-label { color: #999; font-size: 12px; text-transform: uppercase; margin-bottom: 10px; }
74
+ .metric-value { font-size: 24px; font-weight: bold; color: #667eea; }
75
+
76
+ .section {
77
+ background: white;
78
+ padding: 25px;
79
+ border-radius: 8px;
80
+ margin-bottom: 20px;
81
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
82
+ }
83
+ .section h2 { color: #333; margin-bottom: 15px; font-size: 18px; border-bottom: 2px solid #eee; padding-bottom: 10px; }
84
+
85
+ .recommendation {
86
+ display: flex;
87
+ gap: 15px;
88
+ padding: 15px;
89
+ margin-bottom: 10px;
90
+ border-radius: 6px;
91
+ border-left: 4px solid;
92
+ }
93
+ .recommendation.critical { background: #fff5f5; border-left-color: #f56565; }
94
+ .recommendation.warning { background: #fffaf0; border-left-color: #ed8936; }
95
+ .recommendation.info { background: #ebf8ff; border-left-color: #4299e1; }
96
+
97
+ .rec-icon { font-size: 24px; }
98
+ .rec-content { flex: 1; }
99
+ .rec-message { font-weight: 600; margin-bottom: 5px; }
100
+ .rec-action { font-size: 13px; color: #666; }
101
+
102
+ table { width: 100%; border-collapse: collapse; }
103
+ th { background: #f7f7f7; padding: 12px; text-align: left; font-weight: 600; border-bottom: 2px solid #eee; }
104
+ td { padding: 12px; border-bottom: 1px solid #eee; }
105
+ tr:hover { background: #f9f9f9; }
106
+
107
+ footer { text-align: center; color: #999; font-size: 12px; margin-top: 30px; }
108
+ </style>
109
+ </head>
110
+ <body>
111
+ <div class="container">
112
+ <header>
113
+ <h1>📊 Package Analysis Report</h1>
114
+ <div class="timestamp">Generated: ${new Date(result.timestamp).toLocaleString()}</div>
115
+ </header>
116
+
117
+ <div class="metrics-grid">
118
+ <div class="metric-card">
119
+ <div class="metric-label">Total Size</div>
120
+ <div class="metric-value">${(result.metrics.totalSize / 1024 / 1024).toFixed(2)} MB</div>
121
+ </div>
122
+ <div class="metric-card">
123
+ <div class="metric-label">Gzip Size</div>
124
+ <div class="metric-value">${(result.metrics.totalGzipSize / 1024 / 1024).toFixed(2)} MB</div>
125
+ </div>
126
+ <div class="metric-card">
127
+ <div class="metric-label">Modules</div>
128
+ <div class="metric-value">${result.metrics.moduleCount}</div>
129
+ </div>
130
+ <div class="metric-card">
131
+ <div class="metric-label">Chunks</div>
132
+ <div class="metric-value">${result.metrics.chunkCount}</div>
133
+ </div>
134
+ <div class="metric-card">
135
+ <div class="metric-label">Avg Module Size</div>
136
+ <div class="metric-value">${(result.metrics.averageModuleSize / 1024).toFixed(2)} KB</div>
137
+ </div>
138
+ <div class="metric-card">
139
+ <div class="metric-label">Largest Module</div>
140
+ <div class="metric-value">${(result.metrics.largestModule.size / 1024).toFixed(2)} KB</div>
141
+ </div>
142
+ </div>
143
+
144
+ ${result.recommendations.length > 0 ? `
145
+ <div class="section">
146
+ <h2>💡 Recommendations</h2>
147
+ ${recommendations}
148
+ </div>
149
+ ` : ''}
150
+
151
+ <div class="section">
152
+ <h2>📦 Top 10 Modules by Size</h2>
153
+ <table>
154
+ <thead>
155
+ <tr>
156
+ <th>Module Name</th>
157
+ <th>Size</th>
158
+ <th>Percentage</th>
159
+ </tr>
160
+ </thead>
161
+ <tbody>
162
+ ${topModules}
163
+ </tbody>
164
+ </table>
165
+ </div>
166
+
167
+ <footer>
168
+ <p>Package Analyzer Plus v1.0.0 - Advanced Package Analysis Tool</p>
169
+ </footer>
170
+ </div>
171
+ </body>
172
+ </html>
173
+ `;
174
+ }
175
+ function escapeHtml(text) {
176
+ const map = {
177
+ '&': '&amp;',
178
+ '<': '&lt;',
179
+ '>': '&gt;',
180
+ '"': '&quot;',
181
+ "'": '&#039;'
182
+ };
183
+ return text.replace(/[&<>"']/g, char => map[char]);
184
+ }
185
+ //# sourceMappingURL=reports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reports.js","sourceRoot":"","sources":["../../src/visualization/reports.ts"],"names":[],"mappings":";;;;;AAGA,gDAGC;AAND,4CAAoB;AAGpB,SAAgB,kBAAkB,CAAC,MAAsB,EAAE,UAAkB;IAC3E,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAClC,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,YAAY,CAAC,MAAsB;IAC1C,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe;SAC3C,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;mCACmB,GAAG,CAAC,QAAQ;gCACf,GAAG,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;;qCAExE,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC;4CAChB,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC;;;KAG7D,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;IAEZ,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO;SAC1C,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;SACZ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;;cAEA,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;cAC7B,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;cAC1B,CAAC,CAAC,UAAU,C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,CAAC;AACrD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "packlyze",
3
+ "version": "1.0.0",
4
+ "description": "Advanced bundle analyzer with insights, recommendations, and historical tracking",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ }
12
+ },
13
+ "bin": {
14
+ "packlyze": "./dist/cli.js"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "tsc --watch",
22
+ "test": "vitest",
23
+ "test:coverage": "vitest --coverage",
24
+ "lint": "eslint src --fix",
25
+ "format": "prettier --write src",
26
+ "prepublishOnly": "npm run build && npm run test && npm run lint"
27
+ },
28
+ "keywords": [
29
+ "bundle",
30
+ "analyzer",
31
+ "optimization",
32
+ "performance",
33
+ "webpack",
34
+ "rollup",
35
+ "esbuild",
36
+ "tree-shaking",
37
+ "bundle-size",
38
+ "code-splitting"
39
+ ],
40
+ "author": "Abhishek Srinivasan",
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/iamabhshk/packlyze"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/iamabhshk/packlyze/issues"
48
+ },
49
+ "homepage": "https://github.com/iamabhshk/packlyze#readme",
50
+ "dependencies": {
51
+ "commander": "^12.0.0",
52
+ "chalk": "^5.3.0",
53
+ "inquirer": "^9.2.0",
54
+ "ora": "^8.0.0",
55
+ "table": "^6.8.0"
56
+ },
57
+ "devDependencies": {
58
+ "typescript": "^5.3.0",
59
+ "@types/node": "^20.10.0",
60
+ "vitest": "^1.0.0",
61
+ "@vitest/coverage-v8": "^1.0.0",
62
+ "@typescript-eslint/eslint-plugin": "^6.13.0",
63
+ "@typescript-eslint/parser": "^6.13.0",
64
+ "eslint": "^8.55.0",
65
+ "prettier": "^3.1.0"
66
+ }
67
+ }