Package map
@anishbenji/tscache has five entries. Each is a separate import path with its own module graph, so an application loads only what the entry it imports reaches.
| Entry | Platform | What it is |
|---|---|---|
. | browser | the client API: createClient, the CacheHandle and client types, the errors, encodeSnapshot and decodeSnapshot, DTYPES |
./worker | browser | the worker script. Loading it attaches a server to the worker's global scope, as a SharedWorker or a dedicated worker; it is the one file the package marks as having side effects |
./engine | browser | the Engine with no worker and no port, for server code, Node and tests; it imports no client, RPC or worker code |
./fetcher | browser | what a fetcher module needs: AuthInvalidError, AUTH_INVALID_CODE and the fetcher types; it imports errors.ts and nothing else |
./vite | node | fetcherUrl(), the Vite plugin that serves a fetcher module; a build of its own, sharing no chunk with the browser entries, and importing nothing from Vite at run time |
The four browser entries are one tsdown build, so the bundler may share chunks between them; ./vite is a second build for Node (packages/tscache/tsdown.config.ts).
Module graph
The graph and the table below are generated from the package's source by site/scripts/module-graph.ts, which starts at the files package.json exports and follows every relative import. bun run docs:check fails when they no longer match the source; run bun site/scripts/module-graph.ts to regenerate them.
How to read it:
- A node is a directory of
packages/tscache/src/, or a file at its top. Entries, and the files that are loaded withimport(), are nodes of their own. - A solid arrow from A to B means some file in A imports a file in B. Type-only imports are left out: the compiler erases them, so they add nothing to a bundle.
- A dashed arrow is an
import(): a chunk that loads the first time the code that imports it runs. The fetcher module, which the orchestrator loads withimport()from a URL it receives at run time, is not part of the package and does not appear.
| Entry | Source | Bundles (static imports) | Loads on demand (import()) |
|---|---|---|---|
. | entries/index.ts | base64, errors, snapshot, types, client/ (cache, changes, client, dev, events, hosting), engine/ (emitter), rpc/ (lifetime, port-client, protocol) | client/in-process.ts, loaded by client/hosting.ts, adds coverage, grid, random-id, client/ (in-process), engine/ (batch, cache, engine, memory, merge, overlap, read, snapshot, validate), orchestrator/ (auth, orchestrator), persist/ (clear-only, clear-posts), rpc/ (server, workers-channel), segment/ (assert, dense, dtype, own, payload, types); persist/lazy.ts, loaded by client/in-process.ts, adds engine/ (restore), persist/ (clear-disk, failure, idb-store, lazy, persister, records) |
./worker | entries/worker.ts | coverage, errors, grid, random-id, types, engine/ (batch, cache, emitter, engine, memory, merge, overlap, read, snapshot, validate), orchestrator/ (auth, orchestrator), persist/ (clear-only, clear-posts, failure, hosted), rpc/ (generations, lifetime, protocol, server, workers-channel), segment/ (assert, dense, dtype, own, payload, types) | persist/lazy.ts, loaded by entries/worker.ts, adds engine/ (restore), persist/ (clear-disk, idb-store, lazy, persister, records) |
./engine | entries/engine.ts | base64, coverage, errors, grid, snapshot, types, engine/ (batch, cache, emitter, engine, memory, merge, overlap, read, snapshot, validate), segment/ (assert, dense, dtype, own, payload, types) | nothing |
./grid | entries/grid.ts | errors, grid | nothing |
./fetcher | entries/fetcher.ts | errors | nothing |
./vite | entries/vite.ts | vite/ (fetcher-url, urls) | nothing |
The table lists, for each entry, the files its static imports reach, which is what its bundle carries, and the chunks it can load later, each with the files that chunk adds to what is already loaded.
What the graph shows
- The client entry does not carry the engine.
.reaches one engine file,engine/emitter.ts, throughclient/events.ts. The engine, the orchestrator and the RPC server arrive only when the hosting chain reaches the in-process hosting andclient/hosting.tsimportsclient/in-process.ts. - The engine core depends on nothing above it.
engine/,segment/,grid.tsandcoverage.tsimport nothing fromclient/,rpc/,orchestrator/orpersist/; that is why./engineruns in Node. - Persistence sits beside the engine, not inside it.
persist/importsengine/, and nothing inengine/importspersist/. The persister, the IndexedDB adapter andengine/restore.tstravel in thepersist/lazy.tschunk. The SharedWorker loads it at its first persisted cache or its firstclearAll; the dedicated-worker and in-process hostings load it only at their firstclearAll. - A fetcher bundle stays small.
./fetcherreaches onlyerrors.ts.
Drawn from:
packages/tscache/package.json(exports,sideEffects)packages/tscache/src/entries/index.ts#createClientpackages/tscache/src/entries/worker.ts#createServerpackages/tscache/src/entries/engine.ts#Enginepackages/tscache/src/entries/fetcher.ts#AuthInvalidErrorpackages/tscache/src/entries/vite.ts#fetcherUrlpackages/tscache/src/client/hosting.ts#openInProcesspackages/tscache/src/client/events.ts#ClientEmitterpackages/tscache/src/persist/lazy.ts#Persisterpackages/tscache/src/engine/cache.ts#installRestore