How bcomnes/top-bun works
Main Components
a. Core Build Pipeline
• Source Directory Handler
• Page Builders (MD, HTML, JS)
• Layout System
• Asset Bundler (esbuild)
• Static Asset Copier
• Output Directory Generator
b. Supporting Systems
• Template Engine
• Variable Management
• Watch System
• Development Server
Component Relationships
Source Directory → Build Pipeline → Output Directory
• ↑ ↑ ↓
• Watchers Build Systems Dev Server
Detailed Component Breakdown
a. Source Directory Handler
• Input detection for different file types
• Parallel processing paths for different content types
• Markdown Processing Pipeline
• HTML Processing Pipeline
• JavaScript Page Pipeline
• How they converge into the layout system
c. Layout System
• Layout Resolution
• Variable Injection
• Template Processing
• Nested layout capability
d. Asset Processing
• esbuild Bundle Processing
• Static Asset Copying
• Parallel processing
Key Elements to Highlight
a. File Processing Flows:
.md files → Markdown Processor → Layout System
.html files → HTML Processor → Layout System
.js files → JS Processor → Layout System
.css files → esbuild → CSS Bundles
Static files → Direct Copy → Output
b. Variable System:
global.vars.js → Variable Merger ← page.vars.js
• ↓ ↓
• Templates ← Variable Resolver → Layouts
Implementation Details
• esbuild integration for JS/CSS bundling
• markdown-it for MD processing
• cpx2 for static file copying
• Handlebars template processing
• Browser sync dev server
┌─ Input ─┐ ┌─ Processing ─┐ ┌─ Output ─┐
• Source │ → │ Build Pipeline│ → │ Public │
• Tree │ │ Systems │ │ Dir │
• ┬────┘ └──────┬───────┘ └────┬────┘
• Watch System & Dev Server ────┘
Additional Notes
• Version information and key dependencies
• Error handling flows
• Configuration points
• Extension/plugin capabilities
• The complete build pipeline
• How different file types are processed
• Where and how variables are injected
• How layouts and templates interact
• The parallel processing capabilities
• Development workflow integration
• Convention over configuration
• HTML as source of truth
• Library agnostic approach
• Pages as shallow apps
• Standardized entry points
• Colocated assets