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
Eric Ihli 2020-01-20T18:06:38.006400Z

Still troubleshooting the issue mentioned above on Friday. I wanted to compare slurping and parsing the EDN to loading a raw json file. I have this in one of my cljs files. (defonce data (js/require "../../assets/test.json")) When I run npx react-native run-android, I get an error:

Loading dependency graph, done.
error SHA-1 for file /home/eihli/code/ezmonic-mobile/assets/test.json (/home/eihli/code/ezmonic-mobile/assets/test.json) is not computed. Run CLI with --verbose flag for more details.
ReferenceError: SHA-1 for file /home/eihli/code/ezmonic-mobile/assets/test.json (/home/eihli/code/ezmonic-mobile/assets/test.json) is not computed
    at DependencyGraph.getSha1 (/home/eihli/code/ezmonic-mobile/react-native/node_modules/metro/src/node-haste/DependencyGraph.js:258:13) 

Eric Ihli 2020-01-20T18:12:41.011300Z

I found an issue that mentioned a couple of fixes. https://github.com/facebook/metro/issues/330 One fix was to modify a file in metro. metro/src/node-haste/DependencyGraph.js#getSha1 . Since I'm not directly using metro but instead using it through react-native-cli, I didn't want to spend too much time learning the build process of both react-native-cli and metro so that I could build/test/use custom versions of each locally. Another fix was to put assets in a specific folder: ../../assets/asset.png as mentioned in that issue. I figured maybe that was the default assetRegistryPath mentioned https://facebook.github.io/metro/docs/en/configuration#assetexts. But I tried using that path as well as setting the assetRegistryPath in my metro.config.js and I continue to get the same error.

Eric Ihli 2020-01-20T19:47:10.012900Z

Finally figured out the process of applying the change to DependencyGraph.js in that metro issue. It didn't work for me. Still getting the same error about SHA-1 for file...is not computed .

dotemacs 2020-01-20T19:49:01.013900Z

@ericihli What about splitting the large EDN file that you’re trying to load and then loading those smaller files?

Eric Ihli 2020-01-20T19:50:37.014900Z

I've considered it, but the overall time to parse wouldn't change and it would result in having to add async logic.

Eric Ihli 2020-01-20T19:51:17.015800Z

And I can't think of a good way to split up the file where 1/x-th could be used independently of the other (n-1)/x-th.

Eric Ihli 2020-01-20T19:52:02.016700Z

Well... not simply.

vikeri 2020-01-20T19:55:07.019700Z

@ericihli we prebuild a SQLite file for a similar use case. But that requires SQLite though. One reason the performance can be different is that if you’re running with the debugger then the code is executed in Chrome instead of on the device. V8 vs. JSC plus that your workstation surely is more powerful than the average phone.

dotemacs 2020-01-20T19:58:00.020300Z

I’ve just suggested this to him in a DM. Glad to hear that my idea is not so crazy after all.

Eric Ihli 2020-01-20T20:10:42.022Z

Thanks for the idea from both of you. I'm going to test it out and may end up using it if it's fast enough. But I still need to know how to require a json object. It has become personal. A quest to understand.

💪 1
vikeri 2020-01-20T20:11:26.022800Z

Haha, I know the feeling

Eric Ihli 2020-01-20T20:44:25.025200Z

Updating the getSha1 method as described in the github issue worked. I made a mistake in my initial attempt by editing DependencyGraph.js in the wrong package.

1
vikeri 2020-01-20T20:45:06.025800Z

Awesome, how fast did it load?

Eric Ihli 2020-01-20T20:45:56.026500Z

Heh. I'll be lucky if I can answer that question by the end of the day. I just got it to build without error.

vikeri 2020-01-20T20:46:06.026700Z

Haha ok