Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit 2e3341d

Browse files
author
Stephen Gutekanst
committed
frontend: begin removing elm-spa
elm-spa has kind of been a nightmare to use, most recently I have been unable to appropriately handle URL query param changes (when a link is clicked to the same page with a different `?id` parameter, I want to handle that and scroll to that position on the page) because `Effect.fromCmd` in this context just.. does nothing. It doesn't run. I spent over 10 hours trying to debug it, but came up dry. The page's `init` function does in fact have that effect returned, but the task just.. never runs. There is no error from the task, it only sends a message. The message never gets sent. It's also been annoying in other ways: we cannot have truly dynamic URLs which we need for handling `/github.com/foo/bar` project routes that are not pre-defined and so we must instead use the NotFound page to serve our actual primary interace. It's dev server misunderstands `/github.com` to be a file because it has 'an extension' and so it tries to read/serve that file from disk rather than our SPA app. Overall, now that I know a bit more about Elm I would not choose it for most projects. I see what it's trying to do, and certainly there are use cases it's better suited for than this - but in both projects I've done in Elm now (codestat.dev and doctree) I have regretted using it generally. Signed-off-by: Stephen Gutekanst <[email protected]>
1 parent 64bc7c9 commit 2e3341d

File tree

10 files changed

+36
-830
lines changed

10 files changed

+36
-830
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.DS_Store
2-
.elm-spa
32
elm-stuff
43
node_modules
54
dist

Taskfile.yml

+3-7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ tasks:
3939
desc: Run Elm frontend dev server
4040
dir: frontend
4141
cmds:
42-
- npx elm-spa server | grep -v 'Ready at'
42+
- npx elm-live src/Main.elm
4343

4444
build:
4545
desc: Build Go + Elm code in release mode
@@ -52,26 +52,22 @@ tasks:
5252
desc: Build Elm frontend code (debug mode)
5353
dir: frontend
5454
cmds:
55-
- npx elm-spa gen
5655
- mkdir -p public/dist/
57-
- npx elm make --debug .elm-spa/defaults/Main.elm --output ./public/dist/elm.js
56+
- npx elm make --debug src/Main.elm --output ./public/dist/elm.js
5857
sources:
5958
- ./frontend/src/**/*.elm
6059
generates:
61-
- .elm-spa/**/*
6260
- ./frontend/public/dist/elm.js
6361

6462
build-elm-release:
6563
desc: Build Elm frontend code (release mode, minified, etc.)
6664
dir: frontend
6765
cmds:
68-
- npx elm-spa gen
6966
- mkdir -p public/dist/
70-
- npx elm make .elm-spa/defaults/Main.elm --optimize --output ./public/dist/elm.js
67+
- npx elm make src/Main.elm --optimize --output ./public/dist/elm.js
7168
sources:
7269
- ./frontend/src/**/*.elm
7370
generates:
74-
- .elm-spa/**/*
7571
- ./frontend/public/dist/elm.js
7672

7773
build-go-debug:

cmd/doctree/serve.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ app.ports.observeElementID.subscribe(function(id) {
367367

368368
func frontendHandler(cloudMode bool) http.Handler {
369369
if debugServer := os.Getenv("ELM_DEBUG_SERVER"); debugServer != "" {
370-
// Reverse proxy to the elm-spa debug server for hot code reloading, etc.
370+
// Reverse proxy to the elm-live debug server for hot code reloading, etc.
371371
remote, err := url.Parse(debugServer)
372372
if err != nil {
373373
panic(err)

docs/development.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
brew install go-task/tap/go-task
1313
```
1414

15-
Then ensure [Elm](https://elm-lang.org/), [elm-spa](https://elm-spa.dev), frontend dependencies and Zig libraries are cloned using:
15+
Then ensure [Elm](https://elm-lang.org/), frontend dependencies and Zig libraries are cloned using:
1616

1717
```sh
1818
task setup

frontend/elm.json

+27-32
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,31 @@
11
{
2-
"type": "application",
3-
"source-directories": [
4-
"src",
5-
".elm-spa/defaults",
6-
".elm-spa/generated"
7-
],
8-
"elm-version": "0.19.1",
9-
"dependencies": {
10-
"direct": {
11-
"NoRedInk/elm-json-decode-pipeline": "1.0.1",
12-
"dillonkearns/elm-markdown": "7.0.0",
13-
"elm/browser": "1.0.2",
14-
"elm/core": "1.0.5",
15-
"elm/html": "1.0.0",
16-
"elm/http": "2.0.0",
17-
"elm/json": "1.1.3",
18-
"elm/url": "1.0.0",
19-
"mdgriffith/elm-ui": "1.1.8",
20-
"ryannhg/elm-spa": "6.0.0"
21-
},
22-
"indirect": {
23-
"elm/bytes": "1.0.8",
24-
"elm/file": "1.0.5",
25-
"elm/parser": "1.1.0",
26-
"elm/regex": "1.0.0",
27-
"elm/time": "1.0.0",
28-
"elm/virtual-dom": "1.0.2",
29-
"rtfeldman/elm-hex": "1.0.0"
30-
}
2+
"type": "application",
3+
"source-directories": ["src"],
4+
"elm-version": "0.19.1",
5+
"dependencies": {
6+
"direct": {
7+
"NoRedInk/elm-json-decode-pipeline": "1.0.1",
8+
"dillonkearns/elm-markdown": "7.0.0",
9+
"elm/browser": "1.0.2",
10+
"elm/core": "1.0.5",
11+
"elm/html": "1.0.0",
12+
"elm/http": "2.0.0",
13+
"elm/json": "1.1.3",
14+
"elm/url": "1.0.0",
15+
"mdgriffith/elm-ui": "1.1.8"
3116
},
32-
"test-dependencies": {
33-
"direct": {},
34-
"indirect": {}
17+
"indirect": {
18+
"elm/bytes": "1.0.8",
19+
"elm/file": "1.0.5",
20+
"elm/parser": "1.1.0",
21+
"elm/regex": "1.0.0",
22+
"elm/time": "1.0.0",
23+
"elm/virtual-dom": "1.0.2",
24+
"rtfeldman/elm-hex": "1.0.0"
3525
}
26+
},
27+
"test-dependencies": {
28+
"direct": {},
29+
"indirect": {}
30+
}
3631
}

0 commit comments

Comments
 (0)