Fork me on GitHub
#clojurescript
<
2018-02-17
>
artenator01:02:45

I am running figwheel + reagent and using figwheel sidecar in emacs to get a clojurescript repl. When I make changes and save, figwheel detects it and prints “Loading! <filename>” to the browser, but the changes do not actually take effect… anyone run into this before or have any ideas?

artenator01:02:49

got it working

wiseman01:02:40

What was the problem?

Karol Wójcik12:02:21

Hello friends. Could someone tell me how can I trace bugs on production if I develop simple express application using clojurescript and my cljs is minified to js? It is hipothetical question but very important for me. I know that in frontend I can use sourcemaps and they will probably work great but I am wondering what about the nodejs

Jakub Holý (HolyJak)12:02:10

Same, I believe. Use source maps. Haven’t tried though.

Karol Wójcik12:02:07

In production should I use source maps as well?

Karol Wójcik12:02:14

Ok I gonna try 😛

mfikes13:02:54

If you end up with a bug that can't be reproduced with :none, and only appears with :advanced then :pseudo-names is very helpful: https://clojurescript.org/reference/compiler-options#pseudo-names

Jakub Holý (HolyJak)15:02:45

Indeed, great tip. But beware that the size explodes.

justinlee18:02:18

Out of curiosity why are you minifyjng on node?

Karol Wójcik18:02:25

Even If I do not minify, the output js is not readable

justinlee18:02:20

Oh I understand. You’re compiling cljs and running it in node. Got it

justinlee18:02:32

It’s an interesting question whether it is worth it to run advanced optimization on server side code. I always thought the optimizations were for size not speed but I don’t actually know that for sure. It is definitely easier and less error prone to use code without advanced optimization though so I wouldn’t do it unless there is a benefit

Karol Wójcik18:02:23

@U8ES68TGX do you know other alternatives? I mean I can always use lumo, but what cljs community thinks about it?

hlolli20:02:13

If you use lumo and always refer to the cache directory (with same version of lumo on every run), then you are in fact running compiled js code, with source mapping. So first run is slow but after that very fast. It depends tough if you need to distribute this as a library, but for runtime, lumo can be very fast when useing cache.

mathpunk21:02:40

I'm getting inconsistent behavior between the way I've set up tests, and experimentation in the repl: https://github.com/mathpunk/sherman/blob/master/test/sherman/grammar_test.cljs#L7

mathpunk21:02:58

My function seems to do the right thing in a repl, but my test runner says,

noisesmith21:02:19

I expected expanding-symbol to reference bracketed

noisesmith21:02:39

in fact I expected anything to reference bracketed OK I saw it now

mathpunk21:02:12

@noisesmith It will; I discovered the undefined problem, and then broke my test apart further

mathpunk21:02:52

In the state of code I've linked, my expectation is that test-expanding-symbols should have one passing, and one failing test. Instead, term.startsWith('#') is undefined. Or term is undefined?

mathpunk21:02:39

Anyway, defining the function in the repl gets me a bracketed that yields true for "#hi#" and false for "hi", which is correct behavior

mfikes21:02:56

@mathpunk You could instead write

(defn- bracketed [term]
  (and (clojure.string/starts-with? term "#") (clojure.string/ends-with? term "#")))
which is more portable (`.startsWith` and .endsWith don't exist in all JavaScript environments.)

mathpunk21:02:00

@mfikes That's way better. For some reason I got the impression that "clojure.string" wasn't available

mfikes21:02:23

Nah, it's there and delegates to highly-optimized code in Closure library. 🙂

mathpunk21:02:27

I was trying, like, "cljs.string"

mathpunk21:02:42

Still fuzzy on the differences between the platforms

mfikes21:02:05

I'd recommend always requireing clojure.* and let the compiler figure out if it needs to fall back to cljs.*

mfikes21:02:37

FWIW, (prn 'startsWith (.-startsWith term)) prints startsWith nil, so its likely that the test runner JavaScript environment doesn't have .startsWith (which is only specified in ES6)