Bump Your Deps

Update Backpex to the latest version:

defp deps do
  [
    {:backpex, "~> 0.19.0"}
  ]
end

Backpex.LiveResource now imports Phoenix.Component instead of using it

Previously, use Backpex.LiveResource brought in the full use Phoenix.Component (transitively, via use BackpexWeb, :html). It now only imports Phoenix.Component.

Why this changed

use Phoenix.Component registers a @before_compile hook that Elixir does not deduplicate. If your LiveResource also brought in Phoenix.Component — for example through use MyAppWeb, :html (to get your app's components, gettext and verified routes) — that hook ran twice and generated its compile-time component verification code twice. Elixir 1.20+ rejects the resulting duplicate function clause as a redundant clause, failing compilation under --warnings-as-errors.

A LiveResource only needs the ~H sigil (for the injected render_resource_slot/3 clauses and for your own render functions), and import Phoenix.Component provides that without registering the hook. This resolves the compile failure.

Do you need to change anything?

No changes required in the common case. LiveResources that only use the ~H sigil — in render_resource_slot/3 overrides or inline render: field closures — continue to work unchanged.

Action required only if you declare your own function components with attr/slot (or embed_templates, or the component-aware def) directly inside a LiveResource module. This previously worked because Phoenix.Component was pulled in via use. Now you must additionally bring it in yourself with use MyAppWeb, :html (or use Phoenix.Component):

Before (worked in v0.18):

defmodule MyAppWeb.PostLive do
  use Backpex.LiveResource,
    adapter_config: [...]

  attr :label, :string, required: true

  def badge(assigns) do
    ~H"""
    <span class="badge">{@label}</span>
    """
  end
end

After:

defmodule MyAppWeb.PostLive do
  use Backpex.LiveResource,
    adapter_config: [...]

  use MyAppWeb, :html # or `use Phoenix.Component`

  attr :label, :string, required: true

  def badge(assigns) do
    ~H"""
    <span class="badge">{@label}</span>
    """
  end
end