This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-26
Channels
- # announcements (7)
- # babashka (6)
- # beginners (41)
- # clara (27)
- # clerk (2)
- # cljs-dev (6)
- # clojure (121)
- # clojure-europe (31)
- # clojure-nl (2)
- # clojure-norway (98)
- # clojure-uk (12)
- # clojuredesign-podcast (7)
- # conjure (5)
- # cursive (22)
- # holy-lambda (22)
- # hoplon (9)
- # hyperfiddle (19)
- # leiningen (9)
- # malli (4)
- # music (1)
- # nbb (6)
- # off-topic (10)
- # podcasts-discuss (1)
- # polylith (4)
- # re-frame (2)
- # reitit (2)
- # releases (1)
- # sci (1)
- # shadow-cljs (59)
- # sql (9)
- # vim (41)
- # xtdb (23)
Hi 👋:skin-tone-2: I am working on a cljs project and attempting to upgrade the version of @clerk/clerk-react from 4.26.6 to the next version 4.27.0. Typically, upgrades for this package have been seamless. After upgrading to 4.27.0, I receive the following message after running shadow’s watch.
The required JS dependency "@clerk/shared/keys" is not available, it was required by "node_modules/@clerk/clerk-react/dist/cjs/contexts/ClerkProvider.js".
Taking a look at the release notes, I see they upgrade to a new, breaking version of their @clerk/shared package 1.0.0. As a result, code changes for this keys dependency change. e.g.,
-import { createDevOrStagingUrlCache } from '@clerk/shared';
+import { createDevOrStagingUrlCache } from '@clerk/shared/keys';
This was executed in https://github.com/clerkinc/javascript/pull/1915 of the @clerk/shared package: “The package was reworked to allow for better isomorphic use cases and ESM support, resulting in some breaking changes. It now allows for https://nodejs.org/api/packages.html#subpath-exports and restricts some imports to specific subpaths.”
Does shadow-cljs support subpath exports? Is there a way I can workaround this? Or maybe this is actually an upstream misconfiguration?subpath exports are supported, but were a pretty recent addition. maybe you are on an older shadow-cljs version?
Sorry for the delay — taking a look now. I have updated to the most recent version 2.25.10. I’m stopped with a new error, so I do not know if the version update fixed it. The new error occurs after running watch:
[build-cljs:dev] Failed to inspect file
[build-cljs:dev] /Users/kenny/work/kwllc/deeporigin/data-mgmt/projects/ui/node_modules/@tanstack/query-core/build/modern/focusManager.cjs
[build-cljs:dev]
[build-cljs:dev] Errors encountered while trying to parse file
[build-cljs:dev] /Users/kenny/work/kwllc/deeporigin/data-mgmt/projects/ui/node_modules/@tanstack/query-core/build/modern/focusManager.cjs
[build-cljs:dev] {:line 30, :column 2, :message "'}' expected"}
That is pointing to a file in the react-query library. The line it’s pointing to looks like this.
#focused;
And here it is with more context:
var FocusManager = class extends import_subscribable.Subscribable {
#focused;
#cleanup;
#setup;
constructor() {
super();
...
those are unfortunately still not supported by the closure compiler https://github.com/google/closure-compiler/issues/2731
unfortunately nothing I can do about that from the shadow-cljs side. you can use webpack (or any other JS bundler) via https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider-external
Ah got it, ok. Given the upcoming maintenance mode of the closure compiler, do you think it’s pretty unlikely this will get in?
Hmm curious - this library provides a “modern” and “legacy” build. Would I be able to use the “legacy” build for just this library? It seems to not use the class field syntax.
The focusManager code snippet looks like this in the legacy build.
var import_utils = require("./utils.cjs");
var _focused, _cleanup, _setup;
var FocusManager = class extends import_subscribable.Subscribable {
constructor() {
super();
__privateAdd(this, _focused, void 0);
__privateAdd(this, _cleanup, void 0);
__privateAdd(this, _setup, void 0);
__privateSet(this, _setup, (onFocus) => {
It seems like the webpack workaround is fairly straightforward. Thank you for the clear writings on it 🙂
I’m somewhat surprised I’ve never run into this in the many years of cljs work. I suppose it’s somewhat new. Are folks tending to transition to it now? Or did I just get “lucky” with this tanstack library?
its come up a couple of times recently. for whatever reason the JS world jumps on any new syntax feature as soon as webpack supports it
Circling back - I’m writing an internal note about this issue since I’ll likely tackle in in the next couple weeks. Any guess on why upgrading shadow from 2.23.3 to 2.25.10 causes the class field error? i.e., why wasn’t that error thrown before?
the older shadow-cljs didn't support "exports"
, thus it took the legacy version of the tanstack thing
I mean I guess I could add an option to :ignore-exports #{"tanstack"}
or something to ignore it selectively, but not too sure thats a good idea
Hmm. I was wondering if the two were linked — increased use of subpath exports means more likely more code to use the class field syntax, haha
convention for private used to be _foo
, now its #foo
. totally worth breaking the syntax for that
well some blame is also on the closure compiler folks. I don't get why just parsing the #
and discarding it is not a valid path forward 😛
I have a custom defmacro
macro which I'm bringing in like this:
(ns sci.configs.hoplon.javelin
(:refer-clojure :exclude [dosync defmacro])
(:require [sci.core :as sci]
[clojure.set]
[sci.ctx-store :as ctx-store]
[clojure.walk :refer [prewalk]]
[cljs.pprint :as p]
[clojure.string :as str]
[javelin.core])
(:require-macros [sci.configs.macros :as m :refer [defmacro]]
[sci.configs.hoplon.javelin :refer [with-let*]]))
It works in vanilla ClojureScript but in shadow-cljs (latest) it doesn't seem to be calledprobably related to this? https://github.com/thheller/shadow-cljs/blob/45587a80bf55bb971ed009168a80af58a0fd02ac/src/main/shadow/build/compiler.clj#L411-L417
out of curiosity though. what does this do that makes it relevant to be called in CLJS?
I mean since macros run in their own world, keeping defmacro in the regular CLJS world serves no purpose other than creating bugs
(defn add-macro-args [[args body]]
(list (into '[&form &env] args) body))
(clojure.core/defmacro defmacro [name & body]
(let [[?doc body] (if (and (string? (first body))
(> (count body) 2))
[(first body) (rest body)]
[nil body])
bodies (if (vector? (first body))
(list body)
body)]
`(defn ~(vary-meta name assoc :sci/macro true)
~@(when ?doc [?doc])
~@(map add-macro-args bodies))))