Fork me on GitHub
#cljsrn
<
2016-08-04
>
seantempesta09:08:32

@pesterhazy: It looks like you’ve been doing some research on the react-native packager? I’ve hit a point where I can’t bundle my file anymore (due to the babel parser running out of memory). Have you had any luck circumventing it? I’m wondering if it’s possible to just give the packager a list of dependencies and then include the google closure output file in the bundling step?

pesterhazy09:08:55

yes I've run into this problem

seantempesta10:08:16

Yeah, that workaround was working for a while, but no longer.

pesterhazy10:08:30

my workaround is to always use "--dev true"

pesterhazy10:08:42

that disables whole-program optimizations

pesterhazy10:08:16

I'd obviously like to see better solutions to this problem

pesterhazy10:08:43

the packager doesn't seem to be able to cope with the amount of code produced by the Google Closure compiler

seantempesta10:08:09

I saw that you posted a request to have the packager follow the goog.require statements?

pesterhazy10:08:37

yes, my patch makes that work

seantempesta10:08:47

does that help?

pesterhazy10:08:51

don't think it helps with the memory issue though

pesterhazy10:08:02

it's only relevant for development time

pesterhazy10:08:41

to be honest, node is just not a great environment for a memory-hungry tool

pesterhazy10:08:07

especially annoying considering that it defaults to a 1.5G (?) max heap

pesterhazy10:08:24

I was never able to increase the heap for the packager workers

seantempesta10:08:31

yeah, that’s my problem too

balint10:08:26

anyone here using DrawerLayoutAndroid? was trying to hook up a TouchableHighlight to open the drawer, but its imperative interface is a bit awkward in re-frame afaik we cant use refs, so i was trying a wrapper component's component-did-mount fn to get ahold of the drawer

pesterhazy10:08:12

why can't you use refs?

pesterhazy10:08:37

You can use a ref function that swaps an atom. It's a nice pattern

balint10:08:30

@pesterhazy: could you show/link an example, please? i might be confused

andre.richards10:08:46

You can use react ref, but I don't think it is anywhere in the reagent docs

andre.richards10:08:51

Here is an example:

andre.richards10:08:41

Inside the route-mapper, you can create a component that will then have a reference to the drawer, and can call (.openDrawer drawer)

andre.richards10:08:31

(I haven't tested this specific code, but I implemented something like that a while ago, and it should demonstrate at least how to use ref)

pesterhazy10:08:52

in the example the lifecycle method does something to the component

pesterhazy10:08:59

but you can use this in different ways

balint10:08:10

thanks a lot, guys! im gonna look at your examples when i get home (so i can replace my hacky first version of a solution)

seantempesta12:08:24

okay this is an ugly hack, but if anyone else is desperate to just get the stupid bundler to work, try putting this at the top of this file: node_modules/babel-traverse/lib/index.js:

function scheduleGc() {
  if (!global.gc) {
    console.log('Garbage collection is not exposed');
    return;
  }

  setTimeout(function(){
    global.gc();
    console.log('Manual gc', process.memoryUsage());
    scheduleGc();
  },30000);
}
// call this in the startup script of your app (once per process)
scheduleGc();
then call the bundler with these args: node --expose-gc --max_old_space_size=4096 "./node_modules/react-native/local-cli/cli.js" bundle --entry-file ./worker.js --platform ios --dev false --reset-cache true --bundle-output "ios/worker.jsbundle”

seantempesta12:08:49

(of course replace “worker” with whatever you are trying to build. Most likely index.ios.js?)

seantempesta12:08:30

basically it schedules a garbage collection every 30 seconds to stop the heap size from getting too large.

pesterhazy12:08:25

does node not run GC as a last resort before crashing?

seantempesta12:08:32

apparently not?

pesterhazy12:08:23

it'd be great to add that to the RN packager issue

pesterhazy12:08:34

that could save someone a day or two

seantempesta12:08:09

hmm, I need to tweak it a bit. It keeps running the GC even after the thread exits.

seantempesta13:08:23

Okay, I tweaked the code a bit to fix the thread not exiting and posted an updated comment on the github issue. https://github.com/facebook/react-native/issues/5196