I’m running into an issue calling nbb from another JS program.
I use eleventy and eleventy lets you specify your own templating engine. My goal is to have the hiccup in the .cljs files be processed by nbb. You can see my https://github.com/athomasoriginal/eleventy-test-cljs. The idea is, whenever a local .cljs file changes, we:
• https://github.com/athomasoriginal/eleventy-test-cljs/blob/main/.eleventy.js#L21
• nbb runs https://github.com/athomasoriginal/eleventy-test-cljs/blob/main/run_clj.cljs and run_clj.cljs loads the sample template file (https://github.com/athomasoriginal/eleventy-test-cljs/blob/main/src/test.cljs) which depends on .https://github.com/athomasoriginal/eleventy-test-cljs/blob/main/src/extra/components.cljs
when I run eleventy, I can modify test.cljs and it live updates. However, if I modify a components.cljs , the nbb script re-runs, but doesn’t seem to fetch the latest in components.cljs
Is there something in the way resolving local ns’s works that might cause this? think_beret
Sorry I didn’t respond, I missed it. I’ll look into it later today
yes, namespace are loaded asynchronously
you could also use require + :reload possibly
> you could also use require + :reload possibly
Is this a REPL approach? When I try (require '[src.extra.components :as comp] :reload) in the test.cljs file I get
:reload is not ISeqableI’m guessing the issue is that src.extra.components is being cached (possibly by sci?) and as a result, even when changes are made to src.extra.components and run_clj is re-run the changes made to src.extra.components never get picked up?
> :reload is not ISeqable Ah drat, then nbb doesn't support it yet
require is always "cached", if the namespace is already loaded, it isn't reloaded, unless you use :reload but I think nbb might not support it yet
could fix that though
issue welcome
Ahhh, this is why running load-string or load-file on the ns directly seems to work because it reloads the ns manually, yes?
yes
load-file is never cached
https://github.com/babashka/nbb/issues/343 I’m happy to add any additional details we might require! 🙇
alright, I'll have a look soon
The reason I think the issue may be with nbb is because if I slurp the components.cljs I get the latest code. e.g.
(comment
(p/let [components-res (nbb/slurp "./src/extra/components.cljs")]
(-> (nbb/load-string components-res)
(.then (fn [result]
(js/console.log "SLURP TEST 1: " (rds/render-to-static-markup [(last-form result)]))
(js/console.log "SLURP TEST 2: " (rds/rende-to-static-markup [(last-form result)])))))))
The above will pickup the latest code changes when eleventy re-runs the nbb script.I got it to work, when I https://github.com/athomasoriginal/eleventy-test-cljs/blob/main/run_clj.cljs#L15C24-L15C24`p/let`https://github.com/athomasoriginal/eleventy-test-cljs/blob/main/run_clj.cljs#L15C24-L15C24. This was only meant to be a way to debug, but seems to resolve the issue.
Is it an async issue when requiring a local dep? 🤔