Files
soroban-abacus-flashcards/packages/abacus-react/vite.config.ts
Thomas Hallock 7c33d0246f fix: prevent undefined displayRules error in worksheet generator
Fixes production error "Cannot read properties of undefined (reading 'carryBoxes')"
that occurred when users tried to adjust difficulty settings.

Root cause: displayRules was undefined for new users or users with old V1 config
in database. Difficulty adjustment buttons accessed displayRules.carryBoxes without
checking if displayRules existed first.

Changes:
- AdditionWorksheetClient: Initialize displayRules with defaults when missing
- ConfigPanel: Use null-coalescing operators instead of non-null assertions
- ConfigPanel: Add error logging when required fields are missing
- NEW: WorksheetErrorBoundary component to catch all errors in worksheet page
- page.tsx: Wrap client component with error boundary

This ensures users see helpful error messages instead of blank pages,
and never need to open the browser console to understand what went wrong.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 13:01:54 -06:00

41 lines
1.0 KiB
TypeScript

import { defineConfig } from "vite";
import { resolve } from "path";
export default defineConfig(async () => {
const { default: react } = await import("@vitejs/plugin-react");
return {
plugins: [react()],
build: {
lib: {
entry: {
index: resolve(__dirname, "src/index.ts"),
static: resolve(__dirname, "src/static.ts"),
},
formats: ["es", "cjs"],
fileName: (format, entryName) =>
`${entryName}.${format === "es" ? "es" : "cjs"}.js`,
},
sourcemap: true,
rollupOptions: {
external: [
"react",
"react-dom",
"@react-spring/web",
"@use-gesture/react",
"@number-flow/react",
],
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
"@react-spring/web": "ReactSpring",
"@use-gesture/react": "UseGesture",
"@number-flow/react": "NumberFlow",
},
},
},
},
};
});