Fork me on GitHub
#shadow-cljs
<
2020-06-01
>
didibus05:06:45

If I use shadow-cljs, and I have lib A depend on NPM packageX version 1.2 and now say I have lib B depend on NPM packageX version 2.0 and now I have my app depend on both lib A and lib B? What happens? Assuming lib A and B are both ClojureScript libs?

thheller07:06:55

@gmercer launching lein less in a hook is not a good idea. :configure is called whenever your build config changes while watch is running so you can end up with multiple watches. I recommend using some other tool to run multiple processes for you. eg. https://github.com/strongloop/node-foreman

thheller07:06:39

@nathan.probst dynadoc is a leiningen plugin. not sure it can be used without lein. maybe try shadow-cljs run dynadoc.core with maybe some args?

thheller07:06:50

@didibus you have to sort out that conflict and decide which version to install. ultimately the installed version wins. if none are installed shadow-cljs will install the newest one, assuming they are declared in deps.cljs :npm-deps (of those libraries)

gmercer08:06:50

@thheller cheers, yes - a nasty hack, after investigating it looks I should use the less tool directly (rather than lein-less) and get it to run alongside/in conjuction with shadow watch app . Do you know of an example something like that? I guess the trickiness is making sure tools run at the correct part of the lifecycle

thheller08:06:34

again the answer would be a separate tool to run multiple processes for you

thheller08:06:06

I have never used less in any shape so I can't make recommendations on which tools to use

gmercer08:06:00

I mean any other node web pipeline tool that does a transformation to directories watched by shadow

thheller08:06:30

as far as shadow-cljs is concerned it is just files on disk that it reloads

thheller08:06:40

it doesn't care where those files come from

gmercer08:06:04

I was looking for an example of running another node tool .. that places files in shadow-cljs 's area of concern

thheller08:06:35

I don't follow. you are asking how to run generic node tools?

thheller08:06:33

if you configure :dev-http {3000 "public"} which serves the public folder under port 3000

thheller08:06:48

so you generate you css into public/css/foo.css however you like

thheller08:06:08

shadow-cljs will reload it automatically

thheller08:06:32

if you use a custom webserver you'll need to configure :watch-dir, see https://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading

gmercer08:06:11

If I change my search from less to sass or scss .. I can see you have been through this discussion before ..

thheller08:06:44

yes, I have used sass before and have used and continue to use node-sass

thheller08:06:55

node-sass -w src/sass/main.scss public/css/main.css

gmercer08:06:00

do you have the example that shows node-sass "running in the background" or in conjunction with shadow ?

thheller08:06:06

via nf start

thheller08:06:34

nf = node-foreman I linked above

thheller08:06:20

FWIW I also used https://www.npmjs.com/package/npm-run-all in the past but imho nf is simpler and does enough for me

thheller08:06:06

I don't use it to run shadow-cljs though, still run that separately. I guess mostly out of habit

gmercer08:06:43

I was trying to get a beginner started with the re-frame template (which uses lein to kick-off shadow-cljs) and trying to avoid the extra lein less auto step, if I can work it out I would create a PR to make it easier for other beginners.

thheller08:06:35

that is a question for the template then, I have no control over that and my own grievances with the setup it creates

gmercer08:06:16

I could take that the wrong way ... are you going to make a proper shadow-cljs only re-frame template :rolling_on_the_floor_laughing:

rberger20:06:49

I made a clj-new template for re-frame/shadow-cljs/deps.edn projects, might need its dependencies updated, but I’ve been using it https://github.com/omnyway-labs/re-frame-template

superstructor05:06:03

There is already an issue to improve the integration storey between shadow-cljs and re-frame-template @gmercer Please see https://github.com/day8/re-frame-template/issues/128#issuecomment-634414469 Busy working on some documentation related issues atm but will get to this at some point in the near future.

gmercer04:06:49

@U0G75S29H sounds great - looking forward to it

thheller08:06:20

I don't use re-frame so I won't create a template for it. thats a community thing, there are already plenty of templates that just use shadow-cljs directly without the whole lein-shadow setup

thheller08:06:04

its fine to run through lein if you like that setup

thheller08:06:13

a lot of people prefer deps.edn nowadays

gmercer08:06:42

I was just familiar with that template and using lein was fine, they added the shadow-cljs feature and I thought I would check it out .. I might see if I can find a pure shadow-cljs template ... didn't even think of that 😉

thheller08:06:41

the official re-frame-template is definitely the best maintained and has the most options though

gmercer08:06:09

even though they just plonked shadow-cljs on as an option, it should really cope with the other chosen options

gmercer08:06:08

PS I just read your clojure-verse discussion on shadow-cljs templating .. now I need to check out vue cli to see what you mean

thheller09:06:59

yeah the vue ui thing is great

thheller09:06:52

If I had infinite amount of time I'd write something like that 😛

Eliraz09:06:02

hey, is there an easy way to update all the deps to their latest version?

Eliraz09:06:07

so you have to check manually for each one?

thheller09:06:19

if you use project.clj or deps.edn then there are tools that handle that

thheller09:06:16

there is also something that supports shadow-cljs.edn but I can't remember the name

andrewboltachev13:06:42

