cljsrn

https://github.com/drapanjanas/re-natal | https://github.com/drapanjanas/re-natal/wiki/FAQ | https://github.com/condense/mercury-app/wiki | https://github.com/seantempesta/expo-cljs-template/ https://www.npmjs.com/package/create-expo-cljs-app
Oliver George 2020-04-28T02:45:36.354400Z

Hi All, I'm bolding proposing a PR to metro to allow the constantFoldingPlugin to be disabled. This matters if you need to use advanced optimisation on your releases. For example, my app is too big for the metro bundler without it and throws out of memory errors.

Oliver George 2020-04-28T03:15:04.356800Z

And, nothing is simple in life. I found myself playing whackamole with the type system.

Oliver George 2020-04-28T03:15:38.357500Z

Might withdraw that PR for now. Not sure how to slide the option in without touching every related js file.

Oliver George 2020-04-28T03:16:22.358Z

Here's the feature request... https://github.com/facebook/metro/issues/550

dnolen 2020-04-28T11:01:14.358800Z

@olivergeorge did you try altering the Node memory settings?

Oliver George 2020-04-28T11:02:50.360400Z

It was a long time ago when I tried. Didn’t have success but was left wondering if I was doing something wrong.

Oliver George 2020-04-28T11:03:29.361200Z

Can you point me at an example and I’ll try again

dnolen 2020-04-28T11:07:00.362Z

--max-old-space-size and maybe set that to something relatively large like 4-8gb

Oliver George 2020-04-28T11:07:14.362400Z

Thanks I’ll give it a try

Oliver George 2020-04-28T11:16:40.363200Z

Well that worked. A simple build of my app produces a 9mb main.js file.

Oliver George 2020-04-28T11:17:10.363900Z

My baseline was running node /usr/local/bin/react-native start which throws the GC error. Then I tried node --max-old-space-size=8192 /usr/local/bin/react-native start and it loaded successfully.

Oliver George 2020-04-28T11:17:12.364100Z

So thanks!

Oliver George 2020-04-28T11:17:41.364800Z

Is that how you'd have added the flag? I'm wondering how to ensure that is set when I'm bundling for an iOS release.

dnolen 2020-04-28T11:22:34.365700Z

export NODE_OPTIONS=--max_old_space_size=4096

Oliver George 2020-04-28T11:22:48.366200Z

Brilliant. Thanks.

admarrs 2020-04-28T13:12:02.367100Z

Having an initial play with Krell. What's the mechanism for dragging in image assets?

dnolen 2020-04-28T14:23:24.367400Z

works just like JavaScript

dnolen 2020-04-28T14:23:30.367600Z

make a path relative to your file

admarrs 2020-04-28T14:40:39.367800Z

Thanks. Do you need to js/require?

dnolen 2020-04-28T15:12:44.368Z

yes

admarrs 2020-04-28T17:06:40.368200Z

Hmm, now completely broken with "SyntaxError: Unexpected token ':'"

admarrs 2020-04-28T17:07:23.368400Z

What's the most effective way to trace these errors from the simulator back to the code?

dnolen 2020-04-28T19:02:54.369100Z

@admarrs sorry, it would be easier if you just paste what your asset require looks like

admarrs 2020-04-29T09:00:57.392200Z

Working this morning. Finished last night with the Krell_repl.js error outlined above then this morning cleared target and .cpcahe rebuilt and it works as expected. Thanks for your help.

dnolen 2020-04-28T19:16:48.369600Z

adding a new pass to Krell to pick up js/require that loads libs not just assets

dnolen 2020-04-28T19:16:58.369900Z

should help w/ migration from re-natal

raspasov 2020-04-28T22:15:28.370800Z

@olivergeorge Yes, this is so much needed (disabling constantFoldingPlugin)

Oliver George 2020-04-28T22:24:07.373Z

Hi @raspasov - With the workaround David pointed out you might find it's not critical anymore. From my understanding :simple compilation should be suitable for react native since we're rarely worried about code size and can rely on the VM for optimisations.

Oliver George 2020-04-28T22:24:13.373200Z

Was your problem with advanced compilation? Do you mind sharing your situation/experience.

Oliver George 2020-04-28T22:24:27.373700Z

Just interested to unpack the problem and understand more

raspasov 2020-04-28T22:34:56.374400Z

I use this…

raspasov 2020-04-28T22:35:55.375200Z

It’s not critical, but it has been a problem for years with metro with :advanced compilations

raspasov 2020-04-28T22:36:30.375900Z

I wrote this script that patches the node_modules/metro/src/JSTransformer/worker.js file

Oliver George 2020-04-28T22:42:14.376200Z

yeah, I have something very similar.

Oliver George 2020-04-28T22:42:30.376600Z

My problem was the :simple compilation caused the bundler to crash.

Oliver George 2020-04-28T22:43:15.377500Z

But David's tip about telling node to have a larger max space size means I don't need to use :advanced optimisations

Oliver George 2020-04-28T22:43:30.377900Z

Can you see a downside to that?

raspasov 2020-04-28T22:46:00.379400Z

That can work, but I prefer :advanced, :simple can grow very large as your project grows and you add more and more libraries

raspasov 2020-04-28T22:54:45.383100Z

I am not sure how much this constantFoldingPlugin really saves on the average RN project in terms of code size

Oliver George 2020-04-28T23:00:39.385Z

@raspasov size: yep, mine is 9mb off 40k lines of clojurescript. I guess the question is whether that causes real problems or just "feels" heavy compared to the sorts of filesizes we're used to being suspicious of

Oliver George 2020-04-28T23:01:41.385500Z

(e.g. my 9mb gzips down to 900k so I imagine the app download is still small)

raspasov 2020-04-28T23:15:43.386200Z

@olivergeorge are the app downloads gzipped? I am not sure

raspasov 2020-04-28T23:16:03.386600Z

They might be, I just don’t know

raspasov 2020-04-28T23:16:56.387700Z

The other thing to watch for is app startup time, larger files can have somewhat of a noticeable difference (a few seconds) as far as I recall… I might be wrong, that was a few years ago when I last tested this

Oliver George 2020-04-28T23:17:40.387900Z

Good point. Something to watch for.

raspasov 2020-04-28T23:18:07.388400Z

Might be also more pronounced on not-so-top-of-the-line devices

Oliver George 2020-04-28T23:19:00.389Z

Yeah. Should be testable.

Oliver George 2020-04-28T23:19:30.389800Z

But you make a good point. Even if most people don't hit a performance issue it's going to be helpful to some to have an option to disable constant folding.

Oliver George 2020-04-28T23:20:09.390500Z

Or they could fix it!

raspasov 2020-04-28T23:20:14.390700Z

For sure, thanks for re-posting that issue, while I doubt it will get noticed, I’ll keep hoping

👍 1
raspasov 2020-04-28T23:21:09.391500Z

I assume it’s just not a big issue for them since it only affects a small subset of RN developers who use Google Closure

Oliver George 2020-04-28T23:21:41.392Z

Yeah, adding it is more surface area to test etc... so there's always a downside to adding a feature