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
This commit is contained in:
2026-05-19 18:23:24 +02:00
parent 4ea2734ade
commit 9367811c5a
5 changed files with 2309 additions and 105 deletions
+2 -1
View File
@@ -5,7 +5,7 @@
"main": "dist/main.js",
"scripts": {
"test": "jest",
"build": "tsc",
"build": "tsc --noEmit && node -e \"require('esbuild').build({entryPoints:['src/main.ts'],bundle:true,platform:'node',target:'es2020',outfile:'main.js',external:['obsidian','chromadb'],format:'cjs'})\"",
"watch": "tsc --watch",
"lint": "eslint src --ext .ts",
"format": "prettier --write ."
@@ -24,6 +24,7 @@
"@types/node": "^20.11.19",
"@typescript-eslint/eslint-plugin": "^8.59.2",
"@typescript-eslint/parser": "^8.59.2",
"esbuild": "^0.28.0",
"eslint": "^8.56.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^30.3.0",