build.go

15 lines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
package frontend

import "fmt"

// Build compiles all components in SourceDir to OutputDir.
// Requires a bundler configured via WithBundler.
// Safe for concurrent calls — serialized to prevent overlapping esbuild runs.
func (f *Frontend) Build() error {
	f.buildMu.Lock()
	defer f.buildMu.Unlock()
	if f.bundler != nil {
		return f.bundler.Build()
	}
	return fmt.Errorf("frontend: no bundler configured — use WithBundler to set one")
}