shadow-cljs

grahamcarlyle 2025-02-27T16:14:35.683449Z

I've enountered a problem using shadow-cljs "release" compilation with a new version of the lexical npm library (0.25.0). The previous version worked fine (0.24.0), and development builds are ok, but release compilation with any optimization level produces js that generates exceptions in the browser. The browser exceptions are happening when characters are deleted within the editor widget from the lexical library and have the message "ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor". I've created a example repo which reproduces the error https://github.com/grahamcarlyle/shadowcljs-lexical-0.25.0-bug

thheller 2025-02-27T16:23:43.238959Z

are you sure this is not due to some API changes? i.e. the newer version expecting to be passed different props or so?

grahamcarlyle 2025-02-27T16:31:47.862489Z

I don't think so, the example is pretty minimal and corresponds to their "getting started" example. This https://github.com/facebook/lexical/pull/7047 might be relevant as it suggests they might be producing their prod build differently

thheller 2025-02-27T16:33:12.763309Z

that would have been my next guess. the package contains a bunch of .prod.js files that the watch/compile builds do not use

thheller 2025-02-27T16:37:22.036349Z

I'll check in a bit whether it works if the release build also uses the "dev" files

thheller 2025-02-27T19:45:41.943009Z

yep, confirmed it. it is a problem on the library side. the build seems to be broken.

thheller 2025-02-27T19:45:54.316449Z

you can change the config to

{:deps true

 :dev-http {8080 "public"}

 :builds
 {:frontend
  {:target :browser
   :js-options {:export-conditions ["development" "browser" "require" "default" "module" "import"]}
   :modules {:main {:init-fn }}}}}

thheller 2025-02-27T19:46:55.607179Z

that fixes it. if you replace the "development" with "production" it breaks again completely, cause watch/compile will then also use the .prod.js files

thheller 2025-02-27T19:47:12.179839Z

can't say if its the library itself, or the processing the closure compiler does with it

thheller 2025-02-27T19:47:20.804349Z

but there is something off on the production files

thheller 2025-02-27T19:49:31.225699Z

hmm, tested another thing removing the :js-options and just setting :compiler-options {:output-feature-set :es-unsupported}. this also seems to fix it. it basically turns off any transpiling the closure compiler may attempt. so maybe the bug is indeed in the closure compiler

thheller 2025-02-27T19:49:42.974069Z

nothing I can fix from the shadow-cljs side I'm afraid

thheller 2025-02-27T19:50:21.088569Z

> "ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor".

thheller 2025-02-27T19:50:34.694409Z

I never got that error though. only Uncaught TypeError: Q is not a function.

grahamcarlyle 2025-02-27T21:15:54.005739Z

Yes thatโ€™s the error I see in the console too, but if I pause on the exception in chrome devtools then the underlying error seems to be the reference error

grahamcarlyle 2025-02-27T21:17:26.870619Z

Thanks for looking into it ๐Ÿ‘

๐Ÿ‘ 1