2. Monorepo tooling
Date: 2026-11-27 Status: Accepted
Context
Five packages share types and must build, lint and test together. The widget ships as a single IIFE file with a 30 KB gzip budget.
Decision
- pnpm workspaces, pinned with
packageManager. - TypeScript 6.0.x, strict, plus
noUncheckedIndexedAccessandexactOptionalPropertyTypes. TS 7 is out, but typescript-eslint 8 supports only<6.1. Upgrade when typescript-eslint does. - Source-first workspace exports. Each library's
exportspoints atsrc/index.tsandpublishConfig.exportspoints atdist/. Vite, Vitest andtscread sources directly in the repo, so there is no build-order dependency during development. Published packages use compiled output. - Build:
tscforcoreandsource-plugin. Vite library mode for the widget (IIFE for the script tag, ESM for bundler users). Wrangler for the worker. - Tests: a single root Vitest config with
projects, sopnpm testruns everything. DOM tests opt intohappy-domper file. Playwright e2e tests ine2e/run against the built example app. - Lint: ESLint flat config with
typescript-eslintstrictTypeChecked. - Size:
size-limitchecks the widget IIFE against 30 KB gzip in CI. - Versioning: Changesets. The example and the worker are private and ignored.
Consequences
- The widget bundles
corefrom source, socoremust stay tree-shakeable (sideEffects: false). - Locally, set
PLAYWRIGHT_CHROMIUM_EXECUTABLEto use a preinstalled Chromium instead of the version that@playwright/testexpects.