Klenodexempel

Docs

Build And Runtime

Build mode serializes collected module records and assets; runtime mode loads the bundle without build plugins.

Build Without Evaluation

Build mode collects entrypoints and runtime dependencies, waits for generated assets or writes them to disk when requested, and serializes runtime module specs with Klenods JSON bundle format. It should not evaluate application top-level code.

bundle = context.build(
  entrypoints: ["entrypoint"],
  output: "dist/klenod.bundle",
  assets_dir: "dist/public"
)

CLI And Config

The CLI finds the nearest klenod.config.rb by checking the current directory and walking up parent directories. It changes into the config directory before building.

bundle exec klenod build

You can inspect a built bundle without evaluating application modules by exporting Graphviz DOT.

bundle exec klenod graph dist/klenod.bundle > graph.dot
dot -Tsvg graph.dot > graph.svg

Runtime Loading

Runtime bundles contain entrypoint mappings, module specs, import specs, runtime import values, asset specs, source maps, and source-root metadata. Runtime loading evaluates modules lazily.

require "klenod/runtime"

bundle = Klenod::Runtime.load_bundle("dist/klenod.bundle")
page = bundle.exports("entrypoint")

Call bundle.preload_entrypoints to eagerly evaluate everything reachable from configured entrypoints, or bundle.preload to evaluate every module in the bundle.

Production deployments that only load prebuilt bundles should depend on klenod-runtime.

Rack Helpers

klenod-rack provides Rack-compatible helpers for serving runtime assets. It is an optional integration layer and does not define framework routing, rendering, or request dispatch policy.