Clojurians
#shadow-cljs
<
2018-01-30
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

kenbier00:01:03

super excited by this project but i’ve tried to boot up 3 of the examples in the example-repo and each gave me a different error

kenbier00:01:11

all browser errors, no build errors

kenbier00:01:17

curious if im doing something wron

kenbier00:01:49

the browser example said that it couldn’t find references to the jquery and crypto modules, thoug i did a yarn install

kenbier00:01:13

im using node v8.0.0 and 2.0.146

kenbier00:01:43

for local-js i get: > Uncaught ReferenceError: module$node_modules$react$index is not defined

kenbier01:01:13

and my steps are yarn install then shadow-cljs watch app

kenbier01:01:59

perhaps im doing something wrong or some of these examples are stale… really all i want to do is get an example app running that requires rum from clojars and react from NPM

kenbier07:01:46

ah, seems like the lein templates work.

thheller08:01:17

I'll look over the examples. some of them are quite dated yes.

jiyinyiyong09:01:23

it appears too me shadow-cljs is writing some of the logs to stderr. I marked stderr red in my tool. Some of them are red.

jiyinyiyong09:01:52

looks no difference in a terminal though.

thheller09:01:00

The goal was to keep all log-like output to stderr

thheller09:01:33

if you want to use clj-run some.ns/fn which outputs to stdout I wanted to be able to capture that without any log output

thheller09:01:46

but I never quite finished that work

jiyinyiyong09:01:51

so it's a feature.

thheller09:01:05

it is intended yes

thheller09:01:44

although I might as well revert it since it isn't done 100%

jiyinyiyong09:01:49

and something like "shadow-cljs - watching build :browser" will outputs to stderr as well?

thheller09:01:09

honestly I don't know if its a good idea at all

jiyinyiyong09:01:50

not sure either, just thought it looks too random and not as intuitive...

jiyinyiyong09:01:09

> The general practice is to redirect all error messages to stderr and all regular output to stdout. said by StackOverflow :smile:

thheller09:01:11

@kenbier the browser example had a bug which I fixed. local-js should work just fine. I removed the yarn.lock files from the examples since they locked in older version of shadow-cljs. so everything should be using the most recent version now without me having to update it.

kenbier09:01:30

@thheller thanks!

kenbier09:01:20

amazing project btw… lack of npm support has been my biggest pain with CLJS, and honestly something that should be more talked about!

kenbier10:01:04

@jiyinyiyong just read some of your blog posts too, good stuff :slightly_smiling_face:

jiyinyiyong10:01:27

does shadow-cljs handle SIGINT and SIGTERM differently? turned in to https://github.com/thheller/shadow-cljs/issues/186

thheller10:01:08

weird, it should die

thheller10:01:32

but I "fixed" this issue once before

thheller10:01:45

I don't handle any signals at all so no idea

thheller10:01:45

no idea. the node process fully controlls the java process so it should die when node dies

thheller10:01:50

but that had issues before

thheller10:01:11

it might be because I use child_process.spawnSync and don't handle any signals

thheller10:01:28

maybe I'm supposed to use spawn and do everything async with manual signal handling

thheller10:01:59

I expected spawnSync to do the correct thing

jiyinyiyong10:01:31

I'm not familiar enough with those APIs :worried:

thheller10:01:08

you are using it in manager.cljs :wink:

jiyinyiyong10:01:26

I never tried spawnSync.

thheller10:01:28

exec is the same as spawn I think

jiyinyiyong10:01:42

syntax sugar I guess..

thheller10:01:14

btw instead of (.exec cp command (clj->js {:cwd cwd})) you can do (cp/exec command #js {:cwd cwd})

thheller10:01:22

looks a bit nicer

jiyinyiyong10:01:49

cp = require 'child_process'

ret = cp.spawnSync 'sleep', ['100']

console.log ret

jiyinyiyong10:01:00

repeated the problem with CoffeeScript

thheller10:01:35

if anything thats a node issue yes

jiyinyiyong10:01:55

I can't use #js {:cwd cwd} since my code is not written in Clojure directly...

thheller10:01:32

kill with the negative id?

jiyinyiyong10:01:50

Error: kill ESRCH
    at Object._errnoException (util.js:1003:13)
    at process.kill (internal/process.js:173:18)

jiyinyiyong11:01:27

(comment .kill proc)
       (.kill js/process (- 0 pid) "SIGKILL")

jiyinyiyong11:01:08

turned out not working on my Mac

theasp16:01:13

@thheller I've added shadow-cljs to my cljs docker images: https://hub.docker.com/r/theasp/clojurescript-nodejs/

thheller16:01:22

looks much better than the docker image I created :stuck_out_tongue:

thheller16:01:10

https://hub.docker.com/r/thheller/cljs-dev/ can't find the Dockerfile :stuck_out_tongue:

colindresj17:01:19

I have a macro that creates some locally scoped variables, but I’m getting a bunch of use of undeclared Var warnings

colindresj17:01:28

My macro looks like this

colindresj17:01:56

And used like this

colindresj17:01:02

How might I get rid of the warnings?

theasp18:01:21

@colindresj Can you show the warnings?

colindresj18:01:06

Here’s an example @theasp

colindresj18:01:39

------ WARNING #17 -------------------------------------------------------------
 File: /Users/jorge/lunar/src/lunar/ui/catalog/views.cljs:119:69
 Use of undeclared Var lunar.ui.catalog.views/c
--------------------------------------------------------------------------------

colindresj18:01:16

That c would be the var from the for-indexed snippet above

theasp18:01:13

Are you sure c is defined?

theasp18:01:44

Actually, if it was nil that wouldn't matter

colindresj18:01:44

Yeah, if you look at the macro definition above, you’ll see that i and c are set within the argument vector of the mapping function for map-indexed

theasp18:01:43

yes, sorry, I was meaning if c was defined.

theasp18:01:03

user=> (for-indexed [i c [{:card/id 1} {:card/id 2}]] [:li {:class "card" :key i} (:card/id c)])
([:li {:class "card", :key 0} 1] [:li {:class "card", :key 1} 2]

theasp18:01:07

it works in clojure

colindresj18:01:15

Yeah and works without warning in the cljs compiler too

colindresj19:01:21

Found the issue, was forgetting to expose the macro via the namespace

colindresj19:01:48

I’ve got all my macros in a macros.clj file, and forgot to create the matching macros.cljs file with the :require-macros in the ns form

colindresj19:01:54

Thanks for the help @theasp

theasp19:01:07

doh! :slightly_smiling_face:

theasp19:01:17

np, but I don't think I was much help :slightly_smiling_face: