Skip to content

Commit

Permalink
fix(endpoint-cache): reduce bundle size (#2400)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RianFuro authored May 17, 2021
1 parent 6fa9c67 commit b157173
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/endpoint-cache/src/EndpointCache.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { LRUCache } from "mnemonist";
import LRUCache from "mnemonist/lru-cache";

import { Endpoint } from "./Endpoint";
import { EndpointCache } from "./EndpointCache";

jest.mock("mnemonist");
jest.mock("mnemonist/lru-cache");

describe(EndpointCache.name, () => {
let endpointCache;
Expand Down
2 changes: 1 addition & 1 deletion packages/endpoint-cache/src/EndpointCache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LRUCache } from "mnemonist";
import LRUCache from "mnemonist/lru-cache";

import { Endpoint } from "./Endpoint";

Expand Down

0 comments on commit b157173

Please sign in to comment.