fix: align channel module loader cache import

This commit is contained in:
Peter Steinberger
2026-05-02 02:11:54 +01:00
parent d85d782a0a
commit 3e63b7c112
2 changed files with 9 additions and 9 deletions

View File

@@ -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));
});
});

View File

@@ -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",
});