Fork me on GitHub
#cljsrn
<
2017-07-31
>
pesterhazy10:07:59

@jeaye just tried out your repo and was able to repro the problem TimeoutError: transforming /Users/pe/prg/react-native-packager-bug/index.android.js took longer than 301 seconds.

austinbirch11:07:11

Hi @pesterhazy, @jeaye: I just caught myself up on the #cljsrn chat history for the last couple of days, and the timing of this is pretty funny. I used to experience the same type of timeout/memory issues that you have been talking about, but I made some terrible hacks to avoid them when I was on RN 0.40.0. Last week I went through the upgrade process from RN 0.40.0 -> 0.46.4 process for the ClojureScript + React Native app that I work on, which (as expected...) broke my release bundling process again. So, after upgrading my hacky setup, I wrote a rough post (http://austinbirch.co.uk/2017/07/28/clojurescript-and-react-native-bundling-for-release-with-advanced-optimisations.html) about how I hacked my way around the issues for future reference, and mostly finished it up last weekend. I’ve published it in its current state just now in case there’s anything useful in there that can save you time/validate assumptions etc. @pesterhazy, I think your re-natal-husk idea is much much better than the setup I have, but you still might have trouble getting source maps working with it? If so, you might want to take a look at the first part of my approach (custom transfomer); it might help you to come up with something workable for source maps. I really wish I had had waited until this week to start upgrading RN so that I could have started with your approach - it seems pretty promising to me.

pesterhazy11:07:18

@austinbirch very interesting thanks

pesterhazy11:07:18

will read the blog post later today. good point about the source maps. Out of curiosity, what do you need the source maps for in Release builds?

pesterhazy11:07:52

on the larger point, I think we really need to break this cycle of packager updates breaking prod builds, again and again

pesterhazy11:07:34

ideally the fix should go into metro-bundler directly, but I'm not holding my breath given hoe reponsive their devs have been in the past

pesterhazy11:07:05

the 2nd best option would be a reliable workaround, which I think the react-native-husk experiment might prove to be

cristian.sandu12:07:03

hello, how would one go about implementing deep linking in clojure, as in: https://medium.com/react-native-training/deep-linking-your-react-native-app-d87c39a1ad5e

austinbirch13:07:30

@pesterhazy > Out of curiosity, what do you need the source maps for in Release builds? We had some trouble using :simple optimizations. The final main.jsbundle was massive (we have quite a large project, I suppose) so the app did take a long time to start in release. We were also were getting some iOS OOM issues too. Oh, and builds created with :advanced seemed more responsive UI-wise for us too. Compiling with :advanced optimisations solved those problems (much smaller bundle, less time taken for RN to load it, no OOM issues), but meant that any exceptions that occured during use were pretty annoying to debug. The stacktraces sent to Sentry listed columns/lines from main.jsbundle, and obviously all of the names were mangled & minified too. Recovering source maps gives us original file+line+column in Sentry, and inline original-CLJS for the context around those stack traces as well. Agree with the rest of what you’ve said above. I was hoping that as other users of compile-to-JS languages had issues the packager would grow to be able to work with that model, but that doesn’t seem to have happened yet. I did consider figuring out a PR for metro-bundler, but without any documentation it’s pretty hard to understand.

mfikes13:07:22

I’m continuing to dig into why NativeModules is empty for iOS, unless debugging remotely with Chrome. I found that it is also empty when doing prod builds, which seems to exclude the re-natal Figwheel bridging from being a cause. I’ll share if I figure out what is causing this.

pesterhazy13:07:12

@mfikes I'm pretty sure I've used NativeModules from re-natal in both figwheel and prod builds

mfikes13:07:44

@pesterhazy Cool. Perhaps something regressed with later RN versions

pesterhazy13:07:08

Could it be that it's a magical object that only works right of you access a property but you can't enumerate keys?

pesterhazy13:07:38

Maybe the module was there all along but hidden

mfikes13:07:40

@pesterhazy You appear to be correct on the “magical object” theory.

pesterhazy13:07:08

Hidden in plain sight

mfikes13:07:16

I’ve updated the README showing things working now: https://github.com/mfikes/use-native-code

aj taylor19:07:23

What would be the standard way to handle different api urls when in dev vs prod for cljs? I’m fairly newer to front end so I’m not sure if this is even the right question.

pesterhazy19:07:10

the RN packager sets the js/__DEV__ var

pesterhazy19:07:26

I use

(defn dev? [] (and (exists? js/__DEV__) js/__DEV__))

pesterhazy19:07:02

so if you're compiling a bundle for Release configuration (xcode/iOS), (dev?) will be false, and true in Debug configurations

jeaye19:07:14

There's also :closure-defines {"goog.DEBUG" false} in your project.clj

pesterhazy20:07:54

note that you can nicely run Release builds in the simulator: run-ios --configuration Release

pesterhazy20:07:43

@austinbirch just had a chance to read your blog, nice work

austinbirch20:07:51

@pesterhazy thanks. Still want to clear some of it up (usefulness is understanding why the packager tweaks are needed, not the implementation) but hopefully it won't be relevant for much longer!

jeaye21:07:59

@pesterhazy hehe, what a silly macro.

pesterhazy21:07:20

silly but useful 🙂

pesterhazy21:07:35

the husk approach seems to work for me, but it would be great if someone else could try it as well

pesterhazy21:07:06

I still have 2 todos

pesterhazy21:07:34

it'd be great to have a better way to use the script. Currently you need to change your xcode config/ Android build config to use a different script

pesterhazy21:07:07

also it'd be great to auto-generate this file from .re-natal: https://github.com/pesterhazy/re-natal-husk/blob/master/husk-requires.js

jeaye21:07:46

I've brought it up with my guy and we think it's a good workaround. Currently, :advanced is both working around the timeout/OOM issues as well as giving us a smaller/faster bundle. For generating a non-prod APK, using :none or :simple, I think we'll go with your approach, but we don't yet have that need and are trying to meet some other deadlines.

pesterhazy21:07:18

yeah I know how it goes

pesterhazy21:07:34

:advanced is great as well

pesterhazy21:07:54

my approach should have advantages with advanced comp too - much faster bundling step

pesterhazy21:07:06

but i know it doesn't matter so much as long as it finishes

jeaye21:07:39

Yep, agreed that it would be faster. You should add a comment to that RN ticket, for any CLJS users who hit that issue again and need this.

jeaye21:07:06

I can also link the example repo I made there as well.

pesterhazy21:07:34

right, which ticket was that again?

jeaye21:07:55

Nice. I'll follow up with my test repo in a bit.

jeaye21:07:11

Thanks for all your help with this.

pesterhazy21:07:47

it's an itch i wanted to scratch for a long time