From fbed274776292fed7195c36d504b05a5e2f9b2ab Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Thu, 12 Nov 2026 20:14:39 +0500 Subject: [PATCH 1/2] test(sveltekit-e2e): prove the Kit 3 sveltekit({ preprocess }) README wiring runs the annotate preprocessor (#11) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01WeiJxSd4XxSkeZk5vaw6dX --- docs/PROGRESS.md | 2 ++ packages/sveltekit-e2e/package.json | 1 + packages/sveltekit-e2e/test/sveltekit.e2e.ts | 16 ++++++++++++++++ packages/sveltekit-e2e/vite.config.ts | 6 +++++- pnpm-lock.yaml | 3 +++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index c1460c15c..f4a2b264a 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -1518,3 +1518,5 @@ Verified against current majors, all green with no adapter code changes: `@bugse ### launch() with a missing app token no longer throws (#198, 2026-11-12) `launch(undefined)` on Node/Bun died with an opaque `TypeError ... reading 'length'` inside `hashAppToken`, crashing the host at startup. Every runtime composition root (`@bugsee/node` + bun, `@bugsee/electron` `launchMain`/`launchRenderer` (guard before any wiring; a bad-token renderer sends no hello and takes no page slot), `@bugsee/browser` + umbrella/electron-renderer, `@bugsee/vercel-edge` + cloudflare, `@bugsee/webworker`) now calls the shared `createDisabledClientForMissingToken` (`@bugsee/core` `app-token.ts`) first: a missing / empty / whitespace-only / non-string token reports ONE `Bugsee: the app token is missing ...` error through `onError` (else `console.warn`) and returns a DISABLED client (never started, `launch()` is a no-op, claims no carrier slot, so a later valid launch works; the browser one resolves it, `showReportDialog()` resolves `null`). `@bugsee/webview` is untouched (the native host owns the token; the JS side never uses it on the wire). Tests: `app-token.test.ts` + `launch-missing-token.test.ts` per entry. + +**Follow-up 2 (issue #11).** `sveltekit-e2e` now wires `sveltekit({ preprocess: [componentAnnotatePreprocessor()] })` (the `@bugsee/sveltekit` README Kit 3 call, with the plugin imported by path) and asserts the SSR HTML carries `data-bugsee-component` (mutation-checked: removing `preprocess` fails it). The plugin is imported from its built dist (the e2e builds it first) because Kit 3 re-loads `vite.config.ts` in a plain-Node post-build process that cannot resolve the workspace's extensionless TS source. The README nits were already fixed (#157). Only Rollup 5 (still prerelease, `5.0.0-2` on the `beta` tag) remains open: keep watching. diff --git a/packages/sveltekit-e2e/package.json b/packages/sveltekit-e2e/package.json index 2662d714b..e8af714e8 100644 --- a/packages/sveltekit-e2e/package.json +++ b/packages/sveltekit-e2e/package.json @@ -10,6 +10,7 @@ }, "dependencies": { "@bugsee/e2e-kit": "workspace:*", + "@bugsee/svelte-plugin-component-annotate": "workspace:*", "@bugsee/sveltekit": "workspace:*", "@bugsee/util": "workspace:*" }, diff --git a/packages/sveltekit-e2e/test/sveltekit.e2e.ts b/packages/sveltekit-e2e/test/sveltekit.e2e.ts index 3adf2833c..6484af76b 100644 --- a/packages/sveltekit-e2e/test/sveltekit.e2e.ts +++ b/packages/sveltekit-e2e/test/sveltekit.e2e.ts @@ -71,6 +71,17 @@ describe('@bugsee/sveltekit — real SvelteKit boot e2e', () => { beforeAll(async () => { collector = await startMockCollector(); + const annotate = spawnSync( + 'pnpm', + ['--filter', '@bugsee/svelte-plugin-component-annotate', 'build'], + { + cwd: appDir, + encoding: 'utf8', + }, + ); + if (annotate.status !== 0) + throw new Error(`annotate build failed:\n${annotate.stdout}\n${annotate.stderr}`); + const build = spawnSync('pnpm', ['exec', 'vite', 'build'], { cwd: appDir, encoding: 'utf8' }); if (build.status !== 0) throw new Error(`vite build failed:\n${build.stdout}\n${build.stderr}`); @@ -101,6 +112,11 @@ describe('@bugsee/sveltekit — real SvelteKit boot e2e', () => { expect(html).toContain(' { + const html = await (await fetch(`${base}/`)).text(); + expect(html).toContain('

'); // routes/+page.svelte -> enclosing dir name + }); + it('reports a thrown endpoint as an uploaded bundle (moat server-error path)', async () => { const res = await fetch(`${base}/api/boom`); expect(res.status).toBe(500); // the endpoint really threw diff --git a/packages/sveltekit-e2e/vite.config.ts b/packages/sveltekit-e2e/vite.config.ts index 2c7bb18fe..59510e257 100644 --- a/packages/sveltekit-e2e/vite.config.ts +++ b/packages/sveltekit-e2e/vite.config.ts @@ -1,11 +1,15 @@ import adapter from '@sveltejs/adapter-node'; import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; +import { componentAnnotatePreprocessor } from '../svelte-plugin-component-annotate/dist/index.js'; // Kit 3 rejects `svelte.config.js`: configuration is passed through the `sveltekit(...)` plugin. +// `preprocess` mirrors the @bugsee/sveltekit README example (asserted in the e2e). The plugin is imported from +// its BUILT dist (the e2e builds it first): Kit re-loads this file in a plain-Node post-build process, which cannot +// resolve the workspace's extensionless TS source (published consumers get dist anyway). // The @bugsee/* + bugsee packages are consumed as TS SOURCE in the workspace — Vite must bundle+transpile // them for SSR (not externalize them as pre-built JS). export default defineConfig({ - plugins: [sveltekit({ adapter: adapter() })], + plugins: [sveltekit({ adapter: adapter(), preprocess: [componentAnnotatePreprocessor()] })], ssr: { noExternal: [/@bugsee\//, 'bugsee'] }, }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ac9fede39..460435a9a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1293,6 +1293,9 @@ importers: '@bugsee/e2e-kit': specifier: workspace:* version: link:../e2e-kit + '@bugsee/svelte-plugin-component-annotate': + specifier: workspace:* + version: link:../svelte-plugin-component-annotate '@bugsee/sveltekit': specifier: workspace:* version: link:../sveltekit From ac31e91f6448e043c3fcb04fc1d248e3200db64a Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Thu, 12 Nov 2026 20:17:02 +0500 Subject: [PATCH 2/2] test(sveltekit-e2e): tolerate extra attributes on the annotated h1 (review nit) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01WeiJxSd4XxSkeZk5vaw6dX --- packages/sveltekit-e2e/test/sveltekit.e2e.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sveltekit-e2e/test/sveltekit.e2e.ts b/packages/sveltekit-e2e/test/sveltekit.e2e.ts index 6484af76b..be6fc3a7c 100644 --- a/packages/sveltekit-e2e/test/sveltekit.e2e.ts +++ b/packages/sveltekit-e2e/test/sveltekit.e2e.ts @@ -114,7 +114,7 @@ describe('@bugsee/sveltekit — real SvelteKit boot e2e', () => { it('the documented Kit 3 `sveltekit({ preprocess })` wiring runs the component-annotate preprocessor (README example)', async () => { const html = await (await fetch(`${base}/`)).text(); - expect(html).toContain('

'); // routes/+page.svelte -> enclosing dir name + expect(html).toMatch(/]*data-bugsee-component="routes"/); // routes/+page.svelte -> enclosing dir name }); it('reports a thrown endpoint as an uploaded bundle (moat server-error path)', async () => {