@@ -62,72 +62,38 @@ export class SlsFramework implements IFramework {
6262 let resolveVariablesMeta : any ;
6363 let sources : any ;
6464 let Serverless : any ;
65+ let error1 : any | undefined ;
6566
6667 try {
67- // lazy load modules
68- resolveConfigurationPath = (
69- await import (
70- //@ts -ignore
71- 'serverless/lib/cli/resolve-configuration-path.js'
72- )
73- ) . default ;
74- readConfiguration = (
75- await import (
76- //@ts -ignore
77- 'serverless/lib/configuration/read.js'
78- )
79- ) . default ;
80- resolveVariables = (
81- await import (
82- //@ts -ignore
83- 'serverless/lib/configuration/variables/resolve.js'
84- )
85- ) . default ;
86- resolveVariablesMeta = (
87- await import (
88- //@ts -ignore
89- 'serverless/lib/configuration/variables/resolve-meta.js'
90- )
91- ) . default ;
92- const env = await import (
93- //@ts -ignore
94- 'serverless/lib/configuration/variables/sources/env.js'
95- ) ;
96- const file = await import (
97- //@ts -ignore
98- 'serverless/lib/configuration/variables/sources/file.js'
99- ) ;
100- const opt = await import (
101- //@ts -ignore
102- 'serverless/lib/configuration/variables/sources/opt.js'
103- ) ;
104- const self = await import (
105- //@ts -ignore
106- 'serverless/lib/configuration/variables/sources/self.js'
107- ) ;
108- const strToBool = await import (
109- //@ts -ignore
110- 'serverless/lib/configuration/variables/sources/str-to-bool.js'
111- ) ;
112- const sls = await import (
113- //@ts -ignores
114- 'serverless/lib/configuration/variables/sources/instance-dependent/get-sls.js'
115- ) ;
116-
117- sources = {
118- env : env . default ,
119- file : file . default ,
120- opt : opt . default ,
121- self : self . default ,
122- strToBool : strToBool . default ,
123- sls : sls . default ( ) ,
124- } ;
125-
126- Serverless = ( await import ( 'serverless' ) ) . default ;
127- } catch ( error : any ) {
128- Logger . error ( 'Error loading serverless modules' , error ) ;
68+ try {
69+ const frameworkFunctions = await loadFramework ( 'serverless' ) ;
70+ resolveConfigurationPath = frameworkFunctions . resolveConfigurationPath ;
71+ readConfiguration = frameworkFunctions . readConfiguration ;
72+ resolveVariables = frameworkFunctions . resolveVariables ;
73+ resolveVariablesMeta = frameworkFunctions . resolveVariablesMeta ;
74+ sources = frameworkFunctions . sources ;
75+ Serverless = frameworkFunctions . Serverless ;
76+
77+ Logger . verbose ( `[SLS] Npm module 'serverless' loaded` ) ;
78+ } catch ( error : any ) {
79+ Logger . verbose ( `[SLS] Failed to load npm module 'serverless'` , error ) ;
80+
81+ error1 = error ;
82+ const frameworkFunctions = await loadFramework ( 'osls' ) ;
83+ resolveConfigurationPath = frameworkFunctions . resolveConfigurationPath ;
84+ readConfiguration = frameworkFunctions . readConfiguration ;
85+ resolveVariables = frameworkFunctions . resolveVariables ;
86+ resolveVariablesMeta = frameworkFunctions . resolveVariablesMeta ;
87+ sources = frameworkFunctions . sources ;
88+ Serverless = frameworkFunctions . Serverless ;
89+
90+ Logger . verbose ( `[SLS] Npm module 'osls' loaded` ) ;
91+ }
92+ } catch ( error2 : any ) {
93+ const error = error1 ?? error2 ;
94+ Logger . error ( 'Error loading serverless (or osls) module' , error ) ;
12995 Logger . log (
130- '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.' ,
96+ '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. The fork of Serverless Framework https://github.com/oss-serverless/serverless is also supported. ' ,
13197 ) ;
13298 throw new Error ( `Error loading serverless modules. ${ error . message } ` , {
13399 cause : error ,
@@ -315,3 +281,73 @@ export class SlsFramework implements IFramework {
315281}
316282
317283export const slsFramework = new SlsFramework ( ) ;
284+ async function loadFramework ( npmName : string ) {
285+ // lazy load modules
286+ const resolveConfigurationPath = (
287+ await import (
288+ //@ts -ignore
289+ `${ npmName } /lib/cli/resolve-configuration-path.js`
290+ )
291+ ) . default ;
292+ const readConfiguration = (
293+ await import (
294+ //@ts -ignore
295+ `${ npmName } /lib/configuration/read.js`
296+ )
297+ ) . default ;
298+ const resolveVariables = (
299+ await import (
300+ //@ts -ignore
301+ `${ npmName } /lib/configuration/variables/resolve.js`
302+ )
303+ ) . default ;
304+ const resolveVariablesMeta = (
305+ await import (
306+ //@ts -ignore
307+ `${ npmName } /lib/configuration/variables/resolve-meta.js`
308+ )
309+ ) . default ;
310+ const env = await import (
311+ //@ts -ignore
312+ `${ npmName } /lib/configuration/variables/sources/env.js`
313+ ) ;
314+ const file = await import (
315+ //@ts -ignore
316+ `${ npmName } /lib/configuration/variables/sources/file.js`
317+ ) ;
318+ const opt = await import (
319+ //@ts -ignore
320+ `${ npmName } /lib/configuration/variables/sources/opt.js`
321+ ) ;
322+ const self = await import (
323+ //@ts -ignore
324+ `${ npmName } /lib/configuration/variables/sources/self.js`
325+ ) ;
326+ const strToBool = await import (
327+ //@ts -ignore
328+ `${ npmName } /lib/configuration/variables/sources/str-to-bool.js`
329+ ) ;
330+ const sls = await import (
331+ //@ts -ignores
332+ `${ npmName } /lib/configuration/variables/sources/instance-dependent/get-sls.js`
333+ ) ;
334+
335+ const sources = {
336+ env : env . default ,
337+ file : file . default ,
338+ opt : opt . default ,
339+ self : self . default ,
340+ strToBool : strToBool . default ,
341+ sls : sls . default ( ) ,
342+ } ;
343+
344+ const Serverless = ( await import ( npmName ) ) . default ;
345+ return {
346+ resolveConfigurationPath,
347+ readConfiguration,
348+ resolveVariablesMeta,
349+ resolveVariables,
350+ sources,
351+ Serverless,
352+ } ;
353+ }
0 commit comments