clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
2020-10-06T02:32:20.286300Z

is there a good reagent template with routing (frontend only?)

Martin Mariano 2020-10-06T11:35:45.296900Z

the most popular libraries for client side routing are reitit (maintained), bidi (maintained) and secretary (popular but last commit on aug 2019), sadly I don't know any templates, by each repo has examples that you can check

Ping 2020-10-06T04:53:48.287200Z

Is it normal to see a DevTools message in prod? How can I resolve this?

DevTools failed to load SourceMap: Could not parse content 
for 
<https://xxx/js/Loading.js.map>: 
Unexpected token &lt; in JSON at position 0
I get this error as well.
[6:49 AM] Warning: React.createElement: type is invalid -- expected a 
string (for built-in components) or a class/function (for 
composite components) but got: undefined. You likely forgot 
to export your component from the file it's defined in, or 
you might have mixed up default and named imports.

Check the render method of `lba`.
in lba (created by mba)
in Suspense (created by M4)
in M4 (created by mba)
in mba (created by $$)
in $$
in Unknown (created by class_1)
in class_1

phronmophobic 2020-10-06T05:06:15.287300Z

the first error looks like it's trying to load an html page (possibly a 404 response) for the sourcemap

phronmophobic 2020-10-06T05:06:41.287500Z

you can check by loading

<https://xxx/js/Loading.js.map>

phronmophobic 2020-10-06T05:08:15.287700Z

the second error looks like an issue with advanced compilation. you can try the tips from https://clojurescript.org/reference/advanced-compilation#fixing-advanced-compilation-issues to debug

rberger 2020-10-06T05:11:50.287900Z

@nedim Check out https://roman01la.github.io/javascript-to-clojurescript/ it has made life a lot easier for this kind of stuff

Ping 2020-10-06T05:13:54.288100Z

How do I know where and when to provide an extern?

Ping 2020-10-06T05:14:27.288300Z

I have this warning currently -

Ping 2020-10-06T05:14:44.288500Z

Adding extern to Object for property configure due to ambiguous expression (. Amplify/default configure (-&gt;js {:Auth {:identityPoolId config/IDENTITY_POOL_ID, :region config/REGION, :userPoolId config/USER_POOL_ID, :userPoolWebClientId config/USER_POOL_WEB_CLIENT_ID, :oauth {:domain config/OAUTH_DOMAIN, :redirectSignIn config/OAUTH_REDIRECT_SIGN_IN, :redirectSignOut config/OAUTH_REDIRECT_SIGN_OUT, :scope ["phone" "email" "profile" "openid" "aws.cognito.signin.user.admin"], :responseType "code"}}}))

phronmophobic 2020-10-06T05:14:51.288700Z

usually whenever you're using a javascript library. using a clojurescript library is more straightforward and doesn't require externs

phronmophobic 2020-10-06T05:15:52.288900Z

if you're planning on using js libraries, I would consider using shadow-cljs

phronmophobic 2020-10-06T05:16:02.289100Z

http://shadow-cljs.org/

phronmophobic 2020-10-06T05:17:06.289500Z

looks like amplify js in on npm, which means you can shadow-cljs to do a lot of the work for you

phronmophobic 2020-10-06T05:18:25.289700Z

getting set up can be a bit daunting, but it works pretty well once you do

Ping 2020-10-06T05:20:08.289900Z

There is a project that is set-up (not using shadow-cljs). Everything was working until I did a cljs upgrade

phronmophobic 2020-10-06T05:22:49.290200Z

does it work despite the warnings? or do you eventually get an error or unexpected behavior?

Ping 2020-10-06T05:25:34.290400Z

Locally it works despite the warning. In advanced compilation I am wondering if this is what is causing the error.

Ping 2020-10-06T05:26:11.290600Z

When I run advanced compilation, I get no errors with the warning

Ping 2020-10-06T05:26:26.290800Z

But than the app doesn't work

phronmophobic 2020-10-06T05:28:28.291Z

how are you defining react components?

phronmophobic 2020-10-06T05:29:32.291200Z

based off the react warnings, my guess is that the components aren't created in a way amenable to advanced compilation

Ping 2020-10-06T05:35:23.291400Z

i am using the helix wrapper

phronmophobic 2020-10-06T05:38:44.291600Z

hmmm, there is a #helix channel

phronmophobic 2020-10-06T05:39:16.291800Z

which might be more helpful. I've heard of helix, but I've never used it

Ping 2020-10-06T05:41:08.292Z

okay Thanx. Will try there

phronmophobic 2020-10-06T05:41:27.292200Z

I would start with: > Change your production build to use two additional options :pseudo-names true and :pretty-print true. to see if that helps narrow down where the issue might be

Ping 2020-10-06T05:42:09.292400Z

So I have :pseudo-names true

phronmophobic 2020-10-06T05:42:09.292600Z

it won't fix the error, but it should hopefully give you a more useful name to lookup in your code than lba , mba, etc

Ping 2020-10-06T05:50:22.292800Z

Absolutely, I don't know what to do with lba mba

Rama 2020-10-06T09:10:32.296300Z

