aesmail

aesmail

Compiling and loading modules dynamically

I have a bit of an unconventional situation.

I have an app that generates files at runtime. Those files contain valid elixir code (modules basically). I need to compile them and load them at runtime.

I am able to do most of that with Code.compile_file, Code.require_file, and friends.

However, I need to be able to check what new modules have been compiled (or all the modules currently loaded in my app).

I’m using :application.get_key(:my_app, :modules) which lists all modules correctly when the app starts, but this doesn’t include the newly compiled modules at runtime.

Any idea how to achieve that?

All I care about is, I need to compile random modules at runtime and I need to know about all the newly generated modules that were compiled randomly at runtime.

Thanks!

Most Liked

OvermindDL1

OvermindDL1

Personally I’d have the files register themselves, you might have tools and such you don’t want loaded via your normal way as well after all. :slight_smile:

dimitarvp

dimitarvp

I seem to remember the core team saying that there are compiler callbacks or some such now but I am not able to immediately find anything on it.

xlphs

xlphs

If you only care about newly compiled modules, and your app is the one that compiles and loads each module, you can store each module name or the file name into an Agent or your own GenServer.

Last Post!

zaherh8

zaherh8

hello @aesmail, any luck with finding a way to load the newly compiled modules?
I am facing the same case where I need to compile different modules dynamically. I need to make sure that the modules are loaded and accessible. If you found any result please share thanks.

Where Next?

Popular in Questions Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44532 311
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New

We're in Beta

About us Mission Statement