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
This commit is contained in:
2026-05-19 18:12:14 +02:00
parent d31c989423
commit 44cff07ea1
4 changed files with 9 additions and 3 deletions
+1
View File
@@ -65,6 +65,7 @@ Then copy the plugin into your vault:
```bash ```bash
mkdir -p /path/to/vault/.obsidian/plugins/ollama-plugin mkdir -p /path/to/vault/.obsidian/plugins/ollama-plugin
cp manifest.json /path/to/vault/.obsidian/plugins/ollama-plugin/ cp manifest.json /path/to/vault/.obsidian/plugins/ollama-plugin/
cp main.js /path/to/vault/.obsidian/plugins/ollama-plugin/
cp -r dist /path/to/vault/.obsidian/plugins/ollama-plugin/ cp -r dist /path/to/vault/.obsidian/plugins/ollama-plugin/
cp -r node_modules/chromadb /path/to/vault/.obsidian/plugins/ollama-plugin/node_modules/ # optional: only needed for semantic cache cp -r node_modules/chromadb /path/to/vault/.obsidian/plugins/ollama-plugin/node_modules/ # optional: only needed for semantic cache
``` ```
+4 -2
View File
@@ -92,8 +92,9 @@ step "Installing into vault"
mkdir -p "$PLUGIN_DIR" mkdir -p "$PLUGIN_DIR"
# Copy manifest and built output # Copy manifest, entry shim, and built output
cp "$SCRIPT_DIR/manifest.json" "$PLUGIN_DIR/" cp "$SCRIPT_DIR/manifest.json" "$PLUGIN_DIR/"
cp "$SCRIPT_DIR/main.js" "$PLUGIN_DIR/"
cp -r "$SCRIPT_DIR/dist" "$PLUGIN_DIR/" cp -r "$SCRIPT_DIR/dist" "$PLUGIN_DIR/"
# Copy only necessary runtime dependencies (obsidian and chromadb stubs) # Copy only necessary runtime dependencies (obsidian and chromadb stubs)
@@ -111,8 +112,9 @@ info "Plugin installed to $PLUGIN_DIR"
step "Verifying installation" step "Verifying installation"
if [ -f "$PLUGIN_DIR/manifest.json" ] && [ -f "$PLUGIN_DIR/dist/main.js" ]; then if [ -f "$PLUGIN_DIR/manifest.json" ] && [ -f "$PLUGIN_DIR/main.js" ] && [ -f "$PLUGIN_DIR/dist/main.js" ]; then
info "manifest.json ✓" info "manifest.json ✓"
info "main.js ✓"
info "dist/main.js ✓" info "dist/main.js ✓"
else else
error "Installation verification failed — missing files in $PLUGIN_DIR" error "Installation verification failed — missing files in $PLUGIN_DIR"
+3
View File
@@ -0,0 +1,3 @@
// Shim entry point — re-exports the compiled plugin from dist/
// Obsidian expects main.js at the plugin root alongside manifest.json.
module.exports = require('./dist/main.js');
+1 -1
View File
@@ -7,7 +7,7 @@
"author": "Anonymous", "author": "Anonymous",
"authorUrl": "", "authorUrl": "",
"isDesktopOnly": true, "isDesktopOnly": true,
"main": "dist/main.js", "main": "main.js",
"authorization": [], "authorization": [],
"permissions": [], "permissions": [],
"defaultEnabled": true, "defaultEnabled": true,