Open
Description
Background
This issue is a follow-up to #34486 which was temporarily fixed by PR #34498. The temporary fix removed the usage of Injectable decorator from NodejsFunction
L2 construct.
Problem
The current implementation of findDefiningFile
in NodejsFunction
doesn't correctly handle cases where decorators are used. This leads to incorrect file path resolution when trying to determine the source file for a Lambda function.
Proposed Solutions
There are two potential approaches to properly fix this issue:
-
Remove the decorator pattern entirely:
- Replace the decorator with direct injection logic similar to what's done in RestApi
- Reference implementation: aws-cdk/aws-apigateway/lib/restapi.ts#L1143-L1170
- This would be a more straightforward approach but changes the API design pattern
-
Enhance the findDefiningFile function (RECOMMENDED):
- Modify the function to correctly handle decorator patterns
- Current implementation: aws-cdk/aws-lambda-nodejs/lib/function.ts#L279-L295
- This would preserve the current API design but requires more complex changes to the file resolution logic
Metadata
Metadata
Assignees
Labels
No labels