The Vibe Compiler validates generated code before execution, blocking dangerous patterns and enforcing security constraints. It’s used internally by VibeFrame but can also be used directly for pre-validation.
const compiler = new VibeCompiler({ maxCodeSize: 50_000 // 50KB limit})// Large code will be rejectedawait compiler.compile(hugeCodeString)// Error: Code size (150000 bytes) exceeds maximum (50000 bytes)
interface CompiledComponent { // Original source code code: string // Hash for caching hash: string // Render function (in full implementation) render(data?: Record<string, unknown>): ReactNode}
class CustomCompiler extends VibeCompiler { async compile(code: string) { // Run base validation const result = await super.compile(code) // Add custom checks if (code.includes('alert(')) { throw new Error('alert() is not allowed') } if (code.length < 50) { throw new Error('Code is too short to be valid') } return result }}
// Widgets should be smallconst widgetCompiler = new VibeCompiler({ maxCodeSize: 20_000 // 20KB})// Full pages can be largerconst pageCompiler = new VibeCompiler({ maxCodeSize: 100_000 // 100KB})