Skip to content

Commit b157173

Browse files
authored
fix(endpoint-cache): reduce bundle size (#2400)
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.
1 parent 6fa9c67 commit b157173

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/endpoint-cache/src/EndpointCache.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { LRUCache } from "mnemonist";
1+
import LRUCache from "mnemonist/lru-cache";
22

33
import { Endpoint } from "./Endpoint";
44
import { EndpointCache } from "./EndpointCache";
55

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

88
describe(EndpointCache.name, () => {
99
let endpointCache;

packages/endpoint-cache/src/EndpointCache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LRUCache } from "mnemonist";
1+
import LRUCache from "mnemonist/lru-cache";
22

33
import { Endpoint } from "./Endpoint";
44

0 commit comments

Comments
 (0)