This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-08
Channels
- # 100-days-of-code (1)
- # announcements (7)
- # beginners (63)
- # cljs-dev (39)
- # clojure (78)
- # clojure-dev (40)
- # clojure-italy (4)
- # clojure-nl (22)
- # clojure-russia (5)
- # clojure-spec (5)
- # clojurescript (60)
- # cursive (8)
- # datomic (6)
- # emacs (1)
- # figwheel-main (53)
- # fulcro (19)
- # jobs-discuss (11)
- # mount (1)
- # off-topic (3)
- # om (1)
- # pedestal (9)
- # philosophy (1)
- # re-frame (19)
- # reagent (4)
- # reitit (5)
- # shadow-cljs (66)
- # tools-deps (64)
hey everyone! I’m starting out with cljs (done a fair amount of clojure though), and hitting a wall when trying to load a foreign lib
No such namespace: hdom, could not locate hdom.cljs, hdom.cljc, or JavaScript source providing "hdom" in file src/hello_hdom/core.cljs
1 (ns ^:figwheel-hooks hello-hdom.core
^---
2 (:require
3 [goog.dom :as gdom]
4 [hdom :as hdom]))
5
6 (println hdom)
@dazld did you include hdom
in your :npm-deps
? Usually it is in dev.cljs.edn
. Note also that this is not the recommended way of importing js anymore as cljs core suggests to use webpack
I would also recommend checking http://shadow-cljs.org/ as a layer on top of the compiler (like figwheel-main
, but more npm
friendly)
Well interesting but used to be better to have one tool only IMHO. Now non-JS users need to learn webpack - my 2c
@dazld check this demo repository for rationale and howto aspects of using webpack with cljs: https://github.com/pesterhazy/cljs-spa-example
(hi Dan btw!)
@pesterhazy just got that project working with the latest CIDER: very nice 👌, thanks!
@eval2020 cool! did you have to change the configuration in any way?
one tricky thing: after selecting the ClojureScript REPL type it asks Select figwheel-main build (e.g. :dev):
. You should not accept the default (`:dev`), but answer dev
@eval2020 after a week trying to hack emacs/cider/figwheel-main trying new fresh systems.... and suddenly this cracks the sky!!!
did you have to add anything to deps.edn?
cool, maybe I should add that to the README
just did a fresh clone to reproduce:
- run ./script/dev
- kill this process after bundle got build
- M-x cider-jack-in-cljs
- select figwheel-main
- Select figwheel-main build
, type dev
- visit http://localhost:9333
- cljs prompt appears
if script/dev could start an nrepl-server, just a cider-connect would suffice - not sure if that’s possible
yeah I think cider preforms some magic to add in the necessary nrepl middleware
*Messages*
shows it starts
/usr/local/bin/clojure -Sdeps '{:deps {org.clojure/tools.nrepl {:mvn/version "0.2.13"} cider/piggieback {:mvn/version "0.3.9"} cider/cider-nrepl {:mvn/version "0.18.0"}}}' \
-e '(require (quote cider-nrepl.main)) (cider-nrepl.main/init ["cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"])'
clever
so it runs -e
to bootstrap nrepl, cider and piggieback
and then you can still add -m
figwheel.main at the end of the command line?
or does Cider initialize figwheel manually?
@pesterhazy it does not add -m (even though that would work) but you have to start figwheel in the resulting clj repl yourself. can be automated by defining your own type of cljs repl
or you can customize the cider's jack options to add the -m. but I guess that would give you nothing valuable as fig would run headless and you still need to start cljs-repl in the clj repl
thanks for the explanation
that's pretty clean, but not sure if other repl clients can do the same
Is it possible to set a custom initial namespace with figwheel-main? I.e. rather than cljs.user
re CIDER interop. After some experiments I ended up with simple set-up to start fig manually and then cider-connect: deps.edn:
{:paths ["src/cljs" "target"]
:deps {org.clojure/clojure {:mvn/version "1.9.0"}
org.clojure/clojurescript {:mvn/version "1.10.339"}}
:aliases {:fig {:extra-deps {cider/cider-nrepl {:mvn/version "0.18.0"}
cider/piggieback {:mvn/version "0.3.9"}
com.bhauman/figwheel-main {:mvn/version "0.1.9"}
com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}}}
:bs {:extra-paths ["."]
:main-opts ["-m bootstrap"]}}}
bootstrap.clj
(ns bootstrap
(:require [figwheel.main.api]
[cider-nrepl.main :as cider]))
(defn -main [& args]
(cider/init ["cider.nrepl/cider-middleware"])
(println "*********************")
(figwheel.main.api/start "dev"))
then just run in term
>clj -A:fig:bs
and then cider-connect. Once in clojure repl do (figwheel.main.api/cljs-repl "dev")
andvantage of this approach is you can run it on vanilla CIDER and won't need to customize it.if you prefer to customize cider this is one example I found which might help https://github.com/arichiardi/figwheel-main-cider/blob/master/.dir-locals.el
I should actually fix the keyword issue, it should work with both. I might have introduced a regression in cider
@richiardiandrea currently on mobile but it might just work. What I assumed is that by just pressing enter, :dev
would be used as default. But it’s given as an example.
Figwheel rocks!
Is it possible to remotely connect to the Figwheel REPL (either nrepl or socket repl)
I’d like to connect Cursive to the Figwheel REPL