This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-14
Channels
- # announcements (9)
- # beginners (49)
- # calva (26)
- # cider (6)
- # clj-kondo (17)
- # cljsjs (1)
- # cljsrn (2)
- # clojure (72)
- # clojure-europe (5)
- # clojure-france (8)
- # clojure-greece (1)
- # clojure-italy (5)
- # clojure-nl (9)
- # clojure-spec (49)
- # clojure-uk (17)
- # clojuredesign-podcast (13)
- # clojurescript (137)
- # cursive (15)
- # data-science (1)
- # datomic (55)
- # duct (2)
- # emacs (5)
- # figwheel-main (11)
- # fulcro (11)
- # graphql (1)
- # hoplon (1)
- # instaparse (1)
- # jobs (12)
- # jobs-rus (1)
- # leiningen (1)
- # nrepl (34)
- # nyc (2)
- # off-topic (1)
- # onyx (1)
- # pedestal (1)
- # re-frame (6)
- # reitit (3)
- # remote-jobs (1)
- # shadow-cljs (196)
- # sim-testing (1)
- # spacemacs (9)
- # sql (1)
- # vim (70)
- # xtdb (31)
@bbss that kinda looks like you have a dependency conflict somewhere? which shadow-cljs version is this? looks like it might be kinda old?
I just updated the shadow-cljs to latest git version afaict, maybe it's a conflict, but this does run compile with lein +cljs profile.
it is not compatible. it does require compiling a few extra files which deps.edn
doesn't support
there are some .java
files that need to be compiled, which lein
does but deps.edn
doesn't
but you seem to have the correct CLJS version, so it probably just is an old shadow-cljs version? can't see which version that is. doesn't appear to be the latest since the souce doesn't match (ie. compiler.clj:881
isn't par-compile-cljs-sources
)
Getting
"Execution error (FileNotFoundException) at clojure.main/main (main.java:40).\nCould not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.\n"
Hello guys. I’ve started a new project with shadow-cljs and I’m trying to integrate shadow-cljs with leiningen, but getting this warning at the compile-time and it brakes the hot reload
shadow-cljs - running: lein with-profile +cljs run -m shadow.cljs.devtools.cli --npm watch app
[2019-10-14 11:03:20.312 - WARNING] provide conflict for #{minorodata.app.subs} provided by cljs/minorodata/app/subs.cljs and {"/minorodata/app/subs.cljs" #{minorodata.app.subs}}
[2019-10-14 11:03:20.314 - WARNING] provide conflict for #{minorodata.app.db} provided by cljs/minorodata/app/db.cljs and {"/minorodata/app/db.cljs" #{minorodata.app.db}}
[2019-10-14 11:03:20.314 - WARNING] provide conflict for #{minorodata.app.events} provided by cljs/minorodata/app/events.cljs and {"/minorodata/app/events.cljs" #{minorodata.app.events}}
[2019-10-14 11:03:20.315 - WARNING] provide conflict for #{minorodata.app.router} provided by cljs/minorodata/app/router.cljs and {"/minorodata/app/router.cljs" #{minorodata.app.router}}
[2019-10-14 11:03:20.315 - WARNING] provide conflict for #{minorodata.core} provided by cljs/minorodata/core.cljs and {"/minorodata/core.cljs" #{minorodata.core}}
@sergey.tkachenko looks like you might have you :source-paths
configured badly? maybe :source-paths ["src" "src/cljs"]
?
and do you have an extra :source-paths
outside :profiles
? otherwise I believe it defaults to :source-paths ["src"]
?
I'm extending some es6 classes that's now giving me trouble:
[:main] Compiling ...
[:main] Build failure:
Closure compilation failed with 10 errors
--- main/gsv/ui/HighPitchMapController.js:1
Requested module does not have an export "clamp".
--- main/gsv/ui/HighPitchMapController.js:2
Requested module does not have an export "Controller".
--- main/gsv/ui/HighPitchMapController.js:3
Requested module does not have an export "WebMercatorViewport".
--- main/gsv/ui/HighPitchMapController.js:3
Requested module does not have an export "normalizeViewportProps".
--- main/gsv/ui/HighPitchMapController.js:4
Requested module does not have an export "LinearInterpolator".
--- remaining errors ommitted ...
therefore you must resolve conflicts. deps resolves conflicts differently than lein does
so check how they resolved and sort out the differences. most likely a different closure-compiler verison being used
so the issue with JS interop currently is that the closure compiler ONLY accepts "strict" interop
for a while the closure compiler (like webpack) allowed a non-strict variant where this still worked
so the only way to do this now would be import X from "something"
and then X.Controller
it is a bit annoying that it works that way but we are kinda at the mercy of the closure compiler
but webpack is going to be strict-only with v5 also so that'll make things "better" I hope
Okay, this is useful information for me, I am looking to extend that library from cljs, and was kinda hoping I could just magically use shadow-cljs. But in case that won't work out I'll need to understand more about the module importing. So far usually I can get by with js-options resolve.
now it is a breaking change for most JS code out there since babel/webpack at first added a "compatibility" mode that can't actually work if you follow the spec
can you tell me why you are trying to use a git checkout of shadow-cljs in the first place?
I always feel a bit scared when adding an npm dependency, so I hope they figure out something out wrt a spec that will work for everyone, also still having weird issues with aws-amplify for example, thankfully after digging around their code-base and trying several js-options resolve things that worked out eventually.
A while back (months) I needed a fix you had just pushed so that's why I tried to build from a fresh git pull.
Ah well it's a :browser build. but I needed
:js-options {:resolve {"util" {:target :npm
:require "./util"}
"querystring" {:target :npm
:require "query-string"}}}
you need to install npm install shadow-cljs
in your project so that it brings in the node-libs-browser
package. which provides browser polyfills for util
as well as querystring
I think that was what "fixed" it at the time. But admittedly I just use amplify publish for pushing my front-end now, and haven't wanted to touch that code for updating. Ah, that makes sense! I'll try that 🙂
if installing shadow-cljs
in the project doesn't fix it then you may just have a dependency conflict on the npm side
Hi! I’m a member of that crowd who loves clojure/script, but has struggled with tooling every time I’ve tried to start a project. I’m going to try again! With shadow-cljs of course.
1) Is there any reason to configure a project as full stack (server + client in one project) versus having two distinct projects? and
2) Is there any particular reason beyond personal taste to use clojure on the server versus using nodejs? I never considered nodejs as a possibility until I started reading shadow-cljs docs, but the unanswered question for me are the advantages to that approach.
@credulous if you want to share code between client/server it can make it easier if you just have one project. still can use 2 different tools though, lein for CLJ and shadow-cljs for CLJS for example
2) I would never personally write anything in node.js if using clojure is also an option
node is just a horrible platform to build one, clojure on the JVM is soooo much better it doesn't even compare 😛
OK! Enough of the shadow-cljs docs are given over to nodejs integration that I wondered if I was missing out on something.
Very helpful, thanks. I think I’ll do two projects because in retrospect a lot of my difficulties have been in having two repls going in one editor, etc. and I’ve never been that bothered by code sharing between server and client.
@sandbags If you post your question here, I'm sure someone can help you. What is the syntax you are trying to use for js?
Okay it looks like I may have answered my own problem in trying to write it up. However it throws up a question, what worked for including a 3rd party JS file was (:require ["jstest" :as jstest])
however none of js/jstest
, src/js/jstest
or /src/js/jstest
with or without a ".js" extension worked. From my reading of the docs I thought it should be prefixed by 'src/js/` as this is the folder the .js file is in within my project. If anyone can tell me what I missed I'd be grateful. Thanks (and thanks @isak for suggesting i post here because I had to re-try several things to write up what I had done so far and then thought to try with no path!)
Actually I say it worked, the lein dev
compilation phase is not erroring out anymore about the dependency, Cursive is still not resolving it. But maybe it can't from where it lives. Yep, I can find my code in the app.js file. Looks good from here.
Hey! I have problem with what I think is the combination of shadow-cljs
and ptaoussanis's Sente
. Using re-frames lein template to generate a new project with: lein new re-frame re-learn +10x +cider +handler +re-com
. Have a minimal app where I want to send a message back and forth between client and server. But i get failed: Error during WebSocket handshake: Unexpected response code: 500
and ERROR [taoensso.sente:1058] - WebSocket error: [object Event]
all the time. Have used Sente with lein and figwheel before without any hassle. Anyone got an idea?
@sandbags not exactly sure what your question is. there are two different kinds of ways shadow-cljs can include JS. there is npm and then there is the classpath. in case of the classpath prefixing with src/js
is exactly the wrong thing to do. I tried explaining the classpath https://shadow-cljs.github.io/docs/UsersGuide.html#_the_classpath and https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js
in short if you have a src/js/jstest.js
file then :source-paths
needs to include src/js
and you include the file via /jstest.js
@jherrlin do you connect to the correct websocket server? and what does your "handler" look like?
@thheller The handler looks like this:
(def dev-handler (-> #'routes
wrap-reload
ring.middleware.keyword-params/wrap-keyword-params
ring.middleware.params/wrap-params
(ring.middleware.defaults/wrap-defaults
ring.middleware.defaults/site-defaults)
))
It looks to me like the ws request is to the correct host and port.
The project in all its glory is here: https://github.com/jherrlin/sente-example
the generated template starts the server on :3000 so it looks like :8280 is the shadow-cljs http server?
https://github.com/jherrlin/sente-example/blob/master/src/clj/shadow_sente/server.clj
https://github.com/ptaoussanis/sente#getting-started seems like it might support other servers as well
yeah, it got for some other servers to, but i have used http-kit before and that worked good
@thheller had to leave the computer. Will respond when I am back. Thanks for responding!
Hi guys, I ran into this issue when running shadow-cljs watch app
? This seems to be caused by code signing requirement enforced by OSX catalina (root cause seems to be the dynamically loaded https://github.com/gjoseph/BarbaryWatchService). I suspect this might cause issues with figwheel as well.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /private/var/folders/r3/hf3d1qyj6d707240ymkh2yx40000gn/T/jna7357045320253869696.tmp: dlopen(/private/var/folders/r3/hf3d1qyj6d707240ymkh2yx40000gn/T/jna7357045320253869696.tmp, 1): no suitable image found. Did find:
/private/var/folders/r3/hf3d1qyj6d707240ymkh2yx40000gn/T/jna7357045320253869696.tmp: code signature in (/private/var/folders/r3/hf3d1qyj6d707240ymkh2yx40000gn/T/jna7357045320253869696.tmp) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
Has anyone faced the same issue ?@sathya no clue what that is. you can turn off using that watcher via :fs-watch {:hawk false}
. It'll use the default JVM watcher then
seems like that might be a problem for all catalina installs. hawk
or the underlying BarbaryWatchService is only used on macOS because the default JVM file watch is kinda slow and has a 2sec delay which bothered people
https://github.com/wkf/hawk thats the alternate watcher
great, thanks. I think i have to make do with the polling watcher for now (great perk for upgrading this soon ;)). I figured the config actually needs to be :fs-watch {:watcher :polling}
.
:thinking_face: i’m about to upgrade to catalina. hopefully this doesn’t hit hot reload perf too bad
:polling
is basically telling hawk to use the JVM watcher ... which is kinda the same as not using hawk in the first place
> :fs-watch {:hawk false}
didn't work?
Just realised that I had downgraded to shadow-cljs 2.6.0 to test something.
:fs-watch {:hawk false}
works with 2.8.64
, but not with 2.6.0
:fs-watch {:watcher :polling}
works with both versions 🙂
@thheller hrmm… this is puzzling. I assume by :source-paths
you are talking about project.clj
rather than shadow-cljs.edn
. My :source-paths
doesn't include src/js
, only src/clj
and src/cljs
, perhaps I missed an instruction or implied good practice there. However I can reference the files using :js-options :resolve
and (:require ["foo" :as foo])
(where my JS file is src/js/foo.js
). From what you are saying it seems what I've done shouldn't work, or is only working accidentally perhaps.
It's been a long time since i did any CLJS and the last time was using Figwheel so I am trying to catch up with all the changes
Okay so I did read this before, but perhaps not as closely. I have amended my shadow-cljs.edn
as you indicated, removing js-options
and adding a source-paths
including ['src/js']
(I think my confusion here was that using the re-frame template doesn't include source-paths). However every variant of the :require
statement I tried ("/jstest", "/jstest.js", "jstest", "jstest.js") gets "The required JS dependency "jstest" is not available". The file in question is src/js/jstest.js
.
then :source-paths
in shadow-cljs.edn
have no effect whatsoever. lein
is in charge of managing them, so you need to adjust it there
in project.clj: :source-paths ["src/clj" "src/cljs" "src/js"] the file is src/js/jstest.js
so then (:require ["/jstest.js" :as x])
should do it (with no additional config in :js-options
at all)
(i had but had been messing about with variants so didn't have the "/" at the beginning any more)
Hi. As I understand I can use :handler inside of dev-http to provide my own request handling. Is there a way for me to add some jvm deps that I could use inside of the handler?
Ah, ok I've found :deps
Thank you 🙂
your production setup won't run inside shadow-cljs either so your dev stuff shouldn't either
This is private app running on my local machine
So shadowcljs will be running on production 🙂
And the server part will be fairly minimal and stable
I’m getting a strange error under advanced optimizations that’s fixed when I enable pretty-print
and psuedo-names
could also be another conflict with in case you are using other JS on the page or creating globals manually
if you don't have externs for that than its ga
global will clash with one of the variables the CLJS outputs creates
I should probably make it the default always and let people disable it in case they want to optimize