clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
suren 2020-10-14T02:35:23.441400Z

I have tried (.exe (RegExp. ...) too. It seems the value returned by .exe is a malformed Javascript Array. It has the value that looks something like this.

{0: <actual-str>, 1: <match-groups>, matches: {..}}
Now when this value is parsed by Clojurescript it thinks its an array and only returns [<actual-str>, <match-groups>]

suren 2020-10-14T02:36:40.441600Z

It makes sense cos Array in Javascript is an Object whos keys are numbers.

suren 2020-10-14T03:32:55.442Z

how to run clojurescript command in terminal?

suren 2020-10-14T03:33:04.442300Z

something like cljs -m namespace

suren 2020-10-14T03:34:33.443Z

When I run clj -m namespace it looks for .clj and .cljc files but not .cljs files

👀 1
suren 2020-10-14T04:38:49.446600Z

According to Clojurescript doc here https://clojurescript.org/tools/testing > Running Tests > You can run tests by using the `cljs.test/run-tests` macro. This may be done in your REPL or at the end of your file. If you have many test namespaces it’s idiomatic to create a test runner namespace which imports all of your test namespaces and then invokes `run-tests`. So I created the file server.cljs.tests

(ns server.cljs.tests
  (:require [cljs.test :refer-macros [run-tests]]
            [server.cljs.history_test]))

(enable-console-print!)

(defn runn []
 (run-tests))
I have a test at server.cljs.history_test . But when I run function runn in repl with
ClojureScript 1.10.238
cljs.user=&gt; (require '[server.cljs.tests :refer [runn]])
nil
cljs.user=&gt; (runn)

Testing server.cljs.tests

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
nil
It seems run-tests is enable to discover the tests in server.cljs.history_test namescpace.

pez 2020-10-14T06:42:50.448300Z

Good morning. Anyone knows why most ”common” clojure.* libraries are renamed cljs.* in ClojurScript?

victorb 2020-10-14T08:15:08.449500Z

In short, has to do with macros. In long: https://clojurescript.org/guides/ns-forms#_clojure_namespace_aliasing Edit: see now that thheller was about couple of hours faster 😄

pez 2020-10-14T09:24:43.449800Z

I appreciate the link, so good that you missed Thomas’ answer. 😃

😄 1
thheller 2020-10-14T09:34:19.450100Z

the link also explains it much better. didn't know that existed 🙂

thheller 2020-10-14T06:54:33.448800Z

@pez as soon as macros are involved things would clash badly and not work. works for macro-less things like clojure/string.cljs + .clj but more complex stuff like core.async would break completely.

🙏 1
Grigory Shepelev 2020-10-14T12:52:32.454600Z

Hi! I had some experince with javascript (node, webpack, vuejs) and Elm. Now I'm digging into clojurescript webdev. The ecosystem looks kinda compicated for me at the first look. As far as I understood shadow-clj is like webpack. I have a freshstart project with re-frame framework. How do I use frontend css framework? For example material-components (https://www.npmjs.com/package/material-components-web) with hiccup?

p-himik 2020-10-14T12:55:50.454800Z

The documentation of material-components-web says: > Simply render the necessary DOM, and attach the data-mdc-auto-init="MDCIconButtonToggle" attribute Seems like you can just follow the documentation then and simply convert all HTML they provide into Hiccup and all JS into CLJS.

Grigory Shepelev 2020-10-14T12:57:50.455Z

I don't understand. In this case I should use that with CDN? I want to have it in my bundle with npm install

nickt 2020-10-14T13:05:44.455700Z

hey folks, can anybody help me get the cljs compiler to watch my directory for changes and auto re-compile? I'm running clj -m cljs.main -co build.edn -O advanced -c -w ./src/ and get Assert failed: No file for namespace -w exists

nickt 2020-10-14T13:09:23.455800Z

Ok if I add my core namespace to the -c flag I can get a build, but it doesn't watch...

Mikko Harju 2020-10-14T13:10:36.457100Z

Is there a nifty way to preserve keywords with namespaces when converting to JS datastructures and back? How about object metadata?

Mikko Harju 2020-10-14T13:12:16.457500Z

I have a javascript library that needs the data in javascript format, but I'd like to be able to use the data it passses me again as CLJS data. This works fine for most things, but keyword values and object metadata is lost in this roundtrip.

p-himik 2020-10-14T13:15:50.457700Z

Ah. Your initial question was about using it with Hiccup. :) Just follow the shadow-cljs user's guide: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages

2020-10-14T14:24:58.459800Z

Hi @nickt, put the watch flag after the cljs.main like this and it'll works: clj -m cljs.main -w src -co build.edn -O advanced -c

p-himik 2020-10-14T14:46:46.460100Z

Either that library has to support some metadata in some way, or you have to wrap all calls to that library with some code that remembers everything that that library doesn't support, destroys it, and recreates if after the library call is finished.

Ronny Li 2020-10-14T14:58:46.460800Z

Does anyone have tips on incorporating https://tailwindcss.com/docs/installation into a Figwheel project?

uosl 2020-10-14T15:44:16.461400Z

Use the tailwindcss package and call it from a Makefile. As long as you set css-dirs in figwheel config, it should auto-update.

🙏 1
uosl 2020-10-14T15:46:26.461600Z

Also unless you modify style.css (I only have the \@tailwind directives) you won't need to re-run it, except for prod when you wish to purge unused classes. For prod you set in Makefile export NODE_ENV := production to have tailwindcss purge.

🙏 1
Mikko Harju 2020-10-14T17:03:47.462Z

Yeah, that’s what I thought. No way of getting around it..

Mikko Harju 2020-10-14T17:03:51.462200Z

Thanks!

Ronny Li 2020-10-14T17:31:55.462600Z

sorry if this question is really silly. Do you actually have a separate Makefile or are you referring to something like deps.edn or npm's package.json or Webpack?

Hankstenberg 2020-10-14T19:05:41.464300Z

Hi guys, does anybody know where to find the documentation for shadow-cljs-macros like "[:>" ? They are quite hard to google for.

p-himik 2020-10-14T19:10:25.464700Z

:&gt; is not a macro, it's a regular keyword. And it's not related to shadow-cljs - it's a Reagent thing.

Hankstenberg 2020-10-14T19:11:42.465200Z

Ah, guess that's why I didn't find it. Thank you very much. 🙂

👍 1
uosl 2020-10-14T20:01:55.465700Z

Don't worry about it! I do have a Makefile for my own project. Here's a WIP project that has the tailwindcss boilerplate I ended up with: https://github.com/uosl/dataseek

🙏 1
uosl 2020-10-14T20:03:07.466Z

You don't need a Makefile but I find it makes everything easier and more automated (like automatically running npm install if tailwindcss is missing).