From dbf4f2e96f63679298a8beecaf7d519a38ee0837 Mon Sep 17 00:00:00 2001 From: Mike Thicke Date: Sat, 30 May 2026 23:08:58 -0400 Subject: [PATCH] Externalize @codemirror/state and @codemirror/view from the bundle Obsidian ships CodeMirror in its runtime; bundling our own copy is both wasteful (~200 kB) and risky (two CM6 instances in the host). The bundling-by-default also broke pnpm installs because pnpm doesn't hoist devDependencies the way npm does, so Rollup couldn't resolve the import paths. Externalising drops the plugin back to ~620 kB and matches the recommended pattern for Obsidian plugins that use CM6. Co-Authored-By: Claude Opus 4.7 --- vite.config.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index e5220da..01c1f01 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -34,7 +34,14 @@ export default defineConfig({ fileName: () => "main.js", }, rollupOptions: { - external: ["obsidian", "electron"], // don't bundle the host libs + // Obsidian's runtime already loads CodeMirror; importing it as a peer + // keeps our bundle small and avoids two CM6 instances in the host. + external: [ + "obsidian", + "electron", + "@codemirror/state", + "@codemirror/view", + ], output: { exports: "named", assetFileNames: () => "styles.css", // Always output CSS as styles.css