UNPKG

cyberbot-next

Version:

cyberbot, 基于napcat-ts, nodejs,轻量qq机器人框架。

30 lines 1.01 kB
import { createJiti } from 'jiti'; import { logger } from './logger.js'; import { dirname } from 'node:path'; import { createRequire } from 'node:module'; export const globalJitiLoader = createJiti(process.cwd(), { requireCache: true, interopDefault: true, debug: false, fsCache: false, moduleCache: false, sourceMaps: false, jsx: false, extensions: [".js", ".ts"] }); export function clearModuleCache(modulePath) { try { const require = createRequire(import.meta.url); const moduleDir = dirname(modulePath); Object.keys(require.cache ?? {}).forEach(cachedPath => { if (cachedPath.includes(moduleDir)) { Reflect.deleteProperty(require.cache, cachedPath); logger.debug(`模块缓存已清除: ${cachedPath}`); } }); } catch (error) { logger.warn(`模块缓存清理失败: ${error instanceof Error ? error.message : error}`); } } //# sourceMappingURL=jitiLoader.js.map