Fork me on GitHub
#clojurescript
<
2016-10-04
>
rayk02:10:12

Does anyone know if there is blog post or has anyone tried to get clojure + clojurescript + Electron + Om.next + boot to co-exist? tl;dr details posted to https://groups.google.com/forum/#!topic/clojurescript/_YMfU2tti6E

kenny02:10:33

@rayk We have a pretty close setup: clojure + clojurescript + electron + internal ui framework + boot

kenny02:10:00

Just read the groups post and we very similar project to what you described: the server is pretty lightweight (any heavy lifting is sent to the server) and the client has most of the code

rayk02:10:58

@kenny Glad to hear that we are not off the beaten track…. Any tricks or catches to look out for… From a developer workflow point of view, would to keep the clojure repl in atom cause that works nice and the UI on in the browser… So folk can code across the whole code base without jumping between projects.

kenny02:10:03

Ah, one other difference is we use Cursive

kenny02:10:38

Fortunately, it's actually pretty straight forward and works pretty similarly to normal cljs dev

kenny02:10:08

I recommend using https://github.com/binaryage/cljs-oops so you don't need to deal with Electron externs

kenny02:10:37

Essentially the only task our server has is to persist the data to Datomic. We are using Datascript and Datomic so any time the client has a change that should be persisted the :tx-data is sent via websocket to the server which transacts it to Datomic. The server then forwards the changes to all necessary connected clients to get "live" updates.

kenny02:10:11

We build the app using electron-builder. cljs is compiled with :optimization :advanced and parameterized with closure-defines + adzerk/env

bbss02:10:06

Not using clojure I believe though.

rayk02:10:08

Thanks @kenny ditto on Datomic… and I will chekc out oops. Cursive is cool, I hope @cfleming keeps pushing and pans out for him, just too many years on IntelliJ and the further I can get away from maven feel the better… Hence I have love boot. If I could get my deftask in Cursive like the lein task appear I would be right back there…. Believe it is being worked on...

bbss02:10:35

Oh sorry, also not using boot 🙂

kenny02:10:25

Not sure what you mean by your deftask to appear

rayk02:10:33

That is cool/.. MarkRight is good stuff…,

rayk03:10:05

@kenny last time I looked, I think Cursive need a project.clj, So I use to created a little mapping project.clj so cursive would knew which boot task to run… It did work… I think I just wanted to simplify, get rid of another workaround… So soon as someone finished boot support I will be back

kenny03:10:10

You only need to run the task once after changing your :dependencies

kbp04:10:29

Yo: I have 'om-starter project' up. I added (print ...) in the .clj server file. Is there a way to see that print statement? My lein repl doesn't show it.

credulous10:10:47

Hi, I have a configuration problem on my machine that has stopped me dead for 2 days. Seemingly out of the blue my projects won’t load - there is an error when the goog closure library is bootstrapping itself.

credulous10:10:36

I have been generating projects using luminus, and I have been asking on the luminus channel, but no joy so far - I hope it’s OK to ask here, I’m not sure it’s related to luminus.

credulous10:10:01

When I try to start any project (configured with figwheel in case that’s relevant) I get this in the browser console:

credulous10:10:55

The source for that is in goog.loadModule

credulous10:10:52

I really can’t think of anything on my system that has changed, but something must have - but I don’t know where to look. These were projects that were working last week.

dominicm10:10:04

Probably worth testing with some other templates if you can. Also worth double checking you've nothing in ~/.lein that looks suspicious.

dominicm10:10:18

Oh, not fresh projects?

credulous10:10:27

Also happens on fresh projects.

credulous10:10:45

lein new luminus testingproject +cljs shows the same symptom

credulous10:10:20

lein v. 2.7.1, java 1.8.0_60

credulous10:10:02

On the luminus side someone helpfully tried my exact steps and had no problem, so it’s not a bug with the template, it’s me all me.

dominicm10:10:56

https://github.com/swannodette/mies I think this is the preferred debugging template. Are you able to try it?

credulous10:10:08

Thank you, I’ll try that

credulous10:10:59

OK, that seems to work fine

dominicm10:10:42

So something luminus adds is doing this.

credulous10:10:15

I guess that must be so.

dominicm10:10:50

Maybe try pulling in Luminus cljs dependencies, and adding them to a require list of some kind. See if it breaks with them all added. Then comment out until it works.

dnolen12:10:54

@credulous there is a stack trace the starts with goog.require, what does the source code look like for that first element of the trace?

credulous12:10:05

Also: a chestnut template works for me, including the figwheel integration. So it’s certainly something with luminus (but again, I’m the only one who has the problem).

dnolen12:10:29

@credulous you’re not going back far enough

dnolen12:10:35

find the calling code

dnolen12:10:31

it almost seems like you’ve written goog.require() or something has generated that

pesterhazy12:10:37

@credulous, try wiping any caches or old boot artefacts

credulous12:10:43

