Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting to an out-of-process nREPL server and a merged Figwheel-main build #1386

Closed
danieroux opened this issue Nov 17, 2021 · 2 comments
Closed

Comments

@danieroux
Copy link

As discussed with @PEZ on Slack:

  • We start nREPL out-of-process and then connect to it
  • We start figwheel-main with merged builds

The README.md in this repo explains the ideal workflow: https://github.com/danieroux/calva-clojurescript-usage

The less magic, the better ;-)

@danieroux
Copy link
Author

We structure builds this way:

  • common.cljs.edn is the base setup, for cljs.main, annotated with some Figwheel options that does not come into play for cljs.main.
  • min.cljs.edn adds minification
  • some-domain.com.cljs.edn is a production deploy to that domain, with all its flags twiddled and variables set for prod.

This allows us to do this for a production deploy, as a merged build:

clojure -M --main cljs.main --compile-opts common.cljs.edn --compile-opts min.cljs.edn --compile-opts some-domain.com.cljs.edn --compile

Only vanilla cljs.main, no Figwheel required. Stable, clean, clear.

So for development we merge common.cljs.edn and local.cljs.edn. And local.cljs.edn has preloads, and development toggles on. That's how we start Figwheel in dev then, by merging those two:

(defn start-cljs-repl []
  (let [read-build (figwheel.main.api/read-build "common" "local")
        build-id   (:id read-build)]
    (try
      (figwheel.main.api/start {:mode :serve} read-build)
      (figwheel.main.api/cljs-repl build-id)
      (catch RuntimeException _e
        (println "The build is already running, connection to the REPL only")
        (figwheel.main.api/cljs-repl build-id)))))

PEZ added a commit to PEZ/calva-clojurescript-usage that referenced this issue Nov 18, 2021
@PEZ
Copy link
Collaborator

PEZ commented Nov 18, 2021

Thanks. It is strange that the built-in Figwheel Main sequence doesn't work for connecting to local in that repro-repo. I don't really understand what goes wrong.

Anyway, I pushed a PR to that reoro, containing a custom repl connect sequence, that simply calls your (start-cljs-repl) there. It looks like so:

  "calva.replConnectSequences": [
    {
      "name": "My local build",
      "projectType": "deps.edn",
      "cljsType": {
        "dependsOn": "Figwheel Main",
        "connectCode": "(start-cljs-repl)",
        "isConnectedRegExp": "To quit, type: :cljs/quit",
        "buildsRequired": false,
      }
    }
  ]

Not sure the last two settings there are required. You can experiment with removing them and see if it works anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants