@@ -12,6 +12,7 @@ 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 WORKSPACE_AWS_SERVERLESS_DIR = path . resolve ( __dirname , '../../../../../packages/aws-serverless' ) ;
1516const DEFAULT_NODE_VERSION = '22' ;
1617export const SAM_PORT = 3001 ;
1718
@@ -68,9 +69,19 @@ export class LocalLambdaStack extends Stack {
6869
6970 if ( ! addLayer ) {
7071 console . log ( `[LocalLambdaStack] Install dependencies for ${ functionName } ` ) ;
71- const packageJson = { dependencies : { '@sentry/aws-serverless' : '* || latest' } } ;
72- fs . writeFileSync ( path . join ( functionsDir , lambdaDir , 'package.json' ) , JSON . stringify ( packageJson , null , 2 ) ) ;
73- execFileSync ( 'npm' , [ 'install' , '--prefix' , path . join ( functionsDir , lambdaDir ) ] , { stdio : 'inherit' } ) ;
72+
73+ const lambdaPath = path . resolve ( functionsDir , lambdaDir ) ;
74+ // Point the dependency at the locally built aws-serverless package so tests use the current workspace bits
75+ const localAwsServerlessPath = path . relative ( lambdaPath , WORKSPACE_AWS_SERVERLESS_DIR ) ;
76+ const dependencyPath = localAwsServerlessPath . replace ( / \\ / g, '/' ) ;
77+ const packageJson = {
78+ dependencies : {
79+ '@sentry/aws-serverless' : `file:${ dependencyPath } ` ,
80+ } ,
81+ } ;
82+
83+ fs . writeFileSync ( path . join ( lambdaPath , 'package.json' ) , JSON . stringify ( packageJson , null , 2 ) ) ;
84+ execFileSync ( 'npm' , [ 'install' , '--prefix' , lambdaPath ] , { stdio : 'inherit' } ) ;
7485 }
7586
7687 new CfnResource ( this , functionName , {
0 commit comments