Skip to content

Feature request: provide sub-path export for envelopes #3597

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

Closed
1 of 2 tasks
dreamorosi opened this issue Feb 13, 2025 · 5 comments · Fixed by #3598
Closed
1 of 2 tasks

Feature request: provide sub-path export for envelopes #3597

dreamorosi opened this issue Feb 13, 2025 · 5 comments · Fixed by #3598
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 parser This item relates to the Parser Utility

Comments

@dreamorosi
Copy link
Contributor

Use case

As a customer, I'd like to use Parser envelopes without having to import all of them at once, thus keeping my bundle size in check.

Right now if I use any one of the envelopes, they are all imported and included in my bundle since they're exposed only as a barrel export.

Basically I'd like to go from this:

import { ApiGatewayEnvelope } from '@aws-lambda-powertools/parser/envelopes';

to this:

import { ApiGatewayEnvelope } from '@aws-lambda-powertools/parser/envelopes/api-gatweay';

similar to what we're already doing for schemas.

Solution/User Experience

Since we're exporting a large number of modules that are under the same directory, I'd like to try using a more generic and scalable solution than the one I introduced a while back.

Instead of creating one entry for each item in the package.json#exports field, we could instead use * similar to this example.

The tradeoff here is that we'll need to be careful with what we put in the envelopes directory, but in this specific instance I think it's safe to do it since we're likely not going to add anything different there.

To keep names aligned with the exports we provided for schemas, we might have to rename some files.

Alternative solutions

Continue using the barrel export, which pollutes the bundle unnecessarily.

Acknowledgment

Future readers

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

@dreamorosi dreamorosi added confirmed The scope is clear, ready for implementation feature-request This item refers to a feature request for an existing or new utility parser This item relates to the Parser Utility labels Feb 13, 2025
@dreamorosi
Copy link
Contributor Author

While working on this, we should also export APIGatewayRequestAuthorizerEventSchema which was reported by an internal customer as not exposed.

@dreamorosi dreamorosi moved this from Triage to Backlog in Powertools for AWS Lambda (TypeScript) Feb 13, 2025
@am29d am29d self-assigned this Feb 13, 2025
@am29d
Copy link
Contributor

am29d commented Feb 13, 2025

Should we also change the schema exports with the same issue?

@dreamorosi
Copy link
Contributor Author

I think that's risky and we'd be better off doing it in the next major version.

We already provide sub-path exports for schemas, so even if they're hand-coded, they're there and people might be relying on them.

The envelopes ones are additive, so we can do it now.

Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

This issue is now closed. Please be mindful that future comments 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 pending-release This item has been merged and will be released soon and removed confirmed The scope is clear, ready for implementation labels Feb 14, 2025
Copy link
Contributor

This is now released under v2.15.0 version!

@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 Feb 25, 2025
@dreamorosi dreamorosi moved this from Coming soon to Shipped in Powertools for AWS Lambda (TypeScript) Feb 25, 2025
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 parser This item relates to the Parser Utility
Projects
Development

Successfully merging a pull request may close this issue.

2 participants