Fork me on GitHub
#portal
<
2022-03-03
>
Carlo14:03:49

Any tips on how to hack on portal? What's your dev set-up like?

djblue16:03:18

To get started, there is a https://github.com/djblue/portal#development. After https://github.com/djblue/portal#dependencies are installed, it should be as easy as bb dev . For the most part, Portal is a web app so any experience with that should be useful. I used emacs + lsp + inf-clojure but, you should be able to hack on portal any setup.

🙌 1
Carlo17:03:51

So, I also use emacs+lsp, when I jack in I get:

error in process sentinel: Could not start nREPL server: WARNING: Specified aliases are undeclared and are not being used: [:dev-cljs]
WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
Execution error (FileNotFoundException) at nrepl.cmdline/require-and-resolve (cmdline.clj:201).
Could not locate shadow/cljs/devtools/server/nrepl__init.class, shadow/cljs/devtools/server/nrepl.clj or shadow/cljs/devtools/server/nrepl.cljc on classpath.

Full report at:
/tmp/clojure-5183434269168406784.edn

djblue19:03:42

I forgot the docs mention cider-jack-in facepalm. I was having issues with the .dir-locals so I stopped using it a while back. Now, I start the project with bb dev and connect to the repl from emacs. Sorry for the confusion.

🙌 1
Carlo10:03:38

No worries. So, let's say, after starting bb dev I open the src/portal/api.cljc file, then I do cider-connect-clj&cljs which finds automatically portal:37589, then I choose shadow as the cljs repl type, and then I'm presented with a choice of shadow-cljs builds: :client, :pwa, :vs-code, :node, browser-repl and node-repl. Questions: 1. How do they differ and which one should I use? 2. How is it possible that one repl can do both clj and cljs (I'm used to developing apps in cljs only but I'm confused by the two aspects)

Carlo10:03:40

For example, even after choosing I think :client, if I change the definition of portal/ui/state/select-parent I get that there's no cljs repl available

djblue16:03:26

The client is the main one you want for connecting to the UI. The problem you are probably running into is needing to open the dev version of the UI, which can be done like https://github.com/djblue/portal/blob/master/dev/user.clj#L58.

🙌 1
Carlo17:03:34

Yes, that was indeed the problem, thanks! For reference, what thought process should I have used to discover that myself?

djblue18:03:36

I think you can find a bunch of useful dev stuff in the user ns

Carlo19:03:56

I was looking into using dev/portal/setup.cljs . If I open that file, cider-connect-clj&cljs to the nrepl server opened by bb dev, I still get No available JS runtime. How should I invoke, eg, (def portal (p/open {:mode :dev :value state/state})). Why does this happen?

djblue20:03:31

You first need to do (portal.api/open {:mode :dev}) from the jvm which will open the Portal UI (a JS runtime) then your shadow repl should have an environment to evaluate cljs, and then you can run (def portal (portal.web/open {:mode :dev :value state/state})) and other expressions to poke around the client runtime=

🙌 1
Carlo02:03:09

Right, I tried that before, but I get :repl/exception, and then in my repl:

Execution error (TypeError) at (<cljs repl>:1).
Cannot set properties of null (setting 'onunload')

djblue02:03:04

So to use portal.web you need to enable popups

djblue02:03:59

Although I have a feeling that https://github.com/djblue/portal/commit/740ff1d317bbe8fc86deedf1a329e5652adaa090 might be of interest to you 🎉

Carlo07:03:29

Indeed 😂 🎉 🎉 🎉