Fork me on GitHub
#shadow-cljs
<
2018-03-08
>
genRaiy11:03:11

@thheller regarding testing I was really wanting to check that I couldn’t ‘program’ that behaviour in some way from the available tools

thheller11:03:45

you can with the karma or browser-test stuff

genRaiy11:03:46

(original question … can I run tests on node,js after a file has changed?)

thheller11:03:52

but for node not yet

genRaiy11:03:33

ok, fair enough …. like I say I can wait if you have something in the works

thheller11:03:01

you can use anything that watches files really

genRaiy11:03:02

I might end up installing another set of tools but would rather avoid it if poss

genRaiy11:03:16

that’s true

thheller11:03:03

the chokidar thing works well enough and just just an yarn add chokidar-cli --dev away

genRaiy11:03:40

ok, thanks for the options

genRaiy11:03:58

can I link that into the shadow-cljs server

genRaiy11:03:13

or do I just kick off a build / node test?

genRaiy11:03:32

(with chokidar)

genRaiy11:03:43

(assuming the latter)

thheller11:03:52

you can run any clojure code via shadow-cljs clj-run some.ns/fn

thheller11:03:07

so you could write a clojure fn that starts the chokidar process

thheller11:03:36

or even just do it in pure clojure without chokidar

thheller11:03:30

@raymcdermott what do you usually use to do this? maybe I can steal some ideas.

genRaiy12:03:21

honestly I usually just use cursive and run the tests as I go along in the REPL

genRaiy12:03:32

but that doesn’t work so well for CLJS

thheller12:03:11

yeah same here. I do that all the time for CLJ. probably not doing many tests for CLJS since I can't do it there

genRaiy12:03:56

in short, I’ve got nothing 😉

thheller12:03:51

what I can offer you is that I just add a simple option that just runs node when a build completes

thheller12:03:27

@raymcdermott in 2.2.6 you can do

{:target :node-test
 :autorun true
 :output-to "out/demo-test-node/script.js"}

thheller12:03:46

just runs node out/demo-test-node/script.js when the build completes

genRaiy12:03:46

that would be plenty good enough

thheller12:03:28

yeah seemed silly to use another tool for this

thheller12:03:02

you can use :ns-regexp "some.ns-test" to only run the test ns you care about (instead of all -test)

genRaiy12:03:14

esp since you have all the mechanics there already

thheller12:03:03

there is some backstory to testing https://github.com/thheller/shadow-cljs/issues/57. so I had the autorun thing before but removed it because it didn't make sense in many other testing scenarios (eg. browser-test, karma). but now that they are different targets it really makes sense for :node-test

thheller12:03:50

the thing I'm working on is a gui that lets you select which test-ns or singular test you care about

thheller12:03:57

and then auto runs those in the browser or node

thheller12:03:14

too many plans not enough time though 😉

thheller12:03:24

:autorun should be an ok temp solution

genRaiy12:03:50

on a purely selfish note, works for me 🙂

genRaiy12:03:49

so assuming this…

genRaiy12:03:11

what does the autorun? the build server watching the files?

thheller12:03:44

whatever is running the watch

genRaiy12:03:44

in other words would now shadow-cljs watch script be enough?

genRaiy12:03:26

do you have an idea when will that be available?

thheller12:03:44

now with the 2.2.6 release

genRaiy12:03:07

so I can just npm update … cool!

thheller12:03:04

oh wait shadow-cljs watch script would not be enough. shadow-cljs watch script test would. or second shadow-cljs watch test process

thheller12:03:35

but I guess you meant watch test

genRaiy12:03:40

ok, I’ll give it a spin

thheller12:03:32

what also works is making a REPL command in Cursive for (shadow.cljs.devtools.api/compile :test)

thheller12:03:58

then bind it to a key to run tests on demand rather than watch

genRaiy12:03:34

ok, good to know - I’ll try that out too

genRaiy12:03:13

hmmm nothing happening, watch seems to do nothing

genRaiy12:03:25

even on standard builds

thheller12:03:40

