This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-07
Channels
- # announcements (2)
- # babashka (18)
- # beginners (45)
- # bristol-clojurians (1)
- # calva (2)
- # cider (8)
- # clara (8)
- # clj-kondo (4)
- # cljdoc (6)
- # clojure (69)
- # clojure-chennai (1)
- # clojure-dev (21)
- # clojure-europe (3)
- # clojure-gamedev (3)
- # clojure-india (1)
- # clojure-italy (4)
- # clojure-nl (5)
- # clojure-norway (1)
- # clojure-spec (7)
- # clojure-uk (70)
- # clojurescript (122)
- # cloverage (5)
- # cursive (2)
- # data-science (3)
- # fulcro (21)
- # graalvm (3)
- # graphql (14)
- # jackdaw (2)
- # jobs (2)
- # lumo (2)
- # malli (1)
- # mount (1)
- # off-topic (22)
- # re-frame (2)
- # reitit (5)
- # ring (7)
- # shadow-cljs (47)
- # spacemacs (11)
- # tools-deps (127)
- # vim (16)
- # xtdb (9)
This is taken from an example app with aws amplify + shadow https://dev.to/royalaid/cljs-s-aws-amplify-4f25 src/app.cljs:
(:require ["@aws-amplify/api" :refer [graphqlOperation] :default API]
["@aws-amplify/pubsub" :default PubSub]
["/graphql/mutations" :refer [createTodo]]
["/graphql/queries" :refer [listTodos]]
["/graphql/subscriptions" :refer [onCreateTodo]]
["/aws-exports" :default awsconfig] ;; Important Diff, no period
[applied-science.js-interop :as j])
Local directory has src/graphql
generated and corresponding js files (queries, mutations). The following require throws an error:
The required JS dependency "/graphql/mutations" is not available, it was required by "app.cljs"
.
What am I missing?yes, i'm an experienced clojure engineer, but haven't used a mixed cljs/js project with shadow yet
I introduced another dependency and I have a REPL open. Is there any way to reload the dependencies without restarting the REPL? The only thing I found is (shadow/reload-deps!)
but it returns :shadow.cljs.devtools.api/standalone-only
and is doing nothing
I just ran npx shadow-cljs node-repl
from the terminal and received this message. It appears to indicate I need to install the ws module. This is all that's in my package.json
{
"name": "spec1-select",
"dependencies": {},
"devDependencies": {
"karma": "4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-cljs-test": "0.1.0",
"shadow-cljs": "2.8.83"
}
}
This does not exit the JVM. I have to ctrl+c which the results in this message getting printed continuously
cljs.user=> Failed to read: clojure.lang.ExceptionInfo: Input/output error {:type :reader-exception, :line 1, :column 1, :file "repl-input.cljs"}
That will only stop when I ctrl+c again.Adding "ws": "7.2.1" to my package.json fixes this. Seems strange that this is required.
Still ctrl+c'ing after adding the ws module results in continuous printing of that Failed to read message.
ws normally is a dependecy of shadow-cljs so it should be installed. not sure why it wouldn't be
the repl process doesn't really expect the node process to crash on startup so I guess it doesn't handle that correctly
I'm working on a browser extension (using {:target :chrome-extension}
) and trying to set up some functions in a user.cljc
file to help me switch between the REPLs hosted by the background and content scripts. I have the logic figured out (using (shadow/repl-runtime-select ...)
) , but the UX still isn't clean for a few reasons:
1. The base Clojure REPL loads shadow.user
instead of my user
ns
2. Shadow doesn't seem to load my user ns on initial compile into either the CLJ or CLJS REPLs (perhaps because nothing depends on it?)
Is there a way to configure Shadow to load my user ns automatically in all of the REPLs (the default Clojure behavior)?
Can I query the CLJS runtime from within? (similarly to the way shadow.cljs.devtools.api
works from the base Clojure REPL)
Thanks for the quick response, that mostly made it a lot better, but there's still an issue. Once I've switched into the CLJS REPL for the first time, when I try to run a fn from my user
ns, I get this error
(enter-content-script-repl)
no source by provide: user
{:provide user}
ExceptionInfo: no source by provide: user
shadow.build.data/get-source-id-by-provide (data.clj:184)
shadow.build.data/get-source-id-by-provide (data.clj:181)
shadow.build.data/get-source-by-provide (data.clj:187)
shadow.build.data/get-source-by-provide (data.clj:186)
shadow.cljs.repl/repl-compile/fn--14867/fn--14868 (repl.clj:453)
shadow.cljs.repl/repl-compile/fn--14867 (repl.clj:429)
shadow.cljs.repl/repl-compile (repl.clj:427)
shadow.cljs.repl/repl-compile (repl.clj:424)
shadow.cljs.repl/process-read-result (repl.clj:515)
shadow.cljs.repl/process-read-result (repl.clj:491)
shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:844)
shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:798)
shadow.cljs.devtools.server.worker.impl/eval15787/fn--15788 (impl.clj:879)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--15324/fn--15325/fn--15333 (util.clj:285)
shadow.cljs.devtools.server.util/server-thread/fn--15324/fn--15325 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--15324 (util.clj:257)
java.lang.Thread.run (Thread.java:830)
enter-content-script-repl
is a CLJC fn and has a CLJS portion that works fine once I manually load the ns.
you can maybe add :devtools {:preloads [the-repl-init-ns] :init-ns the-repl-init-ns}
Guess that is the latest release. Sometimes I have trouble keeping up, which is a good problem to have 🙂
The :preloads
trick worked. Everything's nice and clean now. Would you like me to file an issue that :repl-init-ns
should imply that the ns gets loaded?
Nevermind, found the existing. I'll pile on that one. https://github.com/thheller/shadow-cljs/issues/474
So I’m back again, trying to get my project to compile with shadow and then produce an uberjar. At some point running the uberjar
task, the payload built by shadow in target/cljsbuild
is being deleted. I’ve disabled :clean-targets
in my project file, but it’s still happening.
What’s the best way to have shadow build the app and put it in the right place for the uberjar task to find it and the app to serve it?
typically people use :output-dir "resources/public/js
so something like that in the shadow-cljs build config
and lein by default will package resources
into the uberjar (or configured via :resources-paths
)
The project is generated by luminus, so those defaults should apply.
Ok, so I’ll start looking at ‘resources’
so whenever things are served it would be /js/main.js
or whatever your files are named
as far as lein is concerned its just files in a dir. it doesn't need to know anything else about CLJS
That’s what I thought as well.
and as far as shadow-cljs is concerned its just writing files into a dir, it doesn't care about lein either
Maybe lein is running a clean before uberjar, and that’s what’s blowing away the js files.
Well, that was it. All I did was change ‘output-dir’ per your suggestion.
I didn’t explicitly.
just clean manually if you have to via rm -rf resources/public/js && shadow-cljs release app && lein uberjar
Will do!
Definitely not! lol