Task 1 of Plan 01-11 (Puppeteer UAT harness). - npm install --save-dev puppeteer@^25.0.2 tsx@^4 @types/node resolved: puppeteer@25.x, tsx@4.22.1, @types/node@25.8.0 pulls ~150MB Chromium binary at install time (T-1-11-03 — accepted, package-lock pins resolved hashes via @puppeteer/browsers). - package.json scripts: add build:test + test:uat (per RESEARCH §10 two-bundle orchestration); existing dev/build/preview/test untouched. - vite.test.config.ts: extends ./vite.config.ts via mergeConfig with mode:'test' + build.outDir:'dist-test' + emptyOutDir:true. Verified npm run build:test produces dist-test/ in 7.93s; npm run build keeps producing dist/ in 7.67s (no clobber). - tsconfig.json `include: ["src"]` already covers src/test-hooks/**/* via wildcard — no edit needed. - tests/background/no-test-hooks-in-prod-bundle.test.ts: Tier-1 gate mirroring sw-bundle-import.test.ts's execFile pattern. Greps the BUILT dist/ tree for 5 forbidden hook surfaces (one `it` per surface for granular failure isolation): __mokoshTest, simulateUserStop, getSegmentCount, setCurrentStream, setSegmentCountGetter. All 5 surfaces absent today (RED-then-GREEN polarity inverted — the gate is GREEN now and MUST stay GREEN after Task 2 lands the hooks). SKIP_BUILD=1 escape hatch for developer iteration. - .gitignore: add dist-test/ (no point versioning generated test bundle). Verification: - npx tsc --noEmit: exit 0 - npm run build: exit 0; dist/ populated (375.37 kB SW chunk) - npm run build:test: exit 0; dist-test/ populated (identical chunk sizes — the gated dynamic imports do not land until Task 2; this commit only proves the two-bundle plumbing) - SKIP_BUILD=1 npx vitest run tests/background/no-test-hooks-in-prod-bundle.test.ts: 6/6 GREEN (1 build-sanity + 5 forbidden-surface) - SKIP_BUILD=1 npx vitest run (full suite): 89/89 GREEN (83 baseline + 6 new Tier-1 surfaces = 89) Working-tree cleanup: a stale 5.4 MB tests/fixtures/last_30sec.webm (unrelated operator smoke regen present at session spawn) was stashed before running the baseline — it caused the webm-playback test to time out at 5s. After stashing back to HEAD's 1.9 MB fixture, baseline passes cleanly. Not committing the fixture restoration here (pre-existing working-tree state, not part of Task 1). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
44 lines
1.9 KiB
TypeScript
44 lines
1.9 KiB
TypeScript
// vite.test.config.ts — Plan 01-11 two-bundle separation.
|
|
//
|
|
// Extends the production `./vite.config.ts` with two delta knobs:
|
|
// 1. `mode: 'test'` — Vite statically replaces `import.meta.env.MODE`
|
|
// everywhere in the input source with the string literal `'test'`.
|
|
// The gated dynamic imports in src/background/index.ts +
|
|
// src/offscreen/recorder.ts (Plan 01-11 Task 2) take the form
|
|
// `if (import.meta.env.MODE === 'test') { await import('../test-hooks/...'); }`.
|
|
// With mode='test' the comparison resolves to a live branch and
|
|
// Rollup KEEPS the dynamic import; with the default mode='production'
|
|
// the comparison is a static dead branch and Rollup tree-shakes the
|
|
// `await import` away entirely (verified by the Tier-1 grep gate
|
|
// `tests/background/no-test-hooks-in-prod-bundle.test.ts`).
|
|
// 2. `build.outDir: 'dist-test'` + `emptyOutDir: true` — emit to a
|
|
// SEPARATE directory so a `npm run build` immediately after this
|
|
// build does not clobber. Puppeteer harness consumes this path via
|
|
// `puppeteer.launch({ enableExtensions: [<abs-path-to-dist-test>] })`.
|
|
//
|
|
// References:
|
|
// - Vite mergeConfig: https://vite.dev/guide/api-javascript.html#mergeconfig
|
|
// - Vite environment variables: https://vite.dev/guide/env-and-mode.html
|
|
// - Rollup tree-shaking literal-comparison dead branches:
|
|
// https://rollupjs.org/plugin-development/#how-rollup-handles-dynamic-imports
|
|
|
|
import { defineConfig, mergeConfig, type UserConfigExport } from 'vite';
|
|
import baseConfig from './vite.config';
|
|
|
|
const baseAsExport: UserConfigExport = baseConfig;
|
|
|
|
export default defineConfig(({ command, mode }) =>
|
|
mergeConfig(
|
|
typeof baseAsExport === 'function'
|
|
? baseAsExport({ command, mode, isPreview: false, isSsrBuild: false })
|
|
: baseAsExport,
|
|
{
|
|
mode: 'test',
|
|
build: {
|
|
outDir: 'dist-test',
|
|
emptyOutDir: true,
|
|
},
|
|
},
|
|
),
|
|
);
|