From fa35bf9d2012921243762629b43ecc2b43523329 Mon Sep 17 00:00:00 2001 From: Kevin Cao <39608887+kev-cao@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:29:21 -0400 Subject: [PATCH] fix: bundle React via preact/compat to satisfy plugin review react-dom emits three dynamic createElement("script") calls (its hoistable-resource code paths) that Obsidian's review scanner flags, even though the plugin never triggers them. Alias react/react-dom to preact/compat at bundle time so those code paths are gone; also shrinks main.js from ~4MB to ~130K. Co-Authored-By: roachdev-claude --- esbuild.config.mjs | 7 +++++++ package-lock.json | 12 ++++++++++++ package.json | 1 + 3 files changed, 20 insertions(+) diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 67e0869..d72c3ff 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -19,6 +19,13 @@ const context = await esbuild.context({ styles: 'src/styles/main.css', }, bundle: true, + alias: { + 'react': 'preact/compat', + 'react-dom': 'preact/compat', + 'react-dom/client': 'preact/compat/client', + 'react/jsx-runtime': 'preact/jsx-runtime', + 'react/jsx-dev-runtime': 'preact/jsx-dev-runtime', + }, external: [ 'obsidian', 'electron', diff --git a/package-lock.json b/package-lock.json index f618fc5..aaae40c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,7 @@ "globals": "^17.6.0", "jiti": "^2.6.1", "obsidian": "latest", + "preact": "^10.29.2", "typescript": "^5.8.3", "typescript-eslint": "^8.59.1" } @@ -4105,6 +4106,17 @@ "node": ">= 0.4" } }, + "node_modules/preact": { + "version": "10.29.2", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.29.2.tgz", + "integrity": "sha512-7tNmwg/7mzzAoB/8kSg6Hl37JraAZw3Z3A0JSY7VXlZwo82Xn0G7wKbNNs2qoF4ZEEsQGTwDAroNdqKs1ofJxQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", diff --git a/package.json b/package.json index 2a8fa52..f7fce10 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "globals": "^17.6.0", "jiti": "^2.6.1", "obsidian": "latest", + "preact": "^10.29.2", "typescript": "^5.8.3", "typescript-eslint": "^8.59.1" },