diff --git a/src/discovery.ts b/src/discovery.ts index 15ce9af6..32301a53 100644 --- a/src/discovery.ts +++ b/src/discovery.ts @@ -218,11 +218,14 @@ async function discoverPluginDir(dir: string, site: string): Promise { file.endsWith('.ts') && !file.endsWith('.d.ts') && !file.endsWith('.test.ts') ) { const jsFile = file.replace(/\.ts$/, '.js'); + // Prefer compiled .js — skip the .ts source file if (fileSet.has(jsFile)) return; - if (!(await isCliModule(filePath))) return; - await import(pathToFileURL(filePath).href).catch((err) => { - log.warn(`Plugin ${site}/${file}: ${getErrorMessage(err)}`); - }); + // No compiled .js found — cannot import raw .ts in production Node.js. + // This typically means esbuild transpilation failed during plugin install. + log.warn( + `Plugin ${site}/${file}: no compiled .js found. ` + + `Run "opencli plugin update ${site}" to re-transpile, or install esbuild.` + ); } })); } diff --git a/src/plugin.ts b/src/plugin.ts index 3397c95b..8d2853fe 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -937,7 +937,10 @@ function transpilePluginTs(pluginDir: string): void { const esbuildBin = resolveEsbuildBin(); if (!esbuildBin) { - log.debug('esbuild not found in host node_modules, via resolve, or in PATH, skipping TS transpilation'); + log.warn( + 'esbuild not found. TS plugin files will not be transpiled and may fail to load. ' + + 'Install esbuild (`npm i -g esbuild`) or ensure it is available in the opencli host node_modules.' + ); return; } @@ -965,8 +968,8 @@ function transpilePluginTs(pluginDir: string): void { log.warn(`Failed to transpile ${tsFile}: ${getErrorMessage(err)}`); } } - } catch { - // Non-fatal: skip transpilation if anything goes wrong + } catch (err) { + log.warn(`TS transpilation setup failed: ${getErrorMessage(err)}`); } }