Dependency model and tree shaking

Which module may import which, and what that means for bundles. Package architecture in the DocStudio developer reference.

Which module may import which

Module May import
core Nothing. No React, DOM or Node APIs
render core
designer core, render, React (optional peer)
pdf core. Browser safe: never Playwright or Node built-ins
server core, render, pdf. Node and Playwright only, never React
root (docstudio) core, render

The direction is acyclic. Modules import each other only through the target module's index. A policy check in the repository fails on deep imports, self imports and wrong directions.

Consequences for your bundle

  • The package is sideEffects: false and ships unbundled ESM, so bundlers tree-shake per symbol.
  • Importing docstudio/core never pulls in React, Playwright or Node built-ins.
  • Importing docstudio (the root) never pulls in the designer, React or Playwright.
  • docstudio/server has a node condition and a null default, so a browser bundle that imports it fails at resolution instead of growing.

Size budgets

The repository enforces size budgets for each entry point with the package check. They are budgets for the minified and gzipped bundle with peers external:

Entry Minified Gzip
core 122,880 40,960
render 40,960 16,384
designer 311,296 99,840
pdf 8,192 4,096
root 163,840 53,248

Budgets are in bytes and are an upper limit, not the current size. Raising one needs a recorded decision.

Runtime dependencies

One: @cfworker/json-schema, pinned to an exact version. It has no transitive dependencies and does not generate code at runtime, so it is safe under strict content security policies (ADR 0008). A host that prefers another validator can inject it through the SchemaValidator port. Adding another runtime dependency needs a recorded decision.

Optional peers

React, React DOM and @dnd-kit/core for the designer, and Playwright for the PDF service. They are never installed implicitly.