cljsrn

hadils 2024-08-03T13:55:21.696189Z

I am having problems with Krell and the Hermes engine. I need to use the engine because I depend on react-native-reanimated in my app. However, the :language-out :es5 setting seems to have no effect. Thanks in advance for any suggestions, answers.

hadils 2024-08-03T14:03:44.872099Z

Turning off the Hermes engine results in a run-time exception (red screen of death).

hadils 2024-08-05T19:22:55.133489Z

I resolved my :language-out :es5 problem with Hermes. It was due to a mismatch between the Clojurescript compiler and Krell. I restored my deps.edn to use Krell only and everything works now.

hadils 2024-08-05T19:29:07.353799Z

However, when I compile, I get the following errors:

ERROR  Could not evaluate  [SyntaxError: 16:150:';' expected]
 ERROR  Could not evaluate  [TypeError: Cannot read property 'getLogger' of undefined]
This is because Krell or Clojurescript inserts exclamation points in the var name. I verified this by replacing these with _ characters and it solves the problem. Also, this bug breaks REPL output, since pprint does not work. Please help me solve this problem. Thanks in advance.

joshmiller 2024-08-05T21:14:22.193309Z

I personally just don’t use Hermes but it comes up in here a lot

hadils 2024-08-05T21:15:01.376719Z

Thanks @joshmiller I really appreciate it.

joshmiller 2024-08-05T21:16:47.094669Z

If that works, could you post your working build.edn here or somewhere else? We just have scattered references to settings in the channel and elsewhere.

hadils 2024-08-05T21:32:38.028659Z

Yes, I will.

👍 1
hadils 2024-08-05T22:34:24.911339Z

That didn’t work. I think that is a shadow-cls setting. I am using Krell.

joshmiller 2024-08-05T22:36:47.230639Z

Argh, yeah, looking back farther I see that now

hadils 2024-08-05T22:37:17.141379Z

I am going to try switching to jsc. I am blocked right now.

👍 1
joshmiller 2024-08-05T22:37:40.545169Z

I have just stuck with JSC, but I’m not using reanimated

hadils 2024-08-05T22:38:05.293719Z

Good to know.

joshmiller 2024-08-05T22:39:05.286509Z

I wonder if you could get away with using advanced optimizations since you wouldn’t get all the special characters in the variable names

hadils 2024-08-05T22:39:22.223519Z

does that work with the REPL?

joshmiller 2024-08-05T22:39:33.906999Z

No, not at all.

joshmiller 2024-08-05T22:39:40.081289Z

Just curious if it would work.

hadils 2024-08-05T22:39:40.621639Z

ok.

hadils 2024-08-05T22:40:12.238819Z

Let me see if I can get jsc to work, then I may try that later.

joshmiller 2024-08-05T22:41:27.388339Z

You could also try :es5-strict as your output

hadils 2024-08-05T22:41:41.176569Z

Tried that, didn’t work.

hadils 2024-08-05T22:44:02.682599Z

When I use JSC, I get the red screen of death saying “Can’t find require”

joshmiller 2024-08-05T22:46:07.313119Z

I wonder if there’s a) a compiler option that will let you remap $ to something Hermes doesn’t choke on and b) if that’s exposed to the Clojurescript compiler tool

joshmiller 2024-08-05T22:46:37.228999Z

--rename_variable_prefix VAL
Specifies a prefix that will be prepended to all variables.

hadils 2024-08-05T22:47:22.168129Z

It is the ! character and it is probably done before the closure compiler, because the repo path is appended to the var name with the !

joshmiller 2024-08-05T22:48:47.005529Z

Can you paste a snippet of what that emitted code looks like?

hadils 2024-08-05T22:49:17.861069Z

I will tomorrow. For now, I am trying to get JSC to work.

joshmiller 2024-08-05T22:49:28.765559Z

Cool 👍

joshmiller 2024-08-05T23:53:13.574889Z

I replicated this in my own project just now, found a couple things:

joshmiller 2024-08-05T23:54:20.033119Z

1) The only place it happens is goog/log/log.js, and that’s also the only place with the file location ..._m2$repository$google_closure_library$ bits at all

joshmiller 2024-08-05T23:54:45.188939Z

2) Someone ran into this with figwheel back in 2021, same place, but without any kind of resolution: https://clojurians-log.clojureverse.org/clojurescript/2021-07-29

hadils 2024-08-06T00:09:05.283499Z

Thank you for your findings, @joshmiller. I am having difficulty with JSC at the moment.

hadils 2024-08-06T00:09:20.602269Z

I will look into encoded JVM resources though

hadils 2024-08-06T00:11:27.398429Z

Would you happend to know how to properly upgrade the Clojurescript dependency in deps.edn?

hadils 2024-08-06T00:11:36.088429Z

for Krell?

joshmiller 2024-08-06T00:34:53.272729Z

You can just specify a Clojurescript version in deps.edn. I tried downgrading to the one described as working in that 2021 conversation, but it broke too many things in my project. I tried upgrading to the latest and it didn’t fix anything.

hadils 2024-08-06T00:35:46.603909Z

Thanks @joshmiller. My JSC is stuck. I am thinking of using RN instead of Expo

joshmiller 2024-08-06T00:42:43.337649Z

The problem seems to be when it rewrites a class Foo into an es5-compatible function, and it expands the file location but when it’s in a jar it doesn’t know that that file is going to have a ! in the resource path

joshmiller 2024-08-06T00:43:09.819999Z

I think log.js is just the only Closure library with classes in it that is likely to be called from ClojureScript

hadils 2024-08-06T00:43:42.029289Z

so should i just write a script to fix it?

joshmiller 2024-08-06T00:48:09.000199Z

I think you could do that as a quick hack, just text replace !$ with _$ in that one file

hadils 2024-08-06T00:48:27.740059Z

good idea!

joshmiller 2024-08-06T00:48:37.242309Z

I’m trying to see if there’s a place to actually fix it in case another file gets pulled in as well

joshmiller 2024-08-06T17:57:48.210119Z

@hadilsabbagh18 I posted about the problem in #clojurescript https://clojurians.slack.com/archives/C03S1L9DN/p1722966979115689

joshmiller 2024-08-06T17:58:10.395299Z

I think it’s a Closure bug? Probably because they’re not expecting JAR file sources.

hadils 2024-08-06T17:58:23.685839Z

Yes I saw that. Thanks @joshmiller

👍 1
hadils 2024-08-06T17:58:55.198829Z

Why only this file, though?

joshmiller 2024-08-06T17:59:57.500429Z

I believe it’s because it’s the only file that uses ES6 classes that’s in a JAR that is required by the CLJS in a normal RN project.

hadils 2024-08-06T18:00:14.145809Z

Ah

joshmiller 2024-08-06T19:22:39.543839Z

Ok, so I have a hack that works for me: • Create a file scripts/fixClosure.sh with these contents:

#!/bin/sh

find ./target/goog -type f -name "*.js" -exec sed -i '' 's/\!\$/_$/g' {} +
• Update my start in package.json to be "sh ./scripts/fixClosure.sh && react-native start" This requires that you wait for Clojure to finish compiling and be ready for a repl before doing yarn start or npx start, but since those files aren’t getting re-compiled during dev, it doesn’t need to run again.

👀 1