Fork me on GitHub

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.


you should also hot-reload the copy-ns call


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


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.


Probably not a SCI issue :)


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


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


to force that ns to reload


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


No, I mean from the normal CLJS REPL


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


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