Fork me on GitHub
#shadow-cljs
<
2022-02-17
>
wodin06:02:41

@thheller Hi. I submitted a PR for reagent-expo yesterday to upgrade it to work with Expo SDK 44 and EAS Build. I also added a way to block Expo Web’s fast refresh and removed that section from the README. If you have a chance to check it, please let me know if I need to change anything 🙂 https://github.com/thheller/reagent-expo/pull/10

thheller06:02:03

what is a EAS build?

wodin06:02:52

It’s Expo’s new way of building which allows you to incorporate custom native code. The old way of building is currently still supported, but will be going away at some point. EAS Build allows you to continue using the Expo Managed workflow, and still install dependencies that you would previously have had to eject for. You can also build plain React Native apps using EAS Build.

wodin06:02:47

EAS == Expo Application Services

thheller06:02:59

I don't follow Expo at all so I don't have any way of checking your PR. I'm fine with merging it if you accept that I direct people asking questions your way 😉

wodin06:02:09

hehe 🙂 you can point them at http://forums.expo.dev and there’s a good chance I will see there question and answer them there.

wodin06:02:03

I understand if you don’t want to bother, but it’s really easy to try it out: • Create an Expo account (I think you might have done this in the past) • npm i -g expo-cli eas-cli # there’s a weird yarn bug that sometimes happens when installing these globally with yarn • clone the reagent-expo repo • run yarn to install the dependencies The development instructions are unchanged. The instructions for building a standalone app that you can submit to the App/Play stores is now just basically “run eas build ...” because npx shadow-cljs release app is run as part of the build. So for example you can run: eas build --platform=android --profile=preview which will build a .apk that you can install on an Android device. The first time you do this it will ask for the Android package (which is normally something like io.github.shadowcljs.reagentexpo (Android doesn’t like dashes there for some reason)). If you build for iOS then it will ask for a bundleIdentifier which is basically the same thing for iOS (but dashes are allowed there.) It will also generate a default eas.json config file.

thheller06:02:21

yeah sorry I'm not gonna do any of that. way too swamped already and no time to look into what looks like an entire new ecosystem

wodin06:02:07

No problem

thheller06:02:26

as far as I can tell from your PR nothing on the shadow-cljs changed at all

thheller06:02:37

I can't possibly keep up with all the platform changes happening elsewhere

👍 1
wodin06:02:15

I understand. Yes, I did not change anything about shadow-cljs (except upgrading the version). The changes were just Expo-related and documentation. I think my PR is useful for people following the link from the Expo section of the Shadow CLJS docs. I’ve pretended that the “classic” build system doesn’t exist for two reasons: 1. The original reagent-expo README basically said :man-shrugging: 2. The classic build system will be going away at some point I will attempt to answer questions people have if you direct them to the Expo forums Thanks for your time and for Shadow CLJS 🙂

orestis08:02:57

Is it possible to control the :asset-path dynamically? Via e.g. setting a top-level JS var on window ? I'm dealing with a convoluted setup that must have the asset path being an absolute URL, even in development, e.g. doing :asset-path "", which works fine, but then I'd like to also test on my phone which means that localhost won't do.

thheller08:02:53

not really no

thheller08:02:40

so that you can use one url but that one talks to other servers?

orestis08:02:55

What about calling manually shadow.loader.init ? It seems to be working in my setup. My generated HTML file is doing roughly

<script src={base-module}>
<script src={main-module}>
<script>shadow.loader.init("")</script>

orestis08:02:06

(with :module-loader-init set to false)

orestis08:02:08

It seems to be working but ideally I should probably put shadow.loader.init after the base module? As, at the time main-module gets loaded, React begins to render so it may trigger asynchronous loading...

thheller08:02:09

well yes that affects the loader but that is not the only use of asset-path

thheller08:02:13

at least not during development

thheller08:02:38

init must be called before and use of the loader

orestis08:02:32

The issue with the init method is that it doesn't accept any arguments, so I have to append an extra script tag in my index.html to do this kind of dynamic thing.

thheller08:02:03

well it is not supposed to accept arguments

thheller08:02:09

but you can look at your environment just fine

orestis08:02:19

I could bypass the init-fn entirely and just call my init-fn after I setup the shadow.loader

thheller08:02:36

so for example you can include a <meta name="my-base-path" value="whatever"> in your html

thheller08:02:02

then in init (js/document.querySelector "meta[my-base-path]") to get it out

thheller08:02:23

or <script>_BASE_PATH = "whatever"</script> before the other script takes

thheller08:02:30

