Given a :browser build. How can I use a module from a remote server?
Can I have the following in my HTML:
How can I use or require automergerepo in my ClojureScript code?> (:require ["https://...."]) didn't work, because the remote code is not Google Closure compatible.
that is completely irrelevant? google closure never sees it? it just emits a literal import * as automerge from "https://..."?
no clue if node has something similar to importmaps, but node can just load the thing probably. and for node targets by default shadow-cljs does not bundle dependencies, so again closure would not ever see automerge. so as long as node can load the thing you likely do not need to do anything
if you are using :target :esm with node you should set :js-options {:js-provider :import} https://shadow-cljs.github.io/docs/UsersGuide.html#_third_party_tool_integration, otherwise :esm will try to bundle
you have several options, best bet is probably using :target :esm instead
https://clojureverse.org/t/generating-es-modules-browser-deno/6116
there you can just do
(ns my.app
(:require ["" :as automerge]))
without the import mapor you keep the import map and (:require ["automergerepo" :as automerge]) but then in the build config set :js-options {:keep-as-import #{"automergerepo"}}. that'll tell shadow-cljs to not bundle that require and instead let it load at runtime
Thank you!
I switched to :target :esm.
(:require ["https://...."]) didn't work, because the remote code is not Google Closure compatible.
So I went with the import map and it works fine in the browser.
Now I want to run the same code in node. But how do I specify the import map? So that my (:require ["automergerepo" :as automerge])` is resolved to the remote URL and loaded?
Hey guys, is there a way to reload a hook definition in shadow-clj? Currently, I just restart the REPL to make it possible, which is tedious. (I define hooks in a separate build.clj file)
why would that need to be a hook? what does it use from the build-state map the hooks receive? if nothing it doesn't need to be a hook
also with manifest v3 I saw no need to generate the file at all anymore?
https://github.com/thheller/chrome-ext-v3/blob/main/ext/manifest.json
The reason why I used a hook is that I need to use different configs between dev and prod, and using Clojure forms is more compact in general.
my general answer is: you probably shouldn't be using hooks in the first place 😛
other than that it is just clojure code. So I'd work on it at the CLJ REPL.
(require 'build :reload) will reload it at the REPL, or the usual load-file. the usual REPL stuff
you can trigger a rebuild from the REPL as well, which will immediately use the latest code
Thanks, I’ll try these. My use case of the hook is to generate a chrome extension’s manifest.json from a Clojure map, is it possible not using a hook?
I use cider to start the repl, and I didn't yet figured out how to bring out the CLJ REPL. But I've workaround-ed the issue by calling load-file in the look following your pointer, thanks!