Skip to content

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.

EntryPlatformWhat it is
.browserthe client API: createClient, the CacheHandle and client types, the errors, encodeSnapshot and decodeSnapshot, DTYPES
./workerbrowserthe 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
./enginebrowserthe Engine with no worker and no port, for server code, Node and tests; it imports no client, RPC or worker code
./fetcherbrowserwhat a fetcher module needs: AuthInvalidError, AUTH_INVALID_CODE and the fetcher types; it imports errors.ts and nothing else
./vitenodefetcherUrl(), 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 with import(), 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 with import() from a URL it receives at run time, is not part of the package and does not appear.
EntrySourceBundles (static imports)Loads on demand (import())
.entries/index.tsbase64, 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)
./workerentries/worker.tscoverage, 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)
./engineentries/engine.tsbase64, coverage, errors, grid, snapshot, types, engine/ (batch, cache, emitter, engine, memory, merge, overlap, read, snapshot, validate), segment/ (assert, dense, dtype, own, payload, types)nothing
./gridentries/grid.tserrors, gridnothing
./fetcherentries/fetcher.tserrorsnothing
./viteentries/vite.tsvite/ (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, through client/events.ts. The engine, the orchestrator and the RPC server arrive only when the hosting chain reaches the in-process hosting and client/hosting.ts imports client/in-process.ts.
  • The engine core depends on nothing above it. engine/, segment/, grid.ts and coverage.ts import nothing from client/, rpc/, orchestrator/ or persist/; that is why ./engine runs in Node.
  • Persistence sits beside the engine, not inside it. persist/ imports engine/, and nothing in engine/ imports persist/. The persister, the IndexedDB adapter and engine/restore.ts travel in the persist/lazy.ts chunk. The SharedWorker loads it at its first persisted cache or its first clearAll; the dedicated-worker and in-process hostings load it only at their first clearAll.
  • A fetcher bundle stays small. ./fetcher reaches only errors.ts.

Drawn from: