Repository navigation
fix(create-plugin): type the scaffolded vite.config.ts's test block - #8398
Conversation
The emitted `vite.config.ts` passed a `test:` block to a `defineConfig`
imported from `vite`, whose `UserConfig` declares no `test` key. The
emitted-code census measures that as TS2769 on this template; in the
scaffolded plugin's own repo — the only audience this generator serves —
it is a red config file on day one, in every editor.
Nothing in the scaffold RUNS a type check today (`buildPackageJson`
writes `build`/`test`/`lint` and no `tsc`, and `vite build` loads the
config through esbuild), so the symptom is editor-only. It is still
wrong in every plugin the generator writes.
The config now opens with `/// <reference types="vitest/config" />`,
which pulls in `vitest/dist/config.d.ts` and its
`declare module "vite" { interface UserConfig { test?: … } }`
augmentation. It is a type-only comment: zero run-time effect, and
`vite build` never sees it.
Deliberately NOT the other shape vitest documents,
`import { defineConfig } from 'vitest/config'`. It type-checks
identically in the scaffolded repo, but `vitest` is declared by this
repository's root manifest and mapped by no package the census covers,
so an emitted import of it trips the census's root bound and the whole
template is refused instead of judged. Measured both ways: with the
reference, `Judged 12 … 7 refused by the root bound` and the TS2769 is
gone; with the import, `Judged 11 … 8 refused` and the census reports
zero diagnostics here only because it stopped compiling the file.
The `test:` block itself is untouched — it is the only thing giving the
scaffolded example test a DOM. A pin plus its own reverse-verification
test keeps the declaration from being dropped again.
Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
|
ACCEPT — The shape choice was decided by a measurement about the INSTRUMENT, and the mechanism checks outThe card left the choice open and triage declined to make it; the dev made it and gave a reason that has nothing to do with the scaffolded repo — where both shapes work, because What decided it is what each shape does to the census that found the bug. if (specifier in paths) return false;
const bare = specifierRoot(specifier);
if (bare in paths) return false;
return rootDeclared.has(bare);
The triple-slash escapes the bound for a different and equally mechanical reason: The three standing rulings all heldVerified in the diff, which is The pin has the control the lane keeps asking for
The ablation is reported by state rather than by exit code (HEAD blob Two declared items, both answeredThe attribution conflict. This dev resolved it the opposite way from #8141's dev — dropping the model identifier to honour the dispatch fence, where the other kept the mandated trailer. ⛔ Neither is wrong and no follow-up is owed either way: this shift has measured three landings ( The self-merge clause. The dev is right that this PR is not governed surface ( Out-of-scope finding#8397 — the census's root bound refuses 3 of create-plugin's 8 recognised templates, and misjudges a 4th, for specifiers the same generator's emitted A changeset is owed and present ( Next: CI convergence → flip ready → post-flip guard → auto-merge SQUASH → queue confirmation → landing probe (the emitted template's first line is Generated by Claude Code |
|
Armed: PR #8398 flipped ready at 2026-09-07T16:37:36Z on head Landing probe on merge, on re-fetched Generated by Claude Code |
|
LANDED — merged into Content probe on re-fetched
⭐ Why that control is the right one for this PR specifically: the shape that was rejected — importing Generated by Claude Code |
Fixes #8139
What was wrong
buildViteConfig()inpackages/create-plugin/src/templates.tsemitted avite.config.tsthat passes atest:block to adefineConfigimported fromvite.vite'sUserConfigdeclares notestkey, so the emitted file is TS2769 —Object literal may only specify known properties, and 'test' does not exist in type 'UserConfigExport'— measured on this exact template by the emitted-code census (objectui#7864 / PR #8138).Triage's severity reading, re-verified on
b38014e82:buildPackageJsonscaffoldsbuild/test/lintand no type-check script, andvite buildloads the config through esbuild, which does not type-check. So nothing in the scaffolded repo RUNS that check and the symptom is an editor-only red squiggle — p3, not p2. It is still red on day one in every plugin this generator writes.The fix
One emitted line: the config now opens with a triple-slash
reference types="vitest/config"directive above the imports. That pulls invitest/dist/config.d.ts:33, whosedeclare module "vite" { interface UserConfig { test?: ... } }augmentation supplies the missing declaration. It is a type-only comment: zero run-time effect, andvite buildnever sees it.The
test:block itself is untouched. PR #8042's ruling on #7524 keeps it deliberately for the out-of-repo audience, and the template's own docblock argues it is the only thing giving the scaffolded example test a DOM.Why the reference and not
import { defineConfig } from 'vitest/config'The card deliberately did not choose. Both shapes type-check identically in the scaffolded repo — measured:
vitest ^4.1.10is a declared devDependency of the emittedpackage.json(DEV_DEPENDENCIES, templates.ts:87-96), so the import would be legitimate there.They are not equivalent here.
vitestis declared by this repository's root manifest and mapped by no package the census covers, so an emittedimport ... from 'vitest/config'trips the census's root bound (resolvesOnlyThroughRootManifest) and the whole template is REFUSED instead of judged. Measured both ways onb38014e82:buildViteConfigfrom 'vite', no reference)Judged 12 ... 7 refused by the root boundvite-plugin-dtsTS2307 — the census reports2 remainfrom 'vite')Judged 12 ... 7 refused by the root boundvite-plugin-dtsTS2307 —1 remainfrom 'vitest/config')Judged 11 ... 8 refused by the root bound0 remain— but only because the block is no longer compiled at all, taking the TS2307 with itA clean number bought by not looking is the one outcome that census exists to avoid, so the reference wins. The reasoning is written into
buildViteConfig's docblock and into the pin, so the next reader who is tempted to "simplify" it hits the measurement first.The TS2307 on
vite-plugin-dtsis untouched, on purposeIt is an artefact of the instrument, not a defect: the scaffolded
package.jsondeclaresvite-plugin-dts ^5.0.3(templates.ts:93) and the census resolves against this monorepo's root manifest, where it is undeclared. The card recorded it precisely so nobody cards it.buildTsconfig()'sextendspath is likewise untouched — triage's unverified passing note, explicitly no card and no change.The pin, and its trade
packages/create-plugin/src/__tests__/templates.test.tsgains atypesTheTestBlock()predicate plus two tests: the pin, and its own reverse verification (strip the reference line and the predicate must say NO, rather than passing vacuously over a config with notest:block — the idiom the rest of that file already uses for objectui#3759).Trade, stated rather than assumed. The census is report-only by objectui#7864's ruling, so without a pin nothing mechanical stops this regressing; the pin is the only guard. The cost is that it is a string pin over generated text, and it deliberately rejects the
vitest/configshape too — a future maintainer who wants that shape has to delete an assertion whose comment carries the measured numbers. That is the intent: the choice was decided by a measurement, so changing it should cost a reading of that measurement, not a silent edit.Verification
Every command run in a dedicated worktree on
0e49b95d8, heavy runs serialised through the shared verify lock.Reverse verification (ablation). Run from the committed state, with a restore trap and on-disk proof, not from an exit code: the reference line was stripped from
templates.ts(git hash-objectbefore1cef5f078, afteraaa5efa66— the mutation is proven to have landed), and both legs turned as predicted:Restore verified by byte identity rather than by exit code:
git hash-objectback to1cef5f078,git diff HEADempty,git status --porcelainempty.Lint, declared narrowing.
eslintwas run on the two changed files only, not repo-wide. The narrowing is a measurement, not a skip: the population is 4453 files per eslint's own config (eslint . --no-inline-config --format json, counted from the JSON), this run covered 2 of them with 0 errors and 0 warnings (--format jsoncounts), andeslint.config.jsenables no type-aware linting (noprojectService, noparserOptions.project), so nothing in this diff can move the verdict on any file it does not touch. The full farm is CI's run.Changeset
.changeset/khaki-cameras-attack.md,patchon@object-ui/create-plugin— the published package emits a different file than before, so this is a real behaviour change of the tarball, not an internal edit.Generated by Claude Code