This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-21
Channels
- # ai (1)
- # announcements (18)
- # aws (7)
- # babashka (54)
- # babashka-sci-dev (6)
- # beginners (22)
- # calva (57)
- # cider (3)
- # clj-http (1)
- # clojure (144)
- # clojure-austin (1)
- # clojure-dev (38)
- # clojure-europe (34)
- # clojure-gamedev (4)
- # clojure-norway (8)
- # clojure-uk (5)
- # clojurescript (12)
- # clr (20)
- # conjure (4)
- # data-science (1)
- # emacs (30)
- # events (1)
- # graphql (9)
- # helix (7)
- # hyperfiddle (22)
- # introduce-yourself (4)
- # jobs (1)
- # leiningen (7)
- # malli (3)
- # off-topic (26)
- # polylith (26)
- # portal (5)
- # random (14)
- # shadow-cljs (113)
- # tools-deps (6)
- # xtdb (9)
Hi! After updating shadow-cljs this morning (from 2.23.5 to 2.23.8), I get a client-side Javascript error "_interopRequireDefault is not a function". Is this a bug or am I doing something wrong?
could be a side effect of you now getting different code due to the "exports"
support I added
you can revert back to the old behavior by setting :js-options {:ignore-exports true}
for now
can you say which dependency is causing that? need some more libs to test against I guess
changed the defaults to be more conservative, might also make :ignore-exports true
the default if more problems come up
I had a similar issue with highlight.js going from 2.23.5 to 2.23.6:
require "./lib/languages/clojure" for package "XXX/node_modules/highlight.js" not exported
which was solved by adding :ignore-exports
(bumping to 2.24.0 didn't solve it)
@U05224H0W Hi, i have got the mentioned problem with 2.26.0, I just upgraded from 2.21.0
[:app] Compiling ...
[:app] Build failure:
package @headlessui/react had exports, but could not resolve ./dist/components/dialog/dialog
{:package #object[java.io.File 0x4ca96c7e "/Users/akiz/Projects/BIM/backend-api/node_modules/@headlessui/react"], :require-from nil, :rel-require "./dist/components/dialog/dialog"}
ExceptionInfo: package @headlessui/react had exports, but could not resolve ./dist/components/dialog/dialog
shadow.build.npm/find-resource-in-package (npm.clj:807)
shadow.build.npm/find-resource-in-package (npm.clj:793)
shadow.build.npm/find-resource (npm.clj:923)
shadow.build.npm/find-resource (npm.clj:847)
shadow.build.resolve/find-npm-resource (resolve.clj:123)
shadow.build.resolve/find-npm-resource (resolve.clj:94)
shadow.build.resolve/eval12174/fn--12177 (resolve.clj:266)
clojure.lang.MultiFn.invoke (MultiFn.java:244)
shadow.build.resolve/find-resource-for-string (resolve.clj:81)
shadow.build.resolve/find-resource-for-string (resolve.clj:70)
shadow.build.resolve/resolve-string-require (resolve.clj:464)
shadow.build.resolve/resolve-string-require (resolve.clj:447)
shadow.build.resolve/resolve-require (resolve.clj:679)
shadow.build.resolve/resolve-require (resolve.clj:672)
shadow.build.resolve/resolve-deps/fn--12123 (resolve.clj:52)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6885)
clojure.core/reduce (core.clj:6868)
shadow.cljs.util/reduce-> (util.clj:42)
shadow.cljs.util/reduce-> (util.clj:41)
shadow.build.resolve/resolve-deps (resolve.clj:50)
shadow.build.resolve/resolve-deps (resolve.clj:34)
shadow.build.resolve/resolve-symbol-require (resolve.clj:666)
shadow.build.resolve/resolve-symbol-require (resolve.clj:626)
shadow.build.resolve/resolve-require (resolve.clj:676)
shadow.build.resolve/resolve-require (resolve.clj:672)
shadow.build.resolve/resolve-deps/fn--12123 (resolve.clj:52)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6885)
clojure.core/reduce (core.clj:6868)
shadow.cljs.util/reduce-> (util.clj:42)
shadow.cljs.util/reduce-> (util.clj:41)
shadow.build.resolve/resolve-deps (resolve.clj:50)
shadow.build.resolve/resolve-deps (resolve.clj:34)
shadow.build.resolve/resolve-symbol-require (resolve.clj:666)
shadow.build.resolve/resolve-symbol-require (resolve.clj:626)
shadow.build.resolve/resolve-require (resolve.clj:676)
shadow.build.resolve/resolve-require (resolve.clj:672)
shadow.build.resolve/resolve-deps/fn--12123 (resolve.clj:52)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6885)
clojure.core/reduce (core.clj:6868)
shadow.cljs.util/reduce-> (util.clj:42)
shadow.cljs.util/reduce-> (util.clj:41)
shadow.build.resolve/resolve-deps (resolve.clj:50)
shadow.build.resolve/resolve-deps (resolve.clj:34)
shadow.build.resolve/resolve-symbol-require (resolve.clj:666)
shadow.build.resolve/resolve-symbol-require (resolve.clj:626)
shadow.build.resolve/resolve-require (resolve.clj:676)
shadow.build.resolve/resolve-require (resolve.clj:672)
shadow.build.resolve/resolve-deps/fn--12123 (resolve.clj:52)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6885)
clojure.core/reduce (core.clj:6868)
shadow.cljs.util/reduce-> (util.clj:42)
shadow.cljs.util/reduce-> (util.clj:41)
shadow.build.resolve/resolve-deps (resolve.clj:50)
shadow.build.resolve/resolve-deps (resolve.clj:34)
shadow.build.resolve/resolve-symbol-require (resolve.clj:666)
shadow.build.resolve/resolve-symbol-require (resolve.clj:626)
shadow.build.resolve/resolve-require (resolve.clj:676)
shadow.build.resolve/resolve-require (resolve.clj:672)
shadow.build.resolve/resolve-deps/fn--12123 (resolve.clj:52)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6885)
clojure.core/reduce (core.clj:6868)
shadow.cljs.util/reduce-> (util.clj:42)
shadow.cljs.util/reduce-> (util.clj:41)
shadow.build.resolve/resolve-deps (resolve.clj:50)
shadow.build.resolve/resolve-deps (resolve.clj:34)
shadow.build.resolve/resolve-symbol-require (resolve.clj:666)
shadow.build.resolve/resolve-symbol-require (resolve.clj:626)
shadow.build.resolve/resolve-require (resolve.clj:676)
shadow.build.resolve/resolve-require (resolve.clj:672)
shadow.build.resolve/resolve-entry (resolve.clj:686)
shadow.build.resolve/resolve-entry (resolve.clj:685)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6885)
clojure.core/reduce (core.clj:6868)
shadow.cljs.util/reduce-> (util.clj:42)
exports
is a way for npm packages to restrict which files you are allowed to directly required. I'm guessing the package maintainers don't want you to access this directly.
@U05224H0W this is from the official documentation. import { Dialog } from '@headlessui/react'
you mean shadow-cljs? the only thing that changed is the added support for exports
. previously it was just ignored. to be clear, what it doesn't like is you doing (:require ["@headlessui/react/dist/components/dialog/dialog" :as Dialog])
, when they want you to do (:require ["@headlessui/react" :refer (Dialog)])
but there are benefits to your style, so I think :ignore-exports
is the correct way to go
exports
is still relatively new and many packages are pretty strict in what they export. note that this is entirely on the side of the npm package itself, not shadow-cljs. shadow-cljs is just following the rules for exports
.
I got another bug when i upgraded https://clojurians-log.clojureverse.org/reagent/2023-03-09 But it was a quick fix. So i guessed there were more changes ;)
perhaps this is the wrong channel for this question, but is there a way to connect a repl to a web worker context? I've setup a web worker like https://shadow-cljs.github.io/docs/UsersGuide.html#_web_workers and it all works, but I can't figure out how to evaluate code in the worker process
under http://localhost:9630/runtimes you can see the connected runtimes
there should be one browser-worker showing up in addition to the regular browser one
when connected to the normal CLJ nrepl you may select the worker via (shadow/repl :app {:runtime-id <id-of-worker>})
it is a bit manual since no editor unfortunately provides any kind of mechanism to select this
:cljs/quit
drops you down back to the CLJ repl, so you can switch back and forth. or just open a second connection of stay connected to both
Thanks! got it all working, a bit of hassle compared to the normal way but I guess like you said thats on cider/conjure/etc
Is there documentation for https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745 beyond that page? Perhaps there's nothing else I need to know about it.
there is not really anything else to know about it, reads a resource and inlines it
I guess it just seems unusual to reach out to a build tool from within project source code.
consider that code a library where I'm just to lazy to make it an actual separate library 😛
An argument for mentioning this in the user guide: When I'm trying to figure out how to do something with shadow, I go to the user guide and skim and ctrl+f my way around before turning to slack. If this was mentioned in the user guide would've saved me from pestering folks here 😁
Why is it that I can reference a var in a CLJS repl, but when shadow compiles my code in the same namespace, it may not find that var? My more general question is: how do I reference a var in a namespace that I cannot require because of circularity?
TLDR; it is not possible. you may find a few tricks to do, but clojure do not support circularity in general. not sure about closure compiler, but closure compiler makes harder because smashes every var name in your code. One trick: add an export
(ns my.cool-ns)
(def ^:export my-global ...)
then you can access (-> js/global .-my .-cool_ns .-my_global)
not tested in newer cljs version. i did this yeeeeaars ago.I see. Maybe also something with the namespace object, which seems to carry all the code. (???)
namespace is not a thing in clojure you can't pass a namespace as a parameter in clojure code. despite that both in JVM and JS you actually can. because of reasons. but it is not a supported/public api.
maybe in the future, with the advance of :as-alias
(a new feature from clj 1.11+) circular namespaces will be possible
I just tried(j/get-in rad-mapper.evaluate ["processRM"]) and was able to run the function "processRM" that evaluated to. NS j is just the applied-science.js-interop.
@U0D4UL3U2 you need to test with cljs advanced build. I think that the way you did only works in non-optimized builds
(or say that you dont care about your app size and do not use advanced at-all. more people than I would like do that)
Yeah, makes sense. Good enough for today's demo I think running under shadow-cljs watch, I think. :face_with_peeking_eye:
don't being afraid of the interop
(some-> js/window .-rad_mapper .-evaluate .-processRM)
(let [^js process-rm (some-> ^js js/window ^js .-rad_mapper ^js .-evaluate ^js .-processRM)]
-----------------------------------^--------------------------------------------
Cannot infer target type in expression (. G__79695 -processRM)
The pointer is at (somehummm
ns .. :require [[goog.object :as gobj]]
(gobj/getValueByKeys js/window "rad_mapper" "evaluate" "processRM")
To be clear. It worked well enough for the demo. As you suggested, it doesn't work on under a release compile. I think that's going to be okay because the code I'm trying to run runs under the Small Clojure Interpreter (SCI) and I think I can untangle my use of SCI from these namespaces.
Updated to 2.24 and seeing this error:
require "./useCallbackRef" for package "/Users/xxx/node_modules/@restart/hooks" not exported
{:rel-require "./useCallbackRef", :package-dir #object[java.io.File 0x4f9ae00a "/Users/xxx/node_modules/@restart/hooks"], :exports {"." {"types" "./esm/index.d.ts", "import" "./esm/index.js", "require" "./cjs/index.js"}, "./*" {"types" "./esm/*.d.ts", "import" "./esm/*.js", "require" "./cjs/*.js"}}}
ExceptionInfo: require "./useCallbackRef" for package "/Users/xxx/node_modules/@restart/hooks" not exported
I'm also seeing the same issue since upgrading:
require "./lib/languages/clojure" for package "/home/xxx/yyy/node_modules/highlight.js" not exported
Possibly https://github.com/thheller/shadow-cljs/commit/97d1500d86972caaed6c1860af66ac59cf5e6e6b
@U05224H0W you seem to have been doing quite a bit with package.json exports recently, is there something we should be doing differently following these changes?
I didn't expect wildcard exports to be so common, thought we could do without but apparently not
For defines, the shadow-cljs repl returns the value being bound in a vector, instead of the var. Reported on Calva here: https://github.com/BetterThanTomorrow/calva/issues/2228 Expected:
(def a 1) => #'cljs.user/a
Actual:
(def a 1) => [1]
It seems to have been introduced somewhere between 2.19.9 and 2.23.3. I can bisect it further if that is helpful?IIRC that’s a setting tweakable in a CLJS REPL, not really a bug with shadow-cljs. I remember seeing something like being able to configure how the CLJS REPL decides to print a var
After experimenting with :def-emits-var
, I take back my statement. I thought it would’ve been related to that. But I see this in Emacs as well
I’ve bisected it a bit more. It was introduced in https://github.com/thheller/shadow-cljs/blob/master/CHANGELOG.md#2210---2023-02-19.
Did you catch this post, @U05224H0W? I don’t mean to nag. It’s not a big problem. Just want to check if you’re aware.
its just a printing issue. I made some changes for the Inspect UI, and one of those changes was defaulting to showing datafy
'd output
so what you are seeing is just a datafied var, where the default implementation wraps that in a vector, just like atoms
Certainly. Things work fine and I have not really noticed this until it was pointed out to me. However, I imagine it could be problematic if a REPL output consumer is not a human. Would you consider a PR restoring the old REPL output?
no PR necessary. just open an issue so I don't forget. I've been meaning to fix it, just forgot.
Hi all. Anyone else had trouble requiring local deps in an esm module, i.e. a chrome extension popup (as per https://github.com/thheller/chrome-ext-v3), and know of a fix?
Currently, my shadow-cljs.edn
sets {:deps true ...}
and deps.edn
has a {:deps {foo/foo {:local/root "../bar"}}
. The whole thing compiles just fine, but when I try to open the popup I get Failed to load resource: net::ERR_FILE_NOT_FOUND
in the console—and indeed the required namespace has no equivalent .js
in the given :output-dir
: ⬇️
Is there something additional I'd need to do to make this dep available? (Other, regular deps e.g. Reagent are all good.)
chrome exts are very picky about loading files. did you reload the extension properly? this has to be done manually unfortunately. so every change you make cannot be hot loaded or anything, you actually need to manually reload it.
otherwise everything should be there. assuming it was required by the build in a regular require and so on
which version do you use though? I made a few changes to :esm
recently, could be that you are using a bad one?
you don't have to use the clj
command line switch just to run with deps.edn
. that is optional.
yep, reloaded must be a mistake in the dep, hmm
as for version, it's "2.23.8" (maven); so I'll see if bumping makes a difference
different problem after bumping :thinking_face:
is it :deps {:aliases [:cljs]}
that allows running shadow-cljs
as normal then? 🙂
nothing wrong with the local dep / require afaict but still no corresponding compiled js
reagent problem unrelated I suspect
Huh. After removing the extension and re-`Load unpacked`ing, all is now fine.
Hope I don't have to do that after every change! 😅
Apparently not. Just reload. Nice.
god extensions are annoying
but thanks for your help @U05224H0W!
but evidently not just reload for some things
(spotty signal on a train; messages may be arriving out of order)
yeah the chrome exts with v3 manifests got even stricter, so we can't do any hot-reload or REPL anymore since eval is forbidden
:deps {:aliases [:cljs]}
is all yes. well in your fork you called the alias :shadow-cljs
and had :main-opts
in there. should remove :main-opts
if you intend to run with just shadow-cljs
, and change to match the alias name of course
yeah I miss the days of mv2 + https://github.com/binaryage/chromex/tree/master/examples/shadow
> and it only sees files that were present when the extension was first loaded > changes made afterwards lead to sort of chaos 🙃 good to know!