This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-07
Channels
- # announcements (10)
- # architecture (25)
- # babashka (5)
- # beginners (95)
- # calva (1)
- # cider (3)
- # clerk (16)
- # clj-on-windows (41)
- # clojure (64)
- # clojure-europe (7)
- # clojurescript (9)
- # deps-new (2)
- # graalvm (25)
- # honeysql (3)
- # hyperfiddle (19)
- # malli (1)
- # meander (5)
- # music (1)
- # nbb (1)
- # off-topic (54)
- # rdf (10)
- # releases (2)
- # shadow-cljs (12)
- # tools-deps (41)
Hi, I’m currently trying to build a mobile app using https://github.com/PEZ/rn-rf-shadow and so far everything is smooth sailing!
Now I’m trying to add a third-party library that uses Buffer
and using it results in the following error:
ERROR ReferenceError: Property 'Buffer' doesn't exist, js engine: hermes
After manually adding buffer
via npx expo install buffer
the error persists.
However, once I add global.Buffer = require('buffer').Buffer;
at the beginning of the index.js produced by shadow-cljs and reload the app in expo, the error disappears and the expected result is shown. But naturally, the added line disappears as soon as shadow-cljs generates a new index.js 😛
Is there any way I could make shadow prepend this line to the output index.js (or set the global variable in another way)? I played around with :prepend-js
and :prepend
a bit and all kinds of stuff in :modules
but I couldn’t really make it work / see any differences.
I cooked up a minimal demo-repo in case anybody is interested in helping me figure this out 😁
https://github.com/dummaso/buffer-problem-demo
Thanks a lot in advance!I don't have a working react-native setup, so I cannot test this. when exactly does this error occur?
depending on WHEN the JS code uses buffer it might be enough to just use (js/goog.exportSymbol "Buffer" Buffer)
in your app.cljs
Good morning, Thomas! Thank you for your support!
1. The error seems to occur after bundling and before shadow-cljs logs that it’s ready.
2. The culprit in this case is https://github.com/cschwarz/wkx for parsing/serializing GeoJson-related data. In my demo-repo, I use it within the wkb->geo-json
fn
3. Adding (js/goog.exportSymbol "Buffer" Buffer)
to the top of app.cljs
unfortunately didn’t show any effect
Here’s the output every time it fails:
› Reloading apps
Android Bundling complete 76ms
ERROR ReferenceError: Property 'Buffer' doesn't exist, js engine: hermes
ERROR Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
LOG shadow-cljs #3 ready!
Changing the js engine to jsc unfortunately also didn’t fix my issue