Fork me on GitHub
#chlorine-clover
<
2020-04-14
>
athomasoriginal14:04:07

@mauricio.szabo in general, what do you think it would take to get Chlorine working with figwheel-main? If I have time, and you’re interested, I wouldn’t mind looking into this…if for nothing else than curiosity.

mauricio.szabo15:04:19

Great, thanks! So, the way that it currently work is the following: everything starts on this file/line: https://github.com/mauricioszabo/repl-tooling/blob/master/src/repl_tooling/editor_integration/connection.cljs#L110-L113

mauricio.szabo15:04:27

If you follow the paths, you'll get here: https://github.com/mauricioszabo/repl-tooling/blob/master/src/repl_tooling/editor_integration/embedded_clojurescript.cljs#L67 This is probably the first line that needs to be changed - something like "use the current :clj/aux REPL to discover if we're running shadow-cljs or Figwheel-main"

mauricio.szabo15:04:51

Currently, there's a special "evaluator" for Shadow-CLJS that uses its internal APIs to evaluate code. This will probably be the default for Shadow in the future. But the "old API" still exists: it basically needs a host / port, and a command. It'll connect to a Clojure REPL, then run a command to transform that REPL in ClojureScript: https://github.com/mauricioszabo/repl-tooling/blob/master/src/repl_tooling/integrations/connection.cljs#L30-L49

mauricio.szabo15:04:27

It is also a good idea to save information on how to get the current ClojureScript env from Clojure code, then save it on the "global state": https://github.com/mauricioszabo/repl-tooling/blob/master/src/repl_tooling/editor_integration/embedded_clojurescript.cljs#L25-L26

mauricio.szabo15:04:38

(sorry if its a little overwhelming 😄)

athomasoriginal16:04:40

This is a good start! Thanks 🙂 I will follow up with questions I may have.

mauricio.szabo16:04:19

Great! I think for figwheel you'll have to add piggieback even for Socket REPL to be able to transform the REPL into a CLJS one

mauricio.szabo16:04:21

At least, when I started to check figwheel-main I had this problem. Don't know if it still exists today 🙂

fabrao16:04:24

@mauricio.szabo Where do I have to change to automatic start deps.edn and connect to it?

fabrao16:04:14

can be direct to init.coffee?

mauricio.szabo17:04:37

You mean like a jack-in command, or something?

fabrao17:04:03

yes, somethink like that

fabrao17:04:57

because I have to write the command into source code to remember 🙂

seancorfield18:04:22

Add it as an :alias in your ~/.clojure/deps.edn file?

mauricio.szabo21:04:35

BTW, there's a FAQ where I explain some of design decisions on Chlorine, and there's a section for Jack-in: https://github.com/mauricioszabo/repl-tooling/blob/master/doc/FAQ.md#when-jack-in-will-be-implemented The problem with these solutions is that you're inside an editor (that's not known to be fast nor memory-friendly), and then you start a Java process (that's also hard on memory)...

mauricio.szabo21:04:51

Also... there's lots of coordination for jack-in to work: it's already kinda hard to coordinate between states on the editor (like, when someone connects, disconnects, starts a CLJS REPL, watch configs, the inline results). To add an external process into the mix can become really complicated...

seancorfield21:04:14

There's also the customizability aspect: as soon as you offer jack in, folks will want to be able to customize all sorts of aspects of it and that gets really nasty.

seancorfield21:04:15

Because of the way we run REPLs at work, I don't think any "built-in" jack-in functionality would ever work for us... I mean, it would basically need to allow us to enter an arbitrary command to start the appropriate REPL... so why not just type that in at the command-line anyway?

seancorfield21:04:22

Also, I tend to start a REPL (from the command line) and run it for days, sometimes even weeks -- so I'd only need "jack in" once a week or less. Seems like a waste of time to divert effort to such a feature.

seancorfield21:04:55

(I've never really understood why CIDER expended so much effort on that... except for it already being a complete "kitchen sink" plugin anyway)

mauricio.szabo21:04:30

I imagine because it's hard to coordinate all dependencies that it needs to run. This "feature discovery" that I do on Chlorine is yet another state control 😄

mauricio.szabo21:04:57

Ah, and I have no idea what "kitchen sink" means in this context 😄

seancorfield21:04:30

Slang for "includes everything"

mauricio.szabo21:04:41

Ah, there's also the problem with env vars! Most editors don't set the environment variables correctly when running external processes. This is not a problem, except when you add private repositories on the mix... and now the REPL doesn't start with bizarre errors