Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React native NPM dependencies fail to load obscurely in the REPL if not on the main code path #1041

Open
dmg46664 opened this issue Jul 29, 2022 · 0 comments

Comments

@dmg46664
Copy link

dmg46664 commented Jul 29, 2022

From https://clojurians.slack.com/archives/C6N245JGG/p1659098445064339

So I wanted to experiment with adding NPM lib react-native-logs to my react-native shadow-cljs project, so I :

  • yarn'd it, created a new namespace
  • and added ["react-native-logs" :refer [logger]]

but nothing I did could get logger to appear in the REPL (loading file or namespace) in a way that made sense.
This is expected ✅ apparently given the way Metro works. It all worked perfectly if I used it from within the :app main namespace, or even required the new namespace from a linked one.

The stacktrace you do get is

[2022-07-29 13:08:26.165 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-compile, :input {:code "(cljs.core/load-file \"/Users/dmg46664/projects/samson/src/main/dimigi/network.cljs\")", :ns user, :repl true}, :include-init false, :call-id 5, :from 3}}
AssertionError Assert failed: (rc/valid-resource? rc)
	shadow.build.data/add-source (data.clj:220)
	shadow.build.data/add-source (data.clj:220)
	shadow.cljs.repl/repl-ns (repl.clj:325)
	shadow.cljs.repl/repl-ns (repl.clj:319)
	shadow.cljs.repl/process-read-result (repl.clj:504)
	shadow.cljs.repl/process-read-result (repl.clj:484)
	shadow.cljs.repl/process-input (repl.clj:647)
	shadow.cljs.repl/process-input (repl.clj:625)
	shadow.cljs.repl/repl-load-file* (repl.clj:281)
	shadow.cljs.repl/repl-load-file* (repl.clj:259)
	shadow.cljs.repl/repl-load-file (repl.clj:317)
	shadow.cljs.repl/repl-load-file (repl.clj:315)

The issue being reported is cosmetic because it's not obvious to the user why the error is occurring and very unlike a Clojure ™️ REPL experience. If shadow-cljs could hint in this scenarios so others don't suffer the hours it took me 😅

Some relevant versions:

thheller/shadow-cljs      {:mvn/version "2.19.8"}
cider/cider-nrepl {:mvn/version "0.28.5"}

    "react": "17.0.2",
    "react-dom": "^17.0.2",
    "react-native": "^0.67.4",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant