Prerequisites
Before you begin, ensure you have the following installed:- Node.js: Version 22.19.0 or higher (specified in
package.json:196) - npm: Comes with Node.js
- Git: For version control
Opal Editor requires Node.js 22.19.0 or later. Check your version with
node --version.Installation
Install dependencies
patch-package via the postinstall script to apply necessary patches.Development Commands
Opal Editor provides several npm scripts for development:Core Development
Worker Development
Testing
Code Quality
Deployment
Project Structure
Understanding the project structure will help you navigate the codebase:Key Directories Explained
/src/data
Contains the data layer with IndexedDB setup using Dexie, DAOs for workspaces, builds, deployments, and the virtual filesystem abstraction.
/src/lib/service-worker
Implements the service worker using Hono router (sw-hono.ts:1) for handling requests like image uploads, markdown rendering, and workspace downloads - enabling the no-server-required architecture.
/src/workspace
Core workspace management, including the Workspace class (Workspace.ts:74) that orchestrates disk, Git repo, and image cache.
/src/services/build
Static site generation with support for various template engines (Eleventy, Mustache, Nunjucks, Liquid, EJS).
Running Tests
Opal Editor uses Playwright for end-to-end testing:Development Tips
Service Worker Development
- Service workers are enabled by default in development
- The service worker controls requests at
http://localhost:3000 - Headers are configured in
vite.config.ts:65-69to allow service worker scope - Check
src/lib/service-worker/sw-hono.tsfor request routing
Hot Module Replacement
Vite’s HMR is enabled by default. Changes to React components will hot-reload without losing state.React Compiler
Opal Editor uses the React 19 compiler (babel-plugin-react-compiler) for automatic memoization. This is configured in vite.config.ts:40-44.
Path Aliases
The project uses@/ as an alias for src/ (configured in vite.config.ts:60 and tsconfig.json:29):
Browser Compatibility
Opal Editor requires modern browser features:- IndexedDB or OPFS (Origin Private File System)
- Service Workers
- Web Workers
- ES2017+ JavaScript features
Troubleshooting
Installation Issues
Ifnpm install fails:
- Ensure you’re using Node.js 22.19.0 or higher
- Clear npm cache:
npm cache clean --force - Delete
node_modulesandpackage-lock.json, then reinstall
Service Worker Issues
If the service worker isn’t working:- Unregister existing service workers in DevTools → Application → Service Workers
- Hard refresh the page (Cmd/Ctrl + Shift + R)
- Check the Console for service worker registration errors
Build Errors
If the build fails:Next Steps
Now that your development environment is set up:- Read the Architecture Guide to understand the codebase structure
- Check open issues on GitHub to find contribution opportunities
- Join the Discord community for developer discussions