How ikasoba/dejamu works
Project Type and Purpose
• Dejamu is a static site generator CLI tool written for Deno.
• It initializes a new site, builds static HTML/CSS/JS by processing source files through a plugin pipeline, and can serve the output locally.
Top-Level Architectural Components
a. CLI Layer
• Entry point: cli/cli.ts
• Subcommands: build, serve, rebuild (cli/lib/*.ts)
• Generator scripts: cli/generator/*.ts (genBuildCode, genServeCode, etc.)
b. Core Engine
• Context & configuration: core/context.ts, core/Config.ts, core/option.ts
• Feature systems: core/features/* (CacheSystem, FileSystem, PageInfoSystem, usePageInfos)
• Plugin framework: core/plugins/* (Plugin base, plugin registry)
• Resolver subsystem: core/resolver/* (cache, dependency, specifier)
• Pre-build hooks: core/PreBuildScript.ts
c. Plugins
• Markdown, Preact, Twind, PostCSS, Static, Virtual, HotReload
• Each plugin implements a standard interface (extends DejamuPluginBase)
• Plugins live in plugins/* and are loaded dynamically by the core
d. Utils & Dependencies
• Utility modules: utils/*.ts, cli/util/*.ts, scripts/*.ts
• External deps: esbuild, marked, preact-render-to-string, nanoid, etc.
e. Output & Server
• Static files generated to a configured output directory via FileSystem feature
• Local server spun up by cli/lib/serve.ts using Deno’s HTTP API
Relationships and Data Flow
• The CLI invokes the generator script for the selected command.
• Generator sets up the Core Context (loads config, plugins, features).
• Core Engine runs the build pipeline:
• Pre-build scripts → Resolver → Feature Systems → Plugin transforms → Output files
• For serve mode, after build, Serve module watches files and uses HTTP server to serve output.
• Rebuild watches for changes, triggers incremental builds using the CacheSystem.
Architectural Patterns and Principles
• Plugin architecture: loose coupling via a base plugin interface and dynamic discovery
• Feature-based modularity: separation of concerns (caching, file IO, routing)
• Command pattern: CLI commands map to generator workflows
• Resolver pattern: abstract module resolution (specifier, dependency graph)
• Incremental build: caching layer speeds up rebuilds
Technologies, Frameworks, Libraries
• Deno runtime and standard library (fs, http, path)
• esbuild for JS/CSS bundling
• marked for markdown parsing
• preact-render-to-string for server-side rendering
• twind for utility-first CSS
• nanoid for unique IDs