From a37fbcb9bcf6ace259e32af5e9258937774fd357 Mon Sep 17 00:00:00 2001 From: Tommaso Casaburi Date: Mon, 16 Mar 2026 20:09:57 +0800 Subject: [PATCH] fix(electron): lazy-load before-pack ipfs downloader --- electron/start-ipfs.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/electron/start-ipfs.js b/electron/start-ipfs.js index c0c25061..4be838f7 100644 --- a/electron/start-ipfs.js +++ b/electron/start-ipfs.js @@ -7,7 +7,6 @@ import proxyServer from './proxy-server.js'; import tcpPortUsed from 'tcp-port-used'; import EnvPaths from 'env-paths'; import { fileURLToPath, pathToFileURL } from 'url'; -import { downloadIpfsClients } from './before-pack.js'; const dirname = path.join(path.dirname(fileURLToPath(import.meta.url))); const envPaths = EnvPaths('plebbit', { suffix: false }); @@ -23,6 +22,12 @@ const getPlatformDir = () => { const getBundledKuboPath = (rootPath) => path.join(rootPath, 'bin', getPlatformDir(), getIpfsBinaryName()); +const downloadBundledIpfsClients = async () => { + // before-pack.js is excluded from packaged builds, so only load it in dev. + const { downloadIpfsClients } = await import('./before-pack.js'); + await downloadIpfsClients(); +}; + // Resolve kubo binary path const getKuboPath = async () => { if (isDev) { @@ -36,7 +41,7 @@ const getKuboPath = async () => { } console.log(`Kubo binary missing at ${bundledKuboPath}, downloading repo-managed binary...`); - await downloadIpfsClients(); + await downloadBundledIpfsClients(); if (fs.existsSync(bundledKuboPath)) { return bundledKuboPath;