Skip to content

Commit 8d48096

Browse files
cnbailianclaude
andcommitted
fix: inline definePlugin to remove runtime dependency on repterm-api
When repterm is installed via symlink/link outside its monorepo, bun resolves imports from the symlink target path rather than the node_modules location. This causes 'Cannot find package repterm-api' errors because repterm-api isn't in the symlink target's resolution path. Fix by inlining the trivial definePlugin function and changing all repterm-api imports to type-only (erased at compile time). The repterm-api package remains in dependencies for TypeScript type resolution but is no longer needed at runtime. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1bfadfb commit 8d48096

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

packages/repterm/src/plugin/index.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,33 @@
77

88
import type { TestContext } from '../runner/models.js';
99
import type { DollarFunction } from '../terminal/dollar.js';
10-
import {
11-
definePlugin as definePluginFromApi,
12-
type BasePluginContext as BasePluginContextGeneric,
13-
type PluginHooks,
14-
type PluginDefinition,
15-
type AnyPlugin,
10+
import type {
11+
BasePluginContext as BasePluginContextGeneric,
12+
PluginHooks,
13+
PluginDefinition,
14+
AnyPlugin,
1615
} from 'repterm-api';
1716

18-
// Re-export plugin-api for consumers (repterm re-exports these from index)
19-
export { definePluginFromApi as definePlugin };
17+
// Inline definePlugin to avoid runtime dependency on repterm-api.
18+
// This prevents "Cannot find package 'repterm-api'" errors when repterm
19+
// is installed via symlink/link outside its monorepo.
20+
function definePlugin<
21+
TName extends string,
22+
TContextIn extends object,
23+
TContextOut extends object,
24+
TMethods extends object,
25+
>(
26+
name: TName,
27+
setup: (ctx: TContextIn) => {
28+
methods: TMethods;
29+
context?: TContextOut;
30+
hooks?: PluginHooks<any>;
31+
},
32+
): PluginDefinition<TName, TContextIn, TContextOut, TMethods> {
33+
return { name, setup };
34+
}
35+
36+
export { definePlugin };
2037
export type { PluginDefinition, AnyPlugin, PluginHooks };
2138
export type BasePluginContext = BasePluginContextGeneric<TestContext>;
2239

0 commit comments

Comments
 (0)