Fork me on GitHub
#shadow-cljs
<
2018-04-24
>
alex-dixon03:04:12

Anyone able to run 2.3.2?

thheller06:04:17

@lilactown what interfaces are reported?

thheller06:04:15

I added IP detection since react-native stuff needs to be able to connect to the shadow-cljs server remotely

thheller06:04:24

needs to be filtered smarter I guess

thheller07:04:53

wow sorry everyone .. the update from yesterday certainly broke some stuff

thheller07:04:57

2.3.4 should be better

ray08:04:10

I’m struggling to run a REPL with Cursive - I have followed the guide but still am a bit stuck

thheller08:04:41

whats the problem?

ray08:04:55

I can’t load CLJS files into a REPL

thheller08:04:14

what is the error?

ray08:04:44

it says I can’t load a CLJS file into a CLJ REPL

ray08:04:56

so maybe I’m not ticking a box somewhere

thheller08:04:17

what steps did you do? is the watch running? did you nrepl-select it?

ray08:04:57

what is nrepl-select

ray08:04:44

LOL, OK let me give that a shot

ray08:04:45

[:no-client :script “Make sure your JS environment has loaded your compiled ClojureScript code.“]

ray08:04:28

I have configured nrepl port in the edn config

javi08:04:05

@raymcdermott have you

