Description
Use case
Currently the three core utilities export the Middy middlewares as part of their barrel file (aka index.ts
). This means that whenever a customer imports the utility (i.e. import { Logger } from '@aws-lambda-powertools/logger';
) the corresponding Middy middleware gets imported and loaded regardless of whether it's going to be used or not.
Newer utilities like Idempotency already moved away from this pattern and instead export the middleware separately using the exports
field in the package.json
, i.e. import { makeHandlerIdempotent } from '@aws-lambda-powertools/idempotency/middleware';
.
With version 2 coming, it's now a good time to make this change also in the base utilities.
Solution/User Experience
Change the following:
import { logMetrics } from '@aws-lambda-powertools/metrics';
import { injectLambdaContext } from '@aws-lambda-powertools/logger';
import { captureLambdaHandler } from '@aws-lambda-powertools/tracer';
to
import { logMetrics } from '@aws-lambda-powertools/metrics/middleware';
import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware';
import { captureLambdaHandler } from '@aws-lambda-powertools/tracer/middleware';
Alternative solutions
No response
Acknowledgment
- This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status