Fork me on GitHub
#shadow-cljs
<
2020-08-21
>
Aron11:08:56

what is a proper handling of multiple watch processes? I keep having to cancel and relaunch them because I get confused by what is being shown.

Aron11:08:46

I am unable to find the blogpost or doc segment or github issue where you described how to use it. Please remind me where it is

thheller11:08:43

shadow-cljs server and then its printed on startup shadow-cljs - server version: 2.8.110 running at

Aron11:08:08

so far I was with you, I did open it, but I don't know where from here 🙂

thheller11:08:19

you click builds and "start watch" for whatever builds you want running

thheller11:08:47

I assuming here that you are on a somewhat recent version where the UI actually works

thheller11:08:54

when you click the name of a build it'll take you to the build output of that build and won't distract you with output of the others

Aron11:08:08

The second thing I am trying to watch is tests with puppeteer that I build with :target :node-test

Aron11:08:17

And I am trying to use it in headful mode

Aron11:08:15

Launching it from the UI I don't know where the output it or why the puppeteer windows don't appear

thheller11:08:49

well for one you should never use :autorun true

thheller11:08:08

run it manually ... then you never have to guess where your output is

Aron11:08:17

well, why is there then? 🙂

thheller11:08:21

as for puppeteer ... no clue. never used it.

thheller11:08:40

because people asked for it and I foolishly said yes

Aron11:08:23

ok, but some convenient way to automatically start the browser again when I close it would be really nice since otherwise I will have to repeat this hundreds of times every day

thheller11:08:27

I don't know what you mean

Aron11:08:22

these are automated tests. The browser loads up and does a bunch of things like a manual tester would, then stays open so I can work with it. But when I need to test if my work is good, I close the browser and autorun relaunches it immediatelly. But with your suggestion, I would have to have a separate terminal where I would have it in bash history and every time I close the browser I would hunt this terminal down and press up arrow and enter 🙂

Aron11:08:11

If there is a better flow to write these tests, I am very open to learning it. This is how I am used to do it, but not something I like.

thheller11:08:57

I don't really see how the question is related to shadow-cljs. I do not use puppeteer and have no clue how to use it. if your concern is not using :autorun true you can easily use other tools to achieve the same without being coupled to shadow-cljs. eg. https://github.com/kimmobrunfeldt/chokidar-cli just have that watch the :output-to file of the build and do stuff when it changes?

thheller12:08:30

I want to build a proper "test runner" at some point but its a whole lot of work and not very high priority for me.

Aron12:08:40

It might be unrelated if it doesn't support it already, you are absolutely correct. I will try to look for other solutions

Aron12:08:07

Another reason I used npm scripts to start the watch process was that I could use the same build both for testing and development, with --config-merge. Now it seems I have to create separated builds or use environment variables. Neither option is better than config-merge.

thheller12:08:04

I feel like you are kinda expecting miracles here. I can only make suggestions. Given how little information I have about what you are actually doing they may fit or not. It is up to you to decide what you want to do and how you want to do it.

Aron13:08:12

Sorry if that's how it comes through. I am actually glad I have a place to ask questions and I get some answers. No expectations whatsoever. My understanding was that you are against using environment variables and suggest instead config-merge with goog-define. This option seems not to be available if I follow your most recent suggestion. I do not expect you to have an answer (I don't know how to convey this without explicitly stating it...), but if you do have some suggestion on how to use the UI + use a single :target :node-test build compile watched + then launch the tests with different modes, one for command line testing through npm test, another for development, maybe with chokidar or similar ... but without using environment variables, then I would like to know. Normally I wouldn't ask such detailed questions, I am used to using lots of environment variables in node and even in the browser, I am not even sure what's the reasoning against them.

thheller13:08:06

First you should maybe explain what you are using environment variables for

thheller13:08:31

since environment variables in node builds can just be actual environment variables. I don't see why they need to become part of the build config?

thheller13:08:01

like if you want to access them at runtime just use js/process.env.WHATEVER_ENV_YOU_WANT

thheller13:08:53

I also don't understand how you are using --config-merge to use one build for testing and development.

Aron13:08:25

"shadow-cljs watch test --config-merge \"{:closure-defines {tests.core/TEST_MODE \"tdd\" tests.core/SITE_URL \\\"$LOCAL_NAMESERVER\\\"}}\" "

Aron13:08:44

