This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (8)
- # babashka (19)
- # beginners (100)
- # boot (3)
- # calva (16)
- # cider (8)
- # cljdoc (6)
- # cljsrn (15)
- # clojure (73)
- # clojure-europe (7)
- # clojure-france (1)
- # clojure-italy (12)
- # clojure-nl (11)
- # clojure-sg (1)
- # clojure-uk (17)
- # clojurescript (63)
- # cursive (22)
- # data-science (2)
- # datomic (2)
- # defnpodcast (1)
- # docs (1)
- # fulcro (7)
- # graalvm (8)
- # jackdaw (1)
- # kaocha (11)
- # off-topic (26)
- # pedestal (4)
- # planck (1)
- # re-frame (35)
- # reitit (5)
- # ring (3)
- # shadow-cljs (25)
- # slack-help (11)
- # spacemacs (8)
- # specter (2)
- # tools-deps (61)
- # vscode (6)
- # xtdb (3)
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)
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.
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 .
@ericihli What about splitting the large EDN file that you’re trying to load and then loading those smaller files?
I've considered it, but the overall time to parse wouldn't change and it would result in having to add async logic.
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.
@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.
I’ve just suggested this to him in a DM. Glad to hear that my idea is not so crazy after all.
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.
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.
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.