






















@@ -3,12 +3,8 @@ import os from "node:os";
33import path from "node:path";
44import { importFreshModule } from "openclaw/plugin-sdk/test-fixtures";
55import { afterEach, describe, expect, it, vi } from "vitest";
6-import {
7-isJavaScriptModulePath,
8-resolveCompiledBundledModulePath,
9-resolveExistingPluginModulePath,
10-resolvePluginModuleCandidates,
11-} from "./module-loader.js";
6+import { isJavaScriptModulePath } from "../../plugins/native-module-require.js";
7+import { resolveExistingPluginModulePath } from "./module-loader.js";
128139const tempDirs: string[] = [];
1410@@ -27,38 +23,12 @@ function createTempDir(): string {
2723}
28242925describe("channel plugin module loader helpers", () => {
30-it("prefers compiled bundled dist output when present", () => {
31-const rootDir = createTempDir();
32-const runtimePath = path.join(rootDir, "dist-runtime", "entry.js");
33-const compiledPath = path.join(rootDir, "dist", "entry.js");
34-fs.mkdirSync(path.dirname(compiledPath), { recursive: true });
35-fs.writeFileSync(compiledPath, "export {};\n", "utf8");
36-37-expect(resolveCompiledBundledModulePath(runtimePath)).toBe(compiledPath);
38-});
39-40-it("keeps dist-runtime path when compiled bundled output is absent", () => {
41-const rootDir = createTempDir();
42-const runtimePath = path.join(rootDir, "dist-runtime", "entry.js");
43-44-expect(resolveCompiledBundledModulePath(runtimePath)).toBe(runtimePath);
45-});
46-47-it("resolves plugin module candidates and picks the first existing extension", () => {
26+it("resolves extensionless plugin module specifiers to the first existing extension", () => {
4827const rootDir = createTempDir();
4928const expectedPath = path.join(rootDir, "src", "checker.mts");
5029fs.mkdirSync(path.dirname(expectedPath), { recursive: true });
5130fs.writeFileSync(expectedPath, "export const ok = true;\n", "utf8");
523153-expect(resolvePluginModuleCandidates(rootDir, "./src/checker")).toEqual([
54-path.join(rootDir, "src", "checker"),
55-path.join(rootDir, "src", "checker.ts"),
56-path.join(rootDir, "src", "checker.mts"),
57-path.join(rootDir, "src", "checker.js"),
58-path.join(rootDir, "src", "checker.mjs"),
59-path.join(rootDir, "src", "checker.cts"),
60-path.join(rootDir, "src", "checker.cjs"),
61-]);
6232expect(resolveExistingPluginModulePath(rootDir, "./src/checker")).toBe(expectedPath);
6333});
6434此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。