introduce shadow-cljs as ClojureScript compiler

This commit is contained in:
skwak22 2020-07-15 21:19:38 +09:00
parent 4de782c50a
commit 44aaf4a156
12 changed files with 85 additions and 3 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -15,6 +15,40 @@ example, `lein run :population-size 100`. You can use something
like `lein run | tee outfile` to send output both to the terminal
and to `outfile`.
## CLJS Usage
### Development
Run in development:
```bash
yarn
(mkdir -p target && cp assets/index.html target/)
yarn shadow-cljs watch app
```
`shadow-cljs` will be installed in `node_modules/` when you run `yarn`.
`:dev-http` specifies that `target/` will be served at http://localhost:8080 .
### REPL
After page is loaded, you may also start a REPL connected to browser with:
```bash
yarn shadow-cljs cljs-repl app
```
### Release
Compile with optimizations with `release` sub-command:
```bash
yarn shadow-cljs release app
mkdir -p target && cp assets/index.html target/
yarn serve # serving target/ on http://localhost:8080
```
## Description
Propel is an implementation of the Push programming

11
assets/index.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>propeller shadow-cljs</title>
<meta charset="UTF-8">
</head>
<body>
<div>See Console!</div>
<script src="main.js"></script>
</body>
</html>

View File

@ -1 +0,0 @@
{:deps {org.clojure/clojurescript {:mvn/version "1.10.758"}}}

21
package.json Normal file
View File

@ -0,0 +1,21 @@
{
"name": "propeller-cljs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"watch": "shadow-cljs watch app",
"compile": "shadow-cljs compile app",
"release": "shadow-cljs release app",
"html": "mkdir -p target && cp assets/index.html target/",
"serve": "yarn html && http-server target/",
"del": "rm -r target/*",
"build": "yarn release && yarn html && yarn serve"
},
"author": "",
"license": "MIT",
"devDependencies": {
"http-server": "^0.12.3",
"shadow-cljs": "^2.10.10"
}
}

7
shadow-cljs.edn Normal file
View File

@ -0,0 +1,7 @@
{:source-paths ["src"]
:dependencies []
:dev-http {8080 "target/"}
:builds {:app {:output-dir "target/"
:asset-path "."
:target :browser
:modules {:main {:init-fn propeller.main/main!}}}}}

BIN
src/.DS_Store vendored

Binary file not shown.

Binary file not shown.

8
src/propeller/main.cljs Normal file
View File

@ -0,0 +1,8 @@
(ns propeller.main
(:require [propeller.core :as propeller]))
(defn main! []
(println "Loading main..."))
(defn ^:dev/after-load reload! []
(propeller/-main))

View File

@ -4,7 +4,8 @@
[propeller.push.state :as state]
[propeller.push.utils.helpers :refer [get-stack-instructions]]
[propeller.utils :as utils]
[propeller.push.state :as state]))
[propeller.push.state :as state]
#?(:cljs [cljs.reader :refer [read-string]])))
;; =============================================================================
;; Tom Helmuth, thelmuth@cs.umass.edu
@ -82,7 +83,8 @@
inputs)
errors (map (fn [correct-output output]
(let [parsed-output (try (read-string output)
(catch Exception e 1))]
#?(:clj (catch Exception e 1000.0)
:cljs (catch js/Error. e 1000.0)))]
(if (= correct-output parsed-output) 0 1)))
correct-outputs
outputs)]

Binary file not shown.