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

Reduce duplicate code to halve large package sizes #1610

Closed
mhart opened this issue Oct 23, 2020 · 2 comments
Closed

Reduce duplicate code to halve large package sizes #1610

mhart opened this issue Oct 23, 2020 · 2 comments
Labels
feature-request New feature or enhancement. May require GitHub community feedback.

Comments

@mhart
Copy link
Contributor

mhart commented Oct 23, 2020

Is your feature request related to a problem? Please describe.

Related to #1536 – each module is twice the size than it needs to be because it bundles near-identical cjs and es implementations.

If I do a basic install of 3 clients, pretty typical for a small Lambda function:

npm install @aws-sdk/client-s3 @aws-sdk/client-dynamodb @aws-sdk/client-ssm

It installs 145 packages and the node_modules directory is 36MB – so more than 10MB worth of deps for each client. Add a few more clients and you already have a pretty chunky Lambda function. This is getting close to the same size as the entire aws-sdk v2, with far fewer clients.

Looking into why it's so large, it seems that each module has a cjs and an es directory – presumably to cover both CommonJS and ESM modules in the one package. Each of these is quite large (eg, 3.4MB each for ssm) and includes a lot of duplicated code (eg a 1MB Aws_json1_1.js file)

Describe the solution you'd like

It would be great if the packages should be spilt into CJS and ESM modules. ESM support is native to Node.js from v12 onwards – so when v10 becomes EOL, this project could just stop adding features to the CJS modules without needing to bump to a new major version. People bundling their Lambdas using a bundler will likely be using the ESM versions too.

If that's too much of a burden, then it would be great to share configuration (eg JSON files) between implementations – it seems overkill to have completely separate implementations of purely configuration data – especially if this makes up the bulk of the size.

Describe alternatives you've considered

Another alternative is to remove Node.js v10 support altogether and only support ESM modules.

@mhart mhart added the feature-request New feature or enhancement. May require GitHub community feedback. label Oct 23, 2020
@trivikr
Copy link
Member

trivikr commented Oct 11, 2021

The AWS SDK for JavaScript team has reduced install size by ~35%
Tweet https://twitter.com/trivikram/status/1446596564969930753

I'm closing this feature request over specific one suggesting splitting CJS and ES versions in #2889

@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 Oct 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request New feature or enhancement. May require GitHub community feedback.
Projects
None yet
Development

No branches or pull requests

2 participants