Fix Electron resolution for optional chromadb dependency

Replace dynamic ESM import with require() for chromadb to ensure
Electron can resolve the package against the plugin's node_modules.
Also wrap default fetch fallback in an arrow function to avoid
potential strict mode issues with global fetch.
This commit is contained in:
2026-05-19 20:19:28 +02:00
parent 3342d7d955
commit 26e178fa96
4 changed files with 11 additions and 17 deletions
+3 -12
View File
@@ -1,9 +1,7 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/main.ts
@@ -194,7 +184,8 @@ var SemanticCacheService = class _SemanticCacheService {
async initialize() {
if (!this.config.enabled) return;
try {
const { ChromaClient } = await import("chromadb");
const chromadb = require("chromadb");
const { ChromaClient } = chromadb;
const chromaURL = this.config.chromaURL || "http://localhost:8000";
this.client = new ChromaClient({ path: chromaURL });
this.collection = await this.client.getOrCreateCollection({
@@ -285,7 +276,7 @@ var OllamaClient = class {
this.currentStreamController = null;
this.baseURL = baseURL;
this.model = model;
this.fetchFn = fetchFn ?? fetch;
this.fetchFn = fetchFn ?? ((url, init) => fetch(url, init));
if (cacheConfig?.enabled) {
this.cacheService = new SemanticCacheService(baseURL, cacheConfig);
void this.cacheService.initialize();