shadow-cljs

greg 2025-02-05T15:12:31.816239Z

Re https://shadow-cljs.github.io/docs/UsersGuide.html#_access_cljs_from_js: What if the CLJS namespace contains dashes? E.g. for this import

import testjs from "goog:example.test-js2"
I get error:
[:app] Build failure:
Closure compilation failed with 1 errors
--- example/test4.js:1
Required namespace "example.test-js2" never defined.
If I remove the dash from the namespace name and namespace import, all works fine.

2025-02-05T16:50:15.988659Z

In js, try an underscore where cljs has the dash

greg 2025-02-05T16:51:19.963139Z

I tried but got yet some other error

greg 2025-02-05T16:57:35.256739Z

[:app] Build failure:
Namespace module$example$testcljsjs2 required example.test_cljsjs1, but the target is example.test-cljsjs1
I attach files that generated this error

greg 2025-02-05T16:58:25.194309Z

again, if I remove - from the namespace, all works just fine

thheller 2025-02-05T18:14:56.199579Z

I do not recommend using this feature. it has very many issues and you will be on your own debugging them

thheller 2025-02-05T18:15:20.870759Z

if you must write JS code it is better to write it as a goog.module, but best to stick with just CLJS 😛

thheller 2025-02-05T18:17:54.617679Z

Required namespace "example.test-js2" never defined. you get because JS files cannot use - in their names as that would map to example.test-js2 variable name which is example.test - js2, as in an actual minus operation. not a valid name.

greg 2025-02-05T19:23:25.163619Z

How can I use goog.module? I couldn't find anything in shadow book about it

greg 2025-02-05T19:26:40.850399Z

You probably mean what is under described under https://shadow-cljs.github.io/docs/UsersGuide.html#_modules. Am I correct?

thheller 2025-02-05T19:59:04.372379Z

no, it is the format used by the google closure library/compiler

thheller 2025-02-05T19:59:12.157969Z

has nothing to do with shadow-cljs specifically

thheller 2025-02-05T20:00:03.244289Z

what are you trying to do? they might not actually do what you need, so kinda need more details