This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-13
Channels
- # announcements (1)
- # babashka (12)
- # beginners (10)
- # biff (9)
- # calva (2)
- # cherry (21)
- # cider (14)
- # clj-commons (76)
- # clj-kondo (8)
- # clj-on-windows (34)
- # cljs-dev (5)
- # clojure (48)
- # clojure-austin (7)
- # clojure-europe (97)
- # clojure-nl (1)
- # clojure-norway (14)
- # clojure-uk (22)
- # clojurescript (137)
- # conjure (33)
- # cursive (4)
- # datalevin (1)
- # deps-new (4)
- # devcards (2)
- # duct (3)
- # events (1)
- # fulcro (12)
- # graphql (9)
- # hyperfiddle (16)
- # jobs (8)
- # kaocha (1)
- # leiningen (6)
- # lsp (39)
- # malli (38)
- # membrane (20)
- # nbb (68)
- # observability (7)
- # off-topic (49)
- # pathom (11)
- # polylith (8)
- # portal (22)
- # re-frame (6)
- # releases (1)
- # remote-jobs (2)
- # shadow-cljs (24)
- # spacemacs (2)
- # squint (6)
- # xtdb (7)
Hmm. I've just (painfully) migrated my app to figwheel-main and I'm trying to figure out if I can start using a ClojureScript REPL after all these years with CIDER. But the standard connect- functions complain about being unable to find build-id.cljs.edn
files, which is correct, because I don't have any. My figwheel-main is started manually from Clojure code. I start the Clojure REPL using leiningen (launched from a Makefile), then connect using cider-connect, then run init code which does a bunch of things and starts figwheel at the end. Any suggestions/directions as to where to look next to connect?
As long as you're running it from the same process which has started the build, it should find it in the registry
(figwheel.main.api/start build)
would certainly look for it, but
(figwheel.main.api/cljs-repl build)
connects to an existing build, so that might circumvent the problem.Another solution would of course be to add the .cljs.edn-file, but I guess you have your reasons to stray from the defaults.
It should, yes. You can also configure CIDER with a custom REPL type for your project so that you can just run cider-connect-cljs
and it will initialize the CLJS REPL for you
I would probably go with the approach of setting up the build EDN files and launching Figwheel as a separate process from your main Clojure app. It seems like a nice idea to have everything in the same process but you have to add a lot of CIDER-specific configuration to get it to "just work"
It's a complex app and there are a number of init steps that need to happen (things like database connection, mount initialization, migrations, etc), and I'd much rather start figwheel from inside the init function. I am using figwheel.main.api/start
to start the build and configuration is supplied to that function. If I have to, I can move this configuration to a file, but… well, it seems rather strange to rely so heavily on things being stored in a single file with a "magic" name.
It seems like CIDER doesn't have a specific REPL type for connecting to a running figwheel-main build. It expects to call figwheel.main/start
and uses the build files to find the build name to pass to that function. Since you're calling start
already, to get a CLJS REPL you need to call figwheel.main.api/cljs-repl
inside of a Clojure REPL to "upgrade" it. Then you can run cider-set-repl-type
to mark it as a CLJS REPL (so that eval works correctly in CLJS buffers). To simplify things, you can configure something like the following in .dir-locals.el
:
((nil
(cider-custom-cljs-repl-init-form . "(do (require 'figwheel.main.api) ((resolve figwheel.main.api/cljs-repl) "build-id"))"
(cider-default-cljs-repl . custom)))
https://docs.cider.mx/cider/cljs/configuration.html#defining-custom-clojurescript-repl-types
That lets you start your regular Clojure REPL, and then run cider-connect-cljs
to launch the CLJS REPL.
The benefit of magic file names is that it's a convention that makes it work more easily with tooling without manual configuration 😄