I didn't think about just using process from node. I was too hung up on finding out what already is there.

thheller13:08:49

if you are running node definitely just use js/process.env. :closure-defines is definitely worse than doing that and pretty much only used by people in browser builds since that can't otherwise access your environment variables

Aron13:08:50

thanks, I will do that

dehli14:08:07

Hello! I have a question about shadow’s watch command. Is it possible to have the artifact built not have a dependency on ws?

dehli14:08:11

I’d like to have watch running and then be able to quickly upload the artifact to AWS as I make code changes without having to do a full build every time

Wilson Velez14:08:26

hi, I’m starting to play with nubank/workspaces and I set a build called cards as explained here: https://github.com/nubank/workspaces#with-shadow-cljs

{:source-paths ["src"]
 :nrepl        {:port 3333}
 :dependencies [[binaryage/devtools "1.0.2"]
                [reagent "1.0.0-alpha2" :exclusions [cljsjs/react cljsjs/react-dom]]
                [nubank/workspaces "1.0.15"]]
 :dev-http     {8080 ["target/" "assets/"]}
 :builds       {:app   {:output-dir "target/"
                        :asset-path "."
                        :target     :browser
                        :modules    {:main {:init-fn app.main/main!}}}
                :cards {:target     nubank.workspaces.shadow-cljs.target
                        :ns-regexp  "-(test|cards)$"
                        :output-dir "target/workspaces"
                        :asset-path "workspaces"
                        :preloads   []}}}     

Wilson Velez14:08:23

but when I “watch” the build I’m getting this error http://localhost:9630/build/cards X Compilation failed.

TBD, classpath indexing is gone.
{}
ExceptionInfo: TBD, classpath indexing is gone.
	shadow.build.classpath/get-all-resources (classpath.clj:1225)
	shadow.build.classpath/get-all-resources (classpath.clj:1223)
	nubank.workspaces.shadow-cljs.target/find-namespaces-by-regexp (target.clj:10)
	nubank.workspaces.shadow-cljs.target/find-namespaces-by-regexp (target.clj:9)
	nubank.workspaces.shadow-cljs.target/resolve-cards-and-tests (target.clj:36)
	nubank.workspaces.shadow-cljs.target/resolve-cards-and-tests (target.clj:30)
	nubank.workspaces.shadow-cljs.target/process (target.clj:61)
	nubank.workspaces.shadow-cljs.target/process (target.clj:53)
	clojure.lang.Var.invoke (Var.java:384)
	shadow.build/process-stage/fn--13688 (build.clj:162)
	shadow.build/process-stage (build.clj:159)
	shadow.build/process-stage (build.clj:151)
	shadow.build/resolve (build.clj:407)
	shadow.build/resolve (build.clj:403)
	shadow.build/compile (build.clj:441)
	shadow.build/compile (build.clj:434)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:364)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:345)
	shadow.cljs.devtools.server.worker.impl/fn--15030 (impl.clj:440)
	shadow.cljs.devtools.server.worker.impl/fn--15030 (impl.clj:429)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--14807/fn--14808/fn--14816 (util.clj:285)
	shadow.cljs.devtools.server.util/server-thread/fn--14807/fn--14808 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--14807 (util.clj:257)
	java.lang.Thread.run (Thread.java:745)

thheller14:08:26

@wvelezva see https://github.com/nubank/workspaces/issues/42. I thought that was fixed. maybe need a different version?

thheller14:08:09

hmm no still open. so I guess not fixed.

mkarp14:08:26

Just tried using :karma target for the first time — it works like a charm 👍 Thank you for it!

đź‘Ť 3
đź‘€ 3
Wilson Velez14:08:01

I’m working with the lastest verstions of shadow and workspaces

Wilson Velez14:08:12

should I ask in workspaces channel?

thheller14:08:54

you can just use the :target :browser-test. don't need to use the workspaces target

thheller14:08:22

{:target     :browser-test
 :ns-regexp  "-(test|cards)$"
 :output-dir "target/workspaces"
 :asset-path "workspaces"
 :runner-ns  nubank.workspaces.shadow-cljs.mount
 :devtools
 {:before-load nubank.workspaces.core/before-load
  :after-load  nubank.workspaces.core/after-load}}

thheller14:08:38

might be enough? don't think the custom target does anything else

Wilson Velez14:08:11

ok, thanks @thheller I will give it a try