Skip to content

Commit

Permalink
Run the REPL in a WebWorker thread
Browse files Browse the repository at this point in the history
  • Loading branch information
theasp committed Oct 21, 2016
1 parent fd6ed96 commit 779934e
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 119 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ pom.xml.asc
/.repl
*.log
/.env
/resources/public/css/site.min.css
2 changes: 1 addition & 1 deletion env/dev/cljs/cljs_webrepl/dev.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(enable-console-print!)

(figwheel/watch-and-reload
:websocket-url "ws://localhost:3449/figwheel-ws"
:websocket-url "wss://figwheel.industrial.gt0.ca/figwheel-ws"
:jsload-callback core/mount-root)

(core/init!)
6 changes: 6 additions & 0 deletions env/dev/cljs/cljs_webrepl/repl_thread_dev.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(ns ^:figwheel-no-load cljs-webrepl.repl-thread-dev
(:require [cljs-webrepl.repl-thread :as repl-thread]))

(enable-console-print!)

(repl-thread/worker)
7 changes: 7 additions & 0 deletions env/prod/cljs/cljs_webrepl/repl_thread_prod.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(ns cljs-webrepl.repl-thread-prod
(:require [cljs-webrepl.repl-thread :as repl-thread]))

;;ignore println statements in prod
(set! *print-fn* (fn [& _]))

(repl-thread/worker)
80 changes: 46 additions & 34 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
:url "http://www.eclipse.org/legal/epl-v10.html"}

:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.229"]
[cljsjs/clipboard "1.5.9-0"]
[cljsjs/material "1.2.1-0"]
[org.clojure/clojurescript "1.9.293"]
[com.cognitect/transit-cljs "0.8.239"]
[com.taoensso/timbre "4.7.4"]
[cljsjs/material "1.2.1-0"]
[environ "1.1.0"]
[figwheel "0.5.8"]
[fipp "0.6.6"]
Expand All @@ -34,15 +33,25 @@
:minify-assets {:assets
{"resources/public/css/site.min.css" "resources/public/css/site.css"}}

:cljsbuild {:builds
{:app {:source-paths ["src/cljs"]
:compiler {:output-to "target/cljsbuild/public/js/app.js"
:output-dir "target/cljsbuild/public/js/out"
:asset-path "js/out"
:main cljs-webrepl.prod
:static-fns true
:optimizations :none
:pretty-print true}}}}
:cljsbuild {:builds {:app {:source-paths ["src/cljs"]
:compiler {:output-to "target/cljsbuild/public/js/app.js"
:output-dir "target/cljsbuild/public/js/app"
:asset-path "js/app"
:main cljs-webrepl.prod
:static-fns true
:optimizations :none
:pretty-print true
:parallel-build true}}

:repl-thread {:source-paths ["src/cljs"]
:compiler {:output-to "target/cljsbuild/public/js/repl-thread.js"
:output-dir "target/cljsbuild/public/js/repl-thread"
:asset-path "js/repl-thread"
:main cljs-webrepl.repl-thread-prod
:static-fns true
:optimizations :simple
:pretty-print true
:parallel-build true}}}}

:profiles {:dev
{:plugins [[lein-figwheel "0.5.8"]
Expand All @@ -52,40 +61,43 @@
:figwheel {:http-server-root "public"
:server-port 3449
:nrepl-port 7001
:css-dirs ["resources/public/css"]}
:css-dirs ["resources/public/css"]
:load-all-builds true}

:env {:dev true}

:cljsbuild {:builds {:app
{:source-paths ["src/cljs" "env/dev/cljs"]
:compiler {:source-map true
:main cljs-webrepl.dev}}
:test
{:source-paths ["src/cljs" "test/cljs" "env/dev/cljs"]
:compiler {:output-to "target/test.js"
:main cljs-webrepl.doo-runner
:optimizations :whitespace
:pretty-print true}}}}}
:cljsbuild {:builds {:app {:source-paths ["src/cljs" "env/dev/cljs"]
:compiler {:source-map true
:main cljs-webrepl.dev}}
:repl-thread {:source-paths ["src/cljs" "env/dev/cljs"]
:compiler {:source-map "target/cljsbuild/public/js/repl-thread.js.map"
:main cljs-webrepl.repl-thread-dev}}
:test {:source-paths ["src/cljs" "test/cljs" "env/dev/cljs"]
:compiler {:output-to "target/test.js"
:main cljs-webrepl.doo-runner
:optimizations :whitespace
:pretty-print true}}}}}

:prod {:hooks [minify-assets.plugin/hooks]
:prep-tasks ["cljsbuild" "once"]
:env {:production true}
:omit-source true
:cljsbuild
{:builds {:app
{:source-paths ["src/cljs" "env/prod/cljs"]
:compiler
{:optimizations :none
:pretty-print false}}}}}
{:builds {:app {:source-paths ["src/cljs" "env/prod/cljs"]
:compiler {:optimizations :advanced
:pretty-print false}}
:repl-thread {:source-paths ["src/cljs" "env/prod/cljs"]
:compiler {:optimizations :simple
:pretty-print false}}}}}

:uberjar {:hooks [minify-assets.plugin/hooks]
:prep-tasks ["cljsbuild" "once"]
:env {:production true}
:omit-source true
:cljsbuild
{:jar true
:builds {:app
{:source-paths ["src/cljs" "env/prod/cljs"]
:compiler
{:optimizations :none
:pretty-print false}}}}}})
:builds {:app {:source-paths ["src/cljs" "env/prod/cljs"]
:compiler {:optimizations :advanced
:pretty-print false}}
:repl-thread {:source-paths ["src/cljs" "env/prod/cljs"]
:compiler {:optimizations :simple
:pretty-print false}}}}}})
Loading

0 comments on commit 779934e

Please sign in to comment.