mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:30:42 +00:00
fix: align channel module loader cache import
This commit is contained in:
@@ -89,13 +89,13 @@ describe("channel plugin module loader helpers", () => {
|
||||
}),
|
||||
).toEqual({
|
||||
loadedBy: "jiti",
|
||||
target: modulePath,
|
||||
target: fs.realpathSync.native(modulePath),
|
||||
});
|
||||
expect(createJiti).toHaveBeenCalledOnce();
|
||||
expect(createJiti).toHaveBeenCalledWith(
|
||||
expect.stringContaining("module-loader.ts"),
|
||||
expect.objectContaining({ tryNative: false }),
|
||||
);
|
||||
expect(loadWithJiti).toHaveBeenCalledWith(modulePath);
|
||||
expect(loadWithJiti).toHaveBeenCalledWith(fs.realpathSync.native(modulePath));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,15 +2,15 @@ import fs from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import { openBoundaryFileSync } from "../../infra/boundary-file-read.js";
|
||||
import {
|
||||
getCachedPluginJitiLoader,
|
||||
type PluginJitiLoaderCache,
|
||||
} from "../../plugins/jiti-loader-cache.js";
|
||||
import { isJavaScriptModulePath } from "../../plugins/native-module-require.js";
|
||||
import {
|
||||
getCachedPluginModuleLoader,
|
||||
type PluginModuleLoaderCache,
|
||||
} from "../../plugins/plugin-module-loader-cache.js";
|
||||
|
||||
const nodeRequire = createRequire(import.meta.url);
|
||||
const SOURCE_MODULE_EXTENSIONS = new Set([".ts", ".tsx", ".mts", ".cts"]);
|
||||
const jitiLoaders: PluginJitiLoaderCache = new Map();
|
||||
const jitiLoaders: PluginModuleLoaderCache = new Map();
|
||||
|
||||
function hasNativeSourceRequireHook(modulePath: string): boolean {
|
||||
const extension = path.extname(modulePath).toLowerCase();
|
||||
@@ -25,11 +25,11 @@ function isSourceModulePath(modulePath: string): boolean {
|
||||
}
|
||||
|
||||
function loadModuleWithJiti(modulePath: string): unknown {
|
||||
const loadWithJiti = getCachedPluginJitiLoader({
|
||||
const loadWithJiti = getCachedPluginModuleLoader({
|
||||
cache: jitiLoaders,
|
||||
modulePath,
|
||||
importerUrl: import.meta.url,
|
||||
jitiFilename: import.meta.url,
|
||||
loaderFilename: import.meta.url,
|
||||
tryNative: false,
|
||||
cacheScopeKey: "channel-plugin-module-loader",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user