Vite plugin + headless: simplified (#2) #23
Loading…
Reference in a new issue
No description provided.
Delete branch "wip/issue-02-simplify"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Supersedes #14. This branch contains #14's change plus the simplification pass, so it is the one to land in
main. #14 is closed in its favour.What it does
Adds
@srhazi/gooey-test/viteand declaresvitean optional peer (>=4), so hosted + headless modes "just work": the plugin serves the runner at a stable URL (/@gooey-test/) and owns test discovery (no hand-wired#/...URL), and headless drives the consumer's Vite.Simplified relative to #14
loadConfigFromFile+createServer) instead of writing a throwaway merged config to disk and spawning the CLI. Removes the mkdtemp/mergeConfigtemplating, the child-process lifecycle, and the read-only/PnP probes.transformIndexHtml).src/discovery.ts), imported by both consumers.virtual:gooey-test/manifest, theentryoption, the no-plugin#/...fallback,--vite-arg/--vite-startup-timeout, and forcedALWAYS_EXCLUDE(a suppliedexcludeis now authoritative).vitepeer widened to>=4, and the smoke now logs + asserts the resolved Vite.Verification
tscclean on all three configs; self-testPASS: 11../s/smoke: 72 passed / 0 failed against Vite 8.3.4 (unpinned).dist/is not committed — it is built at release.Closes #2.
@ -0,0 +11,4 @@export const DEFAULT_EXCLUDE = '**/node_modules/**';/** Glob(s) ignored even when the caller widens `exclude`. */export const ALWAYS_EXCLUDE = ['**/node_modules/**', '**/.git/**'];Let's drop ALWAYS_EXCLUDE, the user should not be prevented from making bad decisions if they choose to
@ -665,2 +339,2 @@]));const include = asArray(options.include) ?? [DEFAULT_INCLUDE];const exclude = withAlwaysExcluded(options.exclude);Which I think means this becomes
const exclude = asArray(options.exclude) ?? [DEFAULT_EXCLUDE];@ -108,4 +61,3 @@existsSync(join(dir, 'entry', 'testrunner.js'));const candidates = [join(root, 'node_modules', PACKAGE_NAME, 'dist', 'testrunner'),join(root, 'dist', 'testrunner'),Question: is this
dist/testrunnerlocation used only for local tests within this repo?Pushed
1375dfeonwip/issue-02-simplify.#213
src/discovery.ts— "Let's drop ALWAYS_EXCLUDE": Done end to end.ALWAYS_EXCLUDEandwithAlwaysExcludedare gone;src/discovery.tsnow exports only the defaults,toPosix,asArrayanddiscoverTestFiles. A caller who widensexcludenow gets exactly that set — no forcednode_modules/.gitadditions. Corrected the one option doc that claimed.gitis always ignored (README/CLI already documented only the**/node_modules/**default). No smoke assertion relied on the forced additions:--exclude '**/hidden/**'and the injected-node_modulesprune both still pass, via the default exclude.#215
src/headless/index.ts— "becomesconst exclude = asArray(options.exclude) ?? [DEFAULT_EXCLUDE];": Yes, exactly. Both the headless runner and the Vite plugin now use that expression, so the two stay one source of truth. Default behaviour is unchanged (**/node_modules/**); the only difference is a suppliedexcludeis no longer overridden.#217
src/vite/index.ts— "is thisdist/testrunnerlocation used only for local tests within this repo?": Yes. InlocateRunnerDir,<root>/node_modules/@srhazi/gooey-test/dist/testrunneris how a real consumer resolves their installed copy (checked first, so it wins when present). The second candidate,<root>/dist/testrunner, only matches this repo's self-test — run from the repo root, where the package is not in its ownnode_modules(e.g.node dist/headless/cli.mjs src/happypath.test.ts). It is not dead weight: removing it would break the self-test, so I left it in place.Verification:
tsc --noEmitclean on all three configs; self-testPASS: 11;./s/smoke69 passed / 0 failed once the known Vite-8 peer conflict is worked around in the harness (the unmodified smoke still aborts innpm install, as flagged in the PR body — untouched).dist/was rebuilt locally for the run but is not committed.Pushed
8563cf7onwip/issue-02-simplify.Peer range widened.
peerDependencies.viteis now>=4.0.0(was^4.0.0 || ^5.0.0 || ^6.0.0); still optional viapeerDependenciesMeta.devDependencies.viteis untouched at^4.0.0.README made accurate. Setup requirement now reads
`vite` (`>=4`)and the optional-peer note ends "Tested on Vite 4 and 8." (Vite 4 from the repo's own devDependency / self-test, Vite 8 from the unpinned smoke.)Smoke against Vite 8, unpinned — 69 passed / 0 failed. No harness pin: the consumer's
npm install --save-dev @playwright/test viteresolved to Vite 8.3.4 (confirmed: an equivalent fresh install of just those two deps pinsvite@^8.3.4).dist/rebuit locally, then./s/smokerun end-to-end; every check passed, including setup across npm/yarn/pnpm, default discovery,--include/--exclude, node_modules prune, thevite defineregression guard, hosted runner, failure artifacts,--debug-failures,--remote-debugging-port, and the option surface.No Vite-8-specific fixes were needed — the integration ran unchanged. The only change required to make a fresh install resolve was the peer range itself.
Also confirmed, out of the harness: the
base: '/app/'consumer flow (gooeyTest()plugin +basein the config) runs green against Vite 8.3.4 (PASS: 1).Other checks:
tscclean on all three configs (.,tsconfig.headless.json,tsconfig.vite.json); self-testnode dist/headless/cli.mjs src/happypath.test.ts→PASS: 11(against the repo's Vite 4.5.14).This resolves the PR's question 1; no
dist/committed.Pushed
0aa2fcbonwip/issue-02-simplify.Smoke now records and guards the resolved Vite. Added a
resolved vitesection tosmoke/smoke.sh, right after the dependency-setup block and before the README flows. For each consumer tree (npm/yarn/pnpm) it reads the installed version fromrequire('<tree>/node_modules/vite/package.json').version, logs it, and asserts the major is>=4— matching the>=4.0.0peer range. A tree outside the range nowfails loudly with the observed version instead of passing silently against whateverlatestresolved to that day.Small and in the smoke's existing style: one loop over the existing
$NPM/$YARN/$PNPMvars, reusing the existingsay/pass/failhelpers; 16 lines, no new machinery../s/smoke: 72 passed / 0 failed (up from 69 — the three new checks). All three trees resolved Vite 8.3.4.dist/was rebuilt locally for the run but is not committed.Simplify the Vite plugin + headless runner (stacked on #14)to Vite plugin + headless: simplified (#2)@srhazi/gooey-test/viteplugin + optionalvitepeer (#2) #14