Fork me on GitHub
#clojurescript
<
2020-04-30
>
lilactown00:04:38

@tekacs I can repro your issue on my laptop too

tekacs00:04:28

Thank you for that, @lilactown. Since Helix is yours, I wonder if you might know why using a basic Helix entrypoint in core.cljs (in that exact repro repo) causes Helix to fail to compile, too: https://gist.github.com/tekacs/a46476615782a45f29005d15bc0f27b7

lilactown00:04:29

how are you building the main.js bundle using parcel?

tekacs00:04:38

I’m not — didn’t get that far

lilactown00:04:50

yeah, I replied in a thread underneath your original message

tekacs00:04:57

Ah, sorry for not noticing

lilactown00:04:08

I don't think helix's master branch will work without shadow-cljs atm

lilactown00:04:13

going to try and fix that this weekend

tekacs00:04:25

Thanks very much 🙏

lilactown00:04:12

I think that you must generate the main.js yourself

lilactown00:04:33

in the webpack guide, webpack consumes out/index.js and generates out/main.js

lilactown00:04:57

which begs the question: WTF is the out/main.js that the CLJS http server is serving?

tekacs00:04:02

Hmm — I took out/main.js from the CLJS splash screen that came up on a build with no index.html

tekacs00:04:16

I think that it’s generated on the fly by the REPL option to cljs.main

tekacs00:04:26

Which is why you can’t just use the compilation output

tekacs00:04:47

To see it for yourself, delete index.html

tekacs00:04:56

And go to localhost:9000

dpsutton00:04:38

If anyone has an example using parcel I would love to see it

tekacs00:04:45

I'll hopefully have one for you @dpsutton once I get this working 🙂

lilactown00:04:26

I'm trying to setup the :bundle-cmd now, I think that will fix this

dpsutton00:04:31

Would love to see it. I looked over the parcel docs and couldn’t find where you put the config file. And my experiments kept failing with not finding goog

tekacs00:04:56

I have a bunch of shadow projects -- last week it took me two days to go from an empty directory to a fairly large, working project -- so I'll probably write that setup up soon. That said, I'd love to get this setup to be comfortable too and to maintain making it easy for people to get started with this stuff for a while -- because for all folks' complaints about CLJS tooling, I've had an infinitely easier time of it (with shadow, admittedly) than I had with a great deal of JS bundling (even CRA!).

lilactown00:04:22

ugh, the parcel docs are for [email protected] :face_with_rolling_eyes:

tekacs00:04:30

haha I'll quickly build it using parcel and see if that helps -- just give me a sec

tekacs00:04:35

these are Parcel 2 docs by the way, @lilactown: https://parcel2-docs.now.sh/

lilactown00:04:57

I can confirm that properly generating the main.js using parcel fixes the issue above

tekacs00:04:02

that makes sense @lilactown -- I'll push ahead on that approach then and see how it goes 🙂

tekacs00:04:08

thanks for looking into it!

tekacs00:04:19

I wonder what is being served as the default file there by CLJS... 😅

tekacs00:04:28

had it served nothing I would have thought it was wrong immediately, but I assumed that it was safe to use the file that hadn't been pre-processed -- it's unclear why a broken main.js exists there -- perhaps it's left over from another build target but is in a broken state on the :bundle one?

dpsutton00:04:45

@lilactown is that parcel 1 or 2? (heard yall talking about doc version)

lilactown00:04:12

I downgraded to parcel 1 since those were the docs i found.

lilactown00:04:35

the only thing I didn't immediately see when glancing through parcel 2 docs was how to change the output file

dpsutton00:04:51

did you see that in parcel 1 docs? i couldn't find any config file

lilactown00:04:59

I just used CLI args

dpsutton00:04:04

there were just snippets that applied but didn't know where it should go

tekacs00:04:05

Parcel is all about having no config file AIUI, @dpsutton

dpsutton00:04:14

ahh. well there's my confusion 🙂

dpsutton00:04:20

thanks both of you

lilactown00:04:42

