⚡ Epic: Prebuilt admin + runtime split — stop shipping the editor to every site
On hold. Don't size or start Phase 1 or Phase 2 yet. v3 is in bug-fix-only support mode, and since this was written the v4 plan has dropped the build and dev commands, so the site's own Vite compiles the admin (https://github.com/tinacms/tinacms/blob/main/packages/v4/README.md). A prebuilt admin shell is planned for v4 but is not a priority. v4 is modular, so the shell first needs a way to load each site's local plugins, which is non-trivial. When this is picked up, rewrite Phase 1 and Phase 2 against v4 paths before sizing anything. Phase 0 and the mermaid lazy-load have shipped, and every scenario B item listed below has since merged or closed.
Tracklist
Phase 0 - baselines (land first)
- https://github.com/tinacms/tinacms/issues/7238 - Size-baseline CI: per-PR install/tarball/bundle budgets + duplicate-copy watchlist
- https://github.com/tinacms/tinacms/issues/7239 - First production-build admin browser suite + the hostile fixture project
Phase 1 - prebuild the shell → scenario C (-68.3 MB)
- https://github.com/tinacms/tinacms/issues/7240 - The runtime seam: @tinacms/app reads project + env at runtime (dual-mode, vite path preserved)
- https://github.com/tinacms/tinacms/issues/7241 - Tailwind two-pass split: export tinaTheme/tinaTwPlugins, make prebuildFilePath optional
- https://github.com/tinacms/tinacms/issues/7242 - @tinacms/app gets a real build: dist/ + manifest.json + shell contract tests (dual-publish src+dist)
- https://github.com/tinacms/tinacms/issues/7243 - ⚡ Flag-gated prebuilt production build: 33 ms project chunk, frozen externals ABI, skew checks
- https://github.com/tinacms/tinacms/issues/7244 - ⚡ tinacms dev without vite: connect server + esbuild watch + reload channel (flag-gated)
Browser-payload wins (independent, main-safe)
- https://github.com/tinacms/tinacms/issues/7245 - ⚡ Lazy-load mermaid: rich-text editor stops shipping 83 MB-closure diagrams to every code block
- https://github.com/tinacms/tinacms/issues/7246 - ⚡ posthog: telemetry chunk loads only when enabled - true opt-out, not a skipped init()
- https://github.com/tinacms/tinacms/issues/7247 - ✨ Version the admin↔site postMessage handshake
Phase 2 - the split → scenario D (-320.0 MB, v4)
- https://github.com/tinacms/tinacms/issues/7248 - Flip the default: prebuilt admin everywhere, delete the vite path (v4)
- https://github.com/tinacms/tinacms/issues/7249 - ⚡ The runtime split: sites import a slim runtime, the 81-dep editor leaves user installs (v4)
Hard edges: https://github.com/tinacms/tinacms/issues/7240 → https://github.com/tinacms/tinacms/issues/7242 → https://github.com/tinacms/tinacms/issues/7243 → https://github.com/tinacms/tinacms/issues/7244; https://github.com/tinacms/tinacms/issues/7241 → https://github.com/tinacms/tinacms/issues/7243; https://github.com/tinacms/tinacms/issues/7243 + https://github.com/tinacms/tinacms/issues/7244 → https://github.com/tinacms/tinacms/issues/7248 → https://github.com/tinacms/tinacms/issues/7249. Parallel lanes: { https://github.com/tinacms/tinacms/issues/7238, https://github.com/tinacms/tinacms/issues/7239 } · { https://github.com/tinacms/tinacms/issues/7240, https://github.com/tinacms/tinacms/issues/7241 } · { https://github.com/tinacms/tinacms/issues/7245, https://github.com/tinacms/tinacms/issues/7246, https://github.com/tinacms/tinacms/issues/7247 }.
Problem
Every tinacms build compiles the entire admin app - 43k LOC of editor - with vite, per project, on the user's machine, with vite's dependency cache force-disabled every run (packages/@tinacms/cli/src/next/vite/index.ts:198-203, optimizeDeps.force: true). To make that possible, the user installs the full editor toolchain: @tinacms/app ships 15 runtime dependencies including monaco (73 MB) and typescript (23 MB), and tinacms ships 81 runtime dependencies (packages/tinacms/package.json) - mermaid, lucide, Plate, Radix, date-fns - into every site that only needs useTina and TinaMarkdown at runtime.
The spike (spike/prebuilt-admin, 87ec040ad, see SPIKE.md on that branch) proved the alternative end-to-end: prebuild the admin shell once, in our CI; per-project, compile only the user's config with esbuild. Result: the per-project build drops from a full vite compile to 608 KB / 33 ms of esbuild, and a real custom field in the real kitchen-sink saved a real change to disk through the real GraphQL backend, served under a basePath the shell never saw at build time.
The measured ladder (real npm installs of an Astro site - do not re-derive, these are the numbers)
| Scenario | Installed node_modules |
Δ |
|---|---|---|
| A - baseline as published today | 1037.8 MB | - |
| B - + the 5 already-open dependency-hygiene PRs | 795.7 MB | -242.1 MB |
| C - + prebuilt admin (this epic, phase 1) | 727.4 MB | -68.3 MB |
| D - + runtime split (this epic, phase 2) | 407.4 MB | -320.0 MB |
Astro's own floor with no Tina at all: 154.4 MB. Total A→D: -630 MB (61%).
Two honesty notes, so nobody quotes the wrong number later:
- The often-quoted 1412 MB baseline no longer reproduces. It was real when measured:
@tinacms/cliexact-pinned[email protected]while3.10.1had shipped, so npm nested 3 copies of tinacms/mermaid/date-fns. Versions have since coincidentally realigned. https://github.com/tinacms/tinacms/pull/7213 (publish ranges instead of exact pins) therefore measures $0 today - it is regression prevention, not a size win. It stops the next release from re-nesting 3 copies. The size-baseline harness (first child issue) exists precisely because this class of drift is invisible until someone measures. - Prebuilding alone is only -68 MB. Its real value is that it is the precondition for the -320 MB split: as long as the CLI must compile the editor on the user's machine, the editor and its 81-dep closure must be installed on the user's machine. Do not sell phase 1 on its own delta.
What's already done (scenario B) - link, don't re-plan
All verified open as of 2026-07-14; no new work in this epic covers them:
- https://github.com/tinacms/tinacms/pull/7213 - publish
workspace:^ranges, not exact pins (reframed: regression prevention, $0 today - see above) - https://github.com/tinacms/tinacms/pull/7214 - drop
monaco-editorfrom@tinacms/app(73 MB) - https://github.com/tinacms/tinacms/pull/7216 - icons → lucide; drop
@headlessui/react+@heroicons/react - https://github.com/tinacms/tinacms/pull/7218 - drop
typescriptfrom@tinacms/app's production deps (23 MB) - https://github.com/tinacms/tinacms/pull/7228 / https://github.com/tinacms/tinacms/pull/7229 - graphql-codegen v7 (lodash ×6 → ×1, ~33 MB) and the RichText scalar
- https://github.com/tinacms/tinacms/issues/7230 / https://github.com/tinacms/tinacms/pull/7231 - dead monaco deps in
packages/tinacms - https://github.com/tinacms/tinacms/issues/7232 / https://github.com/tinacms/tinacms/pull/7233 -
@tinacms/mdx/sanitize-urlsubpath (~2 MB off every site's browser bundle) - https://github.com/tinacms/tinacms/issues/7211 - adjacent:
@tinacms/mdx → typedoc → [email protected]ships a second 22 MB typescript alongside the top-level one
What this epic adds
Phase 0 - baselines first. The spike's four traps all compiled clean and failed silently in a browser; the 1412→1037 drift went unnoticed until re-measured. Before any risky change lands: (a) a size-baseline CI harness that turns the table above into per-PR budgets, and (b) behavioural baselines - the first browser tests this repo has ever run against a production tinacms build output (today every Playwright suite boots tinacms dev), driven by a deliberately hostile fixture config.
Phase 1 - prebuild (scenarios → C). Productionize the spike per .spike-scope.md: the runtime seam in @tinacms/app, the Tailwind two-pass split, a real dist/ + manifest for @tinacms/app, the flag-gated CLI prebuilt path (with the frozen externals ABI - the one decision that can't be walked back cheaply), and a vite-free dev server. Measured value once default: -68.3 MB install, per-project admin build 33 ms instead of a full vite compile, and the CLI sheds its vite stack.
Phase 2 - the split (scenario D, v4). Extract the site runtime (useTina, TinaMarkdown, tinaField) so sites stop depending on the 81-dep editor package. -320.0 MB measured.
On the maintainer's four constraints - read this before filing more issues
- mermaid → optional (83 MB) and 2. posthog → optional, opt-out (42 MB) - these are the genuinely new work, and their meaning changes after the split. Once mermaid and posthog live in our prebuilt shell instead of the user's
node_modules, "optional" stops being about disk (they're already off the user's disk - that's phase 2 doing its job) and becomes about what the browser downloads. So they are lazy-chunk problems in the shell / inpackages/tinacms, not dependency-graph problems - and both can land onmaintoday as browser-payload wins that carry into the shell automatically. Child issues below. - lucide icons we use → bundled into the prebuilt shell and 4. Plate, Radix, dnd-kit, cmdk → bundled into the prebuilt shell - these are not extra work; they are the -320 MB. All four are editor-only dependencies of
tinacms. The moment the editor ships inside the prebuilt shell and sites import the slim runtime package instead, they leave the user'snode_modulesautomatically. No separate issues exist for them by design; they are acceptance criteria of the split issue.
What survives scenario D, so nobody files a bug about it: date-fns (38 MB) and @tinacms/mdx - both independently required by @tinacms/graphql on the server side. The typedoc → [email protected] duplicate is https://github.com/tinacms/tinacms/issues/7211, not this epic.
2. The baseline-test plan (files as child issues https://github.com/tinacms/tinacms/issues/7238 and https://github.com/tinacms/tinacms/issues/7239 - FIRST, before any risky work)
Maintainer's requirement, verbatim: "i want to have baseline tests so that i can discover regressions ahead of time." Two halves. Both land before the runtime seam does.
Ground truth about today's CI (verified 2026-07-14 against .github/workflows/):
- No size measurement of any kind exists - no size-limit, bundlewatch,
du, tarball checks. The only adjacent tool ispublint --strictinlint:packages(rootpackage.json:22), which validates export maps, not size. The 1412→1037 MB drift was invisible for exactly this reason. - No Playwright suite runs against a production build. All six
playwright.config.tsfiles (playwright/tina-playwright,playwright/astro-init, four kitchen-sink examples) use dev servers aswebServer.command; evenplaywright/tina-playwright'sbuildscript istinacms dev -c "next build"- dev-mode Tina wrapping a Next build. The spike's four traps were all invisible to this setup by construction: they only exist in production output. - Runners are ubuntu + macOS (
main.ymlbuild matrix); zero Windows jobs. turbo.json:testdependsOn: ["build", "types"]- package tests may assumedist/exists.pnpm testruns per-PR (main.yml), turbo remote cache viaTURBO_TOKEN.
(a) Size baselines - child issue https://github.com/tinacms/tinacms/issues/7238
What's measured (four metrics, one checked-in baseline file):
- Installed closure of a fixture site, via real
npm. Pack every workspace package (pnpm -r exec pnpm pack- pnpm pack resolvesworkspace:protocols the same way publish does), publish the tarballs into a throwaway local registry (verdaccio) in the CI job, thennpm installa minimal Astro fixture (tests/size-fixture/, mirroring the scenario the ladder was measured on) against that registry. Measuredu -sk node_modules. npm deliberately, not pnpm - npm's nested-duplicate behaviour is the failure mode that produced 1412 MB; pnpm's store would hide it. - Duplicate-copy watchlist - the sharpest check, and the one that would have caught the 1412 MB incident the day it happened:
npm ls --all --jsonin the fixture, assert each watchlist package (tinacms,mermaid,date-fns,typescript,react,graphql,lodash) resolves to exactly one physical copy. This catches the symptom (nesting) regardless of cause; https://github.com/tinacms/tinacms/pull/7213 removes the known cause. - Per-package unpacked size:
npm pack --dry-run --json→unpackedSizefor every publishable package (same discovery looptests/build-verification.test.tsalready uses). - Admin output size: total bytes of
public/admin/aftertinacms buildon the kitchen-sink. Once the prebuilt path exists this splits into two budgets: shelldist/size (in@tinacms/app) and per-projectproject.jssize - the shell budget is also the regression guard for "something that was supposed to be external got re-bundled" (.spike-scope.md§2 Layer 3).
Where the baseline lives: tests/size-baselines.json, checked in. Numbers seeded from the measured ladder.
What fails the build: any metric exceeding baseline by >5% or >5 MB (whichever is larger - small packages need the absolute floor, big closures the percentage); any watchlist package with copy-count >1 fails unconditionally, no tolerance.
How a legitimate increase is re-baselined: pnpm size:update regenerates the JSON; the diff rides in the same PR, so the increase is reviewed as a visible number by a human, with a one-line justification in the PR description. Decreases >10% emit a warning prompting a re-baseline so wins get locked in too.
CI fit: one new job in main.yml (ubuntu only - size is platform-independent enough), triggered on PRs touching packages/** or pnpm-lock.yaml. Cost estimate: verdaccio boot + pack + npm install ≈ 2-4 min. Honest limitation: local-tarball publishing cannot reproduce registry-history interactions (the exact 1412 scenario needed an already-published stale version on npm); the duplicate-copy check covers the symptom anyway, and a scheduled (cron) variant of the same job running against the real registry covers the published state - same harness, two modes.
(b) Behavioural baselines - child issue https://github.com/tinacms/tinacms/issues/7239
Guiding fact from the spike: all four traps compiled clean and died only in a browser. (export * from CJS react → default-only namespace; CJS require() of an ESM external; uncovered tinacms subpaths; ./project.js resolving against the module instead of the document.) So: build-time contract assertions wherever a trap has a build-time signature; a real browser against production output for the rest. This carries .spike-scope.md §2 forward with one sharpening:
The sharpening - the prod-build browser suite lands FIRST, against today's vite build. .spike-scope.md slots the Playwright suite into PR4 (the prebuilt path). Instead: land playwright/prebuilt-admin/ now, with webServer = tinacms build + a static file server + the GraphQL API - running against the current production output. That gives the repo its first-ever prod-output browser coverage before a single line of prebuilt code exists, baselines today's behaviour, and then PR4 simply runs the identical suite a second time with the flag on. Every spec below is meaningful in both modes.
The nasty fixture (one hostile app in playwright/prebuilt-admin/, cloned from playwright/tina-playwright's layout - Next.js, so next/image is naturally available):
| Ingredient | Why it's there | Source of the pattern |
|---|---|---|
| Custom field component colocated with the schema | escape hatch, JSX through the seam | examples/next/kitchen-sink tina/fields/color.tsx (spike-verified end-to-end) |
A component importing next/image - a CJS dependency |
the killer: CJS require('react') against an ESM external (spike trap 2) |
SPIKE.md trap list |
An arbitrary Tailwind class the shell never uses (e.g. aspect-w-9) plus bg-blue-500 |
proves the second Tailwind pass ran AND used Tina's theme (rgb(0,132,255), not stock) |
spike verification no. 3 |
A real media.loadCustomStore with dynamic import() |
documented pattern, exercises esbuild single-outfile + dynamic import | packages/@tinacms/schema-tools/src/types/index.ts:~843-849 (JSDoc example) |
authProvider: new UsernamePasswordAuthJSProvider() from tinacms-authjs/dist/tinacms |
ESM entry that drags in CJS next-auth/react - second CJS-bridge exercise |
.spike-scope.md §1.4 |
cmsCallback registering a createScreen screen |
plugin path; catches a second react-router-dom if the ABI misses it |
.spike-scope.md §1.1/§1.5 |
build.basePath: 'my-site' |
every URL bug the spike hit was basePath-shaped | spike trap 4, .spike-scope.md §1.7 |
Specs (each names the trap it guards):
boot.spec- admin renders the collection list;window.__REACT_DEVTOOLS_GLOBAL_HOOK__.renderers.size === 1(the CI-grade single-React assertion - trap 2's runtime form); zeroconsole.errorduring boot (this alone would have caught traps 1-3, which all threw to console).custom-field.spec- custom field renders, a save round-trips to disk (reuseexamples/next/kitchen-sink/e2e/utils/admin-helpers.ts).tailwind.spec-getComputedStyleon both fixture classes (trap 4's - the Tailwind trap's - runtime form).basepath.spec- boot at/my-site/admin/and at/my-site/adminwithout the trailing slash (the trap.spike-scope.md§1.7 found: the spike harness only ever served the trailing-slash form;next devserves the bare form,document.baseURIbecomes the parent, every relative asset 404s).media.spec/auth.spec- media manager lists via the custom store; the custom auth provider's login screen appears.- Prebuilt-mode-only (added by child https://github.com/tinacms/tinacms/issues/7243):
skew.spec- tampered manifest/env produces a readable error screen, not a white screen; under network throttling the 2 s asset watchdog (packages/@tinacms/app/index.html) doesn't false-fire on the now-async project fetch.
Build-time contract layers (land with the code they constrain, but specified here so they're one coherent plan):
- Layer 0 - shell contract (vitest in
@tinacms/app, runs post-build via turbo'stest→builddependency): for every emittedvendor-*chunk,import()it in node and assertObject.keys(ns)⊇Object.keys(require(sourcePkg))- export-name parity. Future-proof by design: React adding an export fails the test until the vendor list is updated, which is the desired behaviour. Plus: every subpath ofpackages/tinacms/package.jsonexportsis either a vendor entry or on a snapshot-tested exclusion list (ABI completeness,.spike-scope.md§1.1);dist/manifest.jsonexists and itsexposedModulesmatches the vendor entry set. Ships with child https://github.com/tinacms/tinacms/issues/7242. - Layer 1 - CLI build assertions (jest; precedent for running real esbuild in jest:
packages/@tinacms/cli/src/next/config-build-error.test.ts): run the real project-chunk build withmetafile: trueand assert nonode_modules/react/,node_modules/react-dom/,node_modules/tinacms/path appears inmetafile.inputs- "externals actually externalized" as a deterministic, browserless CI check. CJS-bridge tests including the namespace-interop case.spike-scope.md§1.4 caught (require('tinacms').AbstractAuthProvidermust resolve - the spike'sm.default ?? mheuristic returnsundefinedfor it, becausetinacms's default export isTinaCMSProvider2,packages/tinacms/src/index.ts:22). Tailwind two-pass assertions. Stage-Dindex.htmlstring assertions (absolut
Source: tinacms/tinacms