This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-05
Channels
- # announcements (7)
- # babashka (20)
- # beginners (130)
- # bristol-clojurians (1)
- # cider (14)
- # clj-kondo (7)
- # cljdoc (14)
- # cljs-dev (15)
- # cljsrn (16)
- # clojars (11)
- # clojure (190)
- # clojure-dev (4)
- # clojure-europe (7)
- # clojure-italy (9)
- # clojure-nl (3)
- # clojure-romania (6)
- # clojure-uk (51)
- # clojurescript (44)
- # component (4)
- # conjure (28)
- # cursive (1)
- # data-science (4)
- # datascript (1)
- # datomic (30)
- # duct (4)
- # emacs (1)
- # figwheel (4)
- # fulcro (56)
- # graalvm (4)
- # helix (51)
- # jackdaw (2)
- # jobs-discuss (12)
- # joker (4)
- # lambdaisland (1)
- # local-first-clojure (1)
- # meander (73)
- # mid-cities-meetup (2)
- # nrepl (4)
- # off-topic (43)
- # pathom (56)
- # re-frame (37)
- # reagent (26)
- # shadow-cljs (161)
- # slack-help (9)
- # spacemacs (1)
- # tools-deps (18)
- # xtdb (18)
ok, i've added this snippet to my user.ns
to kill browse-open. 😶
(reset! *open-url-script* "/usr/bin/false")
shadow-cljs - watching build :main
[:main] Configuring build.
[:main] Compiling ...
------ WARNING #1 - -----------------------------------------------------------
Resource: simplified-externs.js:2
name ShadowJS is not defined in the externs.
--------------------------------------------------------------------------------
[...]
------ WARNING #5 - -----------------------------------------------------------
Resource: simplified-externs.js:6
name ShadowJS is not defined in the externs.
--------------------------------------------------------------------------------
[:main] Build completed. (1060 files, 1057 compiled, 0 warnings, 52.05s)
I have a couple shadow-cljs questions (again).
1. I'm seeing a CORS preflight error when I try to load my app via the shadow-cljs dev http server. I had an entry in :push-state/headers
which I thought would take care of this, but I'm not quite sure what else to do or even how to debug exactly what is going on.
2. If I don't use the shadow-cljs dev http server, and just go directly to my app's server, everything is mostly OK except I see some weird messages in the console when it tries to reload cljs code, where I just see the line: "shadow-cljs: can't find fn" (I have the impression that this normally would have the fn name after it) ...
1) CORS headers must be set by the server answering the request so if you request data from another server THAT server must set the headers not the :dev-http server.
2) no clue. you just have to load static files, functionality should be identical. only thing I can think of is that some files fail to load? any loading errors in the browser console? maybe some bad caching logic in your server?
Ok, I will try to double-check that the server is doing the right cors things. It's a little baffling because I can't see an awful lot about it in the browser's record of the request. As far as number 2, no loading errors in the console at all, but I've seen this on a couple projects in the last weeks that I am working on that are similar, and I suspect it is particular to the bootstrap build. Since it's a code-reloading thing, and since I think it won't happen if I am going via the dev http server, it probably isn't that important for me to investigate if I can fix the CORS issue.
it always talks directly to the shadow-cljs main server regardless of how the files were served
Yeah that's a reasonable request ... I can't share my actual project but I wonder if I can make a skeleton project with the same characteristics.
shadow-cljs: can't find fn
means that the server-side compile found a hook function (eg. :dev/after-load
or config) but didn't find it at runtime
It may be that it's another path problem somehow (since I'm accessing it via a different URL I guess) ... but I don't see any loading errors at all ... ?
I mean go into the browser console and type in the name of the function it is supposed to call
its kind easy to destroy the runtime state with self-hosted code if you are not careful
Yes, so sorry, I think the munged name is completely present in the js console if I type it.
so maybe you are loading code you shouldn't be loading via self-host? like loading a different cljs.core instance?
do you use the bootstrap helpers described here? https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html
you can also review the websocket messages via the browser console, see if the message actually contains an emtpy fn call (which shouldn't be possible in theory as it would be invalid transit)
no clue how that happens though? especially since that is always done by the shadow-cljs main server and not related to the dev-http at all
Yes, I mean I'm sure you must be correct that it is something in my config I am doing wrong
I just need to learn enough about shadow-cljs internals to be able to effectively debug it
thats the server constructing the info https://github.com/thheller/shadow-cljs/blob/daf95e9dde0245112fc4c844098a9a0e7fcf8f75/src/main/shadow/cljs/devtools/server/worker/impl.clj#L239-L281
Nope, I don't think so, I mean I am launching shadow-cljs with clj
, but I'm not manually managing it or starting servers or anything.
If I wanted to set a breakpoint in that code you showed me, is there an easy way to do that?
Well, thank you very much for your help. I will see what I can do to dig a little more, and then I will try to ask some more useful questions.
I'm guessing it's all some combination of different paths I'm using or something along those lines.
Yeah, I imagine I just need to pass the right jvm args so it will listen on a debug port or whatever
@thheller do you know what can be the cause of the
------ WARNING #5 - -----------------------------------------------------------
Resource: simplified-externs.js:6
name ShadowJS is not defined in the externs.
--------------------------------------------------------------------------------
i start seeing this warning on update from 2.8.93 to the latest version of shadow-cljs (as a side note, if i remove externs/
directory the warning disapears).
not sure. I haven't touched any of the externs related code so it might be the new closure-compiler version having changed something
the simplified-externs.js
is generated by the externs/build.txt
so yeah removing that removes the file
if you do it correctly with shadow-cljs. if you use project.clj it depends. if you use deps.edn it should be picking the newest available version (which shadow-cljs depends on)
whats the problem though? just a couple warnings or does it actually affect anything?
but not sure why it suddenly became a problem when it has worked for the past year or so
yeah, is just a warning, and i just wanted let you know about this, that it start happening suddenly
@niwinz did you try the older closure-compiler version? if so, does it make the warnings to away?
@thheller yes, just tried right now, and no, latest version of shadow-cljs and com.google.javascript/closure-compiler-unshaded {:mvn/version "v20191027"}
uxbox@uxbox-devenv-main:~/uxbox/frontend/ > clj -Adev -Stree |grep closure
org.clojure/google-closure-library 0.0-20191016-6ae1f72f
org.clojure/google-closure-library-third-party 0.0-20191016-6ae1f72f
com.google.javascript/closure-compiler-unshaded v20191027
com.google.javascript/closure-compiler-externs v20191027
uxbox@uxbox-devenv-main:~/uxbox/frontend/ > clj -Adev -Stree |grep shadow
thheller/shadow-cljs 2.8.110
thheller/shadow-cljsjs 0.0.21
thheller/shadow-util 0.7.0
thheller/shadow-client 1.3.2
looks fine. youj can open a github issue if you want. don't have time to look into this further now. really shouldn't warn about internal things so I'd like to fix that.
i'll open an issue, sure. I have an other one related to fingerprint-hash, modules and webworker (where web worker tries to import "shared.js" when the fingerprint-hash is activated and the shared.js is renamed to shared.<md5hash>.js file)
I just started using shadow-cljs and I keep running into an issue on re-compilation. I get the following error which I couldn't find any reference to with my search-engine-fu: ExecutionException: clojure.lang.ExceptionInfo: failed to publish!, offer! failed {:msg {:type :build-log, :build-id :test, :event {:type :flush-source, :resource-name "node_modules/@material-ui/icons/CalendarViewDayTwoTone.js", :timing :exit, :timing-id 1489, :depth 1, :stop 1588684288351, :duration 3, :shadow.build.log/level :info}}, :topic :shadow.cljs.model/build-log}
This doesn't come up after removing the output-dir contents on a first compile / watch.
@schaueho thats odd. its a backpressure thing where its trying to log faster than the log consumer can read it. never heard of anyone else running into this before
My machine is pretty powerful (Ryzen Threadripper), maybe that's part of the reason. I can log an issue, if you want me to.
I fixed the issue in master yesterday (I think). should be good with the next release.
I guess I can turn this into a warning instead since its not really critical to drop that message
guess it just gets overloaded by when trying to flush the thousands of files @materiel-ui
has
@jev I'm using it for the shadow-cljs UI but no news beyond that. still lots of stuff to figure out and not much time to work on it.
hello all, how do I use something like this in cljs var Connection = require('../lib/tedious').Connection;
?
I tried with
(ns app.core
(:require
["express" :as express]
["tedious" :as sql]))
(defn create-connection []
(sql/Connection. {}))
but no Connection
foundI'm assuming you are running a node build because of the express
? ie. now a :target :browser
build?
error when calling lifecycle function app.core/start! TypeError: Cannot read property 'Connection' of undefined
I want to first confirm that it actually works in node. that is the only test you have to do.
require("tedious")
{
connect: [Function: connect],
BulkLoad: [Getter],
Connection: [Getter],
Request: [Getter],
ConnectionError: [Getter],
RequestError: [Getter],
TYPES: [Getter],
ISOLATION_LEVEL: [Getter],
TDS_VERSION: [Getter],
library: { name: 'Tedious' }
}
> require("tedious").Connection
[Function: Connection]
{:source-paths
["src"]
:dependencies
[]
:builds
{:app
{:main app.core/main
:target :node-script
:output-to "app.js"
:devtools
{:after-load app.core/start!
:before-load app.core/stop!}}}}
{
"devDependencies": {
"shadow-cljs": "^2.8.110"
},
"dependencies": {
"express": "^4.17.1",
"tedious": "^8.3.0"
}
}
try shadow-cljs node-repl
and then (require '["tedious" :as x])
and then (js/console.log x)
cljs.user=>
Connection: [Getter],
Request: [Getter],
ConnectionError: [Getter],
RequestError: [Getter],
TYPES: [Getter],
ISOLATION_LEVEL: [Getter],
TDS_VERSION: [Getter],
library: { name: 'Tedious' }
}
nil