lambda-live-debugger 1.0.0 → 1.0.2
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/.vitepress/config.mts
CHANGED
|
@@ -28,7 +28,7 @@ export default defineConfig({
|
|
|
28
28
|
['meta', { property: 'og:image', content: 'https://lldebugger.com/lambda_live_debugger.png' }],
|
|
29
29
|
['meta', { property: 'og:url', content: 'https://lldebugger.com/' }],
|
|
30
30
|
|
|
31
|
-
['meta', { property: 'twitter:card', content: '
|
|
31
|
+
['meta', { property: 'twitter:card', content: 'summary_large_image' }],
|
|
32
32
|
['meta', { property: 'twitter:site', content: '@serverlessl' }],
|
|
33
33
|
|
|
34
34
|
[
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 
|
|
2
2
|
|
|
3
|
-
Lambda Live Debugger is an indispensable tool for debugging AWS Lambda functions from your computer, even though they are deployed in the cloud. It supports Lambdas written in JavaScript or TypeScript.
|
|
3
|
+
Lambda Live Debugger is an indispensable tool for debugging AWS Lambda functions from your computer, even though they are deployed in the cloud. It supports Lambdas written in JavaScript or TypeScript. It is free and open source.
|
|
4
4
|
|
|
5
5
|
This tool offers similar functionality to [SST](https://sst.dev/) and [Serverless Framework v4](https://www.serverless.com/blog/serverless-framework-v4-general-availability), with the addition of an Observability Mode.
|
|
6
6
|
|
|
Binary file
|
|
@@ -193,17 +193,55 @@ export class CdkFramework {
|
|
|
193
193
|
});
|
|
194
194
|
},
|
|
195
195
|
};
|
|
196
|
-
|
|
196
|
+
let isESM = false;
|
|
197
|
+
// get packgage.json
|
|
198
|
+
const packageJsonPath = await findPackageJson(entryFile);
|
|
199
|
+
if (packageJsonPath) {
|
|
200
|
+
try {
|
|
201
|
+
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, { encoding: 'utf-8' }));
|
|
202
|
+
if (packageJson.type === 'module') {
|
|
203
|
+
isESM = true;
|
|
204
|
+
Logger.verbose(`[CDK] Using ESM format`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
Logger.error(`Error reading CDK package.json (${packageJsonPath}): ${err.message}`, err);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const compileOutput = path.join(getProjectDirname(), outputFolder, `compiledCdk.${isESM ? 'mjs' : 'cjs'}`);
|
|
197
212
|
try {
|
|
198
213
|
// Build CDK code
|
|
199
214
|
await esbuild.build({
|
|
200
215
|
entryPoints: [entryFile],
|
|
201
216
|
bundle: true,
|
|
202
217
|
platform: 'node',
|
|
203
|
-
|
|
218
|
+
keepNames: true,
|
|
204
219
|
outfile: compileOutput,
|
|
205
220
|
sourcemap: false,
|
|
206
221
|
plugins: [injectCodePlugin],
|
|
222
|
+
...(isESM
|
|
223
|
+
? {
|
|
224
|
+
format: 'esm',
|
|
225
|
+
target: 'esnext',
|
|
226
|
+
mainFields: ['module', 'main'],
|
|
227
|
+
banner: {
|
|
228
|
+
js: [
|
|
229
|
+
`import { createRequire as topLevelCreateRequire } from 'module';`,
|
|
230
|
+
`global.require = global.require ?? topLevelCreateRequire(import.meta.url);`,
|
|
231
|
+
`import { fileURLToPath as topLevelFileUrlToPath, URL as topLevelURL } from "url"`,
|
|
232
|
+
`global.__dirname = global.__dirname ?? topLevelFileUrlToPath(new topLevelURL(".", import.meta.url))`,
|
|
233
|
+
].join('\n'),
|
|
234
|
+
},
|
|
235
|
+
}
|
|
236
|
+
: {
|
|
237
|
+
format: 'cjs',
|
|
238
|
+
target: 'node18',
|
|
239
|
+
banner: {
|
|
240
|
+
js: [
|
|
241
|
+
`__dirname = '${path.join(...[getProjectDirname(), config.subfolder, 'x'].filter((p) => p))}';`,
|
|
242
|
+
].join('\n'),
|
|
243
|
+
},
|
|
244
|
+
}),
|
|
207
245
|
});
|
|
208
246
|
}
|
|
209
247
|
catch (error) {
|
|
@@ -296,6 +334,12 @@ export class CdkFramework {
|
|
|
296
334
|
reject(new Error(`CDK worker stopped with exit code ${code}`));
|
|
297
335
|
}
|
|
298
336
|
});
|
|
337
|
+
// worker.stdout.on('data', (data: Buffer) => {
|
|
338
|
+
// Logger.log(`[CDK]`, data.toString());
|
|
339
|
+
// });
|
|
340
|
+
// worker.stderr.on('data', (data: Buffer) => {
|
|
341
|
+
// Logger.error(`[CDK]`, data.toString());
|
|
342
|
+
// });
|
|
299
343
|
worker.postMessage({
|
|
300
344
|
compileOutput: compileCodeFile,
|
|
301
345
|
});
|
|
@@ -4,56 +4,53 @@ const require = topLevelCreateRequire(import.meta.url);
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
|
|
6
6
|
import { workerData, parentPort } from 'node:worker_threads';
|
|
7
|
-
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
|
+
import fs from 'fs/promises'; // do not delete this line
|
|
8
9
|
|
|
9
10
|
import { Logger } from '../logger.mjs';
|
|
10
11
|
|
|
11
12
|
Logger.setVerbose(workerData.verbose);
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
-
const __dirname = path.resolve(
|
|
14
|
-
path.join(
|
|
15
|
-
...[workerData.projectDirname, workerData.subfolder, 'x'].filter((p) => p),
|
|
16
|
-
),
|
|
17
|
-
);
|
|
18
13
|
|
|
19
14
|
Logger.verbose(`[CDK] [Worker] Started`);
|
|
20
15
|
|
|
21
16
|
parentPort.on('message', async (data) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
17
|
+
try {
|
|
18
|
+
// this is global variable to store the data from the CDK code once it is executed
|
|
19
|
+
global.lambdas = [];
|
|
20
|
+
|
|
21
|
+
Logger.verbose(`[Worker ${workerData.workerId}] Received message`, data);
|
|
22
|
+
|
|
23
|
+
// execute code to get the data into global.lambdas
|
|
24
|
+
await fixCdkPaths(workerData.awsCdkLibPath);
|
|
25
|
+
await import(data.compileOutput);
|
|
26
|
+
|
|
27
|
+
if (!global.lambdas || global.lambdas?.length === 0) {
|
|
28
|
+
throw new Error('No Lambda functions found in the CDK code');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const lambdas = global.lambdas.map((lambda) => ({
|
|
32
|
+
handler: lambda.handler,
|
|
33
|
+
stackName: lambda.stackName,
|
|
34
|
+
codePath: lambda.codePath,
|
|
35
|
+
code: {
|
|
36
|
+
path: lambda.code?.path,
|
|
37
|
+
},
|
|
38
|
+
cdkPath: lambda.node.defaultChild.node.path,
|
|
39
|
+
bundling: {
|
|
40
|
+
...lambda.bundling,
|
|
41
|
+
commandHooks: undefined, // can not be serialized
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
Logger.verbose(
|
|
46
|
+
`[CDK] [Worker] Sending found lambdas`,
|
|
47
|
+
JSON.stringify(lambdas, null, 2),
|
|
48
|
+
);
|
|
49
|
+
parentPort.postMessage(lambdas);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
Logger.error(`[CDK] [Worker] Error`, error);
|
|
52
|
+
throw error;
|
|
36
53
|
}
|
|
37
|
-
|
|
38
|
-
const lambdas = global.lambdas.map((lambda) => ({
|
|
39
|
-
handler: lambda.handler,
|
|
40
|
-
stackName: lambda.stackName,
|
|
41
|
-
codePath: lambda.codePath,
|
|
42
|
-
code: {
|
|
43
|
-
path: lambda.code?.path,
|
|
44
|
-
},
|
|
45
|
-
cdkPath: lambda.node.defaultChild.node.path,
|
|
46
|
-
bundling: {
|
|
47
|
-
...lambda.bundling,
|
|
48
|
-
commandHooks: undefined, // can not be serialized
|
|
49
|
-
},
|
|
50
|
-
}));
|
|
51
|
-
|
|
52
|
-
Logger.verbose(
|
|
53
|
-
`[CDK] [Worker] Sending found lambdas`,
|
|
54
|
-
JSON.stringify(lambdas, null, 2),
|
|
55
|
-
);
|
|
56
|
-
parentPort.postMessage(lambdas);
|
|
57
54
|
});
|
|
58
55
|
|
|
59
56
|
/**
|
|
@@ -105,3 +102,7 @@ async function fixCdkPaths(awsCdkLibPath) {
|
|
|
105
102
|
exports: pathProxy,
|
|
106
103
|
};
|
|
107
104
|
}
|
|
105
|
+
|
|
106
|
+
process.on('unhandledRejection', (error) => {
|
|
107
|
+
Logger.error(`[CDK] [Worker] Unhandled Rejection`, error);
|
|
108
|
+
});
|
package/dist/nodeWorker.mjs
CHANGED
|
@@ -71,7 +71,7 @@ function startWorker(input) {
|
|
|
71
71
|
Logger.log(`[Function ${input.functionId}]`, data.toString());
|
|
72
72
|
});
|
|
73
73
|
worker.stderr.on('data', (data) => {
|
|
74
|
-
Logger.
|
|
74
|
+
Logger.error(`[Function ${input.functionId}]`, data.toString());
|
|
75
75
|
});
|
|
76
76
|
worker.on('exit', () => {
|
|
77
77
|
Logger.verbose(`[Function ${input.functionId}] [Worker ${input.workerId}] Worker exited`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lambda-live-debugger",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Debug Lambda functions locally like it is running in the cloud",
|
|
6
6
|
"repository": {
|
|
@@ -49,6 +49,8 @@
|
|
|
49
49
|
"test": "npm run build && RUN_TEST_FROM_CLI=true vitest run && RUN_TEST_FROM_CLI=true OBSERVABLE_MODE=true vitest run",
|
|
50
50
|
"test-cdk-basic": "npm run build && RUN_TEST_FROM_CLI=true vitest run test/cdk-basic.test.ts",
|
|
51
51
|
"test-cdk-basic-observable": "npm run build && RUN_TEST_FROM_CLI=true OBSERVABLE_MODE=true vitest run test/cdk-basic.test.ts",
|
|
52
|
+
"test-cdk-esm": "npm run build && RUN_TEST_FROM_CLI=true vitest run test/cdk-esm.test.ts",
|
|
53
|
+
"test-cdk-esm-observable": "npm run build && RUN_TEST_FROM_CLI=true OBSERVABLE_MODE=true vitest run test/cdk-esm.test.ts",
|
|
52
54
|
"test-sls-basic": "npm run build && RUN_TEST_FROM_CLI=true vitest run test/sls-basic.test.ts",
|
|
53
55
|
"test-sls-basic-observable": "npm run build && RUN_TEST_FROM_CLI=true OBSERVABLE_MODE=true vitest run test/sls-basic.test.ts",
|
|
54
56
|
"test-sls-esbuild-cjs": "npm run build && RUN_TEST_FROM_CLI=true vitest run test/sls-esbuild-cjs.test.ts",
|
|
@@ -130,6 +132,7 @@
|
|
|
130
132
|
"src/extension/*",
|
|
131
133
|
"test",
|
|
132
134
|
"test/cdk-basic",
|
|
135
|
+
"test/cdk-esm",
|
|
133
136
|
"test/cdk-config",
|
|
134
137
|
"test/sls-basic",
|
|
135
138
|
"test/sls-esbuild",
|
|
Binary file
|