Klenodexempel

Docs

Development Updates

Klenod can watch source changes, update the collected graph, report reload failures, and keep reusable entry handles current.

Watch And Apply Updates

Watch-mode consumers subscribe to update events and apply them to the current graph.

context.on_update do |event|
  update = context.apply_update(event, entry: entry, assets_dir: "public")

  if update.success?
    css_assets = update.entry.assets(type: :css)
  else
    warn update.error_messages.join("\n")
  end
end

apply_update refreshes the entry, mirrors changed assets when assets_dir: is provided, and returns an update object with entry, exports, asset_write_result, and errors.

Update Results

Use update.success?, update.failed?, update.error_messages, and update.asset_files_changed? for common development branches.

Source changes, removed modules, changed dependencies, watched companion patterns, glob patterns, and virtual modules can all invalidate graph records.

Failed Reloads

When a changed module fails to transform or collect, Klenod stores a failed ModuleRecord with the original error. Dependents of that failed reload are not reevaluated during the same update, which avoids repeated parse/import errors.

Already evaluated dependents are evicted. A later request that needs the failed dependency re-evaluates and raises the stored error, while unrelated routes can continue using the previous good graph.

Source Context

Runtime owns source maps and backtrace rewriting so production error pages can report transformed sources without loading build plugins. Haml generated Ruby includes source map marks that let runtime errors point back to Haml source lines.