Fork me on GitHub

I would like to write a library using shadow-cljs (with npm dependencies) and use it from another shadow-cljs app, I can work out how does the app consume the npm dependencies of the library? There was stuff in the docs about deps.cljs but I could not get that to work and I am not sure if that is what I need?


@sofra A library can provide transitive npm deps to a dependent project by putting a deps.cljs on the classpath containing {:npm-deps {"name" "version"}} . Reagent has an example:


thanks! So does the dependant project then need to also include its own package.json to provide the dependancy?


No. shadow-cljs will inject these into the dependent project's package.json via npm install --save --save-exact ...


hi , where should I look if I want to add support for



yes this helps for sure, thanks


ok i found why


@andre :warnings are nested in :sources which is a sequence of maps


@andre I don't understand the question?

Andy Heywood16:05:12

Hey folks - 100% sure this has been answered somewhere, but I can’t find it. Is there an issue with spec generation in shadow specifically even after I’ve manually included org.clojure/test.check ?

Andy Heywood16:05:31

(which seems to be the working solution for regular cljs)

Andy Heywood16:05:17

found a slack log from a couple of years ago of @thheller discussing the weirdness of it not working

Andy Heywood16:05:47

I’m getting: Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required

Wilson Velez16:05:56

I had the same error last week, the way I solved was requiring clojure.test.check.generators

Andy Heywood16:05:49

ha. that’s embarrassing 😄

Andy Heywood16:05:34

think I switched from one error message to a different one after including test.check and didn’t pay attention - thanks!

Wilson Velez16:05:00

sure, no problem!

Wilson Velez16:05:59

Is there a way of excluding a file when doing the release of the app? I have a cljs file that it’s used only during developtment with some objects and data that I want to exclude when making the final js

Andy Heywood16:05:54

what target? I can’t see anything included in my output for a node-library that’s not referenced by an extern

Andy Heywood16:05:21

i.e. any namespace that’s required by code that’s ultimately extern’d will end up in the output, but if it’s not referenced, it shouldn’t appear

Wilson Velez17:05:41

is for the browser, I have a file with an initial json, used to initialize the state of my re-frame app, this is only for development, because in production the json is provided by the page that loads the clojurescript app

Wilson Velez17:05:12

but when I release my app the data structure I use in develop is in the final js file, so I want to exclude it


@wvelezva would help to see some code. I don't quite understand your setup but build-hooks are likely not the solution.


you can use (def stock-data (delay {... instead of (def stock-data {...)

Wilson Velez19:05:42

I think it doesn’t work, there are some files that I didn’t include


and @data/stock-data in the init


that should allow :advanced to remove the data entirely


but I don't get why you have that data as part of your code


why not go with what release does and pass it into dev in development too

Wilson Velez19:05:37

the data in dev is a subset of what a user get in production


that isn't really relevant


you can just pass in the data you have in the example-data now

Wilson Velez19:05:13

sorry, I don’t understand 😕

Wilson Velez19:05:18

you mean pass in the data where? in the html?


however you do it in release?

Wilson Velez19:05:07

in release I do nothing, the js is used in an html that provide a js structure with all the data

Wilson Velez19:05:57

so there is an “external” app that provides the input to initialize the js


I'm sorry but I really don't quite understand your issue


why not just pass in the sample data from there too?


why does that have to be part of the CLJS code when the release version doesn't do that?

Wilson Velez19:05:32

I had it that way, I wanted to arrive here….

Wilson Velez19:05:12

now, I want to use the same structure in the tests, and I didn’t know how to feed my tests without replicating the data

Wilson Velez19:05:28

I want to use the same src of data


you can put the data into a :preloads and and have that initilialize it


really there are many options ... if you try with the delay you maybe can just leave things as they are


as :advanced should be able to remove the example data

Wilson Velez19:05:04

I read that there is experimental support for loading js file with shadow, so I also thought about create a js which I can include in the index.html and in the test.cljs

Wilson Velez20:05:19

I’m talking about using this in my tests to load the same data that I can use in the index,html of my dev setup


thats no different than what you have now, except that it loads JS files instead of CLJS


but also can't be conditional in any way

Wilson Velez20:05:22

How should I declare an object in the included js file in order to used in the cljs file?

Wilson Velez20:05:49

var testScores = [                                        
    { id: 1, score: 86, gradeLetter: "B" },               
    { id: 2, score: 93, gradeLetter: "A" },
    { id: 3, score: 78, gradeLetter: "C" }
I have this js array


export let testScores = { ... };


(:require ["./the-file.js" :as x]) x/testScores