// Vite+ per-package settings. `vitest.config.ts` beside this file is vitest's own config (vitest // prefers it over this one); this file exists only to declare the `build` and `test` tasks that // `vp run` executes. // // Both are tasks rather than package.json scripts because each reads a path it also writes, and vp // declines to cache such a task: `tsc` emits into `dist/`, which automatic tracking otherwise counts // as an input of the same package, and every `vitest run` rewrites the scratch paths below and reads // them back on the next run. vp forbids a task and a script sharing a name, so the `build` and // `test` scripts are gone -- `vp run -F custom-gatekeeper ` is what replaces them. // This package's own `tsc` output. Package-relative, not workspace-wide: a sibling's `dist/` may be // a real input via its `exports`. const ownDist = { pattern: '!dist/**', base: 'package' } as const // Written and read back by every vitest run, so without these almost nothing caches. Workspace-wide // because tracking reaches past the package that owns the task -- a sibling's scratch files would // otherwise sit in this package's fingerprint. See // cloudflare-os/scripts/vitest-task-vite-config.ts for the full accounting of each path. const vitestScratch = [ { pattern: '!**/node_modules/.vite/**', base: 'workspace' }, { pattern: '!**/node_modules/.vite-temp/**', base: 'workspace' }, // The capnweb-validate build tree, regenerated by any suite that starts a worker under // @cloudflare/vitest-pool-workers. Derived from tracked sources, so dropping it loses nothing. { pattern: '!**/.wrangler/**', base: 'workspace' }, ] as const export default { run: { tasks: { build: { command: 'tsc', cache: { input: [{ auto: true }, ownDist], output: ['dist/**'], }, }, test: { command: 'vitest run', cache: { input: [{ auto: true }, ownDist, ...vitestScratch], output: [{ auto: true }, ownDist, ...vitestScratch], }, }, }, }, }