Fork me on GitHub

I’ve multiple node scripts file. Is it possible to define one build target instead for all of them?


My use case I don’t care about the final output of the script files. I just want to play with the scripts in a repl. And I’d like to define only one build target for all of the scripts.


Hmm :thinking_face: unless I’m misunderstanding, does specifying multiple build profiles to shadow-cljs not work for you? e.g. npx shadow-cljs watch :lib/dev :test 👆 this allows me to connect to a repl that allows me to play around in namespaces in both builds Though, my builds are of node-library targets and I’m using Calva to automate the repl-jack-in process


Are you just trying to avoid specifying multiple builds?


> Are you just trying to avoid specifying multiple builds? Yes.


I have several cljs files, and I just want to play with it.


I don’t care about the generated js files.


What’s the most suitable node target?


It would be desired that I am able to not specify the cljs file names in the build target.


Just specify your :source-paths e.g. ["dev" "src/cljc" "src/cljs"] and then you should be able to just specify a build with either :node-library or :node-script as the target. Doesn’t really matter, because you don’t care about the output file. Then, npx shadow-cljs watch :<your build name> which will start an nrepl you’ll be able to remotely connect to. Once your cljs files have finished compiling, you’ll also [probably need] to run node -e "require('<path to your output file>')" which will give your repl a Node environment to execute in

thanks3 1

For example, for taget :node-script, I have to specify the :main key, which points to a single script. Thus, for every script, I have to have a build target separately.


I feel like nbb might be more suitable here.


Hi @U022T96EFV3 Where you are developing your vscode extension, do you get any code completion support (assume you are using calva)?


@UGC0NEP4Y npx shadow-cljs node-repl just gives you a node REPL. not tied to any build, you can load any namespace you want in there?

thanks3 1
👆 1

> Hi @U022T96EFV3 Where you are developing your vscode extension, do you get any code completion support (assume you are using calva)? Yup, I do get code completion support from Calva!


Completion with node_module code or cljs code?


Oh! As far as I know, just cljs


Hi. I'm trying to build a cljs app targeting expo wrapped react-native with shadow-cljs. I was able to follow the instructions in the guide to stand up an app scaffold that renders a basic view on the phone using cljs and the Rum react wrapper, but I'm having trouble accessing some js dependencies I have installed. I added the "react-native-vision-camera" library with the expo install react-native-vision-camera command, and I've verified that the library was both added to the package.json and yarn.lock, and that there is a directory corresponding to that library within node_modules. I can't seem to require this library at all from cljs land though. I get null pointer errors during app startup when I try to add the dependency to the ns :require clause. When I also try to require it from the repl like this (require '["react-native-vision-camera" :as vision]), the vision object is nil always. I have also tried to install another dependency, "react-native-gifted-chat", in the same way to verify it wasn't something wrong with that particular dependency, and that also doesn't seem to work. I can require dependencies that were already in package.json after generating the app scaffold like "react" and "react-native" however, so I can load things in node_modules; it just doesn't seem like shadow has access to js/expo dependencies I have added after the fact. There must be something I'm missing about the dependency install process, and that there's more to do besides expo install react-native-vision-camera or yarn add react-native-vision-camera from the shell, but I can't seem to pinpoint what I've done wrong or what I'm missing from the guides. Does anyone have any hints on how to add an external js/react-native/expo dependency to a shadow app targeting react-native so that it can be accessed from cljs code?


@zonotope JS dependencies in a react-native REPL cannot be required dynamically in the REPL if they haven't been included in the build otherwise before. JS dependencies are processed by metro which only sees the regular build output not the REPL.


Thanks for your help, and sorry for the late reply, but I was focused on my day job for a bit there 😉. I think this has something to do with errors from the camera library that prevented the rest of the app from loading. Those errors are because this library must be natively built.


It looks like the only native compilation option here is expo's eas build tool. I'm running into another configuration issue there because eas generates an android working directory to compile for that platform with gradle, and it isn't copying over my app directory or app/index js where it should be relative to the android working directory.


error The resource `/tmp/zonotope/eas-build-local-nodejs/5e63e06b-13cb-49a3-a597-aa44d97d5090/build/android/app/index.js` was not found.


and i think i figured out that error at least. my app/ directory was in my .gitignore, and eas doesn't transfer any files in .gitignore. i'll bet there's a build hook i can add in to eas to generate the app directory with shadow instead of copying it, but i'll figure that out later since this works for now.


as part of the regular build it should be fine though


how did you require it in your code? and do you have an example of how you are supposed to include it in JS?

Tiago Dall'Oca16:05:47


   WARNING: shadow-cljs not installed in project.

any way to get rid of this warning?


npm install shadow-cljs?

Tiago Dall'Oca16:05:31

I just want the warning to go away

Tiago Dall'Oca16:05:39

there's really no need in my use case

Tiago Dall'Oca16:05:09

(multiple projects in a mono-repo with pnpm)


what do you mean? if you are using it it should be installed in the project?


not sure how that changes anything?

Tiago Dall'Oca16:05:21

because shadow-cljs is installed in the parent project

Tiago Dall'Oca16:05:33

doesn't need to be installed in the sub-project

Tiago Dall'Oca16:05:39

pnpm works differently

Tiago Dall'Oca16:05:51

it reuses node_module


not sure how that works


the reason it is warning is that the shadow-cljs dependency also brings in other stay that may be required. eg. for node builds ws or for browser build node-libs-browser


so if its not installed wherever it is running those may not be found

Tiago Dall'Oca16:05:33

is there a way to shut the warning?


not currently


too many people didn't install it in the project and kept asking questions why things fail 😛

Tiago Dall'Oca16:05:01

it's not a problem per se, just a bit annoying in my case


still don't understand what your setup is though. where do you control which shadow-cljs version is used?


I hope you are not relying on a global install?


all it is looking for is shadow-cljs installed in the package.json in the dir shadow-cljs is run in


it doesn't care at all about node_modules or pnpm?

Tiago Dall'Oca17:05:20

I installed it in the sub-project too

Tiago Dall'Oca17:05:25

no more warning 🙂

Tiago Dall'Oca17:05:34

thanks for your generosity


I pulled the example todo and have the shadow dev build running. It seems currently like I make changes, shadow updates it instant and then react native automatically refresh the app afterwards - and this auto refreshing I want to disable obviously


sorry I don't use react-native. don't know how you turn it off, but it needs to be turned off on the react-native/metro side. nothing in shadow-cljs can control this.


yea I'm sure there is a setting :thumbsup: