Skip to content

stevenleep/CompileToy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go License

Educational demo: Fast development server with plugin-based transformations

⚠️ This is a recreational demo project for learning purposes only. Not intended for production use.

Features

  • TypeScript/JSX - Sub-50ms compilation via esbuild
  • WebAssembly - Native Go-to-WASM pipeline
  • Plugins - Extensible transformation system
  • Zero Config - Works out of the box

Quick Start

git clone https://github.com/user/vite-go.git
cd vite-go && go run .

Visit http://localhost:9090

Supported Files

Type Output Time
.ts/.tsx ES modules ~15ms
.js/.jsx ES modules ~10ms
.go WASM + JS ~80ms
.css Injected styles ~3ms

Plugin API

type Plugin interface {
    Name() string
    Match(fileInfo *FileInfo) bool
    Transform(ctx context.Context, fileInfo *FileInfo) (*TransformResult, error)
    Priority() int
}

Example:

type SassPlugin struct{}

func (p *SassPlugin) Name() string { return "Sass" }
func (p *SassPlugin) Match(fi *FileInfo) bool { return fi.Extension == ".scss" }
func (p *SassPlugin) Priority() int { return 85 }

func (p *SassPlugin) Transform(ctx context.Context, fi *FileInfo) (*TransformResult, error) {
    css, err := compileSass(fi.Content)
    return &TransformResult{Code: css, ContentType: "text/css"}, err
}

// Register: pluginManager.Register(&SassPlugin{})

License

MIT

About

Educational demo: Fast development server with plugin-based transformations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published