Fork me on GitHub
#shadow-cljs
<
2018-10-27
>
richiardiandrea02:10:32

Oh all releases of all targets? This will make our builds way slower. Haven't followed but I compile my tests always in parallel for note and haven't noticed anything wrong

thheller07:10:46

@wvelezva shadow-cljs always tracks the latest CLJS version and it is not recommended to change that. Downgrades are generally not supported. You can use master in most cases unless there have been breaking changes but I'm not aware of any. There was supposed to be a new release a while ago ...

👍 4
thheller07:10:10

@richiardiandrea when builds reach a certain size they seem to start failing due to parallel compilation timeouts. (Now reported multiple times). I will add the parallel option back as soon as I figure out what could be happening. Right now I can't explain why it would timeout and that bothers me.

👍 4
Jon08:10:53

Curious if I can do this:

Jon08:10:57

{:source-paths ["src"]
 :dependencies []
 :builds {"app" {:output-dir "target/"
                 :asset-path "."
                 :target :browser
                 :modules {"main" {:init-fn app.main/main!}}
                 :devtools {:after-load app.main/reload!
                            :http-root "target"
                            :http-port 8080}}}}

Jon08:10:55

I want to use "app" instead of :app to indicate that it's specified by me and not part of shadow-cljs' options.

Jon08:10:08

same in using "main"

thheller08:10:34

you cannot no. Not sure I see the point. Every key in :modules is always specified by you, not sure how a string would make that clearer?

thheller08:10:04

remember that the keyword is also used again in :depends-on when code splitting

thheller08:10:29

:depends-on #{"foo" "bar"} vs :depends-on #{:foo :bar}

thheller08:10:51

if enough people express interest in this I'll consider it

thheller08:10:35

but you don't use {"foo": {"bar": 1}} in JS either to express that it is "your" value.

Jon08:10:10

no choice in JavaScript.

thheller08:10:52

(I was thinking of webpack config where {foo: {bar: 1}} is possible and used, not .json files)

Jon08:10:45

keywords make me think this field will be checked by program and I have to use a certain word there. while I found strings quite flexible and I know it's my choice to name it.

thheller08:10:50

you can use whatever you want there .. it just matters that its a valid keyword

thheller08:10:05

which is also a useful constraint since it matches what a filename should be

Jon08:10:23

yes, (after I actually know that it means)

thheller08:10:37

:modules {"SOMETHING foo \ bard" {:init-fn ...}}} would be bad

Jon08:10:40

then validate the string?

thheller08:10:20

if you convince me that it has actual benefits over a keyword

thheller08:10:42

its not hard to learn that they key of the :modules map will become the filename

thheller08:10:48

and that is the only restriction it has

Jon08:10:22

kind of agreed...

Jon09:10:49

every time I step away from shadow-cljs.edn for some weeks then looks into it again, I feel a bit confused that :main is in shadow-cljs' specification and where do I specify the filename.

thheller09:10:49

it isn't in any specification

thheller09:10:03

call it :index it is completely up to you

thheller09:10:06

> The :modules section of the config is always a map keyed by module ID. The module ID is also used to generate the Javascript filename. Module :main will generate main.js in :output-dir.

lilactown15:10:08

FWIW I would much rather have namespaced keywords as module keys 😉

thheller16:10:15

:foo.bar or :foo-bar is perfectly valid. what would :foo/bar give you?

thheller09:10:13

from the docs ...

Jon09:10:37

yeah, I knew that. just took several seconds to warm up again.

y.khmelevskii12:10:21

hello! I want to change cljs code during build. I use build hooks for this. For example, I want to remove some lines from sources with comment ;; exclude-line I did something like this

(defn- update-values [m f & args]
  (reduce (fn [r [k v]]
            (assoc r k (apply f v args))) {} m))

(defn exclude-dev-code
  {:shadow.build/stages #{:compile-finish}}
  [build-state]
  (update-in
   build-state
   [:output]
   update-values
   (fn [value]
     (update-in value [:source]
                #(clojure.string/replace
                  %
                  #"(?s)([^\n]+)\;\; exclude-line"
                  "")))))
but unfortunately this approach doesn’t work. Can you explain me please what am I doing wrong?

thheller12:10:29

@y.khmelevskii not sure I understand what you are trying to do. whats the point of removing a comment?

thheller12:10:42

also if you mess with the source after compliation the source maps will be busted

y.khmelevskii12:10:49

I want to remove some lines from my sources during compilation. I use comments for marks these lines

thheller12:10:01

why though?

thheller12:10:15

what is the goal?

thheller12:10:06

do you have a concrete example of what kind of code you want to remove?

thheller12:10:48

your hook doesn't work because the :source in :output is only used for source map and you are calling it in :compile-finish which is after CLJS compilation

thheller12:10:08

you'd need to do it in :compile-prepare and inside :sources

thheller12:10:21

but I think the reader conditionals are probably cleaner?

y.khmelevskii12:10:36

I want to remove some requires, for example

(ns test.components.app.nav.view
  (:require
   [ghostwheel.core :refer [>defn =>]] ;; clj-exclude-line

thheller12:10:55

thats the exact usecase for reader conditionals

y.khmelevskii12:10:07

unfortunately conditional_reading doesn’t work in cljs files

thheller12:10:17

then rename them to .cljc? no other difference really

y.khmelevskii12:10:26

got it, thank you! I will try

neupsh19:10:59

Hello, i am trying to use quil in my cljs project managed by shadow-cljs, i added [quil "2.7.1"] to :dependencies in shaldow-cljs.edn and use the quil.core namespace, but it fails to compile with the following error:

neupsh19:10:16

The required namespace "org.processingjs.Processing" is not available, it was required by "quil/core.cljc"

neupsh19:10:02

This is what i am trying to use https://github.com/quil/quil

neupsh19:10:31

Processing js is packaged by quil and should have been available

neupsh19:10:19

Does anyone have any idea on how to use it with shadow-cljs? They have a wiki on how to use it with clojurescript here: https://github.com/quil/quil/wiki/ClojureScript

thheller19:10:39

processing is probably bundled as a foreign-lib ala cljsjs. this is not supported by shadow-cljs. instead you use the npm package directly (assuming there is one)

neupsh19:10:16

@thheller yes Processing-js library is available in npm

thheller19:10:27

(ns org.processingjs.Processing
  (:require ["processing" :as proc]))

(js/goog.exportSymbol "the-global-quil-uses" proc)

neupsh19:10:12

@thheller cool, let me try that.. Thank you

thheller19:10:57

(js/goog.exportSymbol "Processing" proc) I guess

neupsh19:10:54

@thheller it is a nice drawing library and quil is a clojure(script) wrapper 🙂