This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-02
Channels
- # announcements (21)
- # babashka (1)
- # beginners (67)
- # calva (18)
- # cider (21)
- # clj-kondo (109)
- # cljs-dev (3)
- # clojure (129)
- # clojure-spec (15)
- # clojure-uk (30)
- # clojurescript (3)
- # datomic (2)
- # graalvm (8)
- # graphql (1)
- # juxt (1)
- # malli (28)
- # off-topic (46)
- # reitit (5)
- # rewrite-clj (33)
- # ring-swagger (2)
- # shadow-cljs (199)
- # vim (9)
I… assume that I shouldn’t be doing this:
:closure-defines
{"shadow.cljs.devtools.client.env.ssl" true}
This configuration works perfectly for me. I’m doing this because whilst I have an SSL section in my shadow-cljs.edn
(my dev-http
at https://<hostname>:3000
works), my REPL/devtools connection was using ws://<hostname>:9630
rather than wss://<hostname>:9630
. I’m reverse port forwarding onto the real host. Any chance that someone could point out the error in my config? I tried reading a bunch of places in the shadow-cljs source, but wasn’t sure how to pull off this behaviour in particular.
https://gist.github.com/tekacs/95e2e78f806bc72c9695504426c930a4
Intended behaviour:
- Bind to localhost:3000
over SSL for my dev-http
- Bind to localhost:9630
over SSL for my main server
- Visit https://<hostname>:443
for my dev-http server (due to ssh -R '*:443:localhost:3000
<hostname>`
- Have the client use wss://<hostname>:9630
for devtools connections (due to another -R
to that SSH)has anyone been successful in loading a custom font through AppLoading Font.loadAsync in expo?
@tekacs there is :devtools {:devtools-url "
, see https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support
the dev-http server is completely separate and isn't involved in the websockets setup
is it possible to connect a repl to a :node-test
target?
the repl needs a running process, but when I try to connect node to the output (e.g. node out/test.js
) it will run the tests and exit immediately, leaving no running process for the repl to use
my usecase is that I would like to develop tests with editor support (vscode+calva), and the tooling needs to connect a repl
which effectively turns it into just a node-repl
, but you had to run the process manually
ok, I suppose that I can use the repl directly
but that doesn't make for a very smooth development flow, at least with my current knowledge
in Calva, I would like to jack in to a certain build, and connect to that builds repl
so I guess I want a node-script target with a main that does (cljs.test/run-tests 'your.test-ns)
if I jack into the node-repl, I have to still do (require 'your.test-ns)
(cljs.test/run-tests 'your.test-ns)
right?
I don't want to do anything specific at the repl myself, but to have tooling support in the editor I need to connect a running repl
otherwise I don't get code completions, or repl execution, etc
the total steps seem the same
the repl way:
- jack in
- select the a build? (not sure if this is always needed in calva)
- select node-repl
- input (require 'your.test-ns)
(cljs.test/run-tests 'your.test-ns)
- have tooling support in vscode
the node-script way:
- jack in
- select node-script target
- select node-script target repl
- run node the-output.js
and leave running
- have tooling support in vscode
yes, you are right
I have to do that in a console somewhere and leave it running
added now
there is one less console command, but one more command in a repl
the calva extension has some helpers for that
I don't know if they'll work though, because I was still setting it up and got hung on the repl bit
the calva stuff may actually be dependent on some nrepl middleware so it might not work with CLJS
you can also just jack into node-repl
and run the tests separately (if you just want completion and stuff)
it might be the clojure way but it's also one of those things that isn't obvious and that requires you to figure out how to plug everything together in a unfamiliar way
maybe cursive is better, but if I have to leave my day to day editor for another way, and configure that from scratch, before I can start being productive... well that's an extra overhead
I can do all that, and it might be better. But does it mean there's no point to trying to use Calva? There must be a point
:node-test
is only meant to be supplemental to an actual other build that does stuff
I'm just not convinced that building all tooling on top of the REPL is the best way to go
ok, let me try and describe the workflow I was going for
I have some tests that are meant to be ran on node
I would like to: - open vs code - jack in use calva - get tooling in the test namespaces (completions, eval code) - use the calva commands to run tests (sometimes all of them, sometimes only some of them)
that's a good question, let me try to figure it out
so, having this config:
{:builds
{:test-dev
{:main async-interop.interop-tests/main
:output-to "out/test-dev.js"
:target :node-script}
:test
{:ns-regexp "async-interop.*-tests$"
:output-to "out/test.js"
:target :node-test}}
:dependencies [[org.clojure/core.async "0.4.500"]]
:dev-http {3000 "public"}
:nrepl {:port 3333}
:source-paths ["src/main" "src/test"]}
and this namespace with tests
(ns async-interop.interop-tests
(:require
[async-interop.interop :refer [p->c]]
[async-interop.interop :refer-macros [<p!]]
[cljs.test :refer-macros [deftest is]]))
(deftest interop
(is true))
(defn main [])
I jack in, select test-dev
to build, select the test-dev
repl connectionI run the Calva: run all tests
command
I get this error in the calva pane
maybe thats related to the middleware you just mentioned
if I try to use the node-repl as you mentioned, I can run the tests and get results
kamik@RED-X1C6 MINGW64 /d/sandbox/async-interop (master)
$ yarn shadow-cljs node-repl
yarn run v1.17.3
$ D:\sandbox\async-interop\node_modules\.bin\shadow-cljs node-repl
shadow-cljs - config: D:\sandbox\async-interop\shadow-cljs.edn cli version: 2.8.69 node: v10.16.0
shadow-cljs - connected to server
cljs.user=> (require 'async-interop.interop-tests)
nil
cljs.user=> (cljs.test/run-tests 'async-interop.interop-tests)
Testing async-interop.interop-tests
Ran 1 tests containing 1 assertions.
0 failures, 0 errors.
nil
cljs.user=>
but if instead of the node-repl I connect to a cljs-repl for the target, I do not see test results
kamik@RED-X1C6 MINGW64 /d/sandbox/async-interop (master)
$ yarn shadow-cljs cljs-repl test-dev
yarn run v1.17.3
$ D:\sandbox\async-interop\node_modules\.bin\shadow-cljs cljs-repl test-dev
shadow-cljs - config: D:\sandbox\async-interop\shadow-cljs.edn cli version: 2.8.69 node: v10.16.0
shadow-cljs - connected to server
async-interop.interop-tests=> (require 'async-interop.interop-tests)
nil
async-interop.interop-tests=> (cljs.test/run-tests 'async-interop.interop-tests)
nil
async-interop.interop-tests=>
yes that is what is happening
kamik@RED-X1C6 MINGW64 /d/sandbox/async-interop (master)
$ node out/test-dev.js
Testing async-interop.interop-tests
Ran 1 tests containing 1 assertions.
0 failures, 0 errors.
Testing async-interop.interop-tests
Ran 1 tests containing 1 assertions.
0 failures, 0 errors.
Testing async-interop.interop-tests
Ran 1 tests containing 1 assertions.
0 failures, 0 errors.
I suppose that's the whole story
> This is due to that cider-nrepl doesn't yet support running cljs tests. Something that might not be fixed all that soon. clojure-emacs/cider-nrepl#555
https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/test.clj
I'll add this context to the calva issue, and use the node-repl to run tests manually
is there a way to run a single test via the node-repl?
I'm not a fan of cljs.test
. I think it is implemented in a needlessly complex way which makes it really annoying to use
hm.... I didn't know, that, but it opens up another approach
lots of the problems with tooling is that most of it pretends that clojurescript is like clojure
I was trying this approach instead: - open vs code - jack in using calva to a node-test target, then use node-repl - got tooling in the test namespaces (completions, eval code) - then tried to run the individual test functions in the calva repl window
that got me another odd Calva error
$ yarn list shadow-cljs
yarn list v1.17.3
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ [email protected]
Done in 0.18s.
I am using a shadow-cljs.edn
{:builds
{:test-dev
{:main async-interop.interop-tests/main
:output-to "out/test-dev.js"
:target :node-script}
:test
{:ns-regexp "async-interop.*-tests$"
:output-to "out/test.js"
:target :node-test}}
:dependencies [[org.clojure/core.async "0.4.500"]]
:dev-http {3000 "public"}
:nrepl {:port 3333}
:source-paths ["src/main" "src/test"]}
when shadow-cljs starts it lists these versions
shadow-cljs - config: d:\sandbox\async-interop\shadow-cljs.edn cli version: 2.8.69 node: v10.16.0
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.8.69 running at
shadow-cljs - nREPL server started on port 3333
shadow-cljs - watching build :test-dev
yes I think that's what happens in my editor, because I have Calva configured to automatically load the namespace on save
so I guess it loads the NS at the repl, then shadowcljs detects the file changed and loads from the file?
subscribed to it, thank you for all of your help on this
> - jack in using calva to a node-test target, then use node-repl @filipematossilva: curious, how did you “use node-repl”?
I used jack in, selected a target, then selected node-repl
from this window
Cool. That's what you're supposed to do. 😎 You can then switch between the build you started at jack-in and node-repl at will. (In case that is not made clear enough by Calva)
I didn't know I could, I often just reloaded the vscode window... but I did notice I could do something of the sort on the buttons in the status bar, just never tried much
The command is Calva; Select CLJS Build Connection. Maybe not the best name for it… but, yeah, the status bar has a button for it as well.
I tested several approaches
and logged the results here
that repo can be used to test
on calva's side, the test commands don't work on cljs: https://github.com/BetterThanTomorrow/calva/issues/311
on shadow cljs's side two bad interactions happen with calvas repl window - the test output isn't shown for node repls (https://github.com/thheller/shadow-cljs/issues/373) - running a test build without autoron and with node-repl fails to load the namespace https://github.com/thheller/shadow-cljs/issues/587
From the calva-testing repo: > running tests by name in Calva repl shows nil return, must check separate calva output pane Not sure what the nil results are about, but you can use the Calva setting for async output routing to get Calva to show that output in the REPL window instead of the Output pane. (So at least one inconvenience less.)
but maybe that's not the whole story
atm the best shot seems to be running tests on a autorun node-test build to get around https://github.com/thheller/shadow-cljs/issues/587
I use auto-run
but stay connected to my app-build. So I start both my app build and my test build at jack-in and then connect to the app build. auto-run keeps watching the files and reruns the tests when the files change.
yeah for browser apps I do something similar
@thheller can you confirm that its never valid to use shadow.cljs.devtools.api/nrepl-select
on browser-repl
or node-repl
? This is meant only for a named build?
so maybe there should be a separate op for starting a browser-repl/node-repl but not switching to it
it seems that CIDER always starts a server so there's no good way for it to do this kind of stuff
yeah. there's two repl types for shadow in CIDER. the normal one and then one called shadow-select which doesn't start a watch. I'm trying to figure out how the select version works and what needs to be running for that to make sense.
This kind of CLJS REPL is very helpful for cases when you are already watching
one or more shadow builds in shadow either after having launched the server in
a terminal or from within Cider.
This patch also refactors option normalization out of figwheel-main so that it
can be reused by every other function.
select only switches the nrepl session to CLJS. it doesn't do anything regarding shadow-cljs itself. it is strictly for nrepl purposes.
/usr/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.2 -d cider/cider-nrepl:0.23.0-SNAPSHOT server
and then running (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch <build>) (shadow/nrepl-select <build>))
so in this case, if you choose browser-repl
, it doesn't watch and select, just shadow/browser-repl
let me back up and show the problem that I'm trying to solve. If you choose :browser-repl
the above startup command doesn't work. So I understood that you had to not do watch and nrepl-select for the built in repls but just call shadow.cljs.devtools.api/special-repl
instead
npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.2 -d cider/cider-nrepl:0.23.0-SNAPSHOT clj-repl
(shadow.cljs.devtools.api/watch :browser-repl)
Execution error (ExceptionInfo) at shadow.cljs.devtools.config/get-build! (config.clj:153).
no bulid with id: :browser-repl
and this confirms that this behavior doesn't work for the built in repl types i think
right. so i need spacial behavior for when the user uses a special repl. But you can nrepl-select
the "special" builds?
(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :browser-repl) (shadow/nrepl-select :browser-repl))
hmm. (shadow.cljs.devtools.api/nrepl-select :browser-repl)
-> [:no-worker :browser-repl]