compiler

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildClient

func BuildClient(cfg *config.Config) error

BuildClient bundles Zyra's client runtime and every page component into code-split, tree-shaken JavaScript chunks, builds the Tailwind CSS bundle, and writes manifest.json mapping every entry point to its final (content-hashed) output path.

func BuildSSRWorker

func BuildSSRWorker(cfg *config.Config) error

BuildSSRWorker bundles the SSR worker script into a single, Bun/Node-compatible ESM file at <cfg.OutDir>/ssr-worker.js, for production use in place of running the raw TypeScript source directly. React and react-dom are left external so the bundle resolves them from the project's own node_modules at runtime instead of duplicating them into the bundle.

func BuildStyles

func BuildStyles(cfg *config.Config) error

BuildStyles resolves Tailwind CSS utilities for the project (using cfg.Tailwind.Content to tell Tailwind's CLI what to scan) and bundles the result with esbuild into <cfg.OutDir>/static, updating manifest.json in place. It rebuilds only CSS, without touching any JavaScript, which makes it cheap to call on every class-name change detected by the dev watcher.

func PublicFileHandler

func PublicFileHandler(cfg *config.Config, next http.Handler) http.Handler

PublicFileHandler serves files from cfg.PublicDir directly at the site root (e.g. public/favicon.ico -> /favicon.ico), applying the same cache policy as StaticFileHandler. Any request path that doesn't match a file in cfg.PublicDir falls through to next (typically Zyra's page/SSR handler).

func ResolveAssets

func ResolveAssets(outDir string) (cssPath string, jsPath string)

ResolveAssets reads <outDir>/manifest.json and returns the public URL paths for the primary CSS bundle and the primary client JS bundle.

func StaticFileHandler

func StaticFileHandler(cfg *config.Config) http.Handler

StaticFileHandler serves built client assets (JS/CSS bundles) from <cfg.OutDir>/static, with no-cache headers in dev mode and a long-lived immutable cache in production (safe because output filenames are content-hashed).

func WatchAndRebuild

func WatchAndRebuild(cfg *config.Config, onChange func(changeType string)) error

WatchAndRebuild starts esbuild's native watch mode for both the client JS/page bundle and the Tailwind CSS bundle. Each rebuild invokes onChange (debounced by 300ms; simultaneous JS and CSS rebuilds within that window are coalesced into a single "all" call). WatchAndRebuild returns once both watchers are established; the underlying esbuild watch goroutines keep running for the lifetime of the process.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL