Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,14 @@ async function discoverPluginDir(dir: string, site: string): Promise<void> {
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.`
);
}
}));
}
Expand Down
9 changes: 6 additions & 3 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)}`);
}
}

Expand Down