Fork me on GitHub
#clojurescript
<
2019-12-06
>
Binita Bharati08:12:01

Hello folks, I am trying to compile a production release with this command : clojure --main cljs.main -co '{:closure-defines {"clojure.browser.repl.HOST" "192.168.10.12"} :optimizations "advanced"}' --compile cljs-sample-proj.core I am getting this error : Unexpected error compiling at (REPL:1). Could not write JavaScript nil I also tried clojure --main cljs.main -co '{:closure-defines {"clojure.browser.repl.HOST" "192.168.10.12"}}' -O advanced --compile cljs-sample-proj.core and clojure --main cljs.main -O advanced -co '{:closure-defines {"clojure.browser.repl.HOST" "192.168.10.12"}}' --compile cljs-sample-proj.core . Both of these gives the below error : Dec 06, 2019 8:51:05 AM com.google.javascript.jscomp.LoggerErrorManager println WARNING: WARNING - unknown @define variable clojure.browser.repl.HOST Dec 06, 2019 8:51:05 AM com.google.javascript.jscomp.LoggerErrorManager printSummary WARNING: 0 error(s), 1 warning(s) How do I get this to work please ? Thanks!

p-himik08:12:08

Try :advanced instead of "advanced".

p-himik08:12:45

Also, maybe fore future reference and especially if you want to use NPM libraries, consider using shadow-cljs - it does many sensible things for you.

p-himik08:12:05

Regarding unknown @define variable - that's because you're compiling the app and not running a REPL on it. The variable is defined within the REPL source which is not used during a simple compilation.

p-himik08:12:31

So, to just compile the app, you should omit this particular entry in :closure-defines.

Binita Bharati08:12:55

@U2FRKM4TW - Thanks! Actually, my intention is to build a production release and then execute a clojure -m cljs.main --serve . So, without :closure-defines the server starts at default localhost:9000, whereas I want it to start at my required network IP. Actually, am just trying to follow the clojurescript guide to get a feel of the things. Will definitely use shadow-cljs as I proceed further

p-himik09:12:51

clojure.browser.repl.HOST is for REPL only. It doesn't affect the way you serve your files in the production. Try --serve host:port , as the help available at clj --main cljs.main -h suggests.

Binita Bharati09:12:23

Thank you ! It works.

👍 4
Mehdi H.12:12:01

Hi all, Has anyone ever been able to use cljsjs/delaunator? I have tried multiple combinations of (js/Delaunator.from. [[1 2] [2 3] [1 5] [2 4]]) with different point formats (including the one in the example (<https://github.com/mapbox/delaunator>), which is [[1, 2], [2, 3], [1, 5], [2, 4]]. It seems from is not to be called as prototype values as described here (<https://github.com/cljsjs/packages/wiki/Using-Packages>) because of how the externs are defined here (<https://github.com/cljsjs/packages/blob/master/delaunator/resources/cljsjs/delaunator/common/delaunator.ext.js>). The output is : #object[Error Error: No Delaunay triangulation exists for this input.], although the points are not aligned... What am I doing wrong? Thanks!!

Mehdi H.12:12:25

Using (js/Delaunator.from. or (js/Delaunator/from without '.' doesn't even change the error message...

p-himik12:12:34

Have you tried wrapping your arrays in clj->js?

Mehdi H.12:12:39

holy hell you're right...it works. Well I am not getting any error. Any idea how to access hashedges from there? Cause the externs contain functions but for instance I can't even find in the original index.js the _hashEdge one

p-himik12:12:20

As soon as I see the words "externs" or "cljsjs", I immediately go to shadow-cljs for the help. 🙂 And then I can actually start working instead of yak shaving.

p-himik12:12:38

So that's the only advice I can give - use NPM libraries as is and use shadow-cljs.

Mehdi H.12:12:14

haha ok I will have a look! Thanks a lot for the help!!

p-himik12:12:20

No problem.

Mehdi H.12:12:40

turned out halfedges are properties of the js object, so (.-halfedges Object) worked 🙂 thanks again!!

👍 4
victord12:12:44

Hi, Do clojure and clojurescript code are interchangeable? I mean, if i write a program in clojure (that only use the core language features), can i simply change the dependency on clojure by clojurscript an it will work?

mccraigmccraig12:12:59

roughly @U2KGTH1EG - there are often small differences to take account of

restenb14:12:42

figwheel channels are dead so guess I'll ask here too

restenb14:12:55

i recently updated an old project to figwheel 0.5.19, which seems to have caused it to break somehow. files aren't correctly reloaded in the browser, and i'm presented with Figwheel: error loading filemessage in the console

restenb14:12:32

i tried increasing :time-in-msoption on the server to eliminate a basic timing issue, this looks like a browser issue however

restenb15:12:04

when I make a change, every file that change touches seems to time out independently when attempting to reload in the browser

Mehdi H.15:12:22

Hi all, anyone knows how to get the value at index n of Uint32Array? I can't get the syntax right, and can't find any helpful function or property in here : https://cljdoc.org/d/clojure-interop/cljs-web-api/1.0.4/api/js.Uint32Array

Mehdi H.15:12:23

I tried (get-uint32 array index) but it doesn't work

Mehdi H.16:12:00

oh wow...thank you so much rakyi!!! how could I have found this out?

Mehdi H.16:12:04

I tried all sorts of get...but not this one

rakyi16:12:26

yeah, it is only in Clojure Cheatsheet https://clojure.org/api/cheatsheet

Mehdi H.16:12:22

I'll remember to check both! Thanks again!!

Ben Hammond16:12:30

I am trying to use js/MaterialUIStyles.makeStyles with react/rum/citrus It seems to be absurdly fiddly because • https://material-ui.com/styles/api/#makestyles-styles-options-hook ONLY works as a React hook • rum/defc will ONLY give me a plain-function component (suitable for hooks) if I avoid any kind of mixin complexity Is there a known way to make this less awkward?

dpsutton18:12:24

would like a non-breaking space in a string. should be "\xa0" and this works in the javascript console. However, clojurescript is just a clojure program and "\xa0" and this is an unsupported escape character. A workaround is (char 160) but wondering if there was a more elegant solution?

bfabry18:12:48

not much more elegant lol

dpsutton18:12:19

seems to be an underscore

bfabry18:12:33

oh actually you can put it in a string

bfabry18:12:40

cljs.user=> "foo \u00a0 "
"foo   "

dpsutton18:12:33

awesome. thanks!