Blog
Posts tagged #cloudflare-workers
of 11 - 04 [EmDash] A Vitest Regression Guard for publicHoistPattern and ssr.optimizeDeps.include on Cloudflare Workers A Vitest test that verifies every package in ssr.optimizeDeps.include is both hoisted to node_modules/ and resolvable — so a missing publicHoistPattern entry surfaces as a named, actionable test failure instead of exports is not defined deep inside a workerd stack trace. May 25, 2026 · 2 min
// src/lib/ssr-deps.test.ts
import { existsSync } from "node:fs";
import { createRequire } from "node:module";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
// src/lib/ssr-deps.test.ts
import { existsSync } from "node:fs";
import { createRequire } from "node:module";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
- 03 [EmDash] Why @atproto/api Caused exports is not defined in workerd and How pnpm Hoisting + ssr.optimizeDeps.include Fixes It @atproto/api is CJS and lives only in pnpm's content-addressable store, so Vite's SSR optimizer can't find or convert it — meaning raw CJS reaches Cloudflare workerd, which has no exports global, and crashes. The fix requires both hoisting the package via publicHoistPattern and listing it in ssr.optimizeDeps.include. May 25, 2026 · 2 min
Error: exports is not defined
at runInRunnerObject (workers/runner-worker/index.js:107:3) Error: exports is not defined
at runInRunnerObject (workers/runner-worker/index.js:107:3) - 02 [EmDash] Note `ssr.optimizeDeps.include` Fixes Vite 7's SSR Dep Optimizer Race Condition and Stale Chunk Crashes on Cloudflare Workers Vite 7 separates SSR and client dep optimization, and packages discovered lazily at request time trigger re-optimization rounds that invalidate shared chunks mid-request. The fix is `ssr.optimizeDeps.include` to pre-bundle all CMS sub-paths at startup before any request arrives.
May 25, 2026 · 1 min
[vite] ✨ new dependencies optimized: emdash/middleware, emdash/middleware/redirect,
emdash/middleware/setup, emdash/middleware/auth, emdash/middleware/request-context
[vite] ✨ optimized dependencies changed. reloa… [vite] ✨ new dependencies optimized: emdash/middleware, emdash/middleware/redirect,
emdash/middleware/setup, emdash/middleware/auth, emdash/middleware/request-context
[vite] ✨ optimized dependencies changed. reloa…