nbb

athomasoriginal 2023-11-21T01:54:35.874579Z

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

borkdude 2023-11-22T08:04:54.512879Z

Sorry I didn’t respond, I missed it. I’ll look into it later today

borkdude 2023-11-22T10:27:11.619099Z

yes, namespace are loaded asynchronously

borkdude 2023-11-22T10:27:42.304099Z

you could also use require + :reload possibly

athomasoriginal 2023-11-22T21:18:39.789139Z

> 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 ISeqable

athomasoriginal 2023-11-22T21:20:57.051009Z

I’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?

borkdude 2023-11-22T21:21:12.689099Z

> :reload is not ISeqable Ah drat, then nbb doesn't support it yet

borkdude 2023-11-22T21:21:45.491879Z

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

borkdude 2023-11-22T21:22:05.401019Z

could fix that though

borkdude 2023-11-22T21:22:08.594939Z

issue welcome

👍 1
athomasoriginal 2023-11-22T21:24:55.528749Z

Ahhh, this is why running load-string or load-file on the ns directly seems to work because it reloads the ns manually, yes?

borkdude 2023-11-22T21:25:31.917549Z

yes

borkdude 2023-11-22T21:25:40.205759Z

load-file is never cached

athomasoriginal 2023-11-22T22:01:51.232719Z

https://github.com/babashka/nbb/issues/343 I’m happy to add any additional details we might require! 🙇

borkdude 2023-11-22T22:02:47.458129Z

alright, I'll have a look soon

👍 1
athomasoriginal 2023-11-21T01:57:50.701909Z

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.

athomasoriginal 2023-11-21T02:12:53.706049Z

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.

athomasoriginal 2023-11-21T02:13:29.858129Z

Is it an async issue when requiring a local dep? 🤔