mollusc: design and recommended path #
The problem #
Each desktop wrapper for a web app costs the same gigabytes again. A Tauri
project compiles several hundred Rust crates into a per-project target
directory of 2 to 5 GB. An Electron project keeps its own 250 MB unpacked
runtime under node_modules. Neutralinojs is tiny but has no native menu bar,
one window per process, and cannot receive files or URLs opened from the OS.
A hand-written WKWebView shell is small and fully native, but Mac only.
The apps this is for share one shape: a Node server (or another sidecar process) that owns the data, and a browser UI that talks to it over localhost. kavu, meow-meow and madam are all this. What they need from the desktop is a window, a menu, "open with", a tray icon sometimes, and installers. They do not need a per-app native layer.
The recommendation #
Build mollusc as a generic Electron shell, installed once, driven by a
per-app mollusc.json. Keep the app-side contract runtime-neutral so the
internals can move to Tauri later without touching the apps.
Why Electron rather than Tauri for the shell:
- The Electron binary is prebuilt. Nothing is ever compiled; "build once" is
simply how it works. The shell is one npm package that owns
electronandelectron-builder; apps have neither. - Electron ships Node. A Node sidecar runs on it (
utilityProcess.forkorELECTRON_RUN_AS_NODE), so installers carry no extra runtime and no per-platform Node binary. With Tauri a Node sidecar means shipping Node or packing the server into a single executable per target. - Native menus, file associations, URL schemes, tray, multiple windows, and unprivileged windows all exist on every platform with no plugins.
What it costs: installers are about 200 MB because each carries Chromium, versus about 10 MB plus a sidecar runtime for Tauri. If that ever matters, the shell's internals change and the apps do not; see "Keeping the door open".
Why not the alternatives:
| Option | Build once | Native menus, file types | Node sidecar | Installers | Verdict |
|---|---|---|---|---|---|
| Electron shell | yes, prebuilt | yes | built in | 200 MB | recommended |
| Tauri shell | after first compile, with a shared target-dir |
yes | ship Node | 10 MB + Node | later, if size matters |
| Neutralinojs | yes, prebuilt | no menus, no open-file events | spawn + ship Node | small | rejected |
| Swift WKWebView shell | yes | yes | spawn + ship Node | tiny | Mac only, rejected |
The app contract #
An app is a directory with a mollusc.json. Everything else is the app's own.
{
"id": "com.berjon.kavu",
"name": "kavu",
"version": "0.1.0",
"icon": "icons/kavu.png",
"sidecar": {
"command": "node",
"args": ["server/main.js"],
"env": { "KAVU_PORT": "${port}" },
"ready": "http://127.0.0.1:${port}/api/status",
"node": true
},
"window": {
"url": "http://127.0.0.1:${port}/",
"width": 1440, "height": 900, "minWidth": 900, "minHeight": 600,
"titleBarStyle": "hiddenInset"
},
"api": ["fs.read", "fs.write", "dialog.open", "dialog.save", "shell.openExternal", "app.quit"],
"menu": [
{ "label": "File", "items": [
{ "label": "Open…", "accelerator": "CmdOrCtrl+O", "send": "menu:open" },
{ "label": "Save", "accelerator": "CmdOrCtrl+S", "send": "menu:save" },
{ "role": "close" }
] },
{ "role": "editMenu" }, { "role": "viewMenu" }, { "role": "windowMenu" }
],
"fileTypes": [{ "ext": ["svg"], "name": "SVG image", "role": "Editor" }],
"urlSchemes": ["kavu"],
"tray": null,
"build": {
"files": ["server/**", "web/**", "package.json"],
"productName": "Kavu",
"mac": { "category": "public.app-category.graphics-design" }
}
}
Fields:
sidecaris optional. Whennodeis true the command runs on Electron's own Node, so no runtime is bundled.${port}is a free port the shell picks; the shell waits forreadyto answer before opening the first window. The sidecar is killed when the last window closes, unlesskeepAliveis set. The sidecar's stdout and stderr go to a log file under the app's user data directory and to the terminal in dev.window.urlmay be a localhost URL or a path relative to the app directory, in which case the shell serves it from a customapp://scheme rather thanfile://, so fetch and modules work and the page is not a local file for CORS purposes.apiis an allowlist. The first window gets a preload exposing exactly those entries onwindow.mollusc; nothing else from Node or Electron is reachable. An empty list means a window with no bridge at all.menuuses Electron's menu description with one addition:sendnames an event delivered to the page through the bridge asmollusc.on(name, fn). Roles cover the standard platform menus.fileTypesandurlSchemesare written into the installers. Opened files and URLs arrive in the page asmollusc.on('open-file', path)andmollusc.on('open-url', url), including the one the app was launched with.trayis an icon plus a menu in the same description language, for apps like madam.
The bridge #
The preload is the whole security boundary, so it is small and generic:
contextIsolation: true,sandbox: true,nodeIntegration: falseon every window, always.- Each
apientry maps to one IPC channel. The main process validates the arguments of every call (paths resolved and checked against the app's allowed roots, dialogs restricted to the window that asked) before doing anything. mollusc.openWindow(url, { privileged: false })opens a window with no preload at all. The page can show arbitrary content, including remote content, without any native reach.privileged: truereuses the same allowlist and is only honoured forapp://and the sidecar's origin.- Navigation away from the app's origin is blocked; external links go to the system browser.
- When an app needs something the shell does not offer, the right place for it is the sidecar, which already has full Node. The bridge stays fixed.
Commands #
mollusc dev ./kavu # start the sidecar, open the window, reload on change
mollusc build ./kavu --mac --win --linux
mollusc build ./kavu --mac --sign # notarised dmg when credentials are present
mollusc doctor # check Electron cache, signing identities, platform tools
build generates an electron-builder configuration from mollusc.json,
copies only the build.files globs plus the shell's own main and preload,
and points electron-builder at the shell's shared Electron dist so no
per-app copy is unpacked. Output goes to ./dist in the app.
Cross-building is honest, not magic: Linux and Windows bundles can be made on a Mac; macOS bundles need a Mac for signing; a CI matrix (one job per platform, same command) is the way to produce all three in one go.
Disk footprint, concretely #
- One
molluscinstall: Electron plus electron-builder, about 300 MB, shared by every app. - Per app in development: nothing beyond the app's own code.
- Per built app: a 200 MB installer, in that app's
dist.
Keeping the door open to Tauri #
The contract above does not name Electron. If installer size becomes a
problem, the same mollusc.json can drive a shared Tauri crate: a thin per-app
src-tauri of three files, a global Cargo target-dir so dependencies compile
once, Tauri's window-label capabilities for the allowlist and for unprivileged
windows, and its bundler for installers. The two things that change are the
sidecar (a Node binary or packed executable per target becomes part of the
build) and build time (seconds after a first multi-minute compile). The apps
would not change.
Plan #
- Shell package:
main.js(config, sidecar, windows, menus, tray, open events),preload.js(bridge),app://protocol, logging. mollusc dev.mollusc buildfor macOS, then Windows and Linux.- Port kavu first (the newest and simplest), then meow-meow, then madam (tray app, no main window).
- Signing and notarisation.