@dnolen Thanks.. sorry for being thick in this stuff, the structure is still a bit opaque to me. The generated index.html loads a script: <script src="/js/app.js" type="text/javascript"></script>

credulous12:10:53

That file contains:

pesterhazy12:10:07

@credulous if that doesn't help going back to an earlier, known good version and bisect

pesterhazy12:10:22

with hard problems that's often the only thing that works

credulous12:10:26

var CLOSURE_UNCOMPILED_DEFINES = null;
if(typeof goog == "undefined") document.write('<script src="/js/out/goog/base.js"></script>');
document.write('<script src="/js/out/cljs_deps.js"></script>');
document.write('<script>if (typeof goog == "undefined") console.warn("ClojureScript could not load :main, did you forget to specify :asset-path?");</script>');
document.write('<script>goog.require("hello_world.app");</script>’)

dnolen12:10:23

@credulous so then examine the frames in stacktrace

credulous12:10:29

@pesterhazy Where would I see caches or boot artefacts? Also, I can’t get a good version, even brand new projects fail

dnolen12:10:33

somewhere you are producing undefined

dnolen12:10:46

@credulous probably better asked in #boot

pesterhazy12:10:08

boot doesn't usually leave old files behind

credulous12:10:13

The paste above (8:43 eastern) is the first in the callstack

pesterhazy12:10:25

you could try a fresh checkout of your project in a separate directory

pesterhazy12:10:48

or try removing the target dir

dnolen12:10:05

@credulous what I’m saying is, debug the stacktrace and see where undefined is actually showing up

credulous12:10:10

@pesterhazy If I create a new project with lein new luminus hello-world +cljs it exhibits this problem for me

dnolen12:10:18

you don’t have that much code to look at

dnolen12:10:33

goog.require just finds a name and writes a script tag

pesterhazy12:10:48

also try wiping ~/.m2 and ~/.boot/cache

dnolen12:10:00

@credulous also you haven’t pasted the contents of /js/out/cljs_deps.js

credulous12:10:26

K, trying .m2 and .boot/cache

pesterhazy12:10:46

also try a different browser ! 🙂 browser caches 🙂

dnolen12:10:43

@credulous so are there any undefineds there? if not then I would do as I suggested - poke around in the stack and figure it out 🙂

credulous13:10:51

What’s weird is that goog.moduleLoaderState_ is defined at the top of the try block with moduleName undefined

dnolen13:10:58

@credulous you realize the image you pasted is showing you the bug, right? 🙂

credulous13:10:01

and it doesn’t get mutated after that in the source

credulous13:10:14

No, no I don’t 😄

credulous13:10:35

Be patient, sensei

dnolen13:10:40

does the value of moduleDef make any sense?

credulous13:10:44

It certainly looks weird to me… but when I dove into that loadModuleFromSource it did an eval() on that

credulous13:10:16

So I assumed there was something Very Very Clever going on with google closure passing around source code and evaling int

credulous13:10:36

But I guess not

dnolen13:10:50

there’s nothing clever in this code

dnolen13:10:55

just read it and figure out what is going wrong

dnolen13:10:51

figure out what goog library that string is

dnolen13:10:19

obviously the code expects the eval to set the module state moduleName

manenko13:10:54

For some reason this doesn't work:

(case async-channel
  ch1 (.debug js/console "ch1")
  ch2 (.debug js/console "ch2"))
and fails with No matching clause: [object Object]. But this works:
(if (= async-channel ch1)
  (.debug js/console "ch1")
  (.debug js/console "ch2"))
What's the catch?

dnolen13:10:46

@manenko just doesn’t work, case is for matching literal values

dnolen13:10:42

@credulous I read through goog.base, it seems that thenable.js is considered a module, see goog.addDependency

dnolen13:10:58

for some reason the final argument opt_isModule is set to true

dnolen13:10:09

@credulous when I look at deps.js which includes all of Closure Libary’s dep graph - I see this seems impossible

dnolen13:10:13

the final argument is false

manenko13:10:50

@dnolen ahh, yes, thanks 🙂

dnolen13:10:46

@credulous make sure that your project dependencies aren’t messed up somehow

dnolen13:10:25

make sure there isn’t a conflict for Closure Compiler, Closure Library using whatever your build tool has for that

dnolen13:10:39

clean your build, and try again

credulous13:10:33

What you’re saying makes sense, except that this symptom is happening on virgin projects - right off of lein new… so I don’t think it’s corrupted dependencies.

credulous13:10:53

The conflict between the Closure compiler and the build tool makes the most sense

dnolen13:10:57

you have lot more information now

dnolen13:10:05

and some hints where to look - start looking 🙂

dnolen13:10:22

something impossible is happening - so start forming a theory about what in the chain is screwing things up

dnolen13:10:51

@credulous first thing I would look at of course is deps.js and the goog.addDependency line for thenable.js

dnolen13:10:14

the final argument should not be true

credulous13:10:55

OK, will do… thanks for the help. That all points to a bug in the template, which is really surprising to me because I’m the only one on the planet having this difficulty.

dnolen13:10:48

I’m not familiar with this template, nor have any information about how popular it is

credulous13:10:39

OMG it started working.

credulous13:10:06

I did nothing except put a breakpoint inside deps.js and step into goog.addDependecy

credulous13:10:44

Must have been a browser cache of deps.js?

dnolen13:10:08

yes likely - you can disable caching when the JS console is open - useful

dnolen13:10:20

@credulous another question is wether luminous caches assets

dnolen13:10:31

absolutely don’t want that during dev

pesterhazy14:10:26

caching is automatically disabled if the chrome devtools are open IIRC

pesterhazy14:10:34

(when clicking reload)

pesterhazy14:10:41

I did mention trying a different browser a while ago

bostonaholic14:10:42

it’s a setting in devtools that is disabled by default

dominicm14:10:44

There's also Ctrl-F5 which does a hard reload. That's supposed to clear the cache.

dominicm14:10:59

1001 ways to kill a cache.

rickmoynihan15:10:59

Where do people stand on reframe vs chestnut?

noprompt15:10:13

has anyone attempted to combine rum with javelin?

plexus15:10:30

@rickmoynihan that's a false dichotomy

dialelo15:10:47

@noprompt since javelin cells implement IWatchable they should play well with rum/reactive mixin, haven't tried it myself

plexus15:10:30

re-frame is an architecture + implementation of that architecture based on reagent, Chestnut is a template that tries to handle as much of the boilerplate as possible so it's easy to start clojure+clojurescript web dev

rickmoynihan15:10:47

plexus: I suspected something like that - basically I'm asking for a colleague who wants to get started on front end stuff in cljs... (I've not played with clojurescript since maybe 2 years ago)

