mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:50:43 +00:00
fix(channels): honor module loader native opt-out
This commit is contained in:
@@ -3,7 +3,6 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { importFreshModule } from "openclaw/plugin-sdk/test-fixtures";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { shouldExpectNativeJitiForJavaScriptTestRuntime } from "../../test-utils/jiti-runtime.js";
|
||||
import {
|
||||
isJavaScriptModulePath,
|
||||
resolveCompiledBundledModulePath,
|
||||
@@ -122,7 +121,7 @@ describe("channel plugin module loader helpers", () => {
|
||||
expect(createJiti).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
expect.objectContaining({
|
||||
tryNative: shouldExpectNativeJitiForJavaScriptTestRuntime(),
|
||||
tryNative: false,
|
||||
}),
|
||||
);
|
||||
} finally {
|
||||
|
||||
@@ -11,7 +11,7 @@ export { isJavaScriptModulePath } from "../../plugins/native-module-require.js";
|
||||
function createModuleLoader() {
|
||||
const jitiLoaders: PluginJitiLoaderCache = new Map();
|
||||
|
||||
return (modulePath: string) => {
|
||||
return (modulePath: string, tryNative?: boolean) => {
|
||||
return getCachedPluginJitiLoader({
|
||||
cache: jitiLoaders,
|
||||
modulePath,
|
||||
@@ -19,6 +19,7 @@ function createModuleLoader() {
|
||||
argvEntry: process.argv[1],
|
||||
preferBuiltDist: true,
|
||||
jitiFilename: import.meta.url,
|
||||
tryNative,
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -83,7 +84,8 @@ export function loadChannelPluginModule(params: {
|
||||
}
|
||||
const safePath = opened.path;
|
||||
fs.closeSync(opened.fd);
|
||||
if (params.shouldTryNativeRequire?.(safePath)) {
|
||||
const shouldTryNative = params.shouldTryNativeRequire?.(safePath);
|
||||
if (shouldTryNative) {
|
||||
const nativeModule = tryNativeRequireJavaScriptModule(safePath, {
|
||||
allowWindows: true,
|
||||
});
|
||||
@@ -91,5 +93,5 @@ export function loadChannelPluginModule(params: {
|
||||
return nativeModule.moduleExport;
|
||||
}
|
||||
}
|
||||
return loadModule(safePath)(safePath);
|
||||
return loadModule(safePath, shouldTryNative)(safePath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user