Trouble with publish to exp.host

Loving Expo and React Native, but I’m running into a strange problem once I publish my app…

In debug mode against the local packager, the app runs fine. I can walk through the onboarding process without a problem. However, once “published”, the first few steps of onboarding work as expected, but the culminative step appears to fail and restart the app. The symptom is that the activity stops, I get the white screen with spinner (just like when initially launching) and then the first screen appears.

The step it is failing on is doing some fairly heavy crypto calculations - which takes a couple of seconds on my phone - tying up the JS thread. This is behind a modal spinner which continues to spin - so I figured all was OK. The crypto stuff was hard to get working - but, again, it works fine on my development environment …

Any thoughts?

Have you tried turning minification/production mode on locally?

I haven’t yet - will that give me error log output / exception traces ? How do I get that running?

Thanks.

-pete

If you click the gear icon in the URL bar of XDE, you can uncheck development mode. See if you can reproduce with that JS bundle?

Interestingly, with the gear->Development Mode unchecked it does not exhibit the bad behavior. Works fine.

(Had to fire up XDE, have been using npm start)

What differences are there between the local non-development mode and the bundle that gets created as part of the ‘exp publish’ command?

Hm, interesting. The bundle that’s generated for publish is AFAIK almost exactly identical to the bundle you get when dev mode is turned off. Is my understanding about that accurate @ide?

Publishing currently just creates a bundle with dev=false and minify=true.

@ide - is that different than what I get in non-Development Mode in XDE? Seems like my app works OK in non-Development Mode from XDE, but doesn’t work when published…

Is the behavior I described above “activity stops, I get the white screen with spinner (just like when initially loading) and then the first screen appears again” - indicative of a hard crash and ‘reboot’ in the Expo client? No red-screen of death, just a quiet reboot…

-pete

You also need to turn on minification to faithfully produce the same JS bundle as the published one.

You won’t get the red screen since dev=false disables it. If minification is causing the issue, you could try turning on minification and keeping dev=true and seeing if you get a red box.

Thanks, @ide

OK - running like this:

exp start --minify --no-dev

throws an exception that I am now catching that appears to be minification related. That is, when I run --no-minify --no-dev the code runs as expected.

Now the question is… how do I find the culprit? Just prune back until I figure out what library isn’t minifying properly? Any tips on that front?

Best,

pete

AHA!

Here’s some guidance from the bitcoinjs-lib guys: " When uglifying the javascript, you must exclude the following variable names from being mangled: Array, BigInteger, Boolean, ECPair, Function, Number, Point and Script. This is because of the function-name-duck-typing used in typeforce. "

Is there a way for me to exclude these symbols from uglification without "eject"ing my project?

Best,

pete

Unfortunately not, you’ll need to detach to get more granular control over the minification :confused:

OK - here’s how I solved it for now. I used the .babelrc to map the pesky typeforce package to a stubbed version and everything seems to work ok. This is a bit bogus, but since afaik typeforce is only for doing runtime type checking it should be ok - at least until something else forces me to ‘eject’! :slight_smile:

1 Like

Great. Nice workaround

Excuse me, could you elaborate a little more on the solution? To try to understand it. Forgive the ignorance. Thank you!