I want to get a library working with both Scittle and shadow-cljs. Is there something like this but for Scittle?
#?(:org.babashka/nbb
[nbb.core :refer [load-file]])I want to find out more about how Scittle resolves requires. I'm interested in experimenting with this and finding out more about the current capabilities. Is this currently a sci level thing or specific to Scittle? What's the best way to learn about it?
scittle doesn't resolve anything but built-in namespaces at the moment
What's the best place to look in the code for where this happens?
what problem are you trying to solve?
This is how you implement require with SCI: https://github.com/babashka/sci?tab=readme-ov-file#implementing-require-and-load-file but this isn't used in scittle, as built-in namespace are just handled by SCI itself
Ultimatley I'd like to import existing .cljs libraries I've written without recompiling Scittle and in a way that's compatible with existing shadow-cljs code.
you can do this by adding the .cljs files to a script tag in the right order
Yes and I suppose that's not that big of a step. 🤔 Ok let me try more just doing this.
once a .cljs file is loaded you can use :require to refer to its namespace
Ah yep the problem is the thing I am requiring then in turn depends on js requires. To satisfy that I need a think like "importmap" that will tell Scittle "here's how you resovle this js dep).
ok, that makes sense, so the problem lies with JS libs
I'd like to be able to tell Scittle that ["whatever" :as whatever] corresponds to window.whatever that came in from a script tag.
Even if there was a default to look for "whatever" on the global object. (I realize this could be a lot harder than it looks.)
it makes sense
I think you could use :load-fn for this
but this needs a change in scittle
and I think we would want some configuration for this as well as global names don't always correspond to the library names on npm
feel free to post an issue about this
Alright, will do, thanks! I'll also investigate *load-fn* as I had no idea this existed.
:load-fn is a SCI option, not exposed to users
no earmuffs
Cool, got it.
I saw that but how do I use it? Just #?(:scittle ...) ?
Will test.
yes, just use scittle