From 0e922d90584ccb1fa5232252d2041d0affa1a4bf Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Wed, 13 Aug 2025 13:22:32 -0600 Subject: [PATCH] Update BusterThemeProvider.tsx --- apps/web-tss/package.json | 1 + apps/web-tss/scripts/fix-react-symlink.ts | 45 +++++++++++++++++++ .../BusterStyles/BusterThemeProvider.tsx | 4 ++ 3 files changed, 50 insertions(+) create mode 100644 apps/web-tss/scripts/fix-react-symlink.ts diff --git a/apps/web-tss/package.json b/apps/web-tss/package.json index 942df9c54..0f1dde41b 100644 --- a/apps/web-tss/package.json +++ b/apps/web-tss/package.json @@ -7,6 +7,7 @@ "dev:fast": "pnpm run build && pnpm run start", "start": "node .output/server/index.mjs", "build": "vite build", + "build:fix-react-symlink": "npx tsx scripts/fix-react-symlink.ts", "serve": "vite preview", "test": "vitest run", "lint": "biome check --write", diff --git a/apps/web-tss/scripts/fix-react-symlink.ts b/apps/web-tss/scripts/fix-react-symlink.ts new file mode 100644 index 000000000..3d4f52abb --- /dev/null +++ b/apps/web-tss/scripts/fix-react-symlink.ts @@ -0,0 +1,45 @@ +#!/usr/bin/env node +import { existsSync, rmSync, symlinkSync } from 'fs'; +import { join } from 'path'; + +/** + * Fix React symlink in the production build to ensure React 19 is used + * This script runs after the build to correct any incorrect symlinks + * + * Equivalent to running: + * cd .output/server/node_modules + * rm react + * ln -s .nitro/react@19.1.1 react + */ +async function fixReactSymlink() { + // Get the path to .output/server/node_modules from the root of the app + const nodeModulesDir = join(process.cwd(), '.output', 'server', 'node_modules'); + const reactPath = join(nodeModulesDir, 'react'); + + console.log('🔧 Fixing React symlink in production build...'); + + // Check if the output directory exists + if (!existsSync(nodeModulesDir)) { + console.log('✅ No output directory found, skipping symlink fix'); + return; + } + + // Remove react directory/symlink if it exists (equivalent to: rm react) + if (existsSync(reactPath)) { + rmSync(reactPath, { recursive: true, force: true }); + console.log('🗑️ Removed react'); + } + + // Create symlink to .nitro/react@19.1.1 (equivalent to: ln -s .nitro/react@19.1.1 react) + // Note: The symlink target is relative to the node_modules directory + symlinkSync('.nitro/react@19.1.1', reactPath); + console.log('✅ Created symlink: react -> .nitro/react@19.1.1'); + + console.log('✨ React symlink fix complete!'); +} + +// Run the fix +fixReactSymlink().catch((error) => { + console.error('❌ Error fixing React symlink:', error); + process.exit(1); +}); diff --git a/apps/web-tss/src/context/BusterStyles/BusterThemeProvider.tsx b/apps/web-tss/src/context/BusterStyles/BusterThemeProvider.tsx index eb613f35c..a66259213 100644 --- a/apps/web-tss/src/context/BusterStyles/BusterThemeProvider.tsx +++ b/apps/web-tss/src/context/BusterStyles/BusterThemeProvider.tsx @@ -25,6 +25,8 @@ type ThemeProviderProps = { // Create the context const ThemeProviderContext = createContext(null); +const ENABLED_DARK_MODE = false; + // Theme provider component export function BusterThemeProvider({ children, @@ -50,6 +52,8 @@ export function BusterThemeProvider({ // Apply theme to document root useEffect(() => { + if (!ENABLED_DARK_MODE) return; + const root = window.document.documentElement; // Remove both classes first