Fork me on GitHub
#figwheel-main
<
2018-08-02
>
onetom14:08:15

i've successfully put together a clojure cli based figwheel.main environment here: https://github.com/enumatech/cljs-abi-viewer/tree/dex i was also going thru all the cljs repl solutions via this article: https://lambdaisland.com/guides/clojure-repls/clojurescript-repls but it's still unclear how can i have a cljs.repl over an nREPL connection to the figwheel.main environment using a deps.edn setup, so I can send forms to it from Cursive. is there an example project for such a setup somewhere?

bhauman14:08:31

@onetom you have to start it from within an nREPL session, with (figwheel.main/start "dev")

bhauman14:08:33

also have you seen this guide https://clojurescript.org/guides/webpack to help you with cycle.js

onetom14:08:29

soooo then i can put the figwheel.main/start into a user.clj then i guess

bhauman14:08:16

but there are caveats

onetom14:08:38

no, i haven't looked into the webpack setup, but it sounds a bit insane. one of the main reasons we are trying to get away from javascript is to simplify our builds and the depth of the required toolchain

bhauman14:08:50

if you are inside nREPL you will need to have an nREPL server with piggieback in its middleware

bhauman14:08:01

I hear you there on the simplifying part

bhauman14:08:36

but its just packaging a single static file so...

bhauman14:08:51

which shouldn't change

bhauman14:08:04

until you change versions

bhauman15:08:36

I'm not sure what cursive is providing in terms of Clojure tools support, I don't know if its injecting nREPL or piggieback or what not

onetom15:08:39

we just built the https://gitlab.com/oax/dex-poc project over the last half year and as an experiment we tried to build it with the least amount of tooling so it has no bundler. the frontend code is fully ES6 modules, which the browser can understand natively and nodejs can load it with the help of the very small esm library and run tests against them on nodejs with mocha.

onetom15:08:16

i've actually prepared a blog article about this experiment but it's still in a draft form. my conclusion was to look into the state of clojurescript, because it's madness where the js world is heading to...

bhauman15:08:59

I recently did a tiny project just using the Google Closure API, it was so refreshing

onetom15:08:06

so i was expecting to get away from this whole module misery, hoping that the new closure compiler module support will obviate the need for webpack, browserify, rollup, asbundle, etc bullshit

bhauman15:08:36

yeah it can for somethings, but its still a rocky road

bhauman15:08:49

its such a shit show

bhauman15:08:11

how many ways can you package your module

bhauman15:08:24

and how many styles for each way

bhauman15:08:42

makes object literals look freaking fantastic

onetom15:08:50

as i understood so far, the main issue is that there are no clear standards for packaging something into an npm module and then there is still a divide between code for the browser and code for nodejs...

bhauman15:08:20

So anyway back to the REPL in cursive

onetom15:08:58

oh, actually i've already open sourced an example repo for my above mentioned article and its readme is practically covering the article, just using a different story flow: https://github.com/enumatech/browser-nodejs-es6

onetom15:08:38

yes, cursive repl! if i could make it work, it would seriously raise the chance of adoption in our company it already works from emacs actually, but only one out of 5 people in this specific project are well versed enough in emacs so far

bhauman15:08:26

The problem is that I don't use cursive

onetom15:08:26

cider-jack-in-cljs has a figwheel.main option specifically and it just works after we guessed that we need piggyback 🙂

bhauman15:08:30

I do know that cursive just landed a bunch of Clojure Tools support

bhauman15:08:52

so you may want to make sure you have the latest

bhauman15:08:24

but if you have to you can start your own nREPL server with piggieback middleware installed

onetom15:08:32

i would just still start my app from the terminal (within intellij) and use cursive's "built-in" nREPL client if possible

onetom15:08:47

i wouldn't expect the whole clojure process fully managed by cursive

bhauman15:08:59

cool, so if you are going to do that

bhauman15:08:12

then you can just start your own nREPL server

bhauman15:08:19

with piggieback

onetom15:08:51

so we can model my desired setup as 2 processes: 1. clojure -A:dev 2. lein repl :connect

bhauman15:08:24

in this case dev would have to start the nrepl server https://github.com/clojure/tools.nrepl

bhauman15:08:36

and not run figwheel.main

bhauman15:08:46

it would have to set up the classpath of course for your clojruescript project

bhauman15:08:20

the nREPL server would have to include piggieback middleware

onetom15:08:26

i see a fresh open ticket on the topic: https://github.com/nrepl/piggieback/issues/91

dnolen15:08:09

does figwheel-main still support the ring-handler pattern?

richiardiandrea15:08:50

Sorry for barging in but Bohzidar also added the following nrepl.cmdline, if it can help - https://nrepl.readthedocs.io/en/latest/usage/

onetom15:08:04

nrepl/piggieback is the 2nd result in my piggieback clojure cli search indeed. who is behind that nrepl github org?

bhauman15:08:28

@onetom that ticket should be closed

onetom15:08:32

@richiardiandrea ah, i guess u just answered my question

richiardiandrea15:08:44

The nRepl project was transferred to the cider/clojure-mode community.. 👍

richiardiandrea15:08:23

From contrib -- a couple of months ago iirc

bhauman15:08:33

I'm not sure that figwheel.main works with that yet

bhauman15:08:43

I'm pretty sure it doesn't

bhauman15:08:02

I have to do a tweak so it works with the new nREPL

onetom15:08:33

@richiardiandrea what do u mean by the cider/clojure-mode community?

richiardiandrea15:08:06

I mean, the same people working on the most of the Clojure tooling, Bruce here included :)

richiardiandrea15:08:22

Before it was a Clojure contrib project

onetom15:08:23

@bhauman > the new nREPL what is the new nREPL?

bhauman15:08:41

nrepl/nrepl is the new nREPL

onetom15:08:59

oh, i thought clojure contrib was just pre clojure 1.2 or 1.5 concept... 😕

bhauman15:08:05

clojure.tools.nrepl is the the one you are accustomed to using

bhauman15:08:29

@richiardiandrea is refering to the new one thats not supported by figwheel.main yet

richiardiandrea15:08:30

Bohzidar as usual did a great job with the doc ;)

bhauman15:08:36

but will be shortly

bhauman15:08:53

@richiardiandrea solution is a great solution I just have to fix figwheel.main first

onetom15:08:54

aaah. im starting to see clearer now. but wondering where would one learn about for example this org.clojure/tools.nrepl -> nrepl transition?

bhauman15:08:39

theres a history link in the docs

richiardiandrea15:08:23

It was announced some time ago in places. Cider does the bootstrapping with the right deps already so you don't really need to know which dep. Manual REPL is still considered an art 😃

onetom15:08:14

btw, i read somewhere recently that there is some way to support your work, @bhauman how and where can i send funds? can you handle ETH for example? that would be the quickest and easiest way for me to support you

bhauman15:08:08

Thanks! there is a link at the top of the figwheel-main readme

bhauman15:08:12

it's paypal

bhauman15:08:27

I had an active ETH wallet and then I cashed out

onetom15:08:35

im planning to use devcards too, but maybe with hoplon or just with my own, simple, direct DOM tooling you can see in my above mentioned project: https://github.com/enumatech/cljs-abi-viewer/blob/dex/src/cljs/dom.cljs

onetom15:08:36

btw, what's the story behind https://github.com/clojure/clojurescript/blob/master/src/main/cljs/clojure/browser/dom.cljs i see it's a work of @dnolen @mfikes i just found it after i typed up my own js DOM wrappers... is it something we can expect to be maintained and documented?

onetom15:08:58

i saw there are some tests for it but i couldn't even figure out quickly how to run them

bhauman15:08:59

that is ancient

bhauman15:08:07

it wont change

dnolen15:08:16

@onetom neither I or @mfikes worked on that really

dnolen15:08:36

it’s from 7 years ago, it’s not really meant to be used

onetom15:08:36

im just worried that it might get removed, because without docs and more thorough tests probably not many project would depend on it

bhauman15:08:42

but you are probably better off working on your own as its really tiny

bhauman15:08:48

it won't ever be removed

dnolen15:08:55

Clojure(Script) generally doesn’t remove stuff

dnolen15:08:58

zero value

dnolen15:08:10

DCE makes including it irrelevant

4
dnolen15:08:37

you can use it, but you probably shouldn’t it

dnolen15:08:44

there’s better stuff out there, or just write your own stuff

onetom15:08:19

the "better stuff" is usually a lot more complex too, that's why im looking for some low-key, readily available tooling, which can serve as a gateway drug for ppl who stuck in jquery times (because they gave up on frontend development after wrangling with jquery :)

onetom15:08:10

thanks a lot everyone for the quick responses, directions and tons of useful info!

bhauman18:08:11

I've deployed com.bhauman/figwheel.main 0.1.5-SNAPSHOT with fixes for the new nREPL

👍 8
onetom19:08:23

there is no more .nrepl-port file being generated when the port is picked randomly?

bhauman19:08:20

I wouldn't know unfortunately

bhauman19:08:31

I'm pretty sure that's a lein thing

gas20:08:51

my figwheel-main seems stuck in some sort of cached state - I have removed target/public and simplified my server to bascially your config ⋊> ~/D/c/re-frame-figwheel-deps clojure -m figwheel.main -b dev -r [Figwheel] Validating figwheel-main.edn [Figwheel] figwheel-main.edn is valid! Unable to find :ring-handler ~/D/c/re-frame-figwheel-deps tree target target 0 directories, 0 files

gas20:08:45

ok removing :ring-handler config-manager.server/handler form figwheel-main.edn fixed loading - doesnt seem like that option there

bhauman20:08:47

I have confirmed the option works in both places just now

bhauman20:08:03

the thing that doesn't work is it's not overriding the index

gas20:08:08

so still compile error om server.clj and your basic config except for the http://java.io require

(ns config-manager.server
  (:require [ :as io]
            ))

;; define index content
(def home
  "<!DOCTYPE html>
  <html>
  <head>
    <meta charset=\"UTF-8\">
    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
    <link href=\"css/style.css\" rel=\"stylesheet\" type=\"text/css\">
    <link rel=\"icon\" href=\"">
  </head>
  <body>
    <div id=\"app\"></div>
    <script src=\"/cljs-out/dev-main.js\" type=\"text/javascript\"></script>
  </body>
  </html>")

(defn handler [request]
  (if (and (= :get (:method request))
           (= "/"  (:uri request)))
    {:status 200
     :headers {"Content-Type" "text/html"}
     :body home}}
  {:status 404
   :headers {"Content-Type" "text/plain"}
   :body "Not Found"})

bhauman20:08:39

yeah there is an error in that file

gas20:08:59

argh just found the error and corrected handler but still same error.

bhauman20:08:00

there is an extra } after :body home

bhauman20:08:41

also if you are working in a clj REPL

bhauman20:08:10

you can also do (require 'config-manager.server)

gas20:08:20

yeah my emacs paredit config doesnt seem to pick that up that it matches with diff bracket types - thats my biggest issue with clojure bracket matching

gas20:08:34

this is more interesting

cljs.user=> (require 'config-manager.server)
Could not Analyze: No such namespace: config-manager.server, could not locate config_manager/server.cljs, config_manager/server.cljc, or JavaScript source providing "config-manager.server" (Please check that namespaces with dashes use underscores in the ClojureScript file name) at line 1 <cljs repl>  <cljs repl>   line:1  column:1

bhauman20:08:36

i fixed the bug on the site

bhauman20:08:59

no you have to do it from a clojure repl

gas20:08:31

Clojure 1.9.0
user=> (require 'config-manager.server)
nil

bhauman20:08:07

and that is correct

bhauman20:08:32

and now you should be able to load it as a :ring-handler

bhauman20:08:52

the only problem now being that it will only work for paths other than "/"

bhauman20:08:02

thats the bug

gas20:08:24

not sure I understand.

clj -R:dev -A:fig -b dev -r                  08:34:55
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid!
Unable to find :ring-handler
 clj -R:dev -A:fig                            08:35:39
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid!
[Figwheel] Compiling build figwheel-default-repl-build to "target/public/cljs-out/figwheel-default-repl-build-main.js"
cljs.user=> (load "config_manager/server")
Compile Exception:

bhauman20:08:19

it's not currently working for the root path locahost:9500/

bhauman20:08:33

it will work for other paths locahost:9500/test-path

gas20:08:24

ok so the compile exception is becaue i have http://java.io in my clj loading form cljs repl and I have to set non root pths in my server.clj is what you are saying - sorry still waking up

bhauman20:08:13

OK I fixed it

bhauman20:08:22

it was another problem in the example

bhauman20:08:04

so there is no bug

gas20:08:47

ok whats the fix as I am back at Unable to find :ring-handler and my server.clj compiles ok

gas20:08:44

got to get to work, would like to know how to setup figwheel like https://github.com/bensu/doo/wiki/End-to-end-testing-example - not sure if figwheel already has cors middleware loaded?

thiru21:08:02

Bruce, just curious about your thoughts on having a Clojure noob try implementing nREPL support in rebel-readline?

thiru21:08:43

Not sure if you made any progress on this privately or if someone else is trying?

thiru22:08:08

Maybe you can point me to a few places from where to start.. or is this just a bad idea for a noob? I won't be offended if you say so 😉

cfleming22:08:44

@onetom @bhauman I don’t have time to read all the scrollback right now, but I’ll read over it later. I’m about to improve all this so will ping if I need clarification.

8