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
Oliver George 2020-05-07T00:05:28.007700Z

Code is so similar to the https://github.com/clojure/clojurescript/blob/fef7d05ab398bb20acf07d16cb16aa467631f279/src/main/clojure/cljs/repl/browser.clj#L482 that it's either a subtle bug elsewhere or I am being a muppet.

Oliver George 2020-05-07T01:16:57.008300Z

Yeah, I'm not demonstrably a muppet this time. Needs to be "-c -r" to generate it though. I'll log a bug.

Oliver George 2020-05-07T01:26:14.008500Z

https://github.com/vouch-opensource/krell/issues/80

dnolen 2020-05-07T01:46:21.009Z

thanks

dnolen 2020-05-07T15:40:46.009700Z

untested but I believe everything is in place

dotemacs 2020-05-07T15:41:28.010600Z

Thanks for that @dnolen I’ll give it a spin right away

dnolen 2020-05-07T15:41:30.010700Z

feel free report any tweaks this needs

dnolen 2020-05-07T15:41:54.011200Z

I won't be able to help out wrt. to actually trying this, busy with other stuff - but I don't think there's anything missing to make it work

👍 1
dnolen 2020-05-07T15:42:44.011900Z

krell.api/build is generally useful for scripts

dnolen 2020-05-07T15:43:09.012400Z

(krell.api/build :some-build {:verbose true} "more_opts.edn") works

dnolen 2020-05-07T15:43:18.012700Z

all options merged left to right

dotemacs 2020-05-07T16:01:15.013400Z

The first thing that is missing is '[<http://clojure.java.io|clojure.java.io> :as io] in the :require clause, as io is used.

dnolen 2020-05-07T16:04:12.013600Z

fixed thanks

dotemacs 2020-05-07T16:10:46.013800Z

This is what happens. I eval this in Emacs:

