mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
Add @openchatlab/parser-native (napi-rs v3) with a shared byte-level JSON scanner and two format kernels. Parsing large exports is 4-10x faster in real-data benchmarks. The native module is an optional local build; the pure-TS parsers remain as automatic fallback when it is unavailable, disabled via CHATLAB_DISABLE_NATIVE_PERF=1, or rejects off-spec files. The ChatLab kernel also parses the members array structurally, fixing the TS head-regex heuristic that silently dropped avatars/roles for files with nested arrays or long member lists. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { defineConfig } from 'tsup'
|
|
|
|
export default defineConfig({
|
|
entry: {
|
|
cli: 'src/cli.ts',
|
|
index: 'src/index.ts',
|
|
'semantic-index-worker': '../../packages/node-runtime/src/semantic-index/worker-thread-entry.ts',
|
|
'contacts-worker': '../../packages/node-runtime/src/services/contacts/worker-entry.ts',
|
|
'people-relationships-worker': '../../packages/node-runtime/src/services/people/relationships/worker-entry.ts',
|
|
},
|
|
format: ['esm'],
|
|
outDir: 'dist',
|
|
outExtension: () => ({ js: '.mjs' }),
|
|
splitting: true,
|
|
sourcemap: true,
|
|
clean: true,
|
|
target: 'node20',
|
|
platform: 'node',
|
|
define: {
|
|
'process.env.APTABASE_APP_KEY': JSON.stringify(process.env.APTABASE_APP_KEY || ''),
|
|
},
|
|
noExternal: [/^@openchatlab\/(?!parser-native)/, 'chatlab-mcp', 'stream-json'],
|
|
// parser-native 是本地构建的可选 Rust 内核:不打包也不声明依赖,
|
|
// 运行时 require 失败会自动回退 TS 解析器。
|
|
external: ['better-sqlite3', '@node-rs/jieba', '@openchatlab/parser-native'],
|
|
banner: {
|
|
js: [
|
|
"import { createRequire as __createRequire } from 'module';",
|
|
"import { dirname as __pathDirname } from 'path';",
|
|
"import { fileURLToPath as __fileURLToPath } from 'url';",
|
|
'const require = __createRequire(import.meta.url);',
|
|
'const __filename = __fileURLToPath(import.meta.url);',
|
|
'const __dirname = __pathDirname(__filename);',
|
|
].join('\n'),
|
|
},
|
|
})
|