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 ¶
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
// Splitting is the tri-state build.splitting setting: nil means the key was
// absent (default off this release), a non-nil pointer is the explicit user
// value. Pointer storage so a later release can flip the default in the
// accessor without changing stored semantics.
Splitting *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 ¶
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 ¶
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) Splitting ¶ added in v0.6.0
Splitting reports whether the SPA browser bundle should be built with esbuild code splitting, so a dynamic import() emits a lazy chunk under dist/chunks/ instead of being inlined into app.js. Default is off; enable with build: { splitting: true }.
func (Config) TailwindEnabled ¶
TailwindEnabled reports whether the Tailwind pipeline is declared.