Complete guide to installing and setting up Blop.
- Prerequisites
- Installing Blop
- Setting Up a New Project
- Setting Up Vite
- Setting Up Vitest
- VSCode Extensions
- Development Setup
- Troubleshooting
- Node.js 20 or higher
- npm or yarn
- A code editor (VSCode recommended)
npm install blop-languageIf you want to contribute or use the latest development version:
git clone https://github.com/batiste/blop-language.git
cd blop-language
npm installmkdir my-blop-app
cd my-blop-app
npm init -ynpm install blop-language vitemkdir src
touch src/main.blop
touch index.html
touch vite.config.jsCreate vite.config.js:
import { defineConfig } from 'vite';
import { blopPlugin } from 'blop-language/vite';
export default defineConfig({
plugins: [blopPlugin()],
});Create index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My Blop App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.blop"></script>
</body>
</html>Create src/main.blop:
import { mount } from 'blop'
def App() {
<div>
<h1>'Welcome to Blop!'</h1>
<p>'Your app is running.'</p>
</div>
}
// Mount the app
{ init } = mount(document.getElementById('app'), () => App())
init(){
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
}npm run devOpen http://localhost:5173 in your browser!
Vite provides fast development and optimized builds.
// vite.config.js
import { defineConfig } from 'vite';
import { blopPlugin } from 'blop-language/vite';
export default defineConfig({
plugins: [blopPlugin()],
});// vite.config.js
import { defineConfig } from 'vite';
import { blopPlugin } from 'blop-language/vite';
export default defineConfig({
plugins: [blopPlugin()],
server: {
port: 3000,
open: true
},
build: {
outDir: 'dist',
sourcemap: true
}
});Vitest is the recommended testing framework for Blop.
npm install -D vitest jsdomCreate vitest.config.js:
import { defineConfig } from 'vitest/config';
import { blopPlugin } from 'blop-language/vitest';
export default defineConfig({
plugins: [blopPlugin()],
test: {
include: ['**/*.test.blop'],
globals: true,
environment: 'jsdom',
},
});Update package.json:
{
"scripts": {
"dev": "vite",
"build": "vite build",
"test": "vitest",
"test:ui": "vitest --ui"
}
}Create src/App.test.blop:
import { describe, it, expect } from 'vitest'
def add(a, b) {
return a + b
}
describe('Math', () => {
it('adds numbers', () => {
expect(add(1, 2)).toBe(3)
})
})npm testGet the best development experience with VSCode extensions.
- Open VSCode
- Go to Extensions (Cmd/Ctrl + Shift + X)
- Search for "Blop"
- Install both extensions:
- Blop Language - Syntax highlighting
- Blop Linter - Error checking and diagnostics
If you cloned the repository:
cd blop-language
npm run link-extensionsThen reload VSCode (Cmd/Ctrl + Shift + P → "Developer: Reload Window").
- Syntax Highlighting - Beautiful code coloring
- Error Detection - Real-time error checking
- Autocomplete - Smart code completion
- Go to Definition - Jump to declarations
- Formatting - Code formatting support
If you want to contribute to Blop itself:
git clone https://github.com/batiste/blop-language.git
cd blop-language
npm installnpm run parsernpm testnpm startAfter modifying the linter:
npm run linterThen reload VSCode.
blop-language/
├── src/ # Core language source
│ ├── compile.js # Compiler
│ ├── grammar.js # Grammar definition
│ ├── runtime.js # Runtime library
│ └── vite.js # Vite plugin
├── docs/ # Documentation
├── example/ # Example application
├── vscode/ # VSCode extensions
│ ├── blop-linter/
│ └── blop-syntax-highlighter/
└── vitest.config.js # Test configuration
Solution: Make sure blopPlugin() is in your vite.config.js:
import { blopPlugin } from 'blop-language/vite';
export default defineConfig({
plugins: [blopPlugin()],
});Solutions:
- Make sure extensions are enabled
- Reload VSCode (Cmd/Ctrl + Shift + P → "Developer: Reload Window")
- Check Output panel for errors (View → Output → select "Blop Linter")
- Try reinstalling extensions
Solution: Blop uses ES6 module syntax. Make sure files have proper import/export statements:
// Export
export def myFunction() { ... }
// Import
import { myFunction } from './file.blop'Solution: Check that all files are saved and there are no syntax errors. Run:
npm run build 2>&1 | head -50Solution: Make sure:
- Test files end with
.test.blop vitest.config.jsincludesblopPlugin()jsdomis installed:npm install -D jsdom
Solution: Vite's HMR should work automatically. If not:
- Check browser console for errors
- Try hard refresh (Cmd/Ctrl + Shift + R)
- Restart dev server
- Follow the Quick Start Guide
- Read the Syntax Reference
- Explore Components
- Check out Example Projects