Hello! I'm using shadow-cljs for web project. I have macros, which in the meantime should read from . With shadow-cljs, how do I configure the resources path?

aisamu13:06:41

Check the :source-paths key (or src if you're using deps.edn) https://shadow-cljs.github.io/docs/UsersGuide.html#source-paths

andrewboltachev13:06:49

Yes thanks. Only it's not :resource-paths

Eliraz13:06:40

Hey I have 2 build entries, how would I point a (second?) dev server to the other out dir?

:dev-http {8080 "target/"}
 :builds {:app {:output-dir "target/"
                :asset-path "."
                :target :browser
                :modules {:main {:init-fn }}
                :devtools {:after-load !
                           :preloads [devtools.preload]}}
          :devcards {:output-dir "devcards/"
            :asset-path "."
            :target :browser
            :modules {:main {:init-fn devcards.main/init}}
            :devtools {:after-load !
                       :preloads [devtools.preload]}}}

aisamu13:06:04

:dev-http {8080 ["target/"]
           8081 ["devcards/"]}

Eliraz13:06:39

Thank you !

🎉 4
andrewboltachev13:06:41

@aisamu that worked, thanks!

🎉 4
Eliraz13:06:17

should they have the same output directory?

aisamu13:06:02

You don't need a vector if you don't have multiple folders to serve

Eliraz13:06:49

thanks for the help

🎉 4
andrewboltachev13:06:23

✗ npx shadow-cljs browser-repl
<...>
cljs.user=> .1
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: :1:1
 Use of undeclared Var cljs.user/
--------------------------------------------------------------------------------
0.1
cljs.user=> 

andrewboltachev13:06:44

Having this error. Should this be a warning?

thheller14:06:59

you mean you have this warning but it should be an error?

Eliraz15:06:00

Hey, I'm struggling a bit with devcards, given the following:

(ns devcards.main
  (:require-macros
   [devcards.core :refer [defcard]])
  (:require [reagent.core :as r]
            [devcards.core :as dv]))

(def functional-compiler (r/create-compiler {:function-components true}))

(reagent.core/set-default-compiler! functional-compiler)

(defn hello-component []
  [:div "hello-world"])

(defcard hello
  (r/as-element [hello-component]))

(defn ^:export init [] (devcards.core/start-devcard-ui!))

(defn ^:export reload []
  (println "Refreshing Devcards!"))

Eliraz15:06:27

I get main.js:2232 TypeError: Cannot read property 'start_devcard_ui_BANG__STAR_' of undefined

Eliraz15:06:18

that means that devcards.core is undefined for some reason

Eliraz15:06:06

Am I missing something?

thheller16:06:38

I don't know. any other errors in the browser console?

Eliraz16:06:36

./cljs-runtime/shadow.module.main.append.js:4 An error occurred when calling (devcards.main/init)
eval @ ./cljs-runtime/shadow.module.main.append.js:4
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2229
(anonymous) @ main.js:2411
main.js:2231 An error occurred when loading shadow.module.main.append.js
env.evalLoad @ main.js:2231
(anonymous) @ main.js:2411
main.js:2232 TypeError: Cannot read property 'start_devcard_ui_BANG__STAR_' of undefined
    at Object.devcards$main$init [as init] (main.cljs:18)
    at eval (./cljs-runtime/shadow.module.main.append.js:4)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:836)
    at Object.env.evalLoad (main.js:2229)
    at main.js:2411

Eliraz16:06:43

these are all the errors

Eliraz16:06:12

it looks like it cannot find the devcards/core object or something like it

thheller16:06:43

any warnings during compile?

Eliraz16:06:52

[:devcards] Build failure:The required namespace "devcards-marked" is not available, it was required by "devcards/util/markdown.cljs".

Eliraz16:06:23

maybe it's due to my namespace? I named it devcards

thheller16:06:34

not unless there is a regular devcards.main in the package that you overwrote

thheller16:06:48

seems like the new version relies on some bundled marked dependency. shadow-cljs doesn't support foreign libs so that won't work

thheller16:06:05

you can probably set :js-options {:resolve {"devcards-marked" {:target :npm :require "marked"}}} to "correct" it

Eliraz16:06:17

in the edn file?

thheller16:06:36

in shadow-cljs.edn in your build config yes

Eliraz16:06:34

and I guess I'll need to install it via npm>

Felipe Marques17:06:42

Hello, I'm trying to run some tests using Karma

Felipe Marques17:06:55

But I keep getting shadow is not defined

Felipe Marques17:06:08

I followed the instructions here

thheller17:06:05

sounds like you didn't. this happens if the code produced by shadow-cljs isn't actually included in the code loaded by karma

thheller17:06:30

so make sure all the filenames match exactly

Felipe Marques17:06:48

yes, I saw this thread here in the history, the path seems right

thheller17:06:59

:output-to "target/ci.js" must match the

basePath: 'target',
        // The file itself
        files: ['ci.js'],

Felipe Marques17:06:03

it worked now, I think it was because I didn't add --single-run

rberger20:06:49

I made a clj-new template for re-frame/shadow-cljs/deps.edn projects, might need its dependencies updated, but I’ve been using it https://github.com/omnyway-labs/re-frame-template