This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Vue 2.7 REPL - A browser-based Vue 2.7 component editor with live preview. This is a Vue2 counterpart to the official Vue3 REPL (https://github.com/vuejs/repl).
The project depends on three companion packages (all published on npm):
vue2-jsx-browser- Browser JSX compilation for Vue 2vue2-sfc-compiler- SFC parsing and compilationvue2-sfc-runner- Runtime for executing compiled Vue 2 SFCs
pnpm dev # Start dev server on port 5173
pnpm build # Build library (outputs to dist/)
pnpm build-preview # Build demo site
pnpm lint # ESLint check
pnpm format # Prettier formatting
pnpm typecheck # TypeScript type checking (vue-tsc --noEmit)The library builds to four entry points:
repl-vue2.js/.cjs- Full REPL component with UIcore.js- Headless core (state management + compilation, no UI)codemirror-editor.js- CodeMirror 5 editor implementationmonaco-editor.js- Monaco editor with Volar language services
Store (src/store.ts): Central reactive state managing files, compilation, and serialization. Uses Vue 2.7 Composition API. Key concepts:
- Files stored as
Record<string, File>with compiled JS/CSS output - Supports URL serialization via lz-string compression
- Optional file change tracking for save indicators
Compiler (src/compiler/): Uses vue2-sfc-runner for SFC compilation. Outputs CommonJS format (module.exports, require()) for the preview iframe's module simulator.
Preview (src/output/):
PreviewProxy.ts- IFrame postMessage communicationmoduleCompiler.ts- Bundles compiled files into preview modulessrcdoc.html- Preview page template with module system implementation
Editors (src/editor/):
codemirror/- Lightweight CodeMirror 5 integrationmonaco/- Full Monaco editor with Volar for Vue/TS language services. Key files:env.ts- Monaco environment and Volar initializationvue.worker.ts- Web Worker for language services- Uses
@volar/jsdelivrfor CDN-based type definitions
- Uses
@vitejs/plugin-vue2for Vue 2.7 support - Alias workaround for
@vue/compiler-domto fix Web Worker compatibility (see comment in vite.config.ts:24-32) - External deps:
vue,codemirror,monaco-editor
- TypeScript with strict mode
- Use
typeimports:import { type Foo }orimport type { Foo } - Prefer
constoverlet - Sort imports (declaration sort is ignored)
- Vue: self-closing HTML tags, no multi-word component name requirement
- No semicolons, single quotes (Prettier config)
The REPL preview requires Babel loaded via CDN for TypeScript/JSX:
<script src="https://cdn.jsdelivr.net/npm/@babel/standalone@7/babel.min.js"></script>Optional SCSS/LESS support loaded from CDN as needed.