mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 22:35:51 +00:00
fix: 替换 extractMemories 的 require() 为动态 import() 修复 Vite 构建崩溃
Vite/Rollup 构建时将 require() 通过 __toCommonJS() 包装 ESM 导出,
导致命名导出被包裹在 { default: namespace } 中,访问
extractMemoriesModule.initExtractMemories 为 undefined 触发 React
error boundary 崩溃。改用标准 ESM 动态 import() 绕过 CJS interop。
Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
This commit is contained in:
@@ -39,9 +39,6 @@ import { getTaskListId, listTasks } from '../utils/tasks.js'
|
||||
import { getAgentName, getTeamName, isTeammate } from '../utils/teammate.js'
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||
const extractMemoriesModule = feature('EXTRACT_MEMORIES')
|
||||
? (require('../services/extractMemories/extractMemories.js') as typeof import('../services/extractMemories/extractMemories.js'))
|
||||
: null
|
||||
const jobClassifierModule = feature('TEMPLATES')
|
||||
? (require('../jobs/classifier.js') as typeof import('../jobs/classifier.js'))
|
||||
: null
|
||||
@@ -154,12 +151,16 @@ export async function* handleStopHooks(
|
||||
// Fire-and-forget in both interactive and non-interactive. For -p/SDK,
|
||||
// print.ts drains the in-flight promise after flushing the response
|
||||
// but before gracefulShutdownSync (see drainPendingExtraction).
|
||||
void extractMemoriesModule!.executeExtractMemories(
|
||||
stopHookContext,
|
||||
toolUseContext.appendSystemMessage as
|
||||
| ((msg: import('../types/message.js').SystemMessage) => void)
|
||||
| undefined,
|
||||
)
|
||||
void import('../services/extractMemories/extractMemories.js')
|
||||
.then(({ executeExtractMemories }) =>
|
||||
executeExtractMemories(
|
||||
stopHookContext,
|
||||
toolUseContext.appendSystemMessage as
|
||||
| ((msg: import('../types/message.js').SystemMessage) => void)
|
||||
| undefined,
|
||||
),
|
||||
)
|
||||
.catch(() => {})
|
||||
}
|
||||
if (!toolUseContext.agentId && !poorMode) {
|
||||
void executeAutoDream(stopHookContext, toolUseContext.appendSystemMessage)
|
||||
|
||||
Reference in New Issue
Block a user