Hello all, has anybody in this forum worked on MSAL library for a clojurescript project ? I seek some help on LoginRedirect method. Thank you. I tried to search for any messages related to msal did not find any, so, was curious to ask and I am sure I am not alone in this world.

Lucas 2020-10-06T12:00:18.299300Z

Hello folks, I was reading The Joy of Clojure and in the chapter 13 there are some examples explaining how ClojureScript compile process works. I followed step by step but I'm getting Execution error (NullPointerException) at cljs.analyzer/excluded? (analyzer.cljc:3813). null when trying to use cljs.analyze for generate ast . Can someone help me on that please?

Lucas 2020-10-06T12:01:27.299400Z

compilation.cljs:

(ns joy.compilation
  (:require [cljs.analyzer.api :as api]
            [cljs.analyzer :as ana]
            [cljs.compiler :as comp]))

(def code-string "(defn hello [x] (js/alert (pr-str 'greetings x)))")

(def code-data (clojure.edn/read-string code-string))

(def ast (ana/analyze (assoc (ana/empty-env) :content :expr) code-data))

(comp/emit ast)
Execution error (NullPointerException) at cljs.analyzer/excluded? (analyzer.cljc:3813). null

Lucas 2020-10-06T12:02:32.299700Z

project.clj:

(defproject joy/music "1.0.0"
  :dependencies [[org.clojure/clojure "1.10.1"]
                 [org.clojure/clojurescript "1.10.764"]]
  :plugins [[lein-cljsbuild "1.1.8"]]
  :cljsbuild
    {:builds
     [{:source-paths ["src/cljs"]
       :compiler
        {:output-to "dev-target/all.js"
         :optimizations :whitespace
         :pretty-print true}}
      {:source-paths ["src/cljs"]
       :compiler
                     {:output-to "prod-target/all.js"
                      :optimizations :advanced
                      :pretty-print false}}]})

dnolen 2020-10-06T14:00:31.301600Z

@lucas_s.s book examples that rely on the ClojureScript compiler are a bit dodgy because it changes quite a bit and The Joy of Clojure was published some time ago

dnolen 2020-10-06T14:01:36.302400Z

I think the easiest way to poke around in the compiler is still to look at the tests

dnolen 2020-10-06T14:02:17.302700Z

you can also mess around here to some degree - https://swannodette.github.io/2015/07/29/clojurescript-17/

dnolen 2020-10-06T14:02:45.303400Z

I need to update my blog - but one benefit is that is the version of compiler is stuck at whatever it was when I released that post

dnolen 2020-10-06T14:03:28.304300Z

there maybe other CLJS compiler stuff on the web out there - not sure - I'm assuming you're mostly just interested in the flow from s-expressions to AST

dnolen 2020-10-06T14:03:40.304600Z

so using Clojure or ClojureScript to see that doesn't seem all that important

2020-10-06T16:07:02.305300Z

How would i approach (deref (future ...) 500) in cljs ?

dpsutton 2020-10-06T16:08:14.305600Z

you want to block on a pending value?

dpsutton 2020-10-06T16:08:27.306100Z

assuming deref not defer

1
😬 1
2020-10-06T16:08:50.306800Z

Yes, indeed.

dpsutton 2020-10-06T16:10:02.307800Z

not possible to block in js. there's a notion of promises with callbacks or you could use async to "park"

1
2020-10-06T16:14:21.308200Z

Thanks, I'll hammock about another approach

Lucas 2020-10-06T16:27:56.308300Z

It's an awesome article, thank you so much for share it with me 💜

kah0ona 2020-10-06T17:45:50.309900Z

Hello Folks, somehow my upgrading of cljs to 1.10.741 or higher results in: Uncaught TypeError: $<http://jscomp.Lb|jscomp.Lb> is not a function Simply returning to 1.10.587 makes it work again. Has anybody seen this before?

Pradeep B 2020-10-06T17:52:19.313500Z

Hi, i am just getting started on ClojureScript. Past few months worked on few clojure code & comfortable with ring/compjure/clj-http etc. Can someone help me with pointer on how to move ahead with building a simple cljs project like below. A single page application, displays a tabular view and brings the weather/stock data from some opensource api via async call and render it on page load.

victorb 2020-10-07T07:42:42.317800Z

That's the final piece and you can build the full UI first, then add the Data Source (via either just cljs interop with js/fetch (lookup window.fetch) or r0man/cljs-http that uses core.async)

1
victorb 2020-10-06T17:53:36.313600Z

Yeah, probably the way to go is js/Promise + &lt;p! from core.async. "Fakes" to do kind of what you're asking for https://clojurescript.org/guides/promise-interop#using-promises-with-core-async

1
victorb 2020-10-06T17:55:04.313800Z

A read-through and trying to replicate what's in the Reagent starter is a good start: https://reagent-project.github.io/

victorb 2020-10-06T17:55:28.314Z

(granted you know HTML)

Gleb Posobin 2020-10-06T21:46:10.316200Z

I have stumbled upon this issue from 2018 that says that "`js->clj` is not safe for arbitrary JSON data". Is that still the case? https://github.com/JulianBirch/cljs-ajax/issues/219#issuecomment-425851029

thheller 2020-10-06T21:48:12.316600Z

depends on the data but yes