Skip to content

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

Closed
@dreamorosi

Description

@dreamorosi

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.

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityparserThis item relates to the Parser Utility

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions