Recompile Phoenix Module on external file changes

Hello, I’d like for some phoenix controllers or other modules to recompile when a file in the host filesystem changes. Is there a built-in way to do this? Thanks.

2 Likes

You could use @external_resource attribute…

https://hexdocs.pm/elixir/1.13/Module.html#module-module-attributes

5 Likes

Using this, does the module recompile while the application is running or while starting it? I’m asking because I need it to do it at runtime.

1 Like

Can you elaborate on your use case? I would generally avoid rewriting code at runtime.

2 Likes

You are right, this was a bad way to think about things, I resorted to using file_system for this. Thanks a lot though!

1 Like