shadow-cljs

jrychter 2025-05-02T03:48:54.991889Z

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?

jrychter 2025-05-08T09:58:30.979899Z

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.

thheller 2025-05-08T10:06:03.963799Z

I don't see how changing the :build-id could possibly affect how :release-stubs works?

jrychter 2025-05-08T10:28:22.069099Z

Me neither. But it does, somehow… Does anything caching-related come to mind?

jrychter 2025-05-08T10:30:48.365159Z

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 🤦‍♂️

thheller 2025-05-02T07:07:34.305089Z

@jrychter you can actually can configure which packages are used, so if an alternate "fixed" package exists you can just redirect it

thheller 2025-05-02T07:08:03.231869Z

:resolve {"lower-case" {:target :npm :require "fixed-lower-case"}} https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve

thheller 2025-05-02T07:09:05.121319Z

this also works for indirect requires of some other package, as long as shadow-cljs is bundle it

thheller 2025-05-02T07:09:32.095579Z

(i.e. wouldn't work for :node-script where shadow by default doesn't bundle anything and leaves things to node at runtime)

thheller 2025-05-02T07:19:15.686549Z

btw npm makes publishing pretty trivial, so just fix the package and publish under your name

jrychter 2025-05-02T08:38:53.702989Z

Oh, I have to try this :resolve option, then, thanks.

Pragyan Tripathi 2025-05-02T04:26:03.948929Z

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...

Roman Liutikov 2025-05-02T04:54:40.563909Z

Also try with latest shadow, maybe recent closure compiler upgrade can help

jrychter 2025-05-02T04:54:57.483299Z

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.

Roman Liutikov 2025-05-02T04:58:38.849379Z

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.

jrychter 2025-05-02T04:59:34.030589Z

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.

jrychter 2025-05-02T05:00:12.137379Z

I think what worries me is the amount of dependencies and their silliness (upper-case and lower-case).

👍 1
jrychter 2025-05-02T05:03:26.544849Z

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.

thheller 2025-05-02T06:20:50.763299Z

no closure-compiler forks, only the closure-library. different thing.

thheller 2025-05-02T06:22:49.000849Z

there was an attempt to fix this https://github.com/google/closure-compiler/pull/3647

thheller 2025-05-02T06:23:13.498549Z

but I think the people behind it are no longer with the closure compiler team (or google)