What is the bullet-proof way to get notified when any module in a Phoenix application gets recompiled?

I’m working on a bullet-proof live reload mechanism in Hologram, and I need a reliable way to be notified when any module in a Phoenix application gets recompiled and its .beam file gets updated.

From my research, I’ve discovered that there may be a few ways to approach this:

  1. Watching for .beam file changes - Set up a file system watcher to monitor changes to .beam files
  2. Hook into compilation tracers - Use Elixir’s compilation tracers somehow

What do you recommend? Is there another, more reliable approach that I’m missing?

I’m looking for a solution that’s as robust as possible, with minimal chances of missing any module recompilations, even in edge cases. Importantly, I want a mechanism that is not dependent on any Phoenix-related internals, just a pure Elixir way of doing this.

Thanks for your insights!