Problems with HEEx on upgrading a LiveView-less project from Phoenix 1.5 to 1.6

I’m running into some problems while upgrading a Phoenix project from 1.5 to 1.6. Specifically, my question is: why is phoenix_live_view needed as an extra dependency when you only need HEEx and not LiveView?

Context: the application is a small project originally built in Phoenix 1.4 and later upgraded to Phoenix 1.5. It is a “traditional” application with non-LiveView HTML pages rendered using EEx templates.

As suggested in the Phoenix 1.5.x to 1.6 upgrade instructions, I’d like to replace all my EEx (.html.eex files and ~E sigils) with HEEx (.html.heex and ~H sigils).

This step is marked as optional, but if I don’t do this after upgrading phoenix_html to a 3.x version (per the Update your deps instructions), I get warnings like this:

warning: Phoenix.HTML.sigil_E/2 is deprecated. use the ~H sigil instead

Once I replace ~E with ~H, however, I’m starting to get compilation errors:

== Compilation error in file lib/example_web/views/example_view.ex ==
** (CompileError) lib/example_web/views/example_view.ex:24: undefined function sigil_H/2

After some research, I found that sigil_H/2 is defined inside the Phoenix.LiveView.Helpers module. After adding phoenix_live_view to my dependencies and adding import Phoenix.LiveView.Helpers to my views, the compiler errors indeed disappear.

All in all this leaves me with a working Phoenix 1.6 project that does not need LiveView at all, but does need the phoenix_live_view package only for bare HEEx support. This somehow feels weird, as it seems to go against the idea of HEEx to be a (LiveView-independent) replacement for both EEx and LEEx.

And with that I’m getting back to my original question: has LiveView (phoenix_live_view) indeed become a necessary dependency for any Phoenix 1.6+ project that needs HEEx-based HTML rendering? Thanks!

1 Like

If I remember correctly, it was too hard or too much work to split HEEX out of LiveView and making LV a dependency was the compromise.

Ah, that’s good to know! Out of curiosity: is there an article (or GitHub issue / pull request maybe) you know of where I can read more about this decision?

I think I heard it on this Thinking Elixir podcast :man_shrugging:

The info you figured out is in the upgrade guide & it’s comments.