From 44cff07ea1656a29a2321ffc0d67e5e3f2592b55 Mon Sep 17 00:00:00 2001 From: Florian Egger Date: Tue, 19 May 2026 18:12:14 +0200 Subject: [PATCH] fix: add main.js shim at plugin root for Obsidian loader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- README.md | 1 + install.sh | 6 ++++-- main.js | 3 +++ manifest.json | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 main.js diff --git a/README.md b/README.md index 7c1cda4..01f770e 100755 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Then copy the plugin into your vault: ```bash mkdir -p /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 node_modules/chromadb /path/to/vault/.obsidian/plugins/ollama-plugin/node_modules/ # optional: only needed for semantic cache ``` diff --git a/install.sh b/install.sh index fbba997..9817ee6 100755 --- a/install.sh +++ b/install.sh @@ -92,8 +92,9 @@ step "Installing into vault" 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/main.js" "$PLUGIN_DIR/" cp -r "$SCRIPT_DIR/dist" "$PLUGIN_DIR/" # Copy only necessary runtime dependencies (obsidian and chromadb stubs) @@ -111,8 +112,9 @@ info "Plugin installed to $PLUGIN_DIR" 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 "main.js ✓" info "dist/main.js ✓" else error "Installation verification failed — missing files in $PLUGIN_DIR" diff --git a/main.js b/main.js new file mode 100644 index 0000000..f3f2f23 --- /dev/null +++ b/main.js @@ -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'); diff --git a/manifest.json b/manifest.json index 73d92b5..819f066 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "author": "Anonymous", "authorUrl": "", "isDesktopOnly": true, - "main": "dist/main.js", + "main": "main.js", "authorization": [], "permissions": [], "defaultEnabled": true,