Fork me on GitHub
#clojurescript
<
2021-11-05
>
witek11:11:01

Hello. In my Google Cloud Functions project the deployment broke. shadowcljs compile works, but deployment crashes with:

Error: Error occurred while parsing your function triggers.
TypeError: Cannot read property 'get' of undefined
And this is the generated code where it points to:
java.time.Period=java.time.goog$module$goog$object.get(shadow.js.shim.module$$js_joda$core,"Period");
I always had js_joda in my project and the version did not change. Any suggestions how to debug this? Thanky you very much!

dnolen12:11:39

@witek https://clojurescript.org/news/2021-11-04-release looks like you're running into this since shadow upgraded CLJS as well

dnolen12:11:04

I believe clj-kondo can audit for these cases now? The other things is :global-goog-object&array compiler flag - you can set this to true to get the old behavior

dnolen12:11:25

for the case where the problem is in your dependency which is probably the case

borkdude12:11:41

Yep, clj-kondo reports about this

witek12:11:53

I am using tick... which uses Joda

borkdude12:11:19

the problem is likely in tick

witek12:11:56

The compiler option fixed my issue. Thank you very much. Again! 🙏 ❤️

dnolen14:11:35

I highly recommend doing this in all projects where it is encountered

henryw37416:11:09

Thanks @dnolen - I've pushed a fix to master for that. testing with 1.10.891 I am seeing foreign-lib code is having properties renamed under advanced compilation and so stops working. This is not tick code using foreign code, but actually the foreign code itself. For example in this code from a js lib, the zones property reference of packedJson is renamed. Is there any way to prevent this?

MomentZoneRulesProvider.loadTzdbData = function loadTzdbData(packedJson) {
    TZDB_DATA = packedJson;
    TZDB_VERSION = packedJson.version;

    for (var _iterator = packedJson.zones, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { 

dnolen17:11:11

@henryw374 hrm I would say this is a bit odd - no externs inference test failed (which doesn't prove something regressed but I'm skeptical at the moment)

dnolen17:11:47

@henryw374 we dump the inferred externs to a file in the target - if you're using shadow it might happen in a different way

dnolen17:11:59

you could compared inferred externs from before / after the release

henryw37417:11:51

Ok I'll investigate further. Not using shadow here. I'm surprised foreign lib code is undergoing renaming though. I mean I wouldn't expect to supply any externs for that

dnolen17:11:12

already that's something to look into further

dnolen17:11:43

if the foreign code itself is getting renamed we don't have that much to do w/ that - Closure doesn't process that stuff

dnolen17:11:17

if any renaming is occurring it should be happening in your usage of that foreign lib

henryw37410:11:21

ok - not a cljs problem I think. it turns out that the testing lib, olical/cljs-test-runner, when combined with this version of cljs, does some breaking munging on foreign code.

raymcdermott17:11:55

when porting some code I'm getting a message that the-ns is not in CLJS - is that right?

raymcdermott17:11:16

it's hard to search for answers 🙂

dnolen17:11:15

@raymcdermott very few ns / var facilities exist as they are not applicable

dnolen17:11:31

and/or porting them isn't practical

raymcdermott17:11:05

ok @dnolen good to know that I'm not missing something obvious

raymcdermott17:11:37

I have a function to obtain metadata about any given var

raymcdermott17:11:43

like this in Clojure

raymcdermott17:11:47

(defn add-metadata
  [ns-name var-name]
  (let [ns-thing (the-ns (symbol ns-name))]
    (binding [*ns* ns-thing]
      (meta (resolve (symbol var-name))))))

dnolen17:11:29

@raymcdermott ok, but you shouldn't do that in ClojureSript

dnolen17:11:33

no vars, no namespaces

dnolen17:11:03

there is one edge case where vars become useful in ClojureScript

dnolen17:11:13

but I doubt this applies to what you are doing - and that is lazy loading of code splits

raymcdermott17:11:30

you're right, I'm not doing that

raymcdermott17:11:51

is there another, general way to obtain metadata for functions?

dnolen17:11:37

@raymcdermott I think you need to explain a bit what you are doing?

dnolen17:11:01

you need to reflect into the compiler to get this stuff - nothing works at runtime

dnolen17:11:04

@raymcdermott we haven't done a good job keeping this up-to-date but I just updated some things now - https://raw.githubusercontent.com/clojure/clojurescript/master/devnotes/corelib.org

raymcdermott20:11:05

ah - didn't know about that list 🙂

raymcdermott20:11:58

what I'm trying to do ... inspect the code that somebody is typing into an editor or has pasted in and recognize stuff like meta data. There are heavyweight analysis tools for this but I'm trying to use spec and the core libs to do it all dynamically even if they provide less info.

raymcdermott20:11:31

we don't have time for answering why 😉

p-himik20:11:07

The culprit seems to be the no matching architecture in universal wrapper error. And it also seems that it's caused by using that JDK with that OS - nothing to do with CLJ[S]. I would try a different JDK version, or an x64 version if you're using an x86 one.

Grzegorz Smajdor22:11:59

I’m using M1 processor

Grzegorz Smajdor22:11:51

and I’ve tried jdk-17, and jdk-18

Vinicius Vieira Tozzi23:11:04

I had the same issue with M1, I downloaded the jdk from Zulu: https://www.azul.com/downloads/?package=jdk. And then it worked just fine

Grzegorz Smajdor08:11:49

hmm, interesting, this did not help, I’ve installed it for ARM processors and however, still the same problem, I’ve set the path to the installed one.

Grzegorz Smajdor09:11:34

ok, got it working! needed to bump the

[com.bhauman/figwheel-main] to 0.2.12

Grzegorz Smajdor09:11:45

however, the hot reload does not work

Grzegorz Smajdor09:11:40

however, the dev.cljs.edn contains the ` ^{:watch-dirs [“test” “src”] :css-dirs [“resources/public/css”] :auto-testing true} `

Grzegorz Smajdor09:11:32

nah, never mind! got it working! 🙂 thx!

👍 1
dnolen21:11:57

@raymcdermott I honestly think just using the analyzer would be much easier

1
dnolen21:11:30

All the info you probably need is available