From 3e63b7c1122c33a38c045cbd52459b26fa5a213d Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 2 May 2026 02:11:54 +0100 Subject: [PATCH] fix: align channel module loader cache import --- src/channels/plugins/module-loader.test.ts | 4 ++-- src/channels/plugins/module-loader.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/channels/plugins/module-loader.test.ts b/src/channels/plugins/module-loader.test.ts index b2682c48f9c..ca101083d0b 100644 --- a/src/channels/plugins/module-loader.test.ts +++ b/src/channels/plugins/module-loader.test.ts @@ -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)); }); }); diff --git a/src/channels/plugins/module-loader.ts b/src/channels/plugins/module-loader.ts index fff32363142..9b0feac15fb 100644 --- a/src/channels/plugins/module-loader.ts +++ b/src/channels/plugins/module-loader.ts @@ -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", });