@@ -12,8 +12,8 @@ const LAMBDA_FUNCTIONS_WITH_LAYER_DIR = './src/lambda-functions-layer';
1212const LAMBDA_FUNCTIONS_WITH_NPM_DIR = './src/lambda-functions-npm' ;
1313const LAMBDA_FUNCTION_TIMEOUT = 10 ;
1414const LAYER_DIR = './node_modules/@sentry/aws-serverless/' ;
15+ const DEFAULT_NODE_VERSION = '22' ;
1516export const SAM_PORT = 3001 ;
16- const NODE_RUNTIME = `nodejs${ process . version . split ( '.' ) . at ( 0 ) ?. replace ( 'v' , '' ) } .x` ;
1717
1818export class LocalLambdaStack extends Stack {
1919 sentryLayer : CfnResource ;
@@ -73,22 +73,20 @@ export class LocalLambdaStack extends Stack {
7373 execFileSync ( 'npm' , [ 'install' , '--prefix' , path . join ( functionsDir , lambdaDir ) ] , { stdio : 'inherit' } ) ;
7474 }
7575
76- const isEsm = fs . existsSync ( path . join ( functionsDir , lambdaDir , 'index.mjs' ) ) ;
77-
7876 new CfnResource ( this , functionName , {
7977 type : 'AWS::Serverless::Function' ,
8078 properties : {
8179 CodeUri : path . join ( functionsDir , lambdaDir ) ,
8280 Handler : 'index.handler' ,
83- Runtime : NODE_RUNTIME ,
81+ Runtime : `nodejs ${ process . env . NODE_VERSION ?? DEFAULT_NODE_VERSION } .x` ,
8482 Timeout : LAMBDA_FUNCTION_TIMEOUT ,
8583 Layers : addLayer ? [ { Ref : this . sentryLayer . logicalId } ] : undefined ,
8684 Environment : {
8785 Variables : {
8886 SENTRY_DSN : dsn ,
8987 SENTRY_TRACES_SAMPLE_RATE : 1.0 ,
9088 SENTRY_DEBUG : true ,
91- NODE_OPTIONS : `--${ isEsm ? ' import' : 'require' } =@sentry/aws-serverless/awslambda-auto` ,
89+ NODE_OPTIONS : `--import=@sentry/aws-serverless/awslambda-auto` ,
9290 } ,
9391 } ,
9492 } ,
0 commit comments