I encountered the {:message "Character '̇' (U+0307) is not a valid identifier start char", :line 13, :column 13} problem ("lower-case" npm module). I am looking at https://github.com/thheller/shadow-cljs/issues/941 and https://github.com/google/closure-compiler/issues/3639 and I understand that this is a Google Closure compiler problem. But is there any hope of it being fixed? Do people have workarounds? In my case, it's a stupid "lower-case" npm dependency that is required by something way down the module chain. But it is a showstopper for me, as it blocks me from using Blueprintjs. Should I write my own npm module that overrides this one, perhaps?
This might be very specific to what I do. My build.clj function for building release ClojureScript does this:
(defn compile-cljs [opts language]
(println "Compiling ClojureScript for language" language)
(let [versioned-js-path (str "/v/" version "/js/" language)
versioned-output-dir (str app-web-dir versioned-js-path)
config (-> ((requiring-resolve 'ui.lazy/add-modules-to-shadow-config) (shadow/get-build-config :app))
;; (assoc :build-id (keyword (str "app-" language)))
(assoc :output-dir versioned-output-dir)
(assoc :asset-path versioned-js-path)))]
(shadow/with-runtime (shadow/release* config {}))
(let [js-map-file (str versioned-output-dir "/" "app.js.map")]
(b/copy-file {:src js-map-file :target (str "resources/app-" language ".js.map")})
(b/delete {:path js-map-file})))
Notice the commented (assoc :build-id) line — if I uncomment this, then :release-stubs stops doing anything. I would suspect caching to come into play, but I really don't understand everything that's going on. The only reason I change the build id is voodoo to prevent possible caching issues between languages.I don't see how changing the :build-id could possibly affect how :release-stubs works?
Me neither. But it does, somehow… Does anything caching-related come to mind?
No, hold on. I don't understand what's going on — now I uncommented the line and everything works as expected. Either I was hallucinating, or there is some state somewhere that doesn't get updated. I'll do more testing. Also, sorry for posting this in the wrong thread 🤦♂️
@jrychter you can actually can configure which packages are used, so if an alternate "fixed" package exists you can just redirect it
:resolve {"lower-case" {:target :npm :require "fixed-lower-case"}} https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve
this also works for indirect requires of some other package, as long as shadow-cljs is bundle it
(i.e. wouldn't work for :node-script where shadow by default doesn't bundle anything and leaves things to node at runtime)
btw npm makes publishing pretty trivial, so just fix the package and publish under your name
Oh, I have to try this :resolve option, then, thanks.
I created a patched version removing the characters that were causing the issue... and always copy paste that file within node_modules. I was hoping it would be resolved with latest release in closure compiler... but it doesn't work in lower-case and upper-case npm dependency yet...
You can use patch-package to patch npm modules https://clojurians.slack.com/archives/CNMR41NKB/p1744737986088659?thread_ts=1744724800.642569&channel=CNMR41NKB&message_ts=1744737986.088659
Also try with latest shadow, maybe recent closure compiler upgrade can help
This is such a terrible rabbit hole. I am using Claude Code to try to override "lower-case" with a "simple-lower-case" module. But it turns out that overriding doesn't reliably work in npm (what a surprise). And now that Claude came up with a fix-modules.sh script in npm postinstall scripts that actually works, it turns out that the same problem exists in the "upper-case" package. The npm world is so terrible. Patches and workarounds on top of patches, with a huge tower of brittle dependencies. I'm new to this, I have spent the last 10 years developing ClojureScript without touching npm.
Well to be fair in this case it’s closure compiler not being able to parse some syntax, patching packages is generally not something that I encounter often in js projects.
Thanks for the advice — it seems patch-package might indeed be a good solution. But perhaps I'll just leave the solution that Claude Code came up with for now. Either of those is a terrible hack anyway.
I think what worries me is the amount of dependencies and their silliness (upper-case and lower-case).
I also wonder if the bug in the Google Closure compiler will be fixed at all — the ClojureScript team seems to have forked it, but I'm not sure if it's actively maintained.
no closure-compiler forks, only the closure-library. different thing.
there was an attempt to fix this https://github.com/google/closure-compiler/pull/3647
but I think the people behind it are no longer with the closure compiler team (or google)