Fork me on GitHub
#shadow-cljs
<
2018-04-18
>
tianshu03:04:27

@thheller when start shadow-cljs in clj-repl mode, shadow/watch and shadow/repl can be used in shadow.user namespace. how to have these setup in server mode, or have a headless repl in clj-repl mode?

quang07:04:01

@thheller I would say congrats on http://shadow-cljs.org/ ... but it seemed to have existed before today... I don't think I've ever seen it before today though 😅

thheller07:04:31

@doglooksgood not sure I understand the question? (require '[shadow.cljs.devtools.api :as shadow]) works anywhere?

thheller07:04:17

@quang you are correct I never updated the links. fixed.

kennethkalmer08:04:45

howdy folks, I’m having a small issue where I can’t figure out the correct require dance for using the twitter npm package

kennethkalmer08:04:16

the package has the following export: module.exports = Twitter, where Twitter is a function

kennethkalmer08:04:13

I keep getting variations of: TypeError: shadow.js.shim.module$twitter.Twitter is not a function

thheller08:04:24

@kennethkalmer (:require ["twitter" :as Twitter])

kennethkalmer08:04:03

thanks, will try that again

thheller08:04:48

rule of thumb is when JS libs assign module.exports = ... directly that is :as. if they do exports.foo = ... that is :refer (foo)

👍 4
steveb8n08:04:58

@thheller I’ve fully moved over to shadow from cljsbuild and loving it. Have you applied for a Clojurists Together grant? This kind of tooling is what they want to fund

thheller08:04:12

I did indeed.

thheller08:04:21

and welcome 😉

steveb8n08:04:27

you have my vote

steveb8n08:04:22

I was thinking of knocking up a d3 treemap on top of the release-snapshot data. has anyone else started on this already?

thheller08:04:27

curious to hear about your transition. any specific hurdles?

thheller08:04:31

not sure if anyone started yet. maybe discuss it here: https://github.com/thheller/shadow-cljs/issues/247

steveb8n08:04:54

transition was a couple of days work, I made it easier by building a separate project with all my cljsjs deps ported to shadow first and then migrated my real code over

steveb8n08:04:33

I’d recommend that to anyone making the transition. I was much more confident when I started on my own code

steveb8n08:04:26

I discovered how to use react-faux-dom with d3 while doing this work, what a revelation. idiomatic d3 in react

thheller08:04:07

what do you mean by cljsjs deps ported?

thheller08:04:41

did you create a bunch of cljsjs. namespaces or rewrite your code to use npm directly?

steveb8n08:04:26

the only hiccup was grokking devcards and how it integrates. it seems like :devcards true isn’t quite enough since I’ve had to use preloads and call start-devcard-ui! myself to make that work

steveb8n08:04:38

but not a biggie

thheller08:04:14

devcards comes up a lot. should probably create a proper example for it.

steveb8n08:04:30

re: cljsjs, I switched over to npm deps for all cljsjs deps on the advice of someone in slack. worked great and had the side benefit of allowing me to use any version of npm deps I wanted

steveb8n08:04:37

with cljsjs I was always struggling to get the magic combination of deps + react + cljs versions all to play nicely. with npm deps, it was much easier to combine all the transitive deps and have them all play nice together

pez08:04:32

@jiyinyiyong I fail at getting the server running for development. I get a 404 on localhost:7000. Everything seems to build nicely.

Jon08:04:14

tried yarn page?

Jon08:04:26

you might also need a symbolic link in target/ to entry/

Jon09:04:07

Page is created by running app.page/main!

pez10:04:53

I don’t quite understand how to update the page. The editor only gives me the first line to edit. (Haven’t read up on the editor yet.)

Jon15:04:58

That's the crazy part.

Jon15:04:43

it's an editor I created for generating Clojure code. with it you don't code in parentheses.

Jon15:04:57

could be really hard to pick up.

Jon15:04:35

if you just want to contribute the markdown part, try submit an issue and I will copy/paste.

Jon15:04:32

the harder way is to npm install -g calcit-editor on an Unix/Linux OS and launch my editor. Contact me when you need help about the editor. It's a mind blowing piece.

Jon15:04:13

timezone problem anyway...

pez15:04:24

I did install the editor. 😃 Launched it and it looked pretty awesome. But I couldn’t (or couldn’t figure out how to) edit the actual contents of the page. It only gave me the first line of Markdown.

Jon16:04:44

There is a button at the bottom called "Draft box". Try it.

Jon16:04:05

Pressing "Command d" on a *string* also does the trick.

pez19:04:06

Yes, there it is. 😃

cmal08:04:25

Hi, @thheller . I updated to shadow-cljs 2.2.26 and shadow-cljs watch xxx takes 10-30 seconds when recompiling for a small project. It takes few seconds before that.

thheller08:04:58

@cmal the first compile or all compiles? the first compile will invalidate all caches so thats going to be slower yes.

cmal08:04:18

recompile

cmal08:04:41

I use shadow-cljs watch and every time I changed a cljs source file, it takes 10-30 seconds to recompile.

cmal08:04:11

Build completed. (1030 files, 2 compiled, 0 warnings, 15.31s) Does that mean all files are recompiled?

thheller08:04:34

try running with shadow-cljs watch app --verbose

cmal08:04:24

^Cshutting down ...
JS runtime disconnected.
Worker shutdown.
shutting down ...
shutdown complete.
shutdown complete.
when I try to stop watch

cmal08:04:45

I am restarting watch now...

pez08:04:38

I got that too. Sometimes it works just hitting enter to get the prompt back.

cmal08:04:39

It is quick now..

cmal08:04:57

Build completed. (1030 files, 2 compiled, 0 warnings, 1.67s)

cmal08:04:24

quick now even I connect the js runtime.

thheller09:04:12

@cmal was 1.67s just the initial compile when watch started or is that your recompile time when you change a file?

cmal09:04:07

1.67s is the recompile time, the first compile time is 10.33s. Before restart shadow-cljs watch the recompile time used to be 10-30s .

thheller09:04:35

I mean is it the hot-reload time?

thheller09:04:50

build complete ... change a file .. build complete

thheller09:04:54

what is the second time?

thheller09:04:05

1.67s seems rather slow

cmal09:04:19

[:usercreatedata] Compiling ...
-> Analyzing Module: :app
<- Analyzing Module: :app (28 ms)
-> build target: :browser stage: :compile-prepare
<- build target: :browser stage: :compile-prepare (0 ms)
-> Compile CLJS: usercreatedata/views.cljs
<- Compile CLJS: usercreatedata/views.cljs (180 ms)
Cache write: usercreatedata/views.cljs
-> Compile CLJS: usercreatedata/core.cljs
<- Compile CLJS: usercreatedata/core.cljs (19 ms)
Cache write: usercreatedata/core.cljs
-> build target: :browser stage: :compile-finish
<- build target: :browser stage: :compile-finish (0 ms)
-> build target: :browser stage: :flush
-> Flushing 1030 sources
<- Flushing 1030 sources (81 ms)
-> Flushing unoptimized modules
<- Flushing unoptimized modules (64 ms)
<- build target: :browser stage: :flush (152 ms)
[:usercreatedata] Build completed. (1030 files, 2 compiled, 0 warnings, 2.79s)

cmal09:04:27

my computer is slow.

cmal09:04:52

but 10-30s is problematic

thheller09:04:54

hmm those numbers don't match up?

cmal09:04:13

before I restart shadow-cljs, it was 10-30s

thheller09:04:53

yes I understand. but that seems to fixed by the restart. I'm interested in why your code compiles are so slow

cmal09:04:08

It seems there are two shutting down two shutdown complete when I tried to stop the problematic shadow-cljs watch session , does that mean something is wrong?

thheller09:04:31

not sure but doesn't matter since the jvm exits after that

cmal09:04:34

^Cshutting down ...
JS runtime disconnected.
Worker shutdown.
shutting down ...
shutdown complete.
shutdown complete.

thheller09:04:51

I think the shutdown hook might cause the print twice

cmal09:04:51

Now I stop shadow-cljs there are only one` shutting down...`

thheller09:04:24

probably a bug in the older version that got fixed

thheller09:04:40

I'm curious where the delay is coming from though

thheller09:04:01

if you add all those <- ... (152 ms) timing infos together

thheller09:04:07

you don't get to 2.79s

thheller09:04:18

not sure where it is spending that time

javi13:04:53

"shadow-cljs": "^2.2.21" when adding as a dependency, and compiling with shadow-cljs watch mybuild it can't seem to find io's dependencies and starts asking me to install each one of them... anyone came across this?

thheller13:04:11

@fj.abanses any chance you are trying to use on the client?

thheller13:04:43

I think on the client you must use socket.io-client

javi13:04:00

ummm, you may be right , i remember that from vanilla js...i am bored migrating a project and the cljsjs package for io never asked for that....

justinlee17:04:57

I’m trying to understand the cljsjs compatibility layer. Is the following correct? (1) shadow-cljs ignores the :foreign-libs compiler directive, (2) instead it looks at package.json to extract information would would otherwise have been provided via :foreign-libs, (3) when a project imports a cljsjs dependency or provides a :foreign-lib wrapped package, what we must do in shadow-cljs is provide an empty namespace (of whatever name is expected) that does a :require using shadow-cljs syntax and does a goog.exportSymbol.

thheller17:04:07

1) correct. 2) no, it just looks at node_modules directly. never looks at the project package.json. 3) yes. cljsjs packages typically provide some global variable, eg. cljsjs.react provides js/React. if you use (:require ["react" ...]) that would not provide the global so we need to export it separately for those still expecting to find a js/React

justinlee17:04:55

thanks great. i’ve always been fuzzy on this cljsjs thing and i finally get it now

justinlee17:04:03

in theory, could promesa do some kind of :npm-deps declaration that would download bluebird instead of packaging it?

thheller17:04:58

yes, it could. deps.cljs {:npm-deps {"bluebird" "version"}}

thheller17:04:25

well for shadow-cljs that would work. for most CLJS builds not so much.

justinlee18:04:17

yea okay. they’re not going to want to do that… at least not until npm-deps actually works