Skip to content

Commit 1b5aad9

Browse files
committed
fix: make just commands faster
By only conditionally building ala make
1 parent 84583c6 commit 1b5aad9

File tree

5 files changed

+30
-23
lines changed

5 files changed

+30
-23
lines changed

Justfile

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ _help:
1010

1111
# Generate README.md from lexer definitions
1212
readme:
13-
#!/usr/bin/env sh
13+
#!/usr/bin/env bash
1414
GOOS= GOARCH= ./table.py
1515

1616
# Generate tokentype_string.go
@@ -23,24 +23,30 @@ format-js:
2323

2424
# Build chromad binary
2525
chromad: wasm-exec chroma-wasm
26+
#!/usr/bin/env bash
2627
rm -rf build
27-
esbuild --platform=browser --format=esm --bundle cmd/chromad/static/index.js --minify --external:./wasm_exec.js --outfile=cmd/chromad/static/index.min.js
28-
esbuild --bundle cmd/chromad/static/index.css --minify --outfile=cmd/chromad/static/index.min.css
28+
mk cmd/chromad/static/index.min.js : cmd/chromad/static/{index,chroma}.js -- \
29+
esbuild --platform=browser --format=esm --bundle cmd/chromad/static/index.js --minify --external:./wasm_exec.js --outfile=cmd/chromad/static/index.min.js
30+
mk cmd/chromad/static/index.min.css : cmd/chromad/static/index.css -- \
31+
esbuild --bundle cmd/chromad/static/index.css --minify --outfile=cmd/chromad/static/index.min.css
2932
cd cmd/chromad && CGOENABLED=0 go build -ldflags="-X 'main.version={{ version }}'" -o ../../build/chromad .
3033

3134
# Copy wasm_exec.js from TinyGo
3235
wasm-exec:
33-
#!/usr/bin/env sh
36+
#!/usr/bin/env bash
3437
tinygoroot=$(tinygo env TINYGOROOT)
35-
install -m644 "$tinygoroot/targets/wasm_exec.js" cmd/chromad/static/wasm_exec.js
38+
mk cmd/chromad/static/wasm_exec.js : "$tinygoroot/targets/wasm_exec.js" -- \
39+
install -m644 "$tinygoroot/targets/wasm_exec.js" cmd/chromad/static/wasm_exec.js
3640

3741
# Build WASM binary
3842
chroma-wasm:
39-
#!/usr/bin/env sh
43+
#!/usr/bin/env bash
4044
if type tinygo > /dev/null 2>&1; then
41-
tinygo build -no-debug -target wasm -o cmd/chromad/static/chroma.wasm cmd/libchromawasm/main.go
45+
mk cmd/chromad/static/chroma.wasm : cmd/libchromawasm/main.go -- \
46+
tinygo build -no-debug -target wasm -o cmd/chromad/static/chroma.wasm cmd/libchromawasm/main.go
4247
else
43-
GOOS=js GOARCH=wasm go build -o cmd/chromad/static/chroma.wasm cmd/libchromawasm/main.go
48+
mk cmd/chromad/static/chroma.wasm : cmd/libchromawasm/main.go -- \
49+
GOOS=js GOARCH=wasm go build -o cmd/chromad/static/chroma.wasm cmd/libchromawasm/main.go
4450
fi
4551

4652
# Upload chromad to server

bin/.mk-0.10.1.pkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hermit

bin/mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.mk-0.10.1.pkg

cmd/chromad/static/chroma.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ChromaWASM {
1414
const go = new Go();
1515
const result = await WebAssembly.instantiateStreaming(
1616
fetch("./static/chroma.wasm"),
17-
go.importObject
17+
go.importObject,
1818
);
1919
go.run(result.instance);
2020
this.ready = true;

cmd/chromad/static/index.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import * as Base64 from "./base64.js";
22
import { chroma } from "./chroma.js";
33

44
function init() {
5-
const darkMode =
6-
window.matchMedia?.("(prefers-color-scheme: dark)").matches;
5+
const darkMode = window.matchMedia?.("(prefers-color-scheme: dark)").matches;
76
const style = document.createElement("style");
87
const ref = document.querySelector("script");
98
ref.parentNode.insertBefore(style, ref);
@@ -26,18 +25,18 @@ function init() {
2625

2726
async function renderServer(formData) {
2827
const response = await fetch("/api/render", {
29-
method: "POST",
30-
mode: "cors",
31-
cache: "no-cache",
32-
credentials: "same-origin",
33-
headers: {
34-
"X-CSRF-Token": csrfToken,
35-
"Content-Type": "application/json",
36-
},
37-
redirect: "follow",
38-
referrer: "no-referrer",
39-
body: JSON.stringify(formData),
40-
});
28+
method: "POST",
29+
mode: "cors",
30+
cache: "no-cache",
31+
credentials: "same-origin",
32+
headers: {
33+
"X-CSRF-Token": csrfToken,
34+
"Content-Type": "application/json",
35+
},
36+
redirect: "follow",
37+
referrer: "no-referrer",
38+
body: JSON.stringify(formData),
39+
});
4140
return await response.json();
4241
}
4342

0 commit comments

Comments
 (0)