Commit Graph

5 Commits

Author SHA1 Message Date
fegger 97cc4ed5fe fix: bundle chromadb and fix fetch invocation in Electron
- Bundle chromadb into main.js via esbuild instead of externalizing it.
  Obsidian's renderer cannot resolve bare require('chromadb') against a
  plugin-local node_modules. By bundling, the client library is inlined and
  works out of the box with just manifest.json + main.js.

- Remove eager cache initialization from OllamaClient constructor to avoid
  unhandled promise rejections when chromadb/ChromaDB is unavailable.

- Fix 'Failed to execute fetch on Window: Illegal invocation' by wrapping
  the default fetch fallback in an arrow function:
    this.fetchFn = fetchFn ?? ((url, init) => fetch(url, init));
  This preserves the window binding when fetch is called later.

- Update install.sh and README to remove the obsolete node_modules/chromadb
  copy step.

- Update ollama-client-cache tests to reflect that cache initialization is
  no longer eager.
2026-05-19 20:38:50 +02:00
fegger 3342d7d955 fix: use npm install (not --production) so build tools are available
The install script ran npm install --production, which skips devDependencies.
Since typescript, esbuild, and other build tools live in devDependencies,
npm run build would fail with 'tsc: command not found'.

Switched to plain npm install so all dependencies are available at build
time.  Only the necessary runtime dep (chromadb) is copied to the plugin
folder — obsidian stays out since it's a type stub.
2026-05-19 19:01:45 +02:00
fegger 9367811c5a fix: switch to esbuild bundling — single main.js at plugin root
The root cause: Obsidian's plugin loader expects main.js at the plugin root
alongside manifest.json.  The previous 'dist/' output + shim approach caused
'Cannot find module ./dist/main.js' because dist/ was either missing or not
resolved correctly in Obsidian's module loader.

Changes:
- build: use esbuild to bundle all source into a single main.js (61KB)
  tsc --noEmit for type checking; esbuild for the actual bundle
- main.js: no longer a shim — it's the fully bundled plugin
- package.json: added esbuild as devDependency; obsidian moved to devDeps
- install.sh: remove dist/ copy step, add cleanup of old dist/ from vault
- README.md: updated manual install steps to reflect bundling
2026-05-19 18:23:24 +02:00
fegger 44cff07ea1 fix: add main.js shim at plugin root for Obsidian loader
Obsidian's plugin loader expects main.js at the plugin root alongside
manifest.json — it does not resolve subdirectory paths in the 'main'
field.  Added a thin CommonJS shim that re-exports from dist/main.js.

- main.js: new entry shim (module.exports = require('./dist/main.js'))
- manifest.json: 'main' changed from 'dist/main.js' to 'main.js'
- install.sh: copy main.js shim to plugin folder, verify its presence
- README.md: add main.js to manual install instructions
2026-05-19 18:12:14 +02:00
fegger 378642152e fix: plugin cannot be installed — manifest path, deps, and install script
- manifest.json: fix 'main' from 'src/main.js' to 'dist/main.js'
  (TypeScript compiles to dist/, not src/ — Obsidian could not find the entry point)
- manifest.json: set isDesktopOnly to true (plugin requires a local Ollama server)
- package.json: remove unused node-fetch dependency (ESM-only, conflicts with CommonJS build)
- src/semantic-cache.ts: use dynamic import for chromadb instead of top-level import
  (prevents plugin load crash when chromadb is not installed; cache defaults to disabled)
- install.sh: new script that installs deps, builds, and copies the plugin into a vault
- README.md: add quick install, manual install, and expanded troubleshooting sections
2026-05-19 17:39:10 +02:00