From 4533b55da02dd0488a11238011deb47274ccebf5 Mon Sep 17 00:00:00 2001 From: Adam French Date: Thu, 15 Oct 2026 21:11:09 +0100 Subject: [PATCH] Remove the Rust/WASM crate and its build step Nothing live used it: main.js awaited the wasm init() on every page load, but the only consumer, components/util/wasm/AutoScroll.vue, was never imported. Dropping it removes the rust:slim + wasm-pack stage from the vue image, the two Vite plugins that existed only for it, and the src/wasm/ guard in `make check-vue`, so a fresh clone builds without a Rust toolchain. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/deploy.yaml | 2 +- .gitignore | 6 - CLAUDE.md | 2 +- DEPLOYMENT.md | 7 +- Makefile | 21 +- README.md | 3 +- docker-compose.dev.yml | 12 +- nginx/security_headers.conf | 7 +- vue/Dockerfile | 28 +- vue/README.md | 11 +- vue/crates/stp_wasm/Cargo.lock | 136 -------- vue/crates/stp_wasm/Cargo.toml | 25 -- vue/crates/stp_wasm/src/auto_scroll.rs | 259 --------------- vue/crates/stp_wasm/src/headline.rs | 135 -------- vue/crates/stp_wasm/src/lib.rs | 5 - vue/package-lock.json | 349 +------------------- vue/package.json | 8 +- vue/src/components/util/wasm/AutoScroll.vue | 36 -- vue/src/main.js | 8 - vue/vite.config.js | 4 - 20 files changed, 25 insertions(+), 1039 deletions(-) delete mode 100644 vue/crates/stp_wasm/Cargo.lock delete mode 100644 vue/crates/stp_wasm/Cargo.toml delete mode 100644 vue/crates/stp_wasm/src/auto_scroll.rs delete mode 100644 vue/crates/stp_wasm/src/headline.rs delete mode 100644 vue/crates/stp_wasm/src/lib.rs delete mode 100644 vue/src/components/util/wasm/AutoScroll.vue diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 59a8149..acd825c 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -29,7 +29,7 @@ # # NOT TESTED HERE: THE VUE BUILD # Deliberately skipped. `docker compose up --build` in the deploy job -# already runs the full frontend build (wasm-pack + vite) while building the +# already runs the full frontend build (npm ci + vite) while building the # vue image, and a failed image build aborts `up` BEFORE any container is # replaced, so the old site keeps serving. Building it a second time here # would cost the Pi several minutes per push to learn nothing new. The same diff --git a/.gitignore b/.gitignore index 02e6aa3..623f4c8 100644 --- a/.gitignore +++ b/.gitignore @@ -20,9 +20,6 @@ gitea-runner/.runner gitea-runner/act_runner gitea-runner/nohup.out -# Rust build artifacts -**/target/ - # Python bytecode __pycache__/ *.pyc @@ -31,9 +28,6 @@ __pycache__/ # Virtualenv `make check-python` builds on demand from python/requirements-dev.txt /.venv/ -# Generated WASM output -vue/src/wasm/ - # Logs logs *.log diff --git a/CLAUDE.md b/CLAUDE.md index 925c48b..6f3deb5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -40,7 +40,7 @@ Vite dev server proxies `/api`, `/gitea`, `/py` and `/radio`; the targets defaul cd vue && npm run build ``` -`npm run build` compiles the Rust crate first and needs `wasm-pack`. `npm run build:js` (plain `vite build`) is the check to use when only the JS changed and `src/wasm/` already exists. +`npm run build` is a plain `vite build`. ### Regenerate GraphQL (after editing schema files) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index fbfb973..79cb8ef 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -165,10 +165,9 @@ docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build The override layer changes five services and disables one: - **vue** — `npm run dev` instead of a one-shot build; `./vue` is bind-mounted - for hot reload, with anonymous-volume masks on `/app/node_modules` and - `/app/src/wasm` so the image's installed deps and compiled WASM are not hidden - by the bind mount. You need neither `node_modules` nor a Rust toolchain on the - host. + for hot reload, with an anonymous-volume mask on `/app/node_modules` so the + image's installed deps are not hidden by the bind mount. You don't need + `node_modules` on the host. - **nginx** — `DEV_MODE=true`, which makes the entrypoint self-sign a `CN=localhost` certificate (once, kept in `certbot/conf`) and render `nginx_dev.conf.template`: `/` proxies to the Vite dev server, both `:80` and diff --git a/Makefile b/Makefile index 0738745..13fa4f0 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,7 @@ # WHAT IT NEEDS ON THE HOST # check-backend / generate Go (the version in backend/go.mod) # check-python python3 with the venv module -# check-vue Node + `npm install` done in vue/, and the -# generated vue/src/wasm/ directory (see below) +# check-vue Node + `npm install` done in vue/ # check-compose / dev Docker with the compose plugin # Nothing here installs a toolchain; a missing one fails that target only. # @@ -69,26 +68,12 @@ $(VENV_STAMP): python/requirements.txt python/requirements-dev.txt check-python: $(VENV_STAMP) cd python && ../$(VENV)/bin/python -m pytest tests -q -# `npx vite build`, NOT `npm run build`: the npm script first runs wasm-pack to -# compile the Rust crate, which needs a Rust toolchain most machines (and the -# Pi) do not have. The Vite half alone is enough to catch a broken import or -# template. -# -# It does still need the OUTPUT of that Rust step, vue/src/wasm/, which is -# generated and gitignored — so a fresh clone has none and Vite would fail with -# a bare "could not resolve ../wasm/..." error. The guards below say what is -# actually wrong instead. +# A Vite build is enough to catch a broken import or template; there is no +# test runner or linter for the frontend. # # The build goes to a temp directory that is removed afterwards (success or # failure), so the check never leaves a vue/dist behind or overwrites one. check-vue: - @test -d vue/src/wasm || { \ - echo "check-vue: vue/src/wasm/ is missing."; \ - echo " It is the generated (gitignored) output of the Rust crate in vue/crates/"; \ - echo " and the Vite build imports it. Create it with wasm-pack:"; \ - echo " cd vue && npm run build:wasm"; \ - echo " (needs a Rust toolchain; the vue image builds it for you, see vue/Dockerfile)."; \ - exit 1; } @test -d vue/node_modules || { \ echo "check-vue: vue/node_modules/ is missing. Run: cd vue && npm install"; \ exit 1; } diff --git a/README.md b/README.md index e000871..a6999f3 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ certbot ── SSL Certificate Management (disabled in dev) ## Tech Stack -**Frontend** - Vue 3, Vite, Tailwind CSS v4, Pinia, Vue Router, markdown-it (wikilinks + KaTeX), Rust/WASM +**Frontend** - Vue 3, Vite, Tailwind CSS v4, Pinia, Vue Router, markdown-it (wikilinks + KaTeX) **Backend** - Go (Gin), gqlgen (GraphQL), GORM, PostgreSQL, JWT auth, WebSockets @@ -349,7 +349,6 @@ These files are git-ignored and must be created manually: ## Future Ideas -- More Rust to WASM - ML for chatboards - Cache requests - Design more webpages diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 12f4137..95a72c5 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -32,14 +32,12 @@ services: command: ["npm", "run", "dev"] volumes: - ./vue:/app - # The two bare paths are ANONYMOUS-VOLUME MASKS, not typos. Binding - # ./vue over /app would otherwise hide the node_modules and WASM - # output that were installed/built *inside* the image. Declaring - # them as anonymous volumes re-exposes the image's copies on top of - # the bind mount, so `npm ci` and wasm-pack results survive and the - # host does not need node_modules or a Rust toolchain at all. + # The bare path is an ANONYMOUS-VOLUME MASK, not a typo. Binding + # ./vue over /app would otherwise hide the node_modules that were + # installed *inside* the image. Declaring it as an anonymous volume + # re-exposes the image's copy on top of the bind mount, so the + # `npm ci` result survives and the host does not need node_modules. - /app/node_modules - - /app/src/wasm environment: - NODE_ENV=development backend: diff --git a/nginx/security_headers.conf b/nginx/security_headers.conf index 19b99b6..abaeb16 100644 --- a/nginx/security_headers.conf +++ b/nginx/security_headers.conf @@ -15,9 +15,8 @@ add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" alway # locked-down CSP by declaring Content-Security-Policy again themselves # (a later add_header of the same name within one response wins). # -# ponytail: no site-wide CSP from nginx here. The SPA needs -# 'wasm-unsafe-eval' for its Rust module, Gitea (proxied at /gitea/) relies -# on inline diff --git a/vue/src/main.js b/vue/src/main.js index 75b43b8..dae74cc 100644 --- a/vue/src/main.js +++ b/vue/src/main.js @@ -1,10 +1,5 @@ /** * App entry point. Mounts on #app with the router and a fresh Pinia. - * - * The top-level `await init()` loads the Rust/wasm bundle before anything else - * renders, so components that reach for a wasm export (components/util/wasm/) - * never see an uninitialised module. Top-level await in an entry module is what - * `vite-plugin-top-level-await` in vite.config.js is there to support. */ import { createApp } from "vue"; @@ -12,9 +7,6 @@ import { createPinia } from "pinia"; import App from "./App.vue"; import router from "./router"; import "./assets/styles.css"; -import init from "@/wasm/stp_wasm.js"; - -await init(); const app = createApp(App); diff --git a/vue/vite.config.js b/vue/vite.config.js index 61956b7..8650126 100644 --- a/vue/vite.config.js +++ b/vue/vite.config.js @@ -4,8 +4,6 @@ import { defineConfig, loadEnv } from "vite"; import tailwindcss from "@tailwindcss/vite"; import vue from "@vitejs/plugin-vue"; import vueDevTools from "vite-plugin-vue-devtools"; -import wasm from "vite-plugin-wasm"; -import topLevelAwait from "vite-plugin-top-level-await"; // Dev-server proxy targets (frontend-only `npm run dev`). // @@ -66,8 +64,6 @@ export default defineConfig(({ mode }) => { vue(), ...(process.env.NODE_ENV !== "production" ? [vueDevTools()] : []), tailwindcss(), - wasm(), - topLevelAwait(), ], resolve: { alias: {