lambda-doctor 0.1.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/README.md +150 -0
- package/dist/cli.js +737 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +692 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# ๐ฉบ Lambda Doctor
|
|
4
|
+
|
|
5
|
+
**Diagnose and fix AWS Lambda cold start performance issues.**
|
|
6
|
+
|
|
7
|
+
Static analysis CLI that scans your Node.js Lambda project and tells you exactly what's slowing down your cold starts โ and how to fix it.
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/lambda-doctor)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
[](https://www.typescriptlang.org/)
|
|
12
|
+
|
|
13
|
+
[Quick Start](#quick-start) ยท [What It Checks](#what-it-checks) ยท [Example Output](#example-output) ยท [How It Works](#how-it-works)
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## The Problem
|
|
20
|
+
|
|
21
|
+
Your Lambda cold starts take 3+ seconds. You've read every blog post. You know you should "use smaller packages" and "bundle your code" โ but which packages are actually heavy? Are your imports tree-shakeable? Is your AWS SDK setup optimal?
|
|
22
|
+
|
|
23
|
+
**Lambda Doctor** runs a single command and gives you a prioritized, actionable report with estimated millisecond savings for each issue.
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g lambda-doctor
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
lambda-doctor analyze ./my-lambda
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
That's it. You get a full diagnosis in seconds.
|
|
36
|
+
|
|
37
|
+
## What It Checks
|
|
38
|
+
|
|
39
|
+
| Analyzer | What it does | Severity |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| **Bundle Size** | Scans `node_modules`, reports total size and top 10 largest packages | ๐ด >50MB, โ ๏ธ >10MB |
|
|
42
|
+
| **Heavy Dependencies** | Flags known heavy packages (moment, lodash, axios, etc.) and dev tools in production | ๐ด dev tools in prod, โ ๏ธ heavy deps |
|
|
43
|
+
| **Import Analysis** | Detects `import *` (tree-shaking blocker) and top-level heavy imports | โ ๏ธ per pattern |
|
|
44
|
+
| **AWS SDK** | Detects v2 usage, incomplete v2โv3 migration, unnecessary clients (e.g. SSO in Lambda) | ๐ด v2, โ ๏ธ mixed |
|
|
45
|
+
| **Bundler Detection** | Checks for esbuild/webpack/rollup/tsup โ no bundler = biggest improvement opportunity | ๐ด no bundler |
|
|
46
|
+
|
|
47
|
+
## Example Output
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
๐ฉบ Lambda Doctor โ Diagnosis Report
|
|
51
|
+
|
|
52
|
+
๐ด CRITICAL Dev tool "typescript" in production dependencies
|
|
53
|
+
โ Move "typescript" from "dependencies" to "devDependencies".
|
|
54
|
+
โฑ Est. improvement: ~500ms
|
|
55
|
+
|
|
56
|
+
๐ด CRITICAL Using AWS SDK v2 (aws-sdk)
|
|
57
|
+
โ Migrate to AWS SDK v3 (@aws-sdk/client-*). Only import the clients you need.
|
|
58
|
+
โฑ Est. improvement: ~400ms
|
|
59
|
+
|
|
60
|
+
๐ด CRITICAL No bundler detected
|
|
61
|
+
โ Add esbuild (fastest) or webpack to bundle your Lambda function.
|
|
62
|
+
โฑ Est. improvement: ~500ms
|
|
63
|
+
|
|
64
|
+
โ ๏ธ WARNING Heavy dependency: moment
|
|
65
|
+
โ Use dayjs (2KB) or date-fns with tree-shaking.
|
|
66
|
+
โฑ Est. improvement: ~50ms
|
|
67
|
+
|
|
68
|
+
โ ๏ธ WARNING Wildcard import of "aws-sdk" prevents tree-shaking
|
|
69
|
+
โ Use named imports: import { specificFunction } from "aws-sdk"
|
|
70
|
+
โฑ Est. improvement: ~20ms
|
|
71
|
+
|
|
72
|
+
Summary: 3 critical | 12 warnings | 1 info
|
|
73
|
+
๐ Total estimated cold start improvement: ~2742.5ms
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## How It Works
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
lambda-doctor analyze ./my-lambda
|
|
80
|
+
โ
|
|
81
|
+
โผ
|
|
82
|
+
โโโโโโโโโโโโโโโโโโโโโโโ
|
|
83
|
+
โ Read package.json โ
|
|
84
|
+
โ Scan node_modules โ
|
|
85
|
+
โ Parse source files โ
|
|
86
|
+
โโโโโโโโโโฌโโโโโโโโโโโโโ
|
|
87
|
+
โ
|
|
88
|
+
โผ
|
|
89
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
90
|
+
โ 5 Analyzers (run in parallel) โ
|
|
91
|
+
โ โโ Bundle Size โ
|
|
92
|
+
โ โโ Heavy Dependencies โ
|
|
93
|
+
โ โโ Import Analysis โ
|
|
94
|
+
โ โโ AWS SDK โ
|
|
95
|
+
โ โโ Bundler Detection โ
|
|
96
|
+
โโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
97
|
+
โ
|
|
98
|
+
โผ
|
|
99
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
100
|
+
โ Diagnosis Report โ
|
|
101
|
+
โ โโ Prioritized by severity โ
|
|
102
|
+
โ โโ Actionable recommendations โ
|
|
103
|
+
โ โโ Estimated ms savings each โ
|
|
104
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
All analyzers run in parallel and never crash โ if one fails, you still get results from the others.
|
|
108
|
+
|
|
109
|
+
## CLI Options
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Console output (default)
|
|
113
|
+
lambda-doctor analyze ./my-lambda
|
|
114
|
+
|
|
115
|
+
# JSON output (for CI/CD pipelines)
|
|
116
|
+
lambda-doctor analyze ./my-lambda --format json
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Exit Codes
|
|
120
|
+
|
|
121
|
+
- `0` โ No critical issues found
|
|
122
|
+
- `1` โ Critical issues detected (useful for CI gates)
|
|
123
|
+
|
|
124
|
+
## Requirements
|
|
125
|
+
|
|
126
|
+
- Node.js >= 18
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
Contributions are welcome! Please check out the [issues](https://github.com/ozers/lambda-doctor/issues) page.
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
git clone https://github.com/ozers/lambda-doctor.git
|
|
134
|
+
cd lambda-doctor
|
|
135
|
+
npm install
|
|
136
|
+
npm run build
|
|
137
|
+
npm test
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
[MIT](LICENSE)
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
<div align="center">
|
|
147
|
+
|
|
148
|
+
Built by [Ozer](https://github.com/ozers) โ because staring at CloudWatch cold start metrics at 2am shouldn't be a regular thing.
|
|
149
|
+
|
|
150
|
+
</div>
|