This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-21
Channels
- # announcements (3)
- # aws (11)
- # babashka (5)
- # beginners (116)
- # cider (30)
- # clara (1)
- # clj-kondo (15)
- # clojure (17)
- # clojure-dev (9)
- # clojure-europe (2)
- # clojure-italy (1)
- # clojure-uk (3)
- # clojurescript (9)
- # conjure (3)
- # duct (22)
- # exercism (1)
- # fulcro (8)
- # graalvm (5)
- # graphql (3)
- # helix (3)
- # joker (3)
- # kaocha (2)
- # off-topic (9)
- # pathom (4)
- # re-frame (1)
- # rum (6)
- # shadow-cljs (81)
- # sql (6)
- # xtdb (9)
@currentoor forgot to ask which version you use? the ping behavior was definitely buggy in earler 2.10.x versions. make sure you are on 2.10.12
@thheller I'm on 2.10.12
i was able to open the UI, however i came into my office, which is a different network, and now it's working very robustly
thanks for considering though
strange that this only happens • on android device (android emulator and iOS device worked fine) • connected over lan • at my home network (office works) • for the shadow WS (my app's WS using sente works)
very mysterious but im just glad it's working now
@rberger what does the browser console say? does it not actually rebuild anything? do you maybe have the file in a resources
folder?
Still having this issue that changes in the JS file does not trigger shadow in watch mode to rebuild.
The Browser Console, the shell terminal running shadow-cljs -A:dev watch app
,
nor the webpage itself show any indication that a rebuild happens. The JS file
is not in resources (other than the compiled output).
I wasn’t quite sure what was meant in the guide (https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js)
by:
> The files must not be physically located in the same directory. The lookup for the file appears on the classpath instead. This is unlike node which expects relative requires to always resolve to physical files.
So I tried all the permutations I could think of and none of them would trigger
shadow-cljs watch to rebuild. Updating any CLJS file did as normal.
Here is what I tried:
1. With the JS file in the same source tree (but not directory) as the cljs file requiring the JS file:
deps.edn :path ["src"]
(ns visx.dashboard.antmedia
(:require
["/visx/dashboard/antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
or
(ns visx.dashboard.antmedia
(:require
["./antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
with the file layout:
├── package.json
├── shadow-cljs.edn
└── src
└── visx
└── dashboard
└── antmedia.cljs
|__ antmedia
|__ webrtc_adapter.js
2. Or when the JS file is a different directory tree under src:
(ns visx.dashboard.antmedia
(:require
["/js/dashboard/antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
├── package.json
├── shadow-cljs.edn
└── src
└── visx
└── dashboard
└── antmedia.cljs
|__ antmedia
└── js
└── dashboard
└── antmedia
|__ webrtc-adapter.js
3. Or when the JS is in a different tree but matching class path with updated :path
:
deps.edn: :path ["src/js" "src/cljs"]
(ns visx.dashboard.antmedia
(:require
["/visx/dashboard/antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
or
(ns visx.dashboard.antmedia
(:require
["./antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
├── package.json
├── shadow-cljs.edn
└── src
[__ cljs
└── visx
└── dashboard
└── antmedia.cljs
|__ antmedia
└── js
|__ visx
└── dashboard
└── antmedia
|__ webrtc-adapter.js
it doesn't really matter where the file is. just put it into the same directory you are including it from. all this classpath juggling isn't useful or required
I tried using shadow-cljs on a fresh Windows install today. I "installed clojure" using their new powershell script, and npm and GraalVM using Chocolatey (JAVA_HOME is set, and java is on the path; running clj
works as expected). I did an npm install
in my project and ran clj once so all dependencies are present. Then I tried to run npx shadow-cljs
, but only get the error that the system can't find the path. What could that be?
Find the path of what?
Yea no idea. That is all powershell tells me. "The system couldn't find the specified path".
I am sorry, I don't have a lot of experience with powershell. What could you try is to execute shadow-cljs directly by specifying the full path directly in powershell. I would recommend trying bash though 🙂
yes, and just calling npx on its own shows the normal help text with the possible flags of npx
npx shadow-cljs watch app
suddenly doesn't recompile or reload my code when I save my soruces. I'm not sure what have changed. it might have been cosmic radiation.
On the other hand, changes to shadow-cljs.edn are being watched correctly.
Any idea how to debug this?
what is the relationship between the nREPL and the different JS contents of a chrome extension such as bg script and content scripts?
@thheller With latest 2.10.12 I find a bug: each time I eval the ns form for a file, the functions defined in that ns is lost, calling them in the REPL results in errors like
------ WARNING - :undeclared-var -----------------------------------------------
Resource: <eval>:1:2
Use of undeclared Var my.ns/f1
@wxitb2017 (ns my.ns)
always just declares that ns. you need to (require 'my.ns) (in-ns 'my.ns)
if you want to load and switch? that has always been that way though.
@thheller nope, for a better example, take this ns as an example
// project/lib.js
(ns project.lib)
(defn f1 [])
So this ns has a f1
var. But if I eval the ns form again, and try to catch f1
, it would throw the error I pasted above.this is not a better example. please use shadow-cljs node-repl
or browser-repl
and post everyh single step you do to get to the error
@thheller sorry if I didn't make it clear. I'm not using node-repl or browser-repl, but connecting to shadow-cljs from emacs+cider. and project/lib.js is a file I open in emacs.
// project/lib.js
(ns project.lib)
(defn f1 [])
(comment
(f1)
)
1. I open the project, and cider-jack-in
2. I can call (f1)
in the comment form, which returns nil
3. I put the emacs cursor in the end of the ns
form, and cider-eval that form (e.g. I often do that to add new imports to current ns)
4. now if i try to call (f1)
again, it throws that errorI do not know emacs and this doesn't tell me anything about what you are actually doing
I see. Just replace emacs with "cursive/vim". Open a cljs file in cursive/vim, and eval the ns form of that file. Then all the vars for that ns is gone.
please report it as a reprocucible example with ONLY shadow-cljs node-repl
or shadow-cljs browser-repl
. no editor or other configuration. otherwise I will not investigate this further.
@thheller Here it is with node-repl (TBH, they are essentially the same as my earlier examples):
$ yarn shadow-cljs node-repl
cljs.user=> (ns foo.bar)
nil
foo.bar=> (defn f1 [] (println "foo.bar/f1 called!"))
#'foo.bar/f1
foo.bar=> (f1)
foo.bar/f1 called!
nil
foo.bar=> (ns foo.bar)
nil
foo.bar=> (f1)
------ WARNING - :undeclared-var -----------------------------------------------
Resource: <eval>:1:2
Use of undeclared Var foo.bar/f1
--------------------------------------------------------------------------------
foo.bar=> (require 'foo.bar)
nil
foo.bar=> (f1)
------ WARNING - :undeclared-var -----------------------------------------------
Resource: <eval>:1:2
Use of undeclared Var foo.bar/f1
--------------------------------------------------------------------------------
version info: mac os 10.15 shadow-cljs version: 22:10:44 js | shadow-cljs - server version: 2.10.12 running
@wxitb2017 please report as a github issue. slack will get lost.
@zilti please post the full error. very hard to piece together what you are actually doing or what is missing.
@thheller that is the full error. (Or rather was, I deleted the node_modules folder now, and ran npx shadow-cljs
again, and it installed and ran. I suspect it is a problem that I had shadow-cljs in my package.json file?)
how do I run pure js code from cljs? I have a js code snippet that needs to be run on a dom event. What's a simple way to do this?
This is the code in the google-maps.js file:
(function(exports) {
"use strict";
console.log("loading map");
function initMap() {
exports.map = new google.maps.Map(document.getElementById("map"), {
center: {
lat: -34.397,
lng: 150.644
},
zoom: 8
});
}
exports.initMap = initMap;
})((this.window = this.window || {}));
I have this in google_maps.js:
export function initMap() {
exports.map = new google.maps.Map(document.getElementById("map"), {
center: {
lat: -34.397,
lng: 150.644
},
zoom: 8
});
}
Compilation failed!
The required JS dependency "./google_maps.js" is not available, it was required by
then read https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js and put the file in the correct place
being loaded like so:
(def load-map (with-meta identity
{:component-did-mount
initMap}))
[load-map [:div {:id "map"}]]
gives:
initMap is not a function(index):1 Uncaught (in promise) Vc {message: "initMap is not a function", name: "InvalidValueError", stack: "Error↵ at new Vc (https://maps.googleapis.com/m} Promise.then (async) ij @ js?key=AIzaSyD1r7IEvY&callback=initMap&libraries=&v=weekly:136 google.maps.Load @ js?key=AIzaSyD1r7IEvvf6w8FlHu3k_hP_oJwW4_MfQzY&callback=initMap&libraries=&v=weekly:14 (anonymous) @ js?key=AIzaSyD1r7IEvvf6w8FlHu3k_hP_oJwW4_MfQzY&callback=initMap&libraries=&v=weekly:227 (anonymous) @ js?key=AIzaSyD1r7IEvvf6w8FlHu3k_hP_oJwW4_MfQzY&callback=initMap&libraries=&v=weekly:227 This error is after the console.log print console.log("init map"), the first line of initMap
Hi, I have rebuild my client with 2.10.12 version and I am getting the following errors on the start:
I did some changes in my rf code but it does not seem to be related to this in any way.
I assume there are more errors? all of the errors in that screenshot are likely to something else before that (might be reported after)
Ok, so the error was silly. During refactoring, I moved one namespace and forgot to change its path so it was not matching the new location. Refactoring features in Cursive are not perfect. Couldn't this be checked by Shadow-cljs and some error be displayed?
@pshar10 last warning ... if you continue to be this impatient I will start to ignore youi
I do not know what is going on in your problem but the issue is that the google maps stuff expects to call an initMap
function
so was under the impression that YOU want to call this function but it looks like google will call that function for you
I do not know anything about the google maps API so I cannot tell how the correct version would look
@thheller nope, for a better example, take this ns as an example
// project/lib.js
(ns project.lib)
(defn f1 [])
So this ns has a f1
var. But if I eval the ns form again, and try to catch f1
, it would throw the error I pasted above.Still having this issue that changes in the JS file does not trigger shadow in watch mode to rebuild.
The Browser Console, the shell terminal running shadow-cljs -A:dev watch app
,
nor the webpage itself show any indication that a rebuild happens. The JS file
is not in resources (other than the compiled output).
I wasn’t quite sure what was meant in the guide (https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js)
by:
> The files must not be physically located in the same directory. The lookup for the file appears on the classpath instead. This is unlike node which expects relative requires to always resolve to physical files.
So I tried all the permutations I could think of and none of them would trigger
shadow-cljs watch to rebuild. Updating any CLJS file did as normal.
Here is what I tried:
1. With the JS file in the same source tree (but not directory) as the cljs file requiring the JS file:
deps.edn :path ["src"]
(ns visx.dashboard.antmedia
(:require
["/visx/dashboard/antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
or
(ns visx.dashboard.antmedia
(:require
["./antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
with the file layout:
├── package.json
├── shadow-cljs.edn
└── src
└── visx
└── dashboard
└── antmedia.cljs
|__ antmedia
|__ webrtc_adapter.js
2. Or when the JS file is a different directory tree under src:
(ns visx.dashboard.antmedia
(:require
["/js/dashboard/antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
├── package.json
├── shadow-cljs.edn
└── src
└── visx
└── dashboard
└── antmedia.cljs
|__ antmedia
└── js
└── dashboard
└── antmedia
|__ webrtc-adapter.js
3. Or when the JS is in a different tree but matching class path with updated :path
:
deps.edn: :path ["src/js" "src/cljs"]
(ns visx.dashboard.antmedia
(:require
["/visx/dashboard/antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
or
(ns visx.dashboard.antmedia
(:require
["./antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
├── package.json
├── shadow-cljs.edn
└── src
[__ cljs
└── visx
└── dashboard
└── antmedia.cljs
|__ antmedia
└── js
|__ visx
└── dashboard
└── antmedia
|__ webrtc-adapter.js