cblavier

cblavier

Recompile dependency based on @external_resource

Hey there :wave:

I’m using @external_resource in a library to trigger a macro recompilation when some file is changed in the hosting application.

This is working fine when referencing the lib locally, using {:my_library, path: "../my_library"} in mix.exs: every time I touch a specific file in my application, the library gets recompiled.

But if I switch to a remote dependency (GitHub), It won’t get recompiled anymore.

Is it even possible? Maybe if I tweak the :manager option of my dependency?

Marked As Solved

kip

kip

ex_cldr Core Team

In my first implementation of ex_cldr I spent a lot of time trying to find ways to recompile a dependency when a host app changed and I never found a way to do it. And I came to believe it is an anti pattern in the elixir build system. Its possible another build tool will take another approach. But ultimately this very situation is why I have ended up with defining “backend” modules in the host application that draw on the dependency and are cleanly recompiled by mix when the @external_resource changes. Its probably not a surprise that its also the approach taken by Gettext and others.

TLDR; I suspect your objective may not be met.

Also Liked

cblavier

cblavier

I just implemented your solution and it’s working perfectly :ok_hand:

It also came with an extra benefit: my backend module is watched by phoenix code reloader and is recompiled, at runtime, without restarting the server in dev environment.

Many thanks!

kip

kip

ex_cldr Core Team

Can do, but its been a few years so will take me a little time to dig it out of the repo.

The “best” strategy I could come up with at the time was to roll my own “compiler” (in the Mix sense of compiler) that ran at the end of the compiler chain to force recompilation of certain modules based upon the compiler manifest or timestamps. It was very brittle.

kip

kip

ex_cldr Core Team

I think that’s probably a good idea.

In case there’s any value in it at all (which I doubt), the cldr.compiler I wrote back in 2018 is at cldr/lib/mix/tasks/compile.cldr.ex at v1.8.2 · elixir-cldr/cldr · GitHub

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
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
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
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
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

We're in Beta

About us Mission Statement