5bf6013460
Progressive lesson streaming via onSegment callback (fixes SSE for non-English users — locale was shadowed in lesson-reader useEffect). Adds: BullMQ workers, Redis stream buffer, token budget enforcement, Langfuse tracing, golden-eval runner, Playwright e2e scaffolding, lesson depth/locale/preferences schema, mastery map UI, admin panel (blueprints/users/reports/quality/misconceptions), image queries, source citations, view transitions, reading animations, i18n (next-intl), PDF export, surprise endpoint, and 402 passing unit tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
/**
|
|
* Worker entrypoint. Stubs the `server-only` import guard before loading any
|
|
* src/lib code, then hands off to the real worker registry.
|
|
*
|
|
* Why: src/lib/** modules begin with `import 'server-only'` to keep RSC-only
|
|
* code out of client bundles. That package throws when required outside Next's
|
|
* React Server bundler. Workers are server code but run under plain Node/tsx,
|
|
* so we resolve `server-only` to a no-op here — and ONLY here, so the app's
|
|
* build-time guard is untouched. Mirrors the vitest alias in vitest.config.ts.
|
|
*/
|
|
import Module, { createRequire } from 'module';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname, join } from 'path';
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
const NOOP = join(here, 'server-only.noop.cjs');
|
|
|
|
type ResolveFn = (request: string, ...rest: unknown[]) => string;
|
|
const moduleInternals = Module as unknown as { _resolveFilename: ResolveFn };
|
|
const originalResolve = moduleInternals._resolveFilename;
|
|
|
|
moduleInternals._resolveFilename = function (request, ...rest) {
|
|
if (request === 'server-only') return NOOP;
|
|
return originalResolve.call(this, request, ...rest);
|
|
};
|
|
|
|
// Load the worker graph *after* the stub is installed (require keeps it
|
|
// synchronous — tsx compiles this file to CJS, where top-level await is unavailable).
|
|
const require = createRequire(import.meta.url);
|
|
require('./index');
|