Fork me on GitHub
#clojurescript
<
2020-10-14
>
suren03:10:55

how to run clojurescript command in terminal?

suren03:10:04

something like cljs -m namespace

suren03:10:33

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

šŸ‘€ 3
suren04:10:49

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=> (require '[server.cljs.tests :refer [runn]])
nil
cljs.user=> (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.

pez06:10:50

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

victorb08:10:08

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 šŸ˜„

pez09:10:43

I appreciate the link, so good that you missed Thomasā€™ answer. šŸ˜ƒ

šŸ˜„ 3
thheller09:10:19

the link also explains it much better. didn't know that existed šŸ™‚

thheller06:10:33

@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.

šŸ™ 3
Grigory Shepelev12:10:32

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-himik12:10:50

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 Shepelev12:10:50

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

p-himik13:10:50

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

nickt13:10:44

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

nickt13:10:23

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

Mikko Harju13:10:36

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

Mikko Harju13:10:16

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-himik14:10:46

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.

Mikko Harju17:10:47

Yeah, thatā€™s what I thought. No way of getting around it..

Michaƫl Salihi14:10:58

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

Ronny Li14:10:46

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

herald15:10:16

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

šŸ™ 3
herald15:10:26

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.

šŸ™ 3
Ronny Li17:10:55

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?

herald20:10:55

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

šŸ™ 3
herald20:10:07

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).

Hankstenberg19:10:41

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

p-himik19:10:25

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

Hankstenberg19:10:42

Ah, guess that's why I didn't find it. Thank you very much. šŸ™‚

šŸ‘ 3