bundle-cmd {:none ["npx" "parcel" "build" "out/index.js" "--out-dir" "out" "--out-file" "main.js" "--no-minify"]

tekacs00:04:55

to set the output path you can use package.json

lilactown00:04:05

the only thing I couldn't figure out was how to pass the NODE_ENV through the bundle-cmd

tekacs00:04:08

{"main": "out/main.js"} in package.json will set the output path 🙂

👍 4
lilactown00:04:14

so it's using prod versions of React 😕

kimim03:04:49

80            (for [a (range 10) b (range 10)]
              ^--- Wrong number of args (3) passed to: cljs.core/for
81              [:div a]
82              [:div b]
83              )
Hello, Any idea how to return two hiccup form in one loop? Thanks.

sergey.shvets03:04:22

Wrap them into vector and then use flatten on the result. Smth like this:

(->> (for [a (range 10) b (range 10)]
       [[:div a] [:div b]])
    flatten
    (into []))
Or if you only need to flatten one level:
(->> (for [a (range 10) b (range 10)]
       [[:div a] [:div b]])
    (apply concat)
    (into []))

lilactown03:04:59

you probably want to use a fragment

dpsutton04:04:41

flatten is almost always wrong. just an example:

Clojure 1.10.1
user=> (for [x ["foo" "bar" "baz"]] [:div [:h3 "stuff"] x])
([:div [:h3 "stuff"] "foo"] [:div [:h3 "stuff"] "bar"] [:div [:h3 "stuff"] "baz"])
user=> (flatten (for [x ["foo" "bar" "baz"]] [:div [:h3 "stuff"] x]))
(:div :h3 "stuff" "foo" :div :h3 "stuff" "bar" :div :h3 "stuff" "baz")

kimim04:04:57

@dpsutton yes, that’s too flat..

kimim04:04:28

@lilactown Thanks, it’s exactly what I am looking for.

noisesmith11:04:39

there's a simpler answer

user=> (for [a (range 10) b (range 10) div [[:div a] [:div b]]] div)
([:div 0] [:div 0] [:div 0] [:div 1] [:div 0] [:div 2] [:div 0] [:div 3]  ... ... ...)

noisesmith11:04:16

you never need to concat the result of for, you can lift the result into a clause and emit it element by element

Spaceman06:04:42

I have the following code:

(deftest test-async

  (let [result (waitFor (+ 1 2))
        ;; landing (<p! (waitFor
        ;;       #(see/landing!)
        ;;       ))
        ;; click (<p! (waitFor
        ;;       ;;#(see/landing!)
        ;;       #(interact/click-login-btn)
        ;;       ))
        
        ]
    (async done
           (go
             (is (= 3 (<p! result)))
             (prn "done")
             (done)
             )
           
           )
    
    ))
But this gives me: ERROR in (test-async) (Error:NaN:NaN) expected: (= 3 (<p! result)) actual: #error {:message "Promise error", :data {:error :promise-error}, :cause #object[TypeError TypeError: Cannot read property 'current' of undefined]} "done" Seems related to this: https://github.com/testing-library/react-testing-library/issues/439 But my versions of react and react dom are the same and latest Then why this error?

dominicm10:04:37

Is it possible to produce a source map that isn't written relatively to the output-dir, but also isn't included in sourceMapURL? I am uploading the sourcemap to a service which processes them. I see now why this is a problem :)

Franklin16:04:09

what is the best way to achieve the kind of routing implemented by react-router where when you click a link on any page, the browser does not perform a reload? I was thinking a potential way of doing this is creating a reagent component that encapsulates a HTML <a> tag that receives click events but calls (. e preventDefault) on them. Does anyone here have thoughts on this?

Tuomas16:04:18

I don’t know about the best way, but I’ve used https://github.com/clj-commons/pushy

Franklin17:04:08

cool, thanks... I just found out that accountant is meant for this exact thing

simongray20:04:28

Yeah, when I made my first SPA a few years back I just went with the secretary and accountant. Pretty painless to set up, but it's one of the those things everyone has to figure out for themselves unless they use a batteries-included frontend framework.

v21:04:09

Try reitit