and just js/MY_BASE_PATH in the init fn

orestis08:02:39

Right, I can figure that out in multiple ways - I was wondering about that you said about asset-path being used in other places too though?

thheller08:02:56

source maps mostly. if you don't get any warnings/errors regarding those it most likely is fine

orestis08:02:56

Ah right, that's a production concern. In production I hardcode an absolute path for the asset-path. It's only in dev mode that I need to have it dynamic.

thheller08:02:01

dunno what you are doing so can't comment much. normally proxies make all uses of weird server setups unnecessary

thheller08:02:41

(your server may also opt to do the proxying)

thheller08:02:48

also the files generates by shadow-cljs are just static files

thheller08:02:07

so any webserver can serve them. no need to have any built-in shadow-cljs server serve them

orestis08:02:32

What about double proxies? 🙂

orestis08:02:48

But yes, we have a weird setup. Not using shadow-cljs server to serve anything.

orestis08:02:03

It's the module loader that is out of my control, otherwise loading the base files works just fine.

orestis08:02:21

(But it turns out I can init the module loader just fine, so I'm happy. Problem solved 🙂

mauricio.szabo13:02:25

Hi @thheller, I'm having to work with a native, buggy Javascript code (again!) and somehow Shadow/CLJS is behaving strangely. From what I could get, some namespaces simply change to undefined and I can't call function on them anymore - I start the "watch" process, connect my Javascript app, but as soon as it tries to run anything that's on the ClojureScript side, it simply fails with TypeError: Cannot read property 'after_load' of undefined for example (`after-load` is a function defined on CLJS side). I found out that if, just after I connect to the JS app, I reload a specific namespace (by saving the file) then things work. Is there a way to either debug this issue, or force-reload of this namespace all the time?

mauricio.szabo14:02:45

On this example above, the error was triggered from:

(defn ^:dev/after-load after-load []
  (println "Reloaded!"))

(defn start []
  ;; ..setup here..
 (p/do! ;; promesa
          (p/delay 2000) ;;  wait 2s
          (after-load)))

thheller14:02:26

impossible to say without more detail

thheller14:02:09

could be that the JS is just replacing objects you are working with

thheller14:02:27

say you have (ns lib.foo) and the (defn after-load []) in that

thheller14:02:41

if say the JS code does var lib = {}; the ns will be gone

mauricio.szabo21:02:42

RIGHT you are again! I just searched for the old codebase, and it indeed replaces LOTs of global objects - one with the same exact name as my namespace. Thanks again!

jaide14:02:18

Reading the docs but did not find any hints: Is it possible to swap out the version of clojurescript shadow uses? There's some 1.11 features I would like to try

thheller14:02:31

what are you looking for in particular. As far as I know there have been zero changes in 1.11.4 that affect shadow-cljs

thheller14:02:36

thats why I didn't bump yet

jaide18:02:38

https://clojure.atlassian.net/browse/CLJ-2603 the feature that applies the last map in function calls to keyword args caught my eye. Checked out the shadow-cljs repo and seems it's pinned to 1.10?

thheller18:02:38

pretty sure this was after 1.11.4?

thheller18:02:26

anyways. if you are using deps.edn or project.clj you can use any cljs release you want

thheller18:02:42

I can bump it too I guess. was just waiting for a newer release.

thheller18:02:52

yeah this was after 1.11.4, so not in any release yet

thheller18:02:03

you can use the git version of course with deps.edn

jaide19:02:47

> anyways. if you are using deps.edn or project.clj you can use any cljs release you want That's what I was looking for. Thanks once again! Would you be open to a PR against the docs to mention that?

thheller19:02:35

well "any cljs release" is not quite correct

thheller19:02:00

there are certain version requirements to keep in mind so I'd rather not mention it

thheller19:02:33

I have pretty much always stayed with the very latest CLJS release anyways

thheller19:02:05

just didn't this time since there have been no changes in the 1.11.4 release that added any new features or did anything else that would affect shadow-cljs users

thheller19:02:15

all the new stuff is still pending a release

jaide19:02:48

Fair enough. May not be worth mentioning then, though I guess it comes down to what you find more annoying: Questions like this or people reporting issues using an incompatible version of cljs 😆

thheller19:02:54

the latter for sure. you are the first to ask this, so it doesn't come up often

thheller19:02:50

dependency conflicts however are common, since I can't prevent them when deps.edn or project.clj are used

thheller19:02:17

at least with shadow-cljs.edn I can keep them under control

jaide19:02:37

Hah that's probably the right call then