Fork me on GitHub
#reagent
<
2021-08-22
>
Chris Bidler14:08:09

I have a confusing (to me) issue upgrading to 1.1.0 and I am wondering if maybe yarn is the culprit? Adding [reagent "1.1.0"] to the shadow-cljs.edn of a React Native project, where I already have (and just re-verified that yes, I do have) both react and react-dom in my package.json and present in node_modules, I get this in response to npx shadow-cljs watch app:

shadow-cljs - connected to server
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
The required namespace "react" is not available, it was required by "reagent/core.cljs".

p-himik14:08:58

Just in case - check if you have an old version of shadow-cljs.

Chris Bidler15:08:53

Should be 2.15.3 but I can try updating to 2.15.5 since that seems to be the very latest

p-himik15:08:41

Yeah, I use 2.15.2 just fine with Reagent 1.1.0, although not in a React Native setup. I would also try deleting everything that's cached - node_modules and .shadow-cljs - and trying to install all NPM packages and run the build again.

Chris Bidler15:08:21

Well, thank you for pointing out .shadow-cljs as another place to hit in the all-too-frequent “glass the project and build again” action

Chris Bidler15:08:39

all-too-frequent in RN projects anyhow ^_^;;

Chris Bidler15:08:47

No change in behavior but I will continue to investigate - this question was hoping to shake loose a “oh yeah you have to thing one time after adding 1.1.0, did you try that?”

thheller15:08:29

nothing to add and nothing has changed regard this in shadow-cljs since forever

thheller15:08:56

are you in the correct directories?

thheller15:08:14

ie. <project>/shadow-cljs.edn + <project>/node_modules/react/package.json?

thheller15:08:27

or do you use :js-packages-dirs in the build config?

Chris Bidler15:08:28

I am in the correct directories, I do not use :js-packages-dirs

Chris Bidler15:08:38

I really, truly appreciate your taking the time to come look at this - I’m sure this is something in the guts of my project, which is a quite old RN project that is finally getting a five-year refit from ExpoKit/SDK33/Boot-based config and dev to modern RN, Expo bare workflow, and shadow-cljs

Chris Bidler15:08:22

The process has been more or less a delight to this point, it would be difficult to overstate the just-works-ness of shadow in this complex context

thheller16:08:28

and the node_modules/react directory actually has the files? ie. not an empty dir or link or so?

Chris Bidler16:08:29

ls  -l node_modules/react/
total 56
-rw-r--r--   1 chris  staff  1086 Aug 18 06:59 LICENSE
-rw-r--r--   1 chris  staff   737 Aug 18 06:59 README.md
-rw-r--r--   1 chris  staff   163 Aug 18 06:59 build-info.json
drwxr-xr-x  10 chris  staff   320 Aug 22 11:20 cjs
-rw-r--r--   1 chris  staff   190 Aug 18 06:59 index.js
-rw-r--r--   1 chris  staff   222 Aug 18 06:59 jsx-dev-runtime.js
-rw-r--r--   1 chris  staff   214 Aug 18 06:59 jsx-runtime.js
drwxr-xr-x   3 chris  staff    96 Aug 22 11:20 node_modules
-rw-r--r--   1 chris  staff   777 Aug 18 06:59 package.json
drwxr-xr-x   5 chris  staff   160 Aug 22 11:20 umd

Chris Bidler16:08:33

It would so appear

thheller16:08:40

did you restart shadow-cljs at some point? it sometimes get confused when you run npm install while its running

Chris Bidler16:08:28

Is there anything akin to yarn list available to me without having to generate a project.xml and using lein dependencies:tree or similar? My suspicion is that re-frame (upon which this project also depends) is causing Transitive Badness but I’m not sure how to prove it

Chris Bidler16:08:54

I did - my usual process when changing anything about deps in this project (which I’ve been running for ~4 years) is to glass it and start fresh, so npx shadow-cljs stop; rm -fr node_modules ios/Pods; yarn; cd ios && npx pod install; cd .. && npx shadow-cljs start

Chris Bidler16:08:43

and now thanks to @U2FRKM4TW also rm -fr .shadow-cljs which I didn’t realize was similarly a candidate for nuking-from-orbit

Chris Bidler16:08:53

If I remove the dependency on reagent-1.1.0, the app builds and runs but then crashes in a very telemetry-free way that points only to something called reagent2 not supporting the Name attribute

Chris Bidler16:08:56

so I was hoping to try out reagent 1.1.0 and see if that error was different or instrumented better but I’m stuck on this problem which I agree appears like it “should not happen”

p-himik16:08:43

There's npm list, not sure about yarn. Also not sure about shadow-cljs - I always use it together with deps.edn, so just clj -A:alias1:alias2 -Stree works just fine for me.

Chris Bidler16:08:35

yarn also has list but that’s not the deps for the JVM dependencies in shadow-cljs.edn, and I don’t have a deps.edn added, though I suppose that would be lower-effort than getting lein or boot involved

thheller17:08:39

it doesn't matter where you list your JVM dependencies really. the error you get is not related to JVM dependencies, its a npm dependency thats somehow not found

thheller17:08:43

just as a sanity check try http://localhost:9630/api/project-info in your browser

thheller17:08:01

make sure its the correct project home dir?

thheller17:08:17

its transit encoded JSON but easy enough to decipher

Chris Bidler17:08:16

well, I am not proud to admit this but I’m guessing the error was that I did indeed have a :js-package-dirs in my app alias

Chris Bidler17:08:24

I will know in a moment if the build behavior differs with that gone.

Chris Bidler17:08:22

I wonder how this project was running at all with an explicit reference to a non-existent directory for node_modules all these last few days of upgrading/refactoring/etc.

thheller17:08:50

app alias? you mean build config?

Chris Bidler17:08:54

Yes, the build config for :app had a :js-requires in it because I overzealously copy/pasted from your react-native-reagent project and didn’t notice that line o r its significance

Chris Bidler17:08:46

In my defense it was about 1am and I had been fighting with other problems for many hours already.

Chris Bidler17:08:06

Apologies for the noise, thank you again for your generosity with time and expertise

Chris Bidler17:08:34

…and just to provide closure, with that :js-requires removed from :app, I can in fact build and run with reagent 1.1.0. 😅

👍 4