practice / blog

For personal blogging
1 stars 0 forks source link

Figwheel 을 Cursive 에서 실행하는 법 #18

Open practice opened 8 years ago

practice commented 8 years ago

https://github.com/bhauman/lein-figwheel/wiki/Running-figwheel-in-a-Cursive-Clojure-REPL

위 링크에 나와 있지만 요약하면 ...

$ lein new figwheel figwheel-test  # figwheel 프로젝트 생성

project.clj 를 아래 처럼 수정

(defproject figwheel-test "0.1.0-SNAPSHOT"
  ...
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.122"]
                 [org.clojure/core.async "0.1.346.0-17112a-alpha"]
                 [figwheel-sidecar "0.4.0"]]

  :plugins [[lein-cljsbuild "1.1.0"]]
  ...)

프로젝트 루트에 script/repl.clj 파일을 아래 내용으로 작성

(use 'figwheel-sidecar.repl-api)
(start-figwheel! {:all-builds (figwheel-sidecar.repl/get-project-cljs-builds)})
(cljs-repl)

이제 repl 실행 configuration을 다음과 같이 만든다.

이제 실행만 하면 되는데 나의 경우 intellij cursive 오류 때문에 잘 실행이 되지 않았다. intellij를 다시 실행하면 되더라.

figwheel 이 실행한 nrepl 에 IDE를 연결하자.

위와 같이 잘 실행되면 다행인데, 안되는 경우가 있다. 버전간의 충돌 등의 문제가 대부분이다. 마땅한 해결책이 없다. 이때는 이 방법을 해볼 수 있다.

:figwheel -> :nrepl-port가 설정되어 있으면 figwheel이 nrepl을 실행한다. Cursive에서 remote repl을 이 port로 연결하여 실행한다음 다음을 cursive repl에서 실행

user> (use 'figwheel-sidecar.repl-api)
user> (cljs-repl)