























@@ -3,6 +3,10 @@ import path from "node:path";
33import { bundledDistPluginFile } from "openclaw/plugin-sdk/test-fixtures";
44import { afterEach, describe, expect, it } from "vitest";
55import { stageBundledPluginRuntime } from "../../scripts/stage-bundled-plugin-runtime.mjs";
6+import {
7+clearBundledRuntimeDependencyJitiAliases,
8+registerBundledRuntimeDependencyJitiAliases,
9+} from "./bundled-runtime-deps-jiti-aliases.js";
610import type { PluginJitiLoaderCache } from "./jiti-loader-cache.js";
711import { loadPluginBoundaryModuleWithJiti } from "./runtime/runtime-plugin-boundary.js";
812import { cleanupTrackedTempDirs, makeTrackedTempDir } from "./test-helpers/fs-fixtures.js";
@@ -119,11 +123,85 @@ function expectSharedWhatsAppListenerState(runtimePluginDir: string, accountId:
119123}
120124121125afterEach(() => {
126+clearBundledRuntimeDependencyJitiAliases();
122127cleanupTrackedTempDirs(tempDirs);
123128});
124129125130describe("runtime plugin boundary whatsapp seam", () => {
126131it("shares listener state between staged light and heavy runtime modules", () => {
127132expectSharedWhatsAppListenerState(createBundledWhatsAppRuntimeFixture(), "work");
128133});
134+135+it("resolves staged root runtime dependency aliases while loading boundary modules", () => {
136+const packageRoot = makeTrackedTempDir("openclaw-runtime-boundary-alias", tempDirs);
137+const stageRoot = makeTrackedTempDir("openclaw-runtime-boundary-deps", tempDirs);
138+writeRuntimeFixtureText(
139+packageRoot,
140+"package.json",
141+JSON.stringify(
142+{
143+name: "openclaw",
144+type: "module",
145+bin: {
146+openclaw: "openclaw.mjs",
147+},
148+exports: {
149+"./plugin-sdk": {
150+default: "./dist/plugin-sdk/index.js",
151+},
152+},
153+},
154+null,
155+2,
156+),
157+);
158+writeRuntimeFixtureText(packageRoot, "openclaw.mjs", "export {};\n");
159+writeRuntimeFixtureText(
160+packageRoot,
161+bundledDistPluginFile("acpx", "runtime-api.js"),
162+'export { marker } from "../../root-runtime-chunk.js";\n',
163+);
164+writeRuntimeFixtureText(
165+packageRoot,
166+"dist/root-runtime-chunk.js",
167+'import { marker as depMarker } from "package-only-runtime-dep";\nexport const marker = depMarker;\n',
168+);
169+stageBundledPluginRuntime({ repoRoot: packageRoot });
170+171+writeRuntimeFixtureText(
172+stageRoot,
173+"package.json",
174+JSON.stringify({
175+dependencies: {
176+"package-only-runtime-dep": "1.0.0",
177+},
178+}),
179+);
180+writeRuntimeFixtureText(
181+stageRoot,
182+"node_modules/package-only-runtime-dep/package.json",
183+JSON.stringify({
184+name: "package-only-runtime-dep",
185+version: "1.0.0",
186+exports: {
187+".": "./index.js",
188+},
189+type: "module",
190+}),
191+);
192+writeRuntimeFixtureText(
193+stageRoot,
194+"node_modules/package-only-runtime-dep/index.js",
195+'export const marker = "staged-runtime-dep";\n',
196+);
197+registerBundledRuntimeDependencyJitiAliases(stageRoot);
198+199+const loaders: PluginJitiLoaderCache = new Map();
200+const loaded = loadPluginBoundaryModuleWithJiti<{ marker: string }>(
201+path.join(packageRoot, "dist-runtime", "extensions", "acpx", "runtime-api.js"),
202+loaders,
203+);
204+205+expect(loaded.marker).toBe("staged-runtime-dep");
206+});
129207});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。