From adff6c1ec5de9148f4efedc0ec61bb8d925c28b8 Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Sun, 23 Nov 2025 10:32:56 -0600 Subject: [PATCH] Add WASM backend support for Alpine Linux compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Configure Transformers.js to use WASM backend via TRANSFORMERS_BACKEND environment variable. This resolves onnxruntime-node glibc dependency issues on Alpine Linux (musl libc). Usage: TRANSFORMERS_BACKEND=wasm npm run index:docs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/search/lancedb-indexer.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/search/lancedb-indexer.ts b/src/search/lancedb-indexer.ts index 89b24b1..7e72d2b 100644 --- a/src/search/lancedb-indexer.ts +++ b/src/search/lancedb-indexer.ts @@ -58,6 +58,17 @@ export class LanceDBIndexer { console.log('Initializing LanceDB connection...'); this.db = await connect(this.dbPath); + // Configure ONNX Runtime backend based on environment variable + // TRANSFORMERS_BACKEND=wasm for Alpine Linux (musl libc) + // Default: native ONNX Runtime (faster, requires glibc) + const backend = process.env.TRANSFORMERS_BACKEND; + if (backend === 'wasm' || backend === 'onnxruntime-web') { + console.log('Using WASM backend for Transformers.js (Alpine/musl compatibility mode)'); + process.env.ONNXRUNTIME_BACKEND = 'wasm'; + } else { + console.log('Using native ONNX Runtime backend (glibc required)'); + } + console.log('Loading embedding model (this may take a moment)...'); this.embedder = await pipeline( 'feature-extraction',