Skip to content

Commit b69ac8f

Browse files
committed
Use interactive flag
- [x] Use `CacheBust` field - [x] Use `INTERACTIVE` pragma for local dev - [x] Add `repl` / `watch`
1 parent d50261a commit b69ac8f

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ js: update-js build-js
88
update:
99
wasm32-wasi-cabal update
1010

11+
repl: update
12+
wasm32-wasi-cabal repl app -finteractive --repl-options='-fghci-browser -fghci-browser-port=8080'
13+
14+
watch:
15+
ghciwatch --after-startup-ghci :main --after-reload-ghci :main --watch app/*.hs --debounce 50ms --command 'wasm32-wasi-cabal repl app -finteractive --repl-options="-fghci-browser -fghci-browser-port=8080"'
16+
1117
build:
1218
wasm32-wasi-cabal build
1319
rm -rf public

miso-todomvc.cabal

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ cabal-version: 3.0
22
name: miso-todomvc
33
version: 0.1
44

5+
flag interactive
6+
default:
7+
False
8+
manual:
9+
True
10+
511
common options
12+
if flag (interactive)
13+
cpp-options:
14+
-DINTERACTIVE
15+
616
if impl(ghcjs) || arch(javascript)
717
cpp-options:
818
-DGHCJS_BOTH
@@ -23,6 +33,7 @@ common options
2333
cpp-options:
2434
-DVANILLA
2535

36+
2637
executable app
2738
import:
2839
options

src/Main.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import qualified Miso.CSS as CSS
3030
----------------------------------------------------------------------------
3131
default (MisoString)
3232
----------------------------------------------------------------------------
33-
#if defined(wasm32_HOST_ARCH)
33+
#ifdef WASM
3434
foreign export javascript "hs_start" main :: IO ()
3535
#endif
3636
----------------------------------------------------------------------------
@@ -95,11 +95,11 @@ main = startApp (defaultEvents <> keyboardEvents) app
9595
app :: App Model Msg
9696
app = (component emptyModel updateModel viewModel)
9797
{ mount = Just FocusOnInput
98-
#ifdef VANILLA
99-
-- dmj: when using vanilla GHC append the styles to <head> in dev mode
98+
#ifdef INTERACTIVE
99+
-- dmj: when using WASM repl mode append styles to <head> in dev mode
100100
, styles =
101-
[ Href "https://cdn.jsdelivr.net/npm/todomvc-common@1.0.5/base.min.css"
102-
, Href "https://cdn.jsdelivr.net/npm/todomvc-app-css@2.4.3/index.min.css"
101+
[ Href "https://cdn.jsdelivr.net/npm/todomvc-common@1.0.5/base.min.css" True
102+
, Href "https://cdn.jsdelivr.net/npm/todomvc-app-css@2.4.3/index.min.css" True
103103
]
104104
#endif
105105
}

0 commit comments

Comments
 (0)