(require '[shadow.cljs.devtools.api :as shadow])
  (shadow/nrepl-select :build-id-to-focus-on)
in the clj repl after it starts?

ray08:04:08

and ran shadow-cljs watch script on the command line

thheller08:04:35

> Make sure your JS environment has loaded your compiled ClojureScript code.

thheller08:04:56

ah wait you are building a commend line script right?

ray08:04:19

yes a CLI on top of node

thheller08:04:08

right. so you probably want to use shadow-cljs node-repl + (shadow/nrepl-select :node-repl) for this

thheller08:04:19

if the devtools were injected into your script

thheller08:04:28

their websocket connection would keep the script running even after your work was done

thheller08:04:41

so the script would never exit

thheller08:04:23

node-repl is just a standalone node-repl not tied to any build

thheller08:04:33

you can just (require 'your.script) and work as usual

ray08:04:42

yes, that works!

ray08:04:05

I can now load forms directly from the editor

👍 4
gnl10:04:21

@thheller Do you have a preferred policy on bringing up shadow-cljs issues on Slack first vs. straight to GitHub or just play it by ear?

thheller10:04:31

probably github. slack tends to get lost when I'm busy elsewhere.

👍 4
fatihict13:04:39

Hello, I am trying to set up clojurescript spec instrumentation with shadow, but I am running into an issue. I added an fn in the after-load hook in my shadow-cljs.edn which calls instrument. I am getting spec errors for existing specs, but when I add a new spec I don't see anything. Can anyone help me with this issue?

wilkerlucio13:04:58

@fatihict if you call instrument manually after the js is reloaded, it works?

fatihict13:04:51

I just tried your suggestion @wilkerlucio, but I don't see any messages in my devtools of the new spec I defined.

wilkerlucio13:04:32

I'm just wondering if that's a issue of "timing" or maybe something else

fatihict13:04:17

Yeah, I also really wonder what the issue could be. I did try to define about 20 new specs, so it doesn't look like a timing issue.

thheller13:04:33

@fatihict instrument is a macro so if the code must be recompiled in order for it to update which specs to instrument

thheller13:04:09

you can force recompilation of the namespace that has the instrument call via (ns ^:dev/always that.ns ...)

fatihict14:04:48

@thheller I also tried your suggestion, but it unfortunately doesn't solve my issue

thheller14:04:36

if you look at the browser console when loading code

thheller14:04:53

is your instrument file loaded before or after the code that contains the specs?

thheller14:04:26

if its loaded before that probably is the reason

thheller14:04:10

instrument in CLJS only works on vars that are compiled BEFORE instrument is compiled.

fatihict14:04:11

My instrument file is loaded after the code that contains the specs.

thheller14:04:28

what specs are you testing with?

thheller14:04:56

you might need to set :compiler-options {:static-fns false} in your build config

fatihict14:04:49

I am currently testing with this:

(defn bla [x]
  (+ 1 x))

(s/fdef bla :args (s/cat :x number?))
And calling the function with a string to trigger an error

fatihict14:04:52

I also wrapper the call the instrument with a println and I noticed that the new specs I add are not included in the output of instrument

fatihict14:04:03

I will try adding static-fns to my compiler options now

fatihict14:04:13

Adding static-fns did not fix the issue either

thheller14:04:38

how are you testing then exactly?

thheller14:04:04

are you sure the code running the tests is actually run after calling instrument?

thheller14:04:40

eg. this won't do any spec checking

thheller14:04:42

(defn bla [x]
  (+ 1 x))

(s/fdef bla :args (s/cat :x number?))

(bla 1)
(bla "foo")

(st/instrument)

thheller14:04:38

eg. in your after-load function when calling instrument. if you call a specced function and that does not properly validate thats a bug. anything else is probably an issue related to when things happen.

thheller14:04:47

the instrument macro is kinda icky to use in that regard

fatihict14:04:42

I'm calling instrument and afterwards refreshing my fulcro application. In my application I have a call to the mentioned bla function.

thheller14:04:15

so to recap. you have an (ns ^:dev/always some.thing (:require [your.app :as x] [cljs.spec.test.alpha :as st]))

thheller14:04:36

which has a funtion that calls (st/instrument) and then (x/reload)?

thheller14:04:17

I just tested this

thheller14:04:19

(ns ^:dev/always demo.instrument
  (:require
    [demo.browser :as x]
    [cljs.spec.test.alpha :as st]))

(defn ^:dev/after-load instrument []
  (st/instrument)
  (js/console.log "instrument called")
  (x/bla 1)
  (x/bla "foo"))

thheller14:04:35

in demo.browser I only added the defn bla no spec

thheller14:04:55

then added the spec, saved the file, let live reload do the thing. and the spec failed as expected?

fatihict14:04:23

@thheller That works for me as well. if I require the namespace where I have defined the spec in my instrument file it works, but not if I don't

kanwei14:04:50

How do I get :output-wrapper for production builds?

kanwei14:04:03

putting it in :builds/:compiler-options/:output-wrapper still doesn't wrap

thheller14:04:44

@kanwei :modules {:main {:entries ... :prepend "(function() {" :append "})();"}}

kanwei14:04:10

I saw an add-wrapper fn in the source code, is that not exposed somehow?

thheller14:04:57

don't think I added :output-wrapper as a simplified version of the above. all my builds use multiple modules where you kinda can't use a wrapper

thheller14:04:24

this is just cljs.closure copied from CLJS to fix one particular bug. it is not used at all.

kanwei14:04:39

For a lot of people, output-wrapper has caused problems since non-wrapped fn's can shadow (ha) other vars. Large discussions on the other library pages: https://github.com/boot-clj/boot-cljs/issues/64

thheller14:04:26

@kanwei I'm well aware why :output-wrapper is useful. also gave you the solution you can use for now. same effect.

thheller14:04:48

the issue is that as soon as you use multiple :modules the :output-wrapper breaks things

kanwei14:04:09

I appreciate that, just trying to point out things people will run into

thheller14:04:29

could probably add support for it and just fail when multiple modules are configured

thheller14:04:45

feel free to open a github issue so I don't forget to add it later

kanwei14:04:13

:thumbsup:

wilkerlucio14:04:01

@fatihict so, you have to require it in some way, I guess it was the first thing tomas said, you have to force the ns that define the spec to be loaded before instrument, otherwise it will not work

kanwei15:04:45

also is there any way to turn on :parallel-build for the cljs compiler?

thheller15:04:53

its always on

thheller15:04:59

no way to turn it off actually

fatihict15:04:52

@wilkerlucio Is there a way to force the ns that has the spec to be defined without requiring it? Requiring every namespace with specs in my instrument namespace is not the best solution

wilkerlucio15:04:22

well, it only has to be reloaded if changes, so if you save a spec file, that file should be reloaded before your after-load gets called, thats when I'm getting confused, because if it does so, then it should work @fatihict

thheller15:04:33

@fatihict it should be fine to only require your :entries ns since that will have required everything else?

wilkerlucio16:04:14

@thheller I'm experimenting with some auto-test setup using Shadow and Karma, I see the configuration outputs a single file, I can watch on shadow and karma and get some auto-test running, but it always runs all the tests, do you think would be possible to have something more localized? like generating multiple files and running parts of then, kind like Jest does (in case you know it)

thheller16:04:38

@wilkerlucio definitely possible with some code that doesn't exist yet 😉

thheller16:04:00

never used Jest

wilkerlucio16:04:39

humm, interesting

wilkerlucio16:04:41

Jest has a very cool test runtime, for instance, it can re-run only failing tests until they pass

wilkerlucio16:04:09

then he can run the full suite after the tests get fixed, and it provides interactive commands if you wanna re-run things at anytime (one key shortcuts on the readline of the process)

thheller17:04:28

might be possible to just use Jest?

wilkerlucio17:04:48

I'm really considering it, but there are downsides...

wilkerlucio17:04:02

Jest runs on node environments only, not in the browser

thheller17:04:03

don't have time to look into that currently but shouldn't be hard given that storybook also just works

wilkerlucio17:04:46

although JS community has a lot of tools to deal with that (for testing react things on node), I still think running in the browser is more reliable, and we can do real DOM testing

wilkerlucio17:04:56

so, I'm thinking between having a great dev experience for testing vs been able to use real DOM on tests

wilkerlucio17:04:31

but on the Jest that would be a lot of things to wrap before it gets smooth from a CLJS perspective

wilkerlucio18:04:33

hello, I got some weird thing, I tried removing the clojurescript from my deps, and now when I try to compile I'm getting this:

wilkerlucio18:04:45

shadow-cljs - config: /Users/wilkerlucio/Development/fulcro-shadow-boot/shadow-cljs.edn version: 2.3.5
shadow-cljs - running: lein with-profile cljs run -m shadow.cljs.devtools.cli --npm watch test
Exception in thread "main" java.lang.RuntimeException: No such var: ana/cacheable-files, compiling:(shadow/build/cljs_closure.clj:569:19)
	at clojure.lang.Compiler.analyze(Compiler.java:6792)

thheller18:04:30

which CLJS version did you get? probably an old one.

thheller18:04:41

I make no guarantees for anything when running through lein

wilkerlucio18:04:49

how can I know the version it got?

thheller18:04:49

lein with-profile cljs deps :tree

wilkerlucio18:04:18

ok, found it, was fulcro-spec, thanks

justinlee19:04:54

@thheller have you published your workflow with cursive? from various tidbits i get the sense that you must run your watch command from the terminal (or maybe from the repl?)

justinlee19:04:33

i’m thinking there’s a better way than what i’m doing, which is to run the watch from the cli and then scroll all over the place to look at errors/warnings

fatihict20:04:53

@thheller @wilkerlucio By the way, thanks for your help today. I haven't fixed my issue yet, but will update you once I know more 🙂