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

Importing paginateDescribeInstanceTypes breaks tree-shaking #3093

Closed
ZauberNerd opened this issue Dec 12, 2021 · 3 comments
Closed

Importing paginateDescribeInstanceTypes breaks tree-shaking #3093

ZauberNerd opened this issue Dec 12, 2021 · 3 comments
Assignees
Labels
bug This issue is a bug. p1 This is a high priority issue

Comments

@ZauberNerd
Copy link

ZauberNerd commented Dec 12, 2021

Describe the bug

Using the "bare-bones client" imports I usually get small-ish bundles ~230kb with esbuild + --minify.
However when I import paginateDescribeInstanceTypes the whole bundle blows up to 2.1mb (minified).

Your environment

SDK version number

@aws-sdk/[email protected]

Is the issue in the browser/Node.js/ReactNative?

Browser

Details of the browser/Node.js/ReactNative version

N/A as the problem happens during bundling

Steps to reproduce

import {
  EC2Client,
  DescribeInstanceTypesCommand,
  paginateDescribeInstanceTypes,
} from "@aws-sdk/client-ec2";

console.log({ EC2Client, DescribeInstanceTypesCommand, paginateDescribeInstanceTypes });

Switch between DescribeInstanceTypesCommand and paginateDescribeInstanceTypes in the above code snippet and bundling it via:

esbuild --bundle *.ts --outdir=dist --metafile=dist/metafile.json --sourcemap --minify

Observed behavior

Importing paginateDescribeInstanceTypes blows up the bundle and includes everything (same size as when importing:

import { EC2 } from "@aws-sdk/client-ec2";
console.log(EC2);

Expected behavior

As with other Describe* and paginate* methods, importing them should not result in bundling the entire EC2 library.

Screenshots

Small bundle (source map explorer on bundle-buddy):
small bundle on bundle-buddy (source map explorer)
Large bundle (source map explorer on bundle-buddy):
large bundle on bundle-buddy (source map explorer)

Additional context

Related to: #3023

@ZauberNerd ZauberNerd added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 12, 2021
@vudh1 vudh1 self-assigned this Dec 13, 2021
@vudh1 vudh1 removed their assignment Mar 15, 2022
@yenfryherrerafeliz yenfryherrerafeliz self-assigned this Jun 17, 2022
@kuhe kuhe self-assigned this Mar 6, 2023
@kuhe kuhe added needs-review This issue/pr needs review from an internal developer. and removed needs-triage This issue or PR still needs to be triaged. labels Mar 6, 2023
@kuhe
Copy link
Contributor

kuhe commented Mar 6, 2023

note for fix: the paginators should not attempt to use the aggregated client, since that static import blows up tree-shaking.

@kuhe kuhe added p1 This is a high priority issue and removed needs-review This issue/pr needs review from an internal developer. labels Mar 6, 2023
@kuhe
Copy link
Contributor

kuhe commented Mar 9, 2023

@kuhe kuhe closed this as completed Mar 9, 2023
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. p1 This is a high priority issue
Projects
None yet
Development

No branches or pull requests

4 participants