This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-02
Channels
- # babashka (117)
- # babashka-sci-dev (6)
- # beginners (34)
- # biff (2)
- # calva (7)
- # clj-kondo (27)
- # clojure (6)
- # clojure-dev (8)
- # clojure-europe (41)
- # clojure-israel (1)
- # clojure-nl (1)
- # clojure-norway (2)
- # clojure-uk (1)
- # clojurescript (22)
- # cursive (3)
- # datascript (12)
- # dev-tooling (4)
- # emacs (13)
- # hyperfiddle (60)
- # introduce-yourself (8)
- # joyride (9)
- # lsp (46)
- # malli (3)
- # mranderson (75)
- # off-topic (40)
- # pathom (9)
- # pedestal (4)
- # reagent (11)
- # reitit (18)
- # releases (2)
- # shadow-cljs (81)
- # squint (18)
Happy New Year! 🎆 I'm seeing an issue where I've meta'd all the externs inference warnings, but the build is broken because of un-externed names. Any input on how I can debug this?
Previously, we've used lein extern
to generate them, and if I run that and include those externs in the build, its all fine.
Otherwise I get "Uncaught Module not provided: 10"
(I now always get that error, can't get the app to launch anymore.)
you can create a release build with npx shadow-cljs release app --pseudo-names
. that usually makes it easy to track what was renamed and which externs you would need.
the module not provided I'm guessing you get from either some bad cache or trying to mix files from different builds?
hm, so building with --pseudo-names fixes it
any idea how to proceed from there?
pseuo-names really shouldn't fix anything. if it does it likely means that the conflict is on a very short property name
what kind of externs did you have before? I don't know that lein extern
is so dunno what that generaetd
I do use clj->js and vice versa, not sure if a lot, but I think not
when does this become an issue?
one issue I just saw:
(.on win "close" #(do
(.set Settings "winBounds" (.getBounds win))
(when-not (contains? @!can-close window-id)
(.preventDefault %)
(async/put! event-queue
{:window-id window-id
:payload [:window/close-requested]}))))
this is code from an integrant init-key defmethod and doesn't produce any warnings about inferencesbut it does crash and can be fixed by ^js'ing win and Settings (maybe either is sufficient, have only tested both)
I did get a lot of warnings without setting any :infer-externs option – after silencing all warnings, this one remained (I saw that the default was what I wanted)
2.20.16
I just recompiled with explicit :infer-externs :auto and still no warnings
(I mean no extra warnings)
when I ran the build the first time I did get a lot of warnings that I silenced
... source code ...
hm, it seems the win is tagged as js in the let, but that doesn't carry through to the closure?
yeah, I was tagging lots of stuff to debug this
but where do I trip up the warnings?
shouldn't it give me a warning that I'm not tagging win?
tagging win
once in the start should pretty much be enough for most things I see there
got it
win ^js (BrowserWindow. (clj->js opts))
is not ideal since there are a few places in the compiler that lose type hints. I'm not sure this is one but to be sure just move it to the left
I mean I tagged the locations it gave me
should I try reverting the tagging, go through the inference warnings again, but tag the symbols, not the expressions and see if that fixes it? or is that not the cause?
ok, I'll try that
and report back
(at this point, just getting runtime errors related to non-externed symbols, fwiw)
but without getting non-inferrable externs warnings for those symbols
no compile errors etc.
update: I diligently fixed inference warnings the errors by tagging the named symbol where it appears first. this fixed the build 🎉 (I was led astray originally because of broken builds due to caching)
that said: I get a lot of runtime errors due to missing externs
there definitely is some kind of issue with inference of JS objects that get passed into a function through a clj map
e.g.
(defn do-stuff [system]
(let [{:keys [Dialog]} system]
(.doSomething Dialog "foo")))
we do this kind of stuff a lot. system is a booted integrant system, Dialog is (.-dialog Electron)
no warning about Dialog at build time, but xy is not a function
during runtimeany way I can debug this?
{:editor {:target :browser
:output-dir "resources/public/js/compiled/"
:modules {:editor {:entries [editor.core]}}
:externs [
"resources/externs/react.ext.js"
"resources/externs/react-dom.ext.js"]}
:analyzer {:target :browser
:output-dir "resources/public/js/compiled/"
:modules {:analyzer {:entries [analyzer.core]
:web-worker true}}}
:app {:target :node-script
:main app.core/main
:output-to "resources/public/app.js"}
}
this is our :builds
key – we only h ave source-paths and dependencies set otherwise
just grepped for warn-on-infer and nothing came up
anything I can do to help with that? or would you recommend tagging manually for now as a fix is not straightforward?
got lots of new warnings, thanks! fyi, injecting symbols like Path
or Url
using this pattern does still not trigger warnings, though. (but e.g. FS App Dialog
do trigger warnings)
and it seems it sometimes only triggers one (local) occurrence, though not for later injections in different defn's further down the file