lambda-live-debugger 1.1.1 → 1.1.3

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.
@@ -21,6 +21,6 @@ export declare class SlsFramework implements IFramework {
21
21
  * @returns Lambda functions
22
22
  */
23
23
  getLambdas(config: LldConfigBase): Promise<LambdaResource[]>;
24
- protected getEsBuildOptions(serverless: Serverless): EsBuildOptions | undefined;
24
+ protected getEsBuildOptions(serverless: Serverless, config: LldConfigBase): EsBuildOptions | undefined;
25
25
  }
26
26
  export declare const slsFramework: SlsFramework;
@@ -47,6 +47,9 @@ export class SlsFramework {
47
47
  process.argv = [];
48
48
  let resolveConfigurationPath;
49
49
  let readConfiguration;
50
+ let resolveVariables;
51
+ let resolveVariablesMeta;
52
+ let sources;
50
53
  let Serverless;
51
54
  try {
52
55
  // lazy load modules
@@ -56,11 +59,43 @@ export class SlsFramework {
56
59
  readConfiguration = (await import(
57
60
  //@ts-ignore
58
61
  'serverless/lib/configuration/read.js')).default;
62
+ resolveVariables = (await import(
63
+ //@ts-ignore
64
+ 'serverless/lib/configuration/variables/resolve.js')).default;
65
+ resolveVariablesMeta = (await import(
66
+ //@ts-ignore
67
+ 'serverless/lib/configuration/variables/resolve-meta.js')).default;
68
+ const env = await import(
69
+ //@ts-ignore
70
+ 'serverless/lib/configuration/variables/sources/env.js');
71
+ const file = await import(
72
+ //@ts-ignore
73
+ 'serverless/lib/configuration/variables/sources/file.js');
74
+ const opt = await import(
75
+ //@ts-ignore
76
+ 'serverless/lib/configuration/variables/sources/opt.js');
77
+ const self = await import(
78
+ //@ts-ignore
79
+ 'serverless/lib/configuration/variables/sources/self.js');
80
+ const strToBool = await import(
81
+ //@ts-ignore
82
+ 'serverless/lib/configuration/variables/sources/str-to-bool.js');
83
+ const sls = await import(
84
+ //@ts-ignores
85
+ 'serverless/lib/configuration/variables/sources/instance-dependent/get-sls.js');
86
+ sources = {
87
+ env: env.default,
88
+ file: file.default,
89
+ opt: opt.default,
90
+ self: self.default,
91
+ strToBool: strToBool.default,
92
+ sls: sls.default(),
93
+ };
59
94
  Serverless = (await import('serverless')).default;
60
95
  }
61
96
  catch (error) {
62
97
  Logger.error('Error loading serverless modules', error);
63
- Logger.log('If you are running Lambda Live Debugger from a global installation, install Serverless Framework globally as well.');
98
+ Logger.log('If you are running Lambda Live Debugger from a global installation, install Serverless Framework globally as well. If you are using monorepo, install Serverless Framework also in the project root folder.');
64
99
  throw new Error(`Error loading serverless modules. ${error.message}`, {
65
100
  cause: error,
66
101
  });
@@ -83,7 +118,15 @@ export class SlsFramework {
83
118
  if (config.profile) {
84
119
  options.profile = config.profile;
85
120
  }
86
- const variablesMeta = {};
121
+ const variablesMeta = resolveVariablesMeta(configuration);
122
+ await resolveVariables({
123
+ serviceDir,
124
+ configuration,
125
+ variablesMeta,
126
+ sources,
127
+ options,
128
+ fulfilledSources: new Set(),
129
+ });
87
130
  let serverless;
88
131
  try {
89
132
  serverless = new Serverless({
@@ -117,7 +160,7 @@ export class SlsFramework {
117
160
  });
118
161
  }
119
162
  const lambdasDiscovered = [];
120
- const esBuildOptions = this.getEsBuildOptions(serverless);
163
+ const esBuildOptions = this.getEsBuildOptions(serverless, config);
121
164
  const lambdas = serverless.service.functions;
122
165
  Logger.verbose(`[SLS] Found Lambdas:`, JSON.stringify(lambdas, null, 2));
123
166
  for (const func in lambdas) {
@@ -165,7 +208,8 @@ export class SlsFramework {
165
208
  }
166
209
  return lambdasDiscovered;
167
210
  }
168
- getEsBuildOptions(serverless) {
211
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
212
+ getEsBuildOptions(serverless, config) {
169
213
  // 1) Get from from LLD specific options in custom.lldEsBuild
170
214
  let esBuildOptions = serverless.service.custom?.lldEsBuild;
171
215
  // 2) Get from serverless-esbuild plugin
@@ -189,7 +233,7 @@ export class SlsFramework {
189
233
  const settings = serverless.service.custom?.serverlessPluginTypescript;
190
234
  if (settings) {
191
235
  esBuildOptions = {
192
- tsconfig: settings.tsConfigFileLocation,
236
+ tsconfig: path.resolve(settings.tsConfigFileLocation),
193
237
  };
194
238
  }
195
239
  }
@@ -102,7 +102,7 @@ async function build(input) {
102
102
  isESM = false;
103
103
  }
104
104
  let ctx = input.oldCtx;
105
- Logger.verbose(`[Function ${input.functionId}] Module type: ${isESM ? 'ESM' : 'CJS'})`);
105
+ Logger.verbose(`[Function ${input.functionId}] Module type: ${isESM ? 'ESM' : 'CJS'}`);
106
106
  if (!ctx) {
107
107
  const optionsDefault = {
108
108
  entryPoints: [handlerCodePath],
@@ -103,13 +103,6 @@ async function stopAllWorkers() {
103
103
  for (const worker of workers.values()) {
104
104
  if (worker.used) {
105
105
  worker.toKill = true;
106
- // set timout for 5 minutes and kill the worker if it is still running
107
- setTimeout(() => {
108
- if (worker.toKill) {
109
- worker.toKill = false;
110
- void worker.terminate();
111
- }
112
- }, 300000);
113
106
  }
114
107
  else {
115
108
  promises.push(worker.terminate());
@@ -65,7 +65,7 @@ process.on('unhandledRejection', (error) => {
65
65
  function handleError(error) {
66
66
  parentPort.postMessage({
67
67
  errorType: error.name ?? 'Error',
68
- errorMessage: error.message,
68
+ errorMessage: error.message ?? error.toString(),
69
69
  trace: error.stack,
70
70
  });
71
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambda-live-debugger",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "description": "Debug Lambda functions locally like it is running in the cloud",
6
6
  "repository": {