Skip to content

Commit a2888a0

Browse files
committed
quick checkpoint
1 parent 34d8604 commit a2888a0

19 files changed

Lines changed: 64 additions & 29 deletions

File tree

.github/workflows/pages.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ jobs:
3939
wget -q https://github.com/tinygo-org/tinygo/releases/download/v0.40.1/tinygo_0.40.1_amd64.deb -O /tmp/tinygo.deb
4040
sudo dpkg -i /tmp/tinygo.deb
4141
42+
- name: Install Binaryen
43+
run: sudo apt-get install -y binaryen
44+
4245
- name: Build WASM
4346
run: |
4447
GOOS=js GOARCH=wasm go build -ldflags="-s -w" -trimpath -o gnata.wasm ./wasm/
4548
cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" wasm_exec.js
46-
tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -target wasm ./editor/
49+
tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -scheduler=none -panic=trap -target wasm ./editor/
50+
wasm-opt -Oz --enable-bulk-memory gnata-lsp.wasm -o gnata-lsp.wasm
4751
cp "$(tinygo env TINYGOROOT)/targets/wasm_exec.js" lsp-wasm_exec.js
4852
4953
- name: Install dependencies

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ go build -buildmode=c-shared -o gnata_jsonata.dylib ./sqlite
4949
go build -buildmode=c-shared -o gnata_jsonata.so ./sqlite
5050

5151
# Build WASM LSP
52-
tinygo build -o gnata-lsp.wasm -target wasm ./editor
52+
tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -scheduler=none -panic=trap -target wasm ./editor/
53+
wasm-opt -Oz --enable-bulk-memory gnata-lsp.wasm -o gnata-lsp.wasm
5354

5455
# Build WASM playground
5556
GOOS=js GOARCH=wasm go build -ldflags="-s -w" -trimpath -o gnata.wasm ./wasm

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ go build -buildmode=c-shared -o gnata_jsonata.dylib ./sqlite
2222
Requires [TinyGo](https://tinygo.org):
2323

2424
```bash
25-
tinygo build -o gnata-lsp.wasm -target wasm ./editor
25+
tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -scheduler=none -panic=trap -target wasm ./editor/
26+
wasm-opt -Oz --enable-bulk-memory gnata-lsp.wasm -o gnata-lsp.wasm
2627
```
2728

2829
### Optional: CodeMirror Package

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ extension:
2626
wasm:
2727
GOOS=js GOARCH=wasm go build -ldflags="-s -w" -trimpath -o gnata.wasm ./wasm/
2828
cp "$$(go env GOROOT)/lib/wasm/wasm_exec.js" wasm_exec.js
29-
# -gc=leaking ?
30-
tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -target wasm ./editor/
29+
tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -scheduler=none -panic=trap -target wasm ./editor/
30+
wasm-opt -Oz --enable-bulk-memory gnata-lsp.wasm -o gnata-lsp.wasm
3131
cp "$$(tinygo env TINYGOROOT)/targets/wasm_exec.js" lsp-wasm_exec.js
3232

3333
# CodeMirror npm package

benchmarks/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@gnata-sqlite/benchmarks",
3+
"version": "0.0.0",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"bench": "tsx run.ts",
8+
"bench:quick": "tsx run.ts --iterations 1"
9+
},
10+
"devDependencies": {
11+
"tsx": "^4.19.0",
12+
"typescript": "^5.7.0"
13+
}
14+
}

benchmarks/results/.gitkeep

Whitespace-only changes.

benchmarks/tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "ESNext",
5+
"moduleResolution": "bundler",
6+
"strict": true,
7+
"esModuleInterop": true,
8+
"resolveJsonModule": true,
9+
"noEmit": true
10+
},
11+
"include": ["*.ts"]
12+
}

editor/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CodeMirror 6 language support and LSP server for JSONata, powered by gnata's par
44

55
Two delivery modes from the same codebase:
66

7-
- **Browser** — TinyGo WASM module (182 KB) for CodeMirror diagnostics and autocomplete
7+
- **Browser** — TinyGo WASM module (126 KB) for CodeMirror diagnostics and autocomplete
88
- **Server** — Native Go LSP server (stdio JSON-RPC) for VS Code, Neovim, etc.
99

1010
## Quick Start
@@ -15,7 +15,7 @@ Two delivery modes from the same codebase:
1515
import { EditorView, basicSetup } from "codemirror"
1616
import { jsonataFull, initWasm } from "@gnata-sqlite/codemirror"
1717

18-
// Load the WASM module (182 KB, 85 KB gzipped).
18+
// Load the WASM module (126 KB, 61 KB gzipped).
1919
await initWasm("/gnata-lsp.wasm", "/lsp-wasm_exec.js")
2020

2121
new EditorView({
@@ -58,7 +58,7 @@ require("lspconfig").jsonata.setup({})
5858
+---------------------------+
5959
| Lezer Grammar | WASM |
6060
| (sync, every | (async, |
61-
| keystroke) | 182 KB) |
61+
| keystroke) | 126 KB) |
6262
| | |
6363
| Highlighting | Diags |
6464
| Brackets | Compl. |
@@ -224,16 +224,17 @@ Diagnostics are pushed as `textDocument/publishDiagnostics` notifications.
224224
### WASM Module
225225

226226
```bash
227-
GOOS=js GOARCH=wasm tinygo build \
227+
tinygo build \
228228
-o gnata-lsp.wasm -no-debug \
229-
-gc=conservative \
230-
./editor/
229+
-gc=conservative -scheduler=none -panic=trap \
230+
-target wasm ./editor/
231+
wasm-opt -Oz --enable-bulk-memory gnata-lsp.wasm -o gnata-lsp.wasm
231232

232233
# Copy TinyGo's WASM support file.
233234
cp "$(tinygo env TINYGOROOT)/targets/wasm_exec.js" lsp-wasm_exec.js
234235
```
235236

236-
Output: `gnata-lsp.wasm` (182 KB raw, 85 KB gzipped)
237+
Output: `gnata-lsp.wasm` (126 KB raw, 61 KB gzipped)
237238

238239
### Native LSP Server
239240

editor/codemirror/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ npm install @gnata-sqlite/codemirror
1616
```
1717

1818
You also need the WASM files served from your app:
19-
- `gnata-lsp.wasm` (85KB gzipped)
19+
- `gnata-lsp.wasm` (61KB gzipped)
2020
- `lsp-wasm_exec.js` (TinyGo runtime)
2121

2222
## Quick Start

editor/main_wasm.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
//
77
// Build:
88
//
9-
// GOOS=js GOARCH=wasm tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative ./editor/
9+
// tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -scheduler=none -panic=trap -target wasm ./editor/
10+
// wasm-opt -Oz --enable-bulk-memory gnata-lsp.wasm -o gnata-lsp.wasm
1011
package main
1112

1213
import (

0 commit comments

Comments
 (0)