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) |
| 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: falseand ships unbundled ESM, so bundlers tree-shake per symbol. - Importing
docstudio/corenever pulls in React, Playwright or Node built-ins. - Importing
docstudio(the root) never pulls in the designer, React or Playwright. docstudio/serverhas anodecondition and anulldefault, 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 |
| 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.