From 76fb297622a973cd3ef1abfefc98f0fb109d3e3f Mon Sep 17 00:00:00 2001 From: Mattias Jansson Date: Mon, 22 Jun 2026 10:07:32 +0200 Subject: [PATCH] fix: don't require downstream bon dependency for components Make the default builder for the `#[renderable]`/`#[component]` macro set the `#[builder(crate = ::hypertext::bon)]` parameter so that projects using the macros do not have to add bon to its own dependencies. Without the `crate` parameter, the macro will expand to code that directly refereces bon. If the user of the macro does not have bon as a direct dependency it will generate the following error: ``` 41 | #[renderable] | ^^^^^^^^^^^^^ could not find `bon` in the list of imported crates ``` This adds the `crate` parameter when not setting the builder directly. The DefaultBuilder works without it. But if one was to explicitly set `#[renderable(builder = hypertext::Builder)]` then one can either keep bon as a direct dependency or set the `crate` parameter manually. That should normally not be necessary since `hypertext::Builder` is the default builder. --- crates/hypertext-macros/src/renderable.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/hypertext-macros/src/renderable.rs b/crates/hypertext-macros/src/renderable.rs index 3da992b..e0ae584 100644 --- a/crates/hypertext-macros/src/renderable.rs +++ b/crates/hypertext-macros/src/renderable.rs @@ -148,6 +148,7 @@ pub fn generate(args: RenderableArgs, mut fn_item: ItemFn) -> syn::Result>(); + let is_default_builder = args.builder.is_none() && !fields.is_empty(); let builder = args.builder.or_else(|| { if fields.is_empty() { None @@ -157,9 +158,20 @@ pub fn generate(args: RenderableArgs, mut fn_item: ItemFn) -> syn::Result