clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
borkdude 2021-05-26T09:10:40.290Z

@thheller Would it be possible to compile an advanced build of reagent and let people provide React using a script tag, so the version of React becomes a choice in the HTML?

borkdude 2021-05-26T09:10:59.290400Z

or are the names of the React library also mangled by Closure?

borkdude 2021-05-26T09:13:07.291Z

w000t!

borkdude 2021-05-26T09:13:10.291200Z

thanks

thheller 2021-05-26T09:16:49.291700Z

npm packages in general don't go through advanced so renaming is generally not an issue (if you have externs of course)

borkdude 2021-05-26T09:26:22.292100Z

@thheller is this :js-resolve option something from shadow or cljs?

borkdude 2021-05-26T09:43:06.292800Z

For completeness, I had to configure it like this:

:js-options
   {:resolve {"react" {:target :global
                       :global "React"}
              "react-dom" {:target :global
                           :global "ReactDOM"}}}
You might want to update the example in the book

borkdude 2021-05-26T09:43:17.293Z

but it seems to work perfectly, thanks!

thheller 2021-05-26T09:46:32.293800Z

what do I need to update? isn't that the example in the book? :resolve is purely from shadow, CLJS handles this differently via :foreign-libs

borkdude 2021-05-26T09:49:52.294600Z

@thheller "react-dom". When I left that out, my website got stuck in an infinite loop (since there were still some node modules in the project, things got weird)

borkdude 2021-05-26T09:53:59.295600Z

hmm, the dev build worked fine with React from a CDN, but still got some problems when compiling with release. Somehow it also re-creates a package.json, etc, while, I think it shouldn't have to? EDIT: probably some other dev build running in the background, messing things up.

Dharmendra 2021-05-26T10:56:16.299100Z

Hi, I am new in clojurescript world. I was trying to do breakpoint debugging in VSCode with Calva. But could not able to do that. I followed this doc: https://calva.io/debugger/#:~:text=You%20can%20insert%20a%20breakpoint,level%20form%20with%20alt%2Benter%20. Is there any Video instructions available for it?

p-himik 2021-05-26T11:11:45.299300Z

At the very top of that page: > The debugger currently does not support ClojureScript And there's also the #calva channel here.

1
valerauko 2021-05-26T11:52:36.300200Z

is there some simple cljs http library for node? (preferably one that just blocks for me so i don't have to play around with go chans etc)

borkdude 2021-05-26T12:06:37.300500Z

blocking in node? lol, good luck with that :)

Karol W贸jcik 2021-05-27T13:07:53.329900Z

Await does not block for you 馃槷

Karol W贸jcik 2021-05-27T13:08:37.330100Z

It's just a syntax sugar for Promises. If you looking for such sugar then check Promesa out.

valerauko 2021-05-27T14:03:22.331800Z

promesa isn't much different from just calling .then and .catch though (in cljs world)

Karol W贸jcik 2021-05-27T14:05:57.332Z

Do you thing that async/await is in some sort different?

valerauko 2021-05-27T14:10:11.332200Z

no i'm well aware that it's syntax sugar and i was hoping for something similar

valerauko 2021-05-27T14:10:38.332400Z

<p! is nice but you must use it in a go block which makes passing things around much more difficult

Karol W贸jcik 2021-05-27T14:38:04.332600Z

I'm trying to avoid channels on Clojurescript as much as I can now. It makes the bundle size really huge even for simple operations. Actually promesa is something you seek for: https://cljdoc.org/d/funcool/promesa/6.0.1/api/promesa.core#plet

valerauko 2021-05-27T16:27:15.332900Z

oh wei that plet really looks amazing. reminds me of manifold's let-flow. thanks, i'll check that out!

Karol W贸jcik 2021-05-27T16:53:41.335800Z

It鈥檚 really got soft. To full async/await alike flow only try/catch as a macro would be needed. Plet it's even better than pure async/await and with bluebird you can get a really good performance!

valerauko 2021-05-26T12:08:39.301200Z

okay then just "anything that doesn't want me to juggle around async chans"

borkdude 2021-05-26T12:13:46.301600Z

cljs-ajax is what is used a lot, I've also used it in several projects

borkdude 2021-05-26T12:14:14.301900Z

not sure if it works with node or only in browser

borkdude 2021-05-26T12:14:30.302300Z

in other cases I would just write raw interop with the node stuff

Karol W贸jcik 2021-05-26T12:30:49.302500Z

It's possible when using fibers 馃槃

(defn &lt;!!
    [c]
    (let [f js/Fiber.current]
      (go
        (.run f (&lt;! c)))
      (.yield js/Fiber)))

Karol W贸jcik 2021-05-26T12:31:57.302700Z

But it's Node.js only and it works terribly bad with channels

borkdude 2021-05-26T12:55:06.308300Z

If I have a map like (ns quux) (def namespaces {'foo foo/bar}) in my code, is my assumption correct that the map will only contain a reference to the function foo/bar and Closure will not actually duplicate a copy of that function to the quux namespace? I wonder about this since in this report https://borkdude.github.io/scittle/report.html you see that it pulls in about 300kb from cljs.core but also has about 300kb in sci.impl.namespaces, which is a bit suspicious imo, since sci.impl.namespaces should mostly contain references to other functions.

thheller 2021-05-26T13:13:31.309Z

you are creating huge amounts of vars with metadata, the actual code probably is only a fraction of that. yes, the maps will only contain references, it won't duplicate the code.

borkdude 2021-05-26T13:14:19.309400Z

true, I should investigate if I can elide this stuff, perhaps using some goog defines

valerauko 2021-05-26T13:46:31.310100Z

yup sadly that lib doesn't work on node

valerauko 2021-05-26T13:46:38.310400Z

time to write some Nice Interop

valerauko 2021-05-26T14:08:11.310900Z

thanks!

borkdude 2021-05-26T14:45:53.311400Z

thheller: yep, that was it

馃憤 1
valerauko 2021-05-26T15:44:42.312Z

i was hoping for something along the ease of js await