polypush135
Nimble_publisher and recompiling while running iex or mix
I have made a simple static site using nimble publisher and followed along with the tut from fly.io Crafting your own Static Site Generator using Phoenix · The Phoenix Files
That said I have a simular build() function as from in the tut that just simply compiles the markdown files using earmark and so on with heex and then writes the to a given dir via File.write!
I’ve noticed that if I start a iex session or even run a cowboy server that if I call said build function while in IEx that it will not write anything different from when it started.
If I call recompile after I’ve made a change to a .md file but before I run said build() then it works. I assume this is because the other markdown files are still in memory even though I’ve edited a file, until I recompile that new edit wont be in memory. This is my assumption.
All of that is a non issue when calling from a mix task in a separate terminal session and build can be recalled and works as expected. Only time I see an unexpected behavor is when running the command from in iex or from a genserver that was watching files.
My question is: Is this assumption correct and what can I do about it?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 5 of 5 Posts
andyleclair
Yes, I think since NimblePublisher is storing the posts as a module attr, you’d need to recompile. I just ran into this issue myself! I was trying to code up a filesystem watcher just as I’m assuming you are.
I solved this for now by using
System.cmd("mix", ["site.build"])instead ofMix.Task.run("site.build").jswanner
What if you used rerun/2 instead?
mudasobwa
The issue is reenabling tasks was kinda flawed and had been fixed days ago. The following would do:
On trunk we now have
Mix.Task.Compiler.reenable(compilers: compilers)which would do, too.andyleclair
rerun/2also didn’t work for me. it would work to run the mix tasks, but because of the recompile, it wouldn’t work. . @mudasobwa do you know when that’s going to hit a point release?mudasobwa
v1.19here is a PR https://github.com/elixir-lang/elixir/pull/13771#issuecomment-2564704542 merged.