Fork me on GitHub
#clojurescript
<
2020-05-15
>
dnolen00:05:05

there's just no guide for code splitting with Webpack yet so you're kind of own your own

dnolen00:05:28

in theory you could use the existing code splitting and produce N bundles but far as I know no one has tried that yet and reported issues

didibus03:05:07

I'm trying to use code-mirror from cljjsjs, and it says:

You can add the following boot tasks to add the css to your project.

    (sift :add-jar {'cljsjs/codemirror #"cljsjs/codemirror/development/codemirror.css"})
    (sift :move {#"cljsjs/codemirror/development/codemirror.css" "vendor/codemirror/codemirror.css"})))

didibus03:05:28

But I'm not using boot, only tools.deps, any way for me to accomplish this without boot?

didibus04:05:39

Figured it out

aisamu13:05:10

Would you mind sharing it? For posterity, since things are logged

didibus05:05:06

Add an alias as such in deps.edn:

:sift-codemirror {:paths ["build-scripts"]
                             :main-opts ["-m" "sift-codemirror"]}
create a build_scripts folder, and inside it create your build scripts, such as I created a sift_codemirror.clj :
(ns sift-codemirror
  (:require [ :as io]))

(defn -main
  [& _args]
  (->> (io/resource "cljsjs/codemirror/development/codemirror.css")
       (slurp)
       (spit "./resources/public/vendor/codemirror/codemirror.css")))
Now if you run: clojure -A:sift-codemirror it will run the sift_codemirror script with the classpath of your project, and sift the css file from the jar into my resource dir. You can use this to write any kind of build script you want, its just plain Clojure.

andrea.crotti10:05:23

any suggestions about how to do some simple tracing in clojurescript

andrea.crotti10:05:45

what would be already very useful is just to see all the functions that are called in the right order, even without the arguments

dnolen12:05:23

googling cljs-trace does return some results, not sure if they can be configured to drop args

Fredrik Cumlin13:05:08

Question about the library ag-grid. After setting a css class to a row with getRowClass, can you remove the class when logic to getRowClass is false?

Fredrik Cumlin13:05:52

i.e. I want the background to be white again, when changing the Notstandard to Core.

jaide16:05:55

(ns my-app.module
  (:require
   [group.module.a :as utils]
   [group.module.b :as utils]))
In this case utils will only refer to whatever is in group.module.b only?

lilactown16:05:18

I would expect that would be a compiler warning

jaide17:05:21

That makes sense. Is there a good means to add to a namespace then?

lilactown17:05:40

Iā€™m not sure what you mean. like combine a and b into one namespace?

Aron21:05:38

what's the best way to convert a hashmap keys from keywords to strings? to have the same map but with string keys

jjttjj21:05:31

@ashnur

(reduce-kv (fn [m k v] (assoc m (name k) v)) {} {:a 1 :b 2}) ;;=> {"a" 1, "b" 2}

Aron21:05:55

wow, that's unexpectedly complicated.

dpsutton21:05:48

(into {} (map (fn [[k v]] [(name k) v])) your-map)

dpsutton21:05:56

is that less?

jjttjj21:05:00

There's also the helper library https://github.com/weavejester/medley where you can do

(medley.core/map-keys name {:a 1 :b 2})
for the same result

Aron21:05:01

@dpsutton yes, that is less.

jjttjj21:05:17

and of course, you can create a map keys function yourself by changing a tiny amount of the reduce-kv code i sent first

jjttjj21:05:03

(defn map-keys [f m]
  (reduce-kv (fn [m k v] (assoc m (f k) v)) {} m))

šŸ’Æ 4
Aron21:05:24

reduce is too much

Aron21:05:35

I can do everything with just one reduce šŸ˜‰

dpsutton21:05:59

i don't know what you mean but go for it

Aron21:05:18

@dpsutton I am going with your solution of into {}

souenzzo22:05:30

(letfn [;; WTF Recursive solution
        (namefy-keys [coll]
          (if (coll? coll)
            (into (empty coll)
                  (map (if (map? coll)
                         (juxt (comp name key)
                               (comp namefy-keys val))
                         namefy-keys))
                  coll)
            coll))
        (namefy-keys* [coll]
          (into {} 
                (map (juxt (comp name key)
                           val))
                coll))]
  (let [coll {:a 1
              :b 2
              :c {:d 3
                  :e [[[[{:f 42}]]]]}}]
    (namefy-keys* coll)))
    

Aron06:05:48

šŸ˜„

dvingo21:05:49

basically the same, but using juxt

Martin Rodriguez21:05:45

Hey @jjttjj! Today I read this discussion with @thheller about importing antd https://clojurians-log.clojureverse.org/shadow-cljs/2018-09-05 Have you managed to import only the desired modules instead of the whole library? Importing antd directly did not do the trick for me

Martin Rodriguez21:05:10

(using shadow-cljs)

jjttjj22:05:33

Hey sorry I don't remember this conversation at all or if I ended up getting it working šŸ˜…

thheller22:05:21

@marodriguez you typically just require the component you want to use directly, eg (:require ["antd/es/date-picker" :default DatePicker]) or so

Martin Rodriguez22:05:49

Thanks both for the fast replies. It worked!

didibus05:05:06
replied to a thread:Figured it out

Add an alias as such in deps.edn:

:sift-codemirror {:paths ["build-scripts"]
                             :main-opts ["-m" "sift-codemirror"]}
create a build_scripts folder, and inside it create your build scripts, such as I created a sift_codemirror.clj :
(ns sift-codemirror
  (:require [ :as io]))

(defn -main
  [& _args]
  (->> (io/resource "cljsjs/codemirror/development/codemirror.css")
       (slurp)
       (spit "./resources/public/vendor/codemirror/codemirror.css")))
Now if you run: clojure -A:sift-codemirror it will run the sift_codemirror script with the classpath of your project, and sift the css file from the jar into my resource dir. You can use this to write any kind of build script you want, its just plain Clojure.