@thheller hey, one question, is shadow exposes something on the analyzer (like :shadow.build/ns->mod ..) that can be used to resolve from module-name to the file path (like we have in the manifest.json)?
I think i found it myself: [:shadow.build.cljs-bridge/state :shadow.build.modules/config]
which path are you referring to?
the compiler output path. I'm migrating from :broser target to :esm, and on browser target we have used the modules loader, which one is only available under :browser target
I have build a lightweight approach (witthout module manager and module loader) that loks like
there is a new loader mechanism for esm thats generally "better" I think
basically you apply :lazy-loadable to a var metadata
(defn my-thing {:lazy-loadable true} [a b] ...)
then (shadow.esm/load-by-name 'foo.bar/my-thing) give you a promise that'll resolve to a function for that var
that should make all other needs to know the module name or path obsolete?
oh, interesting, i will look on it. In any case our approach works for us and is drop-in replacement for the previous approach without big code changes
maybe in other iteration i will look on using the load-by-name
load-by-name is just a function, so requires to special macro magic and can easily be integrated into other helper things
{:lazy-loadable "foo"} and (load-by-name "foo") also works
that i'm not cleary understand
what do you mean with {:lazy-loadable "foo"}, where it should be?
you can use your own name I mean. doesn't need to be a fully qualified symbol
on the var metadata
(defn my-thing {:lazy-loadable "foo"} [a b] ...)
ok ok, now is clear
i go to experiment with it, thanks
to be clear it yields a function, so
(js-await [var (shadow.esm/load-by-name "foo")]
(let [actual (var)]
(actual 1 2)))(its not actually a var, just a zero arity function to get the latest reference)
this is because of hot-reload or REPL which may redefine things, so every time the function is called you get the latest value
yep, i'm aware of it, in any case thanks for clarification
I'm playing a bit with it and looks very interesting, but i have some case that does not looks to be working. I have a custom macro for define react components as function, it mimics the defn and looks like this
on that macro, all this metadata is assigned to the symbol metadata but looks like shadow passes before that... or something that i'm not understand right now, still researching
nah, that was my fault, it works as expected, ignore previous chat