(setq cider-custom-cljs-repl-init-form
      "(require '[cider.piggieback]
         '[<http://clojure.java.io|clojure.java.io> :as io]
         '[krell.api :as krell]
         '[krell.repl])

(def config (slurp (io/file \"build.edn\")))
(krell/build config)
(apply cider.piggieback/cljs-repl (krell.repl/repl-env) (mapcat identity config))")
From the root of the project, where deps.edn is, I run M-x cider-jack-in-cljs, which runs:
/usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/piggieback {:mvn/version "0.4.2"} refactor-nrepl {:mvn/version "2.4.0"} cider/cider-nrepl {:mvn/version "0.24.0"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'
Then I’m prompted what REPL type I want, and I type custom. The REPL starts, and this is returned:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See <http://www.slf4j.org/codes.html#StaticLoggerBinder> for further details.
nil#'user/configFileNotFoundException {:main awesome-project.core
:output-to "target/main.js"
:output-dir "target"}
(No such file or directory)  <http://java.io|java.io>.FileInputStream.open0 (FileInputStream.java:-2)
IllegalArgumentException Don't know how to create ISeq from: java.lang.Character  clojure.lang.RT.seqFrom (RT.java:550)

dnolen 2020-05-07T16:35:16.014400Z

need to see a full stracktrace - no much use otherwise

dotemacs 2020-05-07T16:35:51.014600Z

RT.java:  550  clojure.lang.RT/seqFrom
                   RT.java:  530  clojure.lang.RT/seq
                  core.clj:  137  clojure.core/seq
                  core.clj:  717  clojure.core/concat/fn
              LazySeq.java:   40  clojure.lang.LazySeq/sval
              LazySeq.java:   49  clojure.lang.LazySeq/seq
                   RT.java:  528  clojure.lang.RT/seq
                  core.clj:  137  clojure.core/seq
                  core.clj:  726  clojure.core/concat/cat/fn
              LazySeq.java:   40  clojure.lang.LazySeq/sval
              LazySeq.java:   49  clojure.lang.LazySeq/seq
                 Cons.java:   39  clojure.lang.Cons/next
                   RT.java: 1785  clojure.lang.RT/boundedLength
               RestFn.java:  130  clojure.lang.RestFn/applyTo
                  core.clj:  659  clojure.core/apply
                  core.clj:  652  clojure.core/apply
                      REPL:    8  user/eval21162
                      REPL:    8  user/eval21162
             Compiler.java: 7062  clojure.lang.Compiler/eval
             Compiler.java: 7025  clojure.lang.Compiler/eval
                  core.clj: 3206  clojure.core/eval
                  core.clj: 3202  clojure.core/eval
                  main.clj:  243  clojure.main/repl/read-eval-print/fn
                  main.clj:  243  clojure.main/repl/read-eval-print
                  main.clj:  261  clojure.main/repl/fn
                  main.clj:  261  clojure.main/repl
                  main.clj:  177  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   79  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   55  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  142  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  171  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  170  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  834  java.lang.Thread/run

dotemacs 2020-05-07T16:35:54.014800Z

This is it

dnolen 2020-05-07T16:36:04.015Z

terrible

dnolen 2020-05-07T16:36:13.015300Z

this is why I don't use nREPL

dnolen 2020-05-07T16:37:03.015800Z

oh another bug in the code I wrote

dotemacs 2020-05-07T16:38:14.016200Z

Aha 🙂

joshmiller 2020-05-07T16:44:56.016600Z

@dnolen It’s working for me over here, thanks for the update

dotemacs 2020-05-07T16:46:54.017100Z

I can confirm that it works for me too! Thanks @dnolen

dotemacs 2020-05-07T16:49:31.017400Z

Working steps: Eval this in Emacs:

(setq cider-custom-cljs-repl-init-form
      "(require '[<http://clojure.java.io|clojure.java.io> :as io]
         '[clojure.edn :as edn]
         '[cider.piggieback]
         '[krell.api :as krell]
         '[krell.repl])

(def config (edn/read-string (slurp (io/file \"build.edn\"))))
(krell/build config)
(apply cider.piggieback/cljs-repl (krell.repl/repl-env) (mapcat identity config))")
M-x cider-jack-in-cljs When prompted for the REPL type provide custom. The REPL will start and you’ll see user&gt; Start the simulator: react-native run-ios. Once the the connection is established, the REPL prompt will change to: cljs.user&gt;.

joshmiller 2020-05-07T16:55:12.018400Z

@dotemacs Any idea if we can set the REPL type automatically to skip that step?

dotemacs 2020-05-07T16:56:22.019600Z

If by “automatically” you mean we write a custom .dir-locals.el which will set that variable for us, then yes 🙂 But on the serious note, we should submit a patch that runs that step for us when it detects Krell.

joshmiller 2020-05-07T16:57:06.020600Z

Heh, I was already putting the cljs-repl-init form into .dir-locals.el

dotemacs 2020-05-07T16:57:08.020700Z

The same way it does it for the other tools, like for shadow-cljs…

dotemacs 2020-05-07T16:57:15.021Z

🙂

joshmiller 2020-05-07T16:59:06.021800Z

Do you know which cider variable sets that repl type? I’m paging through the 8 million of them and not seeing anything off the top of my head.

dotemacs 2020-05-07T16:59:44.022500Z

I’m trying to find the place where it’s configured for other tools… digging around on GitHub right now…

👍 1
dotemacs 2020-05-07T17:02:25.022800Z

Somewhere around here: https://github.com/clojure-emacs/cider/blob/master/cider.el#L325

dnolen 2020-05-07T17:05:17.024600Z

glad it's working!

👏 2
dotemacs 2020-05-07T17:06:15.025600Z

The way I see it, you can tell easily if a project is lein, boot, shadow-cljs… based, simply based on the config file: project.clj, boot…, deps.edn, shadow-cljs.edn. But for krell, I guess we have to see if it’s a dependency …

dotemacs 2020-05-07T17:10:51.025800Z

This is what I’m talking about: https://github.com/clojure-emacs/cider/blob/master/cider.el#L1478

joshmiller 2020-05-07T17:12:06.026600Z

Ah, I see. I was just looking to set the repl type to custom, this would skip that step entirely.

dotemacs 2020-05-07T17:13:13.027800Z

I get you. But I was hoping that there could be a “smart” step within CIDER that would figure out if it’s a Krell based project and then just inject the dependency. If it can’t figure it out, then it would revert to prompting the user…

joshmiller 2020-05-07T17:13:20.028Z

Right.

joshmiller 2020-05-07T17:13:53.028700Z

I mean, you could rename build.edn in your project to krell-build.edn and look at that, but then you have to explain the difference to official docs.

dotemacs 2020-05-07T17:14:43.029100Z

I guess that could be an option.

dotemacs 2020-05-07T17:15:19.029900Z

But for now, I guess we could “suffer” this manual approach and see if that will be painful enough to warrant a PR…

dotemacs 2020-05-07T17:15:21.030100Z

Not sure

joshmiller 2020-05-07T17:17:30.030600Z

I’m going to commit the current setup to a blog post so it doesn’t get lost to the sands of Slack.

👍 2
dotemacs 2020-05-07T17:17:53.031100Z

Nice 🙂

dotemacs 2020-05-07T17:26:30.031600Z

I created this issue to start a discussion: https://github.com/clojure-emacs/cider/issues/2841

joshmiller 2020-05-07T17:37:10.032Z

Ok, instructions are here: https://increasinglyfunctional.com/2020/05/07/clojurescript-react-native-krell-emacs.html

đź’Ą 2
dnolen 2020-05-07T17:39:48.032500Z

thanks for writing that up

👍 1
dotemacs 2020-05-07T17:39:58.032800Z

But it was @dnolen who did all the work, so all kudos to him 🙂

👍 1
dotemacs 2020-05-07T17:40:52.033400Z

I’m just mentioning that in reference to your blog post @joshmiller because you gave me credit 🙂

dotemacs 2020-05-07T17:41:44.034100Z

Maybe you can amend it and also add cider-cljs-repl-type set to custom?

joshmiller 2020-05-07T17:55:30.034800Z

Tried that, no dice on skipping the repl type selection step.

👍 1
dotemacs 2020-05-07T18:49:45.036200Z

@joshmiller this works, after adding it to .dir-locals.el:

((nil . ((cider-default-cljs-repl . custom)
         (cider-custom-cljs-repl-init-form . "(require '[<http://clojure.java.io|clojure.java.io> :as io]
         '[clojure.edn :as edn]
         '[cider.piggieback]
         '[krell.api :as krell]
         '[krell.repl])
(def config (edn/read-string (slurp (io/file \"build.edn\"))))
(krell/build config)
(apply cider.piggieback/cljs-repl (krell.repl/repl-env) (mapcat identity config))"))))
you can just C-c M-J. You won’t get prompted for anything.

👍 1
joshmiller 2020-05-07T18:53:12.036500Z

Oh cool, let me try that

joshmiller 2020-05-07T18:58:08.036700Z

That works, I’ll update.

👍 1
adamtait 2020-05-07T21:25:20.040400Z

I would love to hear if anyone has tips/scripts on making an iOS archive from a Krell app? It seems that re-natal has a complicated story based on leiningen for building publish-able archives. Unfortunately, the https://github.com/vouch-opensource/krell/wiki/Reagent-Tutorial#production-build tip hasn’t helped me; I haven’t seen a main.js being built and iOS archives result in an app waiting for the Krell repl socket.

adamtait 2020-05-07T21:54:46.042200Z

ha I keep asking questions then fixing them myself shortly after. In case anyone has similar questions, this process seems to work:

clj -Srepro -m krell.main -v -co build.edn -O advanced -c
npx react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'
# finally, run standard build/archive process in XCode following <https://reactnative.dev/docs/running-on-device.html#building-your-app-for-production>

👍 1
Oliver George 2020-05-07T23:07:41.042400Z

Thanks for sharing @adamtait