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

fix(endpoint-cache): reduce bundle size #2400

Merged
merged 1 commit into from
May 17, 2021
Merged

fix(endpoint-cache): reduce bundle size #2400

merged 1 commit into from
May 17, 2021

Conversation

RianFuro
Copy link
Contributor

@RianFuro RianFuro commented May 16, 2021

Description

mnemonist is a pretty big (well, for web-bundles anyway) commonjs package, which is currently included IN FULL from the endpoint-cache package. This is less than ideal when using the sdk on the frontend side, since it adds about 270kb to the bundle (before minification).

Since only the LRU-Cache is needed, changing the import to directly target the lru-cache module helps bundlers tree shake correctly, reducing the included code to about 15kb.

Testing

I ran compilation on the endpoint-cache package and executed the commonjs build via node dist/cjs/EndpointCache.js just to check if the import would throw. I tested the es build integrated in my webpack project to check the reduced bundle size.
Also ran yarn test:all

Additional context

Before:
image
After:
image


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

mnemonist is a pretty big commonjs package, which is currently included
IN FULL from the endpoint-cache package. This is less than ideal when
using the sdk on the frontend side, since it adds about 270kb to the
bundle (before minification).

Since only the LRU-Cache is needed, changing the import to directly
target the lru-cache module helps bundlers tree shake correctly,
reducing the included code to about 15kb.
@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (main@6fa9c67). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2400   +/-   ##
=======================================
  Coverage        ?   59.12%           
=======================================
  Files           ?      490           
  Lines           ?    26186           
  Branches        ?     6218           
=======================================
  Hits            ?    15482           
  Misses          ?    10704           
  Partials        ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6fa9c67...066f096. Read the comment docs.

@trivikr trivikr merged commit b157173 into aws:main May 17, 2021
@github-actions
Copy link

github-actions bot commented Jun 1, 2021

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 Jun 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants