Fork me on GitHub
#sci
<
2022-04-27
>
pmooser08:04:11

I'm still making some slow progress on my integration with sci. I'm working with shadow-cljs, with hot code reloading. If I add a var (for example) to some cljs namespace, and shadow-cljs hot loads that, I'm struggling to figure out how to make it visible to sci. I think that when I'm calling copy-ns, the source ns that I'm copying from maybe doesn't have the new var, which I suppose probably isn't a sci issue but I'm a little baffled by all this.

borkdude09:04:12

you should also hot-reload the copy-ns call

pmooser09:04:25

Yeah, I have something that looks like this:

(defn ^:export ^:dev/after-load update-repl-namespaces
  []
  (when-let [repl-config (:repl @state)]
    (let [namespaces ((:namespace-fn repl-config))]
      (swap! repl/state update :sci-env sci/merge-opts namespaces))))
And that namespaces variable is something like:
{:namespaces {'client (copy-ns foo.client (sci/create-ns 'client))
              ...}}

pmooser09:04:21

But when I print out the namespaces there (triggered by the reload), it doesn't contain the new var, unless some other namespace makes a reference to it ... or something along those lines. I haven't untangled it yet. I don't know if there's some fundamental reason this can't work.

borkdude09:04:22

Probably not a SCI issue :)

pmooser09:04:36

Ok, thanks for confirmation. I'll see if I can get thheller to comment.

borkdude09:04:37

You can call (require '[my.sci.config-ns] :reload) from the REPL

borkdude09:04:57

to force that ns to reload

pmooser09:04:24

You mean like if I define a sci namespace user, from within the (sci-based) repl I should be able to re-require it?

borkdude09:04:45

No, I mean from the normal CLJS REPL

pmooser09:04:17

Ah yeah. Ok, thanks. I'll see if this is achievable or not ...

borkdude09:04:49

You can also insert from println in the namespace to see if it's properly hot-reloaded and then print the keys of the copied namespace