Fork me on GitHub
#clojurescript
<
2020-10-06
>
Daniel Tan02:10:20

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

Martin Mariano11:10:45

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

Ping04:10:48

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 
: 
Unexpected token < 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

phronmophobic05:10:15

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

phronmophobic05:10:41

you can check by loading

phronmophobic05:10:15

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

Ping05:10:54

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

Ping05:10:27

I have this warning currently -

Ping05:10:44

Adding extern to Object for property configure due to ambiguous expression (. Amplify/default configure (->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"}}}))

phronmophobic05:10:51

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

phronmophobic05:10:52

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

phronmophobic05:10:06

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

phronmophobic05:10:25

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

Ping05:10:08

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

phronmophobic05:10:49

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

Ping05:10:34

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

Ping05:10:11

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

Ping05:10:26

But than the app doesn't work

phronmophobic05:10:28

how are you defining react components?

phronmophobic05:10:32

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

Ping05:10:23

i am using the helix wrapper

phronmophobic05:10:44

hmmm, there is a #helix channel

phronmophobic05:10:16

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

Ping05:10:08

okay Thanx. Will try there

phronmophobic05:10:27

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

Ping05:10:09

So I have :pseudo-names true

phronmophobic05:10:09

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

Ping05:10:22

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

Rama09:10:32

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.

Lucas12:10:18

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?

Lucas12:10:27

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

Lucas12:10:32

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}}]})

dnolen14:10:31

@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

dnolen14:10:36

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

Lucas16:10:56

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

dnolen14:10:45

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

dnolen14:10:28

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

dnolen14:10:40

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

thumbnail16:10:02

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

dpsutton16:10:14

you want to block on a pending value?

dpsutton16:10:27

assuming deref not defer

😬 3
3
thumbnail16:10:50

Yes, indeed.

dpsutton16:10:02

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

3
thumbnail16:10:21

Thanks, I'll hammock about another approach

victorb17:10:36

Yeah, probably the way to go is js/Promise + <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

3
kah0ona17:10:50

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

Pradeep B17:10:19

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.

victorb17:10:04

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

victorb17:10:28

(granted you know HTML)

Pradeep B02:10:37

thanks @UEJ5FMR6K yes, comfortable with HTML. Will look into this.

Pradeep B02:10:33

at first glance ddin’t find anything related to making an AJAX call (basiclly to make async call to some api and render api response).

victorb07:10:42

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)

thumbsup_all 3
Gleb Posobin21:10:10

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

thheller21:10:12

depends on the data but yes