This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-24
Channels
- # announcements (3)
- # babashka (47)
- # beginners (40)
- # biff (21)
- # calva (12)
- # cider (2)
- # clj-kondo (31)
- # cljsrn (8)
- # clojure (14)
- # clojure-berlin (2)
- # clojure-conj (1)
- # clojure-dev (24)
- # clojure-europe (84)
- # clojure-italy (8)
- # clojure-nl (1)
- # clojure-spec (1)
- # clojure-sweden (2)
- # clojure-uk (2)
- # clojurescript (34)
- # clr (3)
- # community-development (1)
- # cursive (14)
- # datalevin (8)
- # datomic (5)
- # defnpodcast (2)
- # dev-tooling (1)
- # etaoin (4)
- # events (3)
- # fulcro (26)
- # graphql (3)
- # honeysql (6)
- # hyperfiddle (45)
- # lsp (40)
- # malli (1)
- # missionary (1)
- # nbb (18)
- # podcasts-discuss (1)
- # reagent (8)
- # reitit (2)
- # releases (2)
- # ring-swagger (1)
- # scittle (78)
- # shadow-cljs (96)
- # vim (7)
- # xtdb (3)
I would like to see if I can use scittle from inside a Swift playground. It must be possible. I was able to load the file and evaluate the module without errors. However, after that I'm pretty much lost. The file I'm using is scittle.min.js
from JSDelivr. Before I set up the scittle dev env on my system, is there some way I can bundle everything in one file but it's not optimized? There is a bb dev
task but that might not be bundled.
@UPJP9G4G1 You can compile with :optimizations :simple
to get one file without optimizations
I'm not sure how Swift relates to JavaScript but I'd like to hear more about it. I'll check back in tomorrow after getting some sleep
So, I added a new task, created a new build for shadow-cljs. I ran npm install
and then bb tasks
to see if my task had registered. Afterwards, I ran bb ios
and got the attached error. I also got this error when I opened VSCoded because Calva complained about it and told me that the build might not work correctly. I'll attach the changed files, also because I'm not sure if I'm doing this right :D
Alright, now calva says that shadow-cljs is not installed. I might have to read the docs for shadow-cljs. My only project in cljs was done with figwheel-main.
Hm, I did that and when I run it again, it says all is installed. The error log above is looking for some .cp
file in .cpcache
but I thought that is only available after compilation.
> Library org.babashka/sci has prefix sha, use full sha or add tag Do you still get that?
Can you push the branch you're working on? This is easier than looking at snippets of code in slack
Sure, no hurry, though. I have errands to run today and my family needs me as well. I'll try to find some time later on. I'll let you know.
It could also be that this is something with my system. I'll go and see if something similar is occurring in other repos as well.
I’ll try but as I wrote, this error occurred right when I opened Calva for the first time.
I'm only interested in the output of bb dev
in the main
branch of scittle without any of your changes
Here's the output. I also tried on a different system, and did get an error but a different one. 😊 So, it's probably my system configuration.
Let me talk to #C6QH853H8 and see what they're saying. I'll get back to you as soon as I know what's wrong.
Yeah, I just ran my custom ios task. I’m going to have lunch with my family now. Will get back to you later.
Alright, I was able to compile scittle with different optimizations but I run into a couple of problems on the Swift side of things.
First of all, this should in principle be possible. iOS has https://developer.apple.com/documentation/javascriptcore which allows evaluation of JavaScript. It's specifically meant for running JS code from within Swift and even treat JavaScript entities such as functions and data structures like Swift entities. This is pretty cool.
However, what I need is just Scittle's (eval-string)
. I was hoping that if I evaluate Scittle I will have access to the module somehow but I'm not even sure if it's properly loaded as the evaluation function just returns undefined for stuff like 1 +
which is obviously broken JS and should cause some kind of error. I think part of the problem is that Scittle is meant to be run in the browser and there are references to window
in the compiled code. So, I suspect it's not even loading. If I try to run it in node it just breaks. I tried changing the target to :node-library
but that caused some errors, so I need to take some time and look into it more closely.
Then you can delete this: https://github.com/babashka/scittle/blob/cfaf6b0b33e6a2fd1fb82ef99871be38ce0e5c53/src/scittle/core.cljs#L66-L104
and also you won't need reagent etc, so I'd also leave that out (just delete it from the shadow-cljs.edn)
About the window reference. That was in the compiled code. So, I'm not sure if you have actual references to it in the cljs code 🙂
but it still has references to js/document
to load the script tags, you can remove those
Alright, so, I’m in a little bit of a dead end right now. I created a minimal project and targeted node
and none
and in both cases the Google Closure code relied on something that did not exist and the code execution did not reach the namespace I created. I managed to get the namespace to run and execute my function but only by manually deleting Google Closure code from the compiled js file. However, I still think that this is possible. I hear that there is react native applications written in ClojureScript that run in iOS. However, I used cljs.main for this. Maybe I should use shadow-cljs. In addition to that there is [replete](https://github.com/replete-repl) which is using some compiles version of clojurescript from [planck](https://github.com/planck-repl/planck)