@raymcdermott btw :optimizations only applies to release builds. so :none is actually invalid. :none is enforced for watch and compile always so you do not need to set it to :none ever.

genRaiy12:03:44

do I have to do a standard build first?

thheller12:03:53

did you restart the server? after updating?

genRaiy12:03:28

I’ll shut up

thheller12:03:04

there might be an issue with the output and where it ends up

genRaiy12:03:21

shadow-cljs - error ENOENT: no such file or directory, open '.shadow-cljs/logging.properties'

thheller13:03:01

hmm odd. this was supposed to be fixed.

genRaiy13:03:07

seems like it needs something new

thheller13:03:33

what did you run?

genRaiy13:03:02

shadow-cljs watch script test

thheller13:03:33

and there really is no .shadow-cljs/logging.properties?

genRaiy13:03:22

wrong folder!

thheller13:03:45

oh. its supposed to be smart about that

genRaiy13:03:03

oh well, in the top dir it’s working

thheller13:03:12

next version it will work in nested folders as well 😉

genRaiy13:03:41

I feel less dumb now 🙂

claudiu18:03:26

if I only use semantic-ui (seems to work well with the default compiler) would you still recommend going with shadow-cljs for the project ?

thheller18:03:35

why would you want to run anything else 😉

dominicm19:03:12

@thheller we previous discussed not embedding shadow into a running project, If I used something like https://github.com/RutledgePaulV/clj-embed except without the isolation (you can access cljs/clj files from the parent classloader) do you see any reason why this would be ill advised?

thheller19:03:45

its perfectly fine to embed shadow in a project. I just don't recommend doing so since you are then in charge of resolving conflicts and such and the tool can't help you with that.

thheller19:03:05

clj-embed you might as well start a new JVM since you'll be paying the full startup cost for the isolation

thheller19:03:58

you can't not-isolate the clojure runtime

thheller19:03:03

you can't "fork" it

dominicm19:03:06

The benefit is simpler running for developers, without the conflicts. The startup cost isn't what I'm avoiding, it's the complex "start this, then that". Hmm, I will have to ensure that piggieback is happy to work cross-classloader. I'm not certain it will be.

thheller19:03:42

start one thing for clojure and another thing for clojurescript seems perfectly reasonable

dominicm19:03:06

Sorry, I was referring to being able to access the parent classloader. I know clojure.lang.RT must be isolated.

thheller19:03:26

you can't share the parent classloader

thheller19:03:52

clojure just doesn't work this way

dominicm19:03:13

I think we're misunderstanding each other. I'm referring to having clj-embed have an embedded version of clojure, but being able to access files on the classpath of the parent, so that cljs compilation can happen as normal.

thheller19:03:15

but the clojure stuff does not need the CLJS deps

dominicm19:03:19

No, that's correct.

thheller19:03:41

clj-embed also doesn't allow using the parent classloader IIRC?

thheller19:03:28

I guess I don't really understand what your goal is

dominicm19:03:39

It doesn't, but the code is relatively short, and changing that is simply switching a flag.

thheller19:03:54

if you expose the parent classloader you have to deal with the same conflicts you'd have when just embedding

thheller19:03:11

yes but this flag is what makes it work in the first place

dominicm19:03:17

Not quite, because the local classloader gets priority.

thheller19:03:18

if you switch it nothing works anymore

dominicm19:03:59

The different version of immutant isn't loaded into the nested container, as the local one gets priority.

dominicm19:03:45

Essentially, the idea is to minimize friction to running the project. Having the cljs load with cider's jack-in is very useful for emacs users who are used to that. Same for ProtoREPL's "Start REPL" etc.

thheller19:03:51

I honestly don't know what a good approach for all of this is. All tools seem to treat CLJS like CLJ but it just isn't the same. Things work differently in almost all aspects.

thheller19:03:35

so sure you can all do it over one process just fine. the only downside is having to deal with conflicts manually.

thheller19:03:47

besides that it works just fine

ddrbt22:03:04

Hi, I'm trying to write a boot task for shadow-cljs. Can I programmatically set the :output-to and :output-dir options?