jlutteringer15:10:06

is anyone aware of a clojure syntax highlighter in clojurescript? preferably one that produces hiccup rather than html strings, I found glow https://github.com/venantius/glow/tree/master/src/glow but it looks like it’s tied to the jvm

plexus15:10:54

If they just want to do frontend/cljs then I would say start with the Figwheel of re-frame template. Or start with the modern-cljs tutorials which use boot

plexus15:10:36

But it's a hard question, depends what their aim is and what they expect to find

rickmoynihan15:10:16

thanks for the tip - appreciate its not a simple thing to answer

bcbradley19:10:08

if you wanted to have a basic text editor in the browser, how would you implement it?

bcbradley19:10:15

using canvas, or using a text field?

bcbradley19:10:28

would you use something else?

dnolen19:10:26

just depends, textarea is simplest, there are a variety of JS text editor widgets you can try as well

bcbradley19:10:55

If you type into a textarea, do you have to submit a form or something in order for the server to be aware of what you've typed?

bcbradley19:10:03

or is it synchronized with the server?

bcbradley19:10:32

I know thats probably being too hopeful xd

dnolen19:10:49

integration with a backend is just whole other problem

bcbradley19:10:23

i was just wanting to make an online text editor that multiple people could "log in" to and work on at the same time

bcbradley19:10:26

kind of like a google doc

bcbradley19:10:33

except with a slant towards programming

bcbradley19:10:03

do you think textarea would be the right approach?

bcbradley19:10:07

or do you suggest something different?

dnolen19:10:35

no I’m just saying this sounds like a lot of work

dnolen19:10:37

there is no simple solution

dnolen19:10:04

working at the same time a la google docs is even harder

edbond19:10:09

How to include two compiled cljs files on one page? I have two files both of them use reagent, when second one initialize reagent var already initialized.

edbond19:10:13

one file with adv.optimizations, other :none

dnolen19:10:21

@edbond this sounds like a situation that one would want to avoid at all costs

dnolen19:10:46

working around it is just going to be more of a waste of time IMO

edbond19:10:08

what if that is a two different projects I don’t want to merge?

dnolen19:10:18

you don’t want to do that

dnolen19:10:31

the premise is fundamentally flawed

dnolen19:10:05

wrt. to how ClojureScript & Google Closure work anyway

edbond20:10:17

yes, maybe I need to use modules?

dnolen20:10:37

if your question is "I want to split my build so I can load it incrementally"

dnolen20:10:48

then there’s an answer for that

edbond20:10:05

anyway I’ll need to join two projects.

dnolen20:10:41

I don’t know what you mean by “join two projects"

dnolen20:10:46

it’s just a bunch of namespaces

dnolen20:10:05

unrelated to any build you might want to make

dnolen20:10:29

one way would be to make a 3rd project which just requires the two and specifies the build

dnolen20:10:07

anytime the idea of separate compilation crosses your mind - think of another idea and you will save yourself a lot of trouble 🙂

edbond20:10:14

got it, the easiest is to put all namespaces in one project.

liamd21:10:41

if i just create a directory called test in my cljs project and then lein test should that be enough to run tests or do i need to hook something else up?

dnolen21:10:38

@liamd not enough, Lein can only run Clojure tests

liamd22:10:07

ah got it, that makes sense