Skip to content

Commit dca540e

Browse files
Doctor-wuclaude
andauthored
fix(agent-inbox): replace opaque dynamic import with static import() for bundler (#43)
* fix(agent-inbox): replace opaque dynamic import with static import() for bundler The `importRuntimeModule` helper used `Function('modulePath', 'return import(modulePath)')` to dynamically import IM runtime packages. This pattern is completely opaque to the bundler's static analysis, so `@agent-im-relay/discord`, `@agent-im-relay/feishu`, and `@agent-im-relay/slack` were never bundled into dist — causing ERR_MODULE_NOT_FOUND at runtime after `npm install`. Replace with direct `import()` expressions that the bundler can statically resolve and inline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore(agent-inbox): bump version to 1.2.5 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9b36a4b commit dca540e

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

apps/agent-inbox/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@doctorwu/agent-inbox",
3-
"version": "1.2.4",
3+
"version": "1.2.5",
44
"type": "module",
55
"main": "dist/index.mjs",
66
"types": "dist/index.d.mts",

apps/agent-inbox/src/runtime.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ type RuntimeLoaders = {
77
slack?: () => Promise<{ startSlackRuntime: () => Promise<unknown> }>;
88
};
99

10-
function importRuntimeModule<T>(specifier: string): Promise<T> {
11-
return Function('modulePath', 'return import(modulePath)')(specifier) as Promise<T>;
12-
}
13-
1410
function setOptionalEnv(key: string, value: string | undefined): void {
1511
if (value) {
1612
process.env[key] = value;
@@ -87,20 +83,20 @@ export async function startSelectedIm(
8783
applyRuntimeEnvironment(selectedIm, runtime, paths);
8884

8985
if (selectedIm.id === 'discord') {
90-
const loadDiscord = loaders.discord ?? (() => importRuntimeModule<{ startDiscordRuntime: () => Promise<unknown> }>('@agent-im-relay/discord'));
86+
const loadDiscord = loaders.discord ?? (() => import('@agent-im-relay/discord'));
9187
const discord = await loadDiscord();
9288
await discord.startDiscordRuntime();
9389
return;
9490
}
9591

9692
if (selectedIm.id === 'feishu') {
97-
const loadFeishu = loaders.feishu ?? (() => importRuntimeModule<{ startFeishuRuntime: () => Promise<unknown> }>('@agent-im-relay/feishu'));
93+
const loadFeishu = loaders.feishu ?? (() => import('@agent-im-relay/feishu'));
9894
const feishu = await loadFeishu();
9995
await feishu.startFeishuRuntime();
10096
return;
10197
}
10298

103-
const loadSlack = loaders.slack ?? (() => importRuntimeModule<{ startSlackRuntime: () => Promise<unknown> }>('@agent-im-relay/slack'));
99+
const loadSlack = loaders.slack ?? (() => import('@agent-im-relay/slack'));
104100
const slack = await loadSlack();
105101
await slack.startSlackRuntime();
106102
}

0 commit comments

Comments
 (0)