Fork me on GitHub
#cljsrn
<
2021-05-03
>
dsp19:05:39

Hi folks. I've spent several days experimenting trying to get my cljsrn setup working, having tried krell, expo, react-native-figwheel-bridge, and custom hand-made configurations. I keep hitting issues, and I'm pulling my hair out a bit. I have moderate clojure experience, but none with the js ecosystem. I'd appreciate some pointers! I figure expo would be the easiest entrypoint. However:

❯ lein new expo your-project +reagent
Generating fresh Expo project.
README.md contains instructions to get you started.
If you have any questions, you can ask us on Clojurians #cljsrn channel. 
❯ cd your-project
❯ yarn install
yarn install v1.22.10
warning ../package.json: No license field
info No lockfile found.
[1/4] Resolving packages...
warning expo > fbemitter > fbjs > [email protected]: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
warning react-native > fbjs > [email protected]: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
warning react-native > fbjs-scripts > [email protected]: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
warning react-native > metro-babel-register > [email protected]: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
warning react-native > @react-native-community/cli > metro > metro-minify-uglify > [email protected]: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
warning react-native > @react-native-community/cli > metro > jest-haste-map > sane > [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning react-native > @react-native-community/cli > metro > jest-haste-map > sane > micromatch > snapdragon > source-map-resolve > [email protected]: 
warning react-native > @react-native-community/cli > metro > jest-haste-map > sane > micromatch > snapdragon > source-map-resolve > [email protected]: Please see 
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "react-native > [email protected]" has unmet peer dependency "@babel/core@*".
warning "react-native > @react-native-community/cli > [email protected]" has unmet peer dependency "@babel/core@*".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 11.18s.
❯ lein figwheel
Source maps enabled.
Figwheel: Starting server at 
Figwheel: Watching build - main
Figwheel: Cleaning build - main
Compiling build :main to "target/expo/index.js" from ["src" "env/dev"]...
Successfully compiled build :main to "target/expo/index.js" in 11.065 seconds.
Launching ClojureScript REPL for build: main
Figwheel Controls:
          (stop-autobuild)                ;; stops Figwheel autobuilder
          (start-autobuild id ...)        ;; starts autobuilder focused on optional ids
          (switch-to-build id ...)        ;; switches autobuilder to different build
          (reset-autobuild)               ;; stops, cleans, and starts autobuilder
          (reload-config)                 ;; reloads build config and resets autobuild
          (build-once id ...)             ;; builds source one time
          (clean-builds id ..)            ;; deletes compiled cljs target files
          (print-config id ...)           ;; prints out build configurations
          (fig-status)                    ;; displays current state of system
          (figwheel.client/set-autoload false)    ;; will turn autoloading off
          (figwheel.client/set-repl-pprint false) ;; will turn pretty printing off
  Switch REPL build focus:
          :cljs/quit                      ;; allows you to switch REPL to another build
    Docs: (doc function-name-here)
    Exit: :cljs/quit
 Results: Stored in vars *1, *2, *3, *e holds last exception object
Prompt will show when Figwheel connects to your application
... and it just hangs, indefinitely.

naomarik20:05:56

try shadow-cljs, was extremely easy for me to get a new setup going

dsp20:05:50

I dunno. I tried with shadow-cljs, certainly not intuitive how to get it set up to launch anything in an android emulator. It isn't even mentioned in the user guide.

dsp20:05:13

Trivial to go from 0 to browser REPL, but as for later tooling, official docs seem thin on the ground.

naomarik22:05:00

from my recent experience shadow-cljs let me make extremely minimal changes on a brand new app created with react-native's cli tools and there's tons of documentation around how to get things running on simulators there, all works for me

naomarik22:05:24

compared to my experience awhile ago when using re-natal, it's enormously easier

raspasov00:05:54

I’m guessing you have some locahost/IP issue.

raspasov00:05:38

Assuming you’re using figwheel-main, what does you figwheel-main.edn look like?

raspasov00:05:47

Following the instructions here, you should be able to get things running: https://figwheel.org/docs/react-native.html

raspasov00:05:46

I’ve had issues like this, initially. It seems like everything is compiling fine for you, but at the very end the application is not connecting to the REPL. My figwheel-main.edn looks like this:

{:ring-server-options {:port 9500 :host "192.168.1.62"}}
I’ve found that using the local IP of the network works the best for me, allowing me to connect both from simulators and real devices (that are on the same WiFi)

dsp08:05:21

seems this missing figwheel-main.edn was the issue. couldn't see it referenced in any of the guides, though maybe I missed something.

dsp08:05:39

thanks so much!

👍 3
raspasov12:05:36

Glad it works!

dsp20:05:57

When experimenting with react-native-figwheel-bridge, I kept running into issues with Error: Can't resolve './Libraries/Components/AccessibilityInfo/AccessibilityInfo' and similar. None of the 'out-of-the-box' instructions seem to work for me. Am I doing something horribly wrong?

dsp20:05:16

(figwheel-bridge optionsUrl also cannot be fetched: [Error: Figwheel Bridge Unable to fetch optionsUrl: http://localhost:19001/target/public/cljs-out/android/cljsc_opts.json])

raspasov00:05:07

Try compiling for a second time, there’s some weird issue with this, as far as I can tell.

dsp20:05:35

My previous experience was mostly plain clj projects, and am familiar with lein. Plain react native projects have no problem with my setup, launching in the emulator without problems. Am running on Linux.