Add WASM backend support for Alpine Linux compatibility

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 <noreply@anthropic.com>
This commit is contained in:
Michael Mainguy 2025-11-23 10:32:56 -06:00
parent a166b8aea6
commit adff6c1ec5

View File

@ -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',