Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: isolate exports for middleware in core utilities #1759

Closed
1 of 2 tasks
dreamorosi opened this issue Oct 20, 2023 · 2 comments · Fixed by #1760
Closed
1 of 2 tasks

Feature request: isolate exports for middleware in core utilities #1759

dreamorosi opened this issue Oct 20, 2023 · 2 comments · Fixed by #1760
Assignees
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility
Milestone

Comments

@dreamorosi
Copy link
Contributor

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

Future readers

Please react with 👍 and your use case to help us understand customer demand.

@dreamorosi dreamorosi added feature-request This item refers to a feature request for an existing or new utility confirmed The scope is clear, ready for implementation labels Oct 20, 2023
@dreamorosi dreamorosi added this to the Version 2.0 milestone Oct 20, 2023
@dreamorosi dreamorosi self-assigned this Oct 20, 2023
@dreamorosi dreamorosi changed the title Feature request: TITLE Feature request: isolate exports for middleware in core utilities Oct 20, 2023
@dreamorosi dreamorosi linked a pull request Oct 20, 2023 that will close this issue
9 tasks
@dreamorosi dreamorosi added pending-release This item has been merged and will be released soon and removed confirmed The scope is clear, ready for implementation labels Oct 20, 2023
@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added completed This item is complete and has been merged/shipped and removed pending-release This item has been merged and will be released soon labels Nov 1, 2023
@aws-powertools aws-powertools deleted a comment from github-actions bot Nov 2, 2023
@dreamorosi dreamorosi added pending-release This item has been merged and will be released soon completed This item is complete and has been merged/shipped and removed completed This item is complete and has been merged/shipped pending-release This item has been merged and will be released soon labels Nov 2, 2023
@dreamorosi
Copy link
Contributor Author

This is available in preview starting from the 2.0.0-alpha.1 release. You can install this version using the next tag, i.e. npm i @aws-lambda-powertools/logger@next.

@dreamorosi dreamorosi moved this from Coming soon to Shipped in Powertools for AWS Lambda (TypeScript) Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility
Projects
Development

Successfully merging a pull request may close this issue.

1 participant