This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-27
Channels
- # babashka (35)
- # beginners (85)
- # cider (14)
- # clojure (115)
- # clojure-europe (15)
- # clojure-norway (2)
- # clojure-portugal (9)
- # clojure-uk (3)
- # clojurescript (28)
- # conjure (35)
- # data-science (10)
- # datomic (4)
- # graalvm (28)
- # holy-lambda (7)
- # hyperfiddle (2)
- # jobs (2)
- # joker (4)
- # malli (9)
- # meander (6)
- # nbb (6)
- # off-topic (23)
- # pathom (3)
- # remote-jobs (1)
- # shadow-cljs (158)
- # sql (15)
- # tools-deps (35)
- # vim (5)
when requring a https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js file, it doesn’t trigger a rebuild when I change it or detect changes to this file when I trigger a recompile by changing the requiring cljs file. Is this expected and is there a workaround?
although it doesn't work for commonjs files probably? do you use ES modules (import/export) or commonjs?
hmm nope also works for commonjs, although somewhat limited by design given its commonjs
which version do you use? I tried with master, can't remember if there was something broken related to this in earlier versions maybe?
> it doesn’t trigger a rebuild when I change it or detect changes to this file when I trigger a recompile by changing the requiring cljs file.
the second part confuses me? changing the requiring cljs file will recompile the js file?
no, I mean that when I trigger a recompile of the file requiring my js file (the file that has (:require ["/barcode-detector-zbar/BarcodeDetector.js$default" :as barcode-detector-polyfill])
in it, I don’t see changes to the js file
I'm confused. what changes would you see in the JS file if you modify the CLJS file?
ok, thats the relevant bit. it should reload just fine, regardless of what you do to the CLJS file
and changing the CLJS file should have no effect on what the JS files does whatsoever, so that is working as expected I guess
I just tried by adding a console.log to the JS file and changing that log. works fine. but I dunno what else you might be doing?
using :deps
with shadow, but resources
in on the classpath brought in by the root deps declaration
oh yeah, resources
are filtered out because many people put their outputs into resources/public
and watching the resources
folder thus becomes very noisy and expensive
now running into Uncaught TypeError: gaa.default.setupPolyfill is not a function
in advanced. Externs should be inferred automatically with :compiler-options {:infer-externs :auto}
, is that correct?
I've posted a question/issue about target esm https://github.com/borkdude/cherry/issues/24 but feel free to discuss it here as well 🧵
The context:
cherry-cljs/cljs.core.js
is a target esm-built .js file with core functions. It has e.g. js-keys
which AFAIK doesn't depend on any other core function, so when only importing that, I'd expect that the tree-shaken build of a JS file, would be rather small.what do you mean by "only importing"? shadow-cljs can only see what you configured and keeps all that stuff alive
I've just posted a question/issue about an as of yet non-existing :target :jupyter
https://github.com/thheller/shadow-cljs/issues/1039. But am also on slack 👋
Yes, I've tried it but ran into some issues with it sadly. The target that got me furthest so far is :npm-module
, but that doesn't seem to inject the repl, unacceptable!
https://twitter.com/lambduhh/status/1548064443564560386?t=Dvf-_w4d9xMDYdMFvAWjNA&s=09
https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs is the name / location fixed and I can’t put it elsewhere and reference it via :compiler-options :externs
?
@mkvlr externs inference only covers CLJS files, no inference is done for JS files. yes, there are no options to configure the simplified externs
@bbss to get a REPL for :npm-module
builds you just need to require the REPL client ns *from* javascript somewhere. so something like if (process.env.NODE_ENV === "development") { require("./path-to-cljs/shadow.cljs.devtools.client.browser"); }
or so
Okay, good to know that should work! I think I am probably a special case for npm-module
though, since eventually jupyter notebook extensions run in the browser anyway..
thats no problem. the issue is just that the :npm-module
build doesn't have a clearly defined "entry" point
:browser
and the others do so shadow-cljs can ensure that the devtools client is loaded before those
for npm-module that is not the case because it can't tell which file you are going to access from JS
:npm-module
doesn't use shadow$provide
unless you specifically configure it? or was that :target :browser
?
@bbss what would help if you setup a repo with stuff that does not work! much easier to look at an actual failing thing than just guessing
this repo would just need to require added here somewhere https://github.com/jelmerderonde/jupyter-lab-parinfer/blob/master/index.js
so just if (process.env.NODE_ENV === "development") { require("./lib/shadow.cljs.devtools.client.browser"); }
Is there a way to run shadow-cljs clj-repl
and immediately execute some code in it? Right now, I'm having to do: clojure -M:dev:shadow-cljs clj-repl
, and then inside the repl I have to type (integrant.repl/go)
. Can I do it in a single line?
I've been trying to combine clj-eval
and clj-repl
options, but that doesn't seem to work.
do you actually intend to use the REPL provided by clj-repl
or do you just leave that running and connect via nrepl or so?
Hmmm. I haven't thought about it. What would be the difference? Would there be something blocking?
basically you create a (defn start {:shadow/requires-server true} [] (integrant.repl/go))
and shadow-cljs run that.ns/start
Oh, that's interesting. Let me try it out. I feel I'd have to come back with some more questions. Thank you Thomas.
does shadow only consider the deps in the aliases passed to shadow-cljs.edn's :dep's key? e.g will i get foo and bar in this setup or just bar?
shadow-cljs.edn
:deps ["cljs"]
and my deps files
:deps {foo ...} :aliases {:cljs {:extra-deps {bar ....}
Agreed.
are the extra-deps in the aliases in addition to the ones in the deps :deps key?
ty ty. I was just setting up a project to test it. 🙂
what's the current stable version of shadow-cljs? I just tried upgrading to 2.19.8
, but I'm getting Exception in thread "main" Syntax error compiling at (shadow/build/data.clj:362:5)
... something that seems to be related to clojure.lang.Compiler.analyze
. Do I miss an exclusion?
this is the content of deps.edn, maybe you can spot something I don't.
{:paths ["src" "resources"]
:deps
{org.clojure/clojure {:mvn/version "1.11.1"}
integrant/integrant {:mvn/version "0.8.0"}
ring/ring-core {:mvn/version "1.9.5"}
ring/ring-jetty-adapter {:mvn/version "1.9.5"}
metosin/reitit {:mvn/version "0.5.17"}
hiccup/hiccup {:mvn/version "2.0.0-alpha2"}
org.clojure/tools.logging {:mvn/version "1.2.4"}
org.slf4j/log4j-over-slf4j {:mvn/version "2.0.0-alpha7"}
org.slf4j/slf4j-jdk14 {:mvn/version "2.0.0-alpha7"}
org.clojure/tools.cli {:mvn/version "1.0.206"}
;; front-end
org.clojure/clojurescript {:mvn/version "1.11.4"}
reagent/reagent {:mvn/version "1.1.1"}
re-frame/re-frame {:mvn/version "1.3.0-rc3"}
cljs-bean/cljs-bean {:mvn/version "1.8.0"}
day8.re-frame/http-fx {:mvn/version "0.2.4"
:exclusions [commons-logging/commons-logging]}
day8.re-frame/test {:mvn/version "0.1.5"}
hickory/hickory {:mvn/version "0.7.1"}
metosin/reitit-frontend {:mvn/version "0.5.17"}
metosin/reitit-schema {:mvn/version "0.5.17"}
re-frame-utils/re-frame-utils {:mvn/version "0.1.0"}
inflections/inflections {:mvn/version "0.13.2"}}
:aliases
{:shadow-cljs
{:extra-paths ["test"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.19.8"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}
:dev
{:extra-paths ["dev"]
:extra-deps
{integrant/repl {:mvn/version "0.3.2"}}}
:test
{:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "b3fd0d2"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}
:build
{:extra-paths ["src"]
:extra-deps {io.github.clojure/tools.build
{:git/tag "v0.8.1" :git/sha "7d40500"}}
:ns-default build}
:cider-cljs {:main-opts
["-m" "nrepl.cmdline" "--middleware"
"[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}}}
that line is using commons-codec? I guess you maybe have that excluded somewhere when it shouldn't be?
I'm sorry, I have yet another one: when I'm in the repl and I run shadow.cljs.devtools.api/nrepl-select
:app`, it complains :missing-nrepl-middleware
. Do I need to add piggieback? I thought you don't have to when using deps.edn with shadow-cljs, no?
I have added :repl-options {:init-ns user
into :shadow-cljs alias, now when I run clojure -M:dev:shadow-cljs clj-repl
, should I expect it to land me in user
ns? Because it doesn't. It still starts in shadow.user
no, that does nothing. nrepl doesn't look there. that was a lein specific config option
you can set :repl {:init-ns user}
in shadow-cljs.edn
at the top level. but that again would only affect the nrepl server started by shadow-cljs? which I guess you don't actually use?
Yes, it looks like I don't need :cider-cljs alias. with that :repl-options config you mentioned earlier.
On slightly unrelated note, I'm getting these, btw:
------ WARNING #1 - :redef -----------------------------------------------------
Resource: no/en/core.cljc:137:1
--------------------------------------------------------------------------------
134 | [s]
135 | (parse-number s #(#?(:clj Integer/parseInt :cljs js/parseInt) %1)))
136 |
137 | (defn parse-long
-------^------------------------------------------------------------------------
parse-long already refers to: cljs.core/parse-long being replaced by: no.en.core/parse-long
--------------------------------------------------------------------------------
...
yes, it seems from inflections. Sorry. I thought it's somehow related to me bumping Cljs. Apologies for the noise.
right, bumping it fixed it. I blame my OCD. I should learn to be more patient and learn how to read the error messages.
I put up a https://github.com/mk/shadow-barcode-wasm#attempt-to-use-barcode-detector-zbar-with-shadow-cljs. Would appreciate any pointers of other things I could try to get this working.
https://github.com/lekoala/barcode-detector-zbar/blob/master/BarcodeDetectorPolyfill.js#L1
Failed to inspect file
/Users/mk/dev/shadow-barcode/node_modules/zbar.wasm/dist/zbar.wasm.bin
it was required from
/Users/mk/dev/shadow-barcode/node_modules/zbar.wasm/dist/load-browser.js
Errors encountered while trying to parse file
/Users/mk/dev/shadow-barcode/node_modules/zbar.wasm/dist/zbar.wasm.bin
{:line 1, :column 0, :message "Character '' (U+0000) is not a valid identifier start char"}
this would be https://www.npmjs.com/package/zbar.wasm
https://github.com/thheller/wasm-pack-cljs/blob/master/src/gen/demo/without_a_bundler.js#L113-L176
those are the imports passed to the wasm file. :advanced
was renaming all of them, so I changed imports.wbg.*
to imports["wbg"]["..."]
instead
re simple: I guess if there’d be a way to only use simple for this js module, the bundle size impact would be basically zero
I cannot tell what the min file is doing, but it must construct such an object somewhere
well if you use :target :esm
you can also load it via (:require ["esm:./BarcodeDetectorPolyfill.min.js$default" :as barcode-detector-polyfill])
so you recommend esm these days for cases like this or do you still expect rough edges?
dynamic-import
also works, see https://clojureverse.org/t/generating-es-modules-browser-deno/6116
I haven't worked on :esm
much but there isn't much to work on. it seems to work fine.
(due to closure compiler rewriting import()
still I think, something regarding that broke)
yeah, getting main.js:1425 ReferenceError: shadow_esm_import is not defined
with dyanamic import
set :prepend "function shadow_esm_import(name) { return import(name) }"
to your build :modules
config
yeah, that works for getting functions, to create an instance I’m doing (.construct js/Reflect (.-default polyfill-module) #js [])
or is there an easier way?
well this is nice & compact now, thanks again
(-> (dynamic-import "/barcode-detector-zbar/BarcodeDetectorPolyfill.min.js")
(.then (fn [^js mod]
(let [$default (.-default mod)]
(js/console.log "native api support:" (.checkBarcodeDetectorSupport $default))
(.setupPolyfill $default)
(doto (new $default)
(js/console.log))))))
(js-await [^js mod (dynamic-import "/barcode-detector-zbar/BarcodeDetectorPolyfill.min.js")]
(let [$default (.-default mod)]
(js/console.log "native api support:" (.checkBarcodeDetectorSupport $default))
(.setupPolyfill $default)
(doto (new $default)
(js/console.log))))
is there an approved way to get out-of-tree source files into shadow-cljs :paths
? i have some cljc i need to share between front and back ends. I get a warning when i try
:paths ["../../components" "src"]