Fork me on GitHub
#clojurescript
<
2017-09-14
>
vinai03:09:00

Good morning. In a production build that compiles without errors I'm getting an uncaught error when accessing the page: Uncaught Error: Assert failed: c. This causes the main export variable that is called in the html shell <script type="text/javascript">main.system.go();</script> to be undefined. Can someone give me a pointer how to pinpoint what is causing the issue? What other info can I provide that might be helpful?

vinai04:09:25

Resolved, found :pretty-print and :pseudo-names compiler options 👍

tomaas07:09:52

hi, i'm getting this error Caused by: org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- sass/util when running lein sass watch in my windows. Anyone had similar issue?

juhoteperi07:09:07

@tomaas You could try https://github.com/Deraen/sass4clj instead, I have Windows CI running the tests so it should work

leongrapenthin10:09:10

Wasn't there some symbol metadata that prevents minification as an alternative to using externs? Is that documented somewhere?

leongrapenthin10:09:07

or was that just when property names begin with two underscores, like in the impl of om

leongrapenthin10:09:33

(which is also not documented)

darwin11:09:36

@leongrapenthin you might want to use string names to prevent minification

darwin11:09:06

btw. I wrote a library[1] which makes it pretty convenient: https://github.com/binaryage/cljs-oops

tatut11:09:05

Looks neat. Excellent readme!

yogthos13:09:22

I notice the compiler is setting NODE_ENV to "production" when the optimizations are not set to :none https://github.com/clojure/clojurescript/blob/79041d10ce11e9e2f15c261a9a4174c6a7066834/src/main/clojure/cljs/closure.clj#L2062

yogthos13:09:47

this masks environment variables when running on node

yogthos13:09:22

is there a workaround for this?

yogthos13:09:58

I have a request for macchiato, where the users is trying to run it on heroku, and the application needs access to host/port environment variables

dnolen13:09:50

@yogthos why do you need to use anything other than :none under Node.js?

yogthos13:09:01

using simple makes packaging easier because you end up with a single js file

yogthos13:09:36

so the only artifacts that need to be provided are package.json and app.js

yogthos13:09:01

what's the rationale for masking the environment variables?

dnolen13:09:37

@yogthos when you’re not targeting Node.js

yogthos13:09:23

so ideally that should be done if :target is not set to node.js then?

dnolen13:09:15

@yogthos I’m pretty sure we handled your problem but maybe there’s a bug

dnolen13:09:37

we don’t shim process nor set the environment unless not Node.js target

yogthos13:09:16

possibly, when I log (-> js/process .-env js/console.log) with :simple optimizations I see { NODE_ENV: 'production' }

dnolen13:09:31

that’s not a bug report

dnolen13:09:44

anyways that’s how the source reads - look at shim-process?

dnolen13:09:57

if you have a case that doesn’t work make something minimal and file a ticket

yogthos13:09:07

ok sounds good

yogthos13:09:11

ah good news, the template was on 1.9.854 and 1.9.908 fixes it, I'm guessing shim-process? was added there?

dnolen13:09:53

@yogthos yeah we realized the old behavior was a problem

yogthos14:09:32

I guess now with Lumo there's a lot more testing happening for node use cases 🙂

erwinrooijakkers14:09:14

When using Reagent, is there any use for placing a reaction around every query? Or only around the db? E.g.,

(defonce app-db
  (let [ratom (r/atom (d/db conn))]
    (add-watch conn :watch-conn (fn [_ _ _ new-db] (reset! ratom new-db)))
    ratom))
And then:
(let [screen-state (reaction (d/q '[:find (pull ?e [*]) .
                                      :where [?e :ui/screen-element :ui/page]]
                                    @app-db))] ...)
When the reaction around the query in screen-state is removed the behaviour does not seem to change.

erwinrooijakkers14:09:12

Does the reaction in screen-state do anything useful?

hugh.jf.chen14:09:48

can i use javascript unary operators in clojurescript? i want to convery string to number

dnolen14:09:03

@erwinrooijakkers you probably want to ask in #reagent

dnolen14:09:36

@hugh.jf.chen you can use js/parseInt

dnolen14:09:48

Google Closure Library might have some stuff too

hugh.jf.chen14:09:25

Parseint is not safe

hugh.jf.chen14:09:02

Parseint('44jpg') will return 44

hugh.jf.chen14:09:22

That is not what I want

dnolen14:09:44

@hugh.jf.chen then use something else

petterik14:09:12

cljs.reader/read-string and checking if the return is a number? is another alternative

hugh.jf.chen14:09:48

Check goog.string and found toNumber

john14:09:45

(js/Number. "44jpg") returns #object[Number NaN]

madstap16:09:35

Check if it's the right format with a regex maybe?

peeja17:09:37

Is it possible to get var metadata from JavaScript? var is a special form, so I can't do normal interop stuff. Is there some kind of var registry I can look at at runtime from JS?

peeja17:09:01

(This is for a dev-time helper, so hacky and dev-only stuff is fine here)

john17:09:58

vars aren't reified in CLJS

noisesmith17:09:02

are vars even reified in a useful way? they don’t appear to be form my experimentation but something could have changed

noisesmith17:09:06

Oh, right, what he said ^

darwin17:09:06

@peeja AFAIK you can use macros to “export” some metadata into your generated js code and use it at runtime from cljs code

peeja17:09:50

They're not reified as vars, but I thought the metadata were available at runtime now

peeja17:09:03

as of a few months ago?

john17:09:05

via macros. What @darwin said

noisesmith17:09:10

if they were reified, you could use ns-publics to get the vars of an ns, without needing macros of any sort

noisesmith17:09:53

the closest we have I guess in cljs is (goog.object/getKeys js/some.ns)

peeja17:09:28

I think I've got it actually

peeja17:09:30

cljs.analyzer.api/ns-resolve

noisesmith17:09:47

ev:cljs.user=> (gob/getKeys js/cljs.core)
#js ["_STAR_clojurescript_version_STAR_" "_STAR_unchecked_if_STAR_" "_STAR_warn_on_infer_STAR_" "PROTOCOL_SENTINEL" "_STAR_target_STAR_" "_STAR_ns_STAR_" "_STAR
_out_STAR_" "_STAR_assert_STAR_" "_STAR_print_fn_STAR_" ...

john17:09:41

ah. resolve was added recently

bherrmann19:09:59

What is the canonical way to turn clojurescript code into html (with syntax highlight etc) to show to coworkers ?

john19:09:57

Hadn't heard of one. There are various highlighters online that can do clojure, like this one: http://hilite.me/

john19:09:17

If you want to build a tool though, there's things like this: https://github.com/venantius/glow

bherrmann19:09:05

but I cant get it to look very good. better than nothing.

bherrmann20:09:13

Boo... I'm going withh just <pre> for now....

hlolli21:09:23

bit google-lazy, what was again the name of the math operator that returnes decimals from float, what I want is to split for ex. 1.666 to 1 (int or parseInt of course) and 0.666 or 666.

thheller21:09:06

(rem 1.666 1)

hlolli21:09:33

ok I see that there's no math operator specific to this, I have three ways. (mod 1.666 1) or (- 1.666 (int 1.666) or turn it into string and split-at "." and read the number.

hlolli21:09:10

I guess mod and rem are the one and same function?

thheller21:09:33

not actually sure what the correct mathematical definition is 😛

hlolli21:09:02

modulo === remainder of division 🙂 I think