config

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package config loads puzzle.config.js — the app's optional configuration file (constellation/doc/DOC-DECISIONS.md D12). The Go side must never parse JavaScript (D3), so the config is read by executing node: it imports the ES module and prints its default export as JSON, which Go then unmarshals. No config file present means zero-config defaults and no node invocation at all.

v1 surface (SPEC §3, §11): styles.use accepts the single string entry "tailwindcss". The object form (`{ name: 'sass', ... }`) and any other string are parsed and rejected with a clear "not in v1" error — the grammar is recognized so the message can name what was deferred, not a generic failure.

Index

Constants

View Source
const ConfigFileName = "puzzle.config.js"

ConfigFileName is the app-root config file. Its absence is not an error.

Variables

This section is empty.

Functions

This section is empty.

Types

type Build

type Build struct {
	// DropConsole is the tri-state build.dropConsole setting: nil means the key
	// was absent (default behavior), a non-nil pointer is the explicit user
	// value. The pointer lets "unset" be distinguished from an explicit false.
	DropConsole *bool

	// SourceMap is the build.sourceMap setting. It defaults to false, so
	// production builds emit no linked source map unless explicitly enabled.
	SourceMap bool
}

Build mirrors the `build` block of puzzle.config.js.

type Config

type Config struct {
	Styles Styles
	Build  Build
	Dev    Dev
	// Output is the resolved `output` key: "" (absent — the default SPA build),
	// "static" (the true static-pages mode: per-route HTML, per-page module
	// bundles, no router), or "hybrid" (per-route prerendered HTML that the full
	// SPA runtime takes over on load — the mode formerly spelled 'static'). Any
	// other value is rejected by validate with a message naming both.
	Output string
}

Config is the resolved, validated configuration. The zero value is the valid "no config file" state: no style pipelines declared, default build, SPA output.

func LoadConfig

func LoadConfig(appRoot string) (Config, error)

LoadConfig loads and validates puzzle.config.js from appRoot.

  • No config file: returns the zero Config and no error (no node needed).
  • Config present but node missing / unrunnable: a clear error.
  • Config present but malformed JS: node's syntax error, surfaced.
  • A deferred entry (object form, or a non-"tailwindcss" string): a "not in v1" error naming the entry.

func (Config) DropConsole

func (c Config) DropConsole() bool

DropConsole reports whether production builds should strip console.* calls. Unset (no config file, or build.dropConsole absent) defaults to true — the v1 behavior; build.dropConsole: false opts out.

func (Config) TailwindEnabled

func (c Config) TailwindEnabled() bool

TailwindEnabled reports whether the Tailwind pipeline is declared.

type Dev added in v0.1.2

type Dev struct {
	// Proxy maps same-origin path prefixes to backend origins for puzzle dev.
	Proxy map[string]string `json:"proxy"`
}

Dev mirrors the `dev` block of puzzle.config.js.

type Styles

type Styles struct {
	// Use lists the enabled style pipelines. In v1 the only accepted entry is
	// "tailwindcss"; the slice is therefore either empty or ["tailwindcss"].
	Use []string
}

Styles mirrors the `styles` block of puzzle.config.js.

Jump to

Keyboard shortcuts

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