Files
goose/MONACO_FINAL_FIX.md
spencrmartin 0223f4cd61 fix(lint): remove unused variables and imports
- Remove unused setIsGoosehintsModalOpen parameter in AppLayout
- Add eslint-disable comments for insights and error in SessionsInsights
- Remove unused TabsList and TabsTrigger imports in SettingsView
2025-11-06 12:59:50 -05:00

1.9 KiB

Monaco Editor - Final Fix

The Problem

The vite-plugin-monaco-editor package has ESM compatibility issues with Vite 7 and Electron Forge.

The Solution

Instead of using the plugin, we configure Monaco Editor to load directly from the bundled monaco-editor package.

Changes Made

1. Vite Renderer Config (vite.renderer.config.mts)

export default defineConfig({
  plugins: [tailwindcss()],
  
  build: {
    target: 'esnext',
    rollupOptions: {
      output: {
        // Manually chunk Monaco Editor
        manualChunks: {
          'monaco-editor': ['monaco-editor'],
          'monaco-react': ['@monaco-editor/react'],
        },
      },
    },
  },

  optimizeDeps: {
    include: ['monaco-editor', '@monaco-editor/react'],
    esbuildOptions: {
      target: 'es2020',
    },
  },

  worker: {
    format: 'es',
  },
});

2. MonacoCodeInput Component

import * as monacoEditor from 'monaco-editor';
import { loader } from '@monaco-editor/react';

// Configure Monaco loader to use the bundled version
loader.config({ monaco: monacoEditor });

How It Works

  1. Direct Import: We import monaco-editor directly in the component
  2. Loader Configuration: We tell @monaco-editor/react to use our imported Monaco instance
  3. Vite Bundling: Vite bundles Monaco and its workers using the worker.format: 'es' config
  4. Electron Compatible: This approach works in Electron because everything is bundled locally

Try It Now

The app should start successfully now:

npm run start-gui

Then test Monaco:

  • Type #python in the chat input
  • Monaco should load and work perfectly!

Why This Works Better

  • No plugin compatibility issues
  • Works with Vite 7 and Electron Forge
  • All Monaco features available
  • Proper worker loading
  • Fast and reliable

Monaco Editor is now properly configured! 🚀