sauercrowd / clojureworker

https://clojars.org/com.github.sauercrowd/clojureworker
MIT License
16 stars 2 forks source link

How to use repl? #2

Open janat08 opened 3 years ago

janat08 commented 3 years ago

I don't see code for connecting to the lein-cljsbuild, and I can't tell how you'd use a worker file to test it.

janat08 commented 3 years ago

Lein compile on my machine doesn’t run, I had to call plug-in for compile.

janat08 commented 3 years ago

The plug-in docs expect some repl specific code.

sauercrowd commented 3 years ago

Hey @janat08,

the example worker should be a fully working examples (it get's tested with github actions here on every push).

Does that example help you? Let me know if you hit any particular error. I can definitely confirm that the most seamless experience for a repl has been Calva in vscode for me, after trying numerous others + alternative build tools.

janat08 commented 3 years ago

3 the lein repl command actually errors as things stand so I added calva as prerequisite.

janat08 commented 3 years ago

Do you have to start a repl server too?

janat08 commented 3 years ago

Because simply trying to load the cljs doesn’t work.

sauercrowd commented 3 years ago

Could you share how you're starting the repl? It sounds like you're starting it from the command line, but that way we could double check the arguments provided on startup

janat08 commented 3 years ago

I just installed calva extensions and asked it to load file in output tab i think, or the repl window it opens. Then I tried following lein-cljs help text which suggests requiring and running repl server using browser, but I'm using gitpod (cloud ide) so it connect to localhost as it doesn't exist but is instead on cloud (usually how reloading and websockets don't work with cloud ides). Did you at all do anything to make lein-cljsbuild work like put repl server command and packages, because if I remember I might have had to install the repl server package.

janat08 commented 3 years ago

Any thoughts? They also came up with miniflare so arguably this repo is just about repl integration. Does JS interop affect repl capabilities?

sauercrowd commented 3 years ago

Hey @janat08,

I definitely recommend using node rather than the browser as I had issues with the browser version many times, however you should be able to run it with lein + cljs in calva basically out of the box. With calva I didn't have to add any additional dependencies to lein except for the ones listed here

Regarding your second point, the goal of this package was to provide clojure-friendly interfaces for building a worker and providing the glue between javascript and clojurescript. One it's main objectives was to get minimise the amount of boilerplate needed to get a clojurescript worker running.

It is not meant to replace any of the worker toolchains. The simulate-worker function is provided to allow for a repl friendly way to test a worker, without any external dependencies. It is purely a helper however.