This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-29
Channels
- # announcements (3)
- # babashka (47)
- # beginners (88)
- # calva (17)
- # clj-kondo (8)
- # cljdoc (1)
- # clojars (9)
- # clojure (98)
- # clojure-europe (53)
- # clojure-norway (2)
- # clojure-seattle (1)
- # clojure-uk (5)
- # clojurescript (20)
- # cursive (11)
- # data-oriented-programming (1)
- # data-science (3)
- # datahike (1)
- # datascript (3)
- # events (3)
- # graalvm (5)
- # honeysql (7)
- # hyperfiddle (1)
- # jobs-discuss (10)
- # leiningen (3)
- # malli (16)
- # music (4)
- # nbb (17)
- # off-topic (45)
- # pathom (9)
- # portal (7)
- # releases (1)
- # shadow-cljs (80)
- # sql (15)
- # tools-build (5)
- # xtdb (23)
Firstly thanks for a great product! 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. I thought maybe it was an ecma issue and tried react-native-logs$default
, tried :as
instead, but nothing worked. I got AssertionError Assert failed: (rc/valid-resource? rc)
errors in the shadow-cljs
console :thinking_face:. However it all worked perfectly if I used it from within the :app
main namespace, or even required
the new namespace from a linked one ❗ Obviously very unlike a Clojure REPL experience. I was wondering if it would be possible to give a hint in this scenarios so others don't suffer the hours it took me 😅
that is because the code needs to be processed by the react-native metro build tool and it cannot see what you do at the REPL
Can shadow not see this attempt and warn the user?
I thought it did https://github.com/thheller/shadow-cljs/blob/fd7360dd334119283242eb85340ed04aa16310ac/src/main/shadow/boot/react-native.js#L40
but I don't use react-native myself so maybe that check just does nothing and it blows up in other ways
I mean what is AssertionError Assert failed: (rc/valid-resource? rc)
and in which context did you get it?
so far nobody has opened an issue about this so I assume everything is fine in react-native land 😉
[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)
Damn, I just realised I upgrade recently by changing the shadow dependency and not yarning the shadow upgrade 😬
you can also set :version "2.19.8"
in shadow-cljs edn if you want to be less reliant on npm/yarn stuff
Oh, that's what I did, but in the edn file.
deps.edn
shadow-cljs - server version: 2.19.8 running at
well, yes with deps.edn the version is managed in deps.edn and package.json version doesn't really matter for compilation
😅 yes get that error in that version... but before upgrading from 2.11.7
I got a little more out of the stacktrace:
"react-native-logs" - failed: simple-symbol? in: [:requires 3] at: [:requires] spec: :shadow.build.resource/require
Cool, I thought best here before opening an issue.
Oh, is it relevant that I'm using cider-nrepl
as well?
Errors encountered while trying to parse file
/home/tianshu/workspace/race-poker/racepoker-dapp/node_modules/lower-case/dist/index.js
{:line 13, :column 13, :message "Character '̇' (U+0307) is not a valid identifier start char"}
Got some errors, the JS file is
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.lowerCase = exports.localeLowerCase = void 0;
/**
* Source:
*/
var SUPPORTED_LOCALE = {
tr: {
regexp: /\u0130|\u0049|\u0049\u0307/g,
map: {
İ: "\u0069",
I: "\u0131",
İ: "\u0069",
},
},
...
The reason could be shadow-cljs has its own identifier rules?no, that is a known error in the closure compiler. unfortunately nothing I can do about it
don't know what that means. be careful when changing that file. you might leave invalid characters due to the non-visible unicode stuff
I just commented them. When the compiling can't complete, how can I investigate what's going on?
what do you mean by "can't complete"? I can't see your screen so I cannot guess what you are doing
if you use something like cider the error might be in some other hidden buffer or something
I recommend running shadow-cljs in the terminal somewhere to ensure you see all output
maybe a have a similar cause? ie. changing the package folder name but not the package.json name?
suppose you created a node_modules/my-lower-case
and just copied the original package.json
file there
I'm sure it's caused by some packages, but I don't know which one it is. Because I introduce one package which bring me a lot dependencies
I can understand this code here, but it doesn't give me anything in the inspector. Nor it does with print
instead of tap>
.
shadow.user=> (alter-var-root #'shadow.build.npm/find-resource-in-package
(fn [orig]
(fn [npm package require-from rel-require]
(try
(orig npm package require-from rel-require)
(catch Exception e
(tap> [:what rel-require package require-from])
(throw e))))))
#object[shadow.user$eval25371$fn__25372$fn__25373 0xead9010e "shadow.user$eval25371$fn__25372$fn__25373@ead9010e"]
shadow.user=> (shadow/compile :app)
[:app] Compiling ...
Execution error (AssertionError) at shadow.build.npm/find-resource-in-package (npm.clj:686).
Assert failed: (str/starts-with? rel-require "./")
shadow.user=> (alter-var-root #'shadow.build.npm/find-resource-in-package
(fn [orig]
(fn [npm package require-from rel-require]
(try
(orig npm package require-from rel-require)
(catch Exception e
(println [:what rel-require package require-from])
(throw e))))))
#object[shadow.user$eval25784$fn__25785$fn__25786 0xa9377baa "shadow.user$eval25784$fn__25785$fn__25786@a9377baa"]
shadow.user=> (shadow/compile :app)
[:app] Compiling ...
Execution error (AssertionError) at shadow.build.npm/find-resource-in-package (npm.clj:686).
Assert failed: (str/starts-with? rel-require "./")
I print the package before call the orig
. But it shows me a package I used to have it in my project.