Files
ChatLab/apps/cli/tsup.config.ts
T
digua 0aa30359ab fix(cli): resolve ESM module resolution for tsx dev mode
- Remove "type": "module" from apps/cli/package.json to avoid
  ESM/CJS interop issues with workspace packages in tsx dev mode
- Configure tsup to output .mjs files (always treated as ESM by Node.js)
- Rename bin entry from chatlab.js to chatlab.mjs
- Change chatlab web default port to 3100 (serve keeps 3110)
- Fix vite plugin: use pnpm instead of npx for tsx invocation
2026-05-19 22:13:00 +08:00

29 lines
817 B
TypeScript

import { defineConfig } from 'tsup'
export default defineConfig({
entry: {
cli: 'src/cli.ts',
index: 'src/index.ts',
},
format: ['esm'],
outDir: 'dist',
outExtension: () => ({ js: '.mjs' }),
splitting: true,
sourcemap: true,
clean: true,
target: 'node20',
platform: 'node',
noExternal: [/^@openchatlab\//, 'stream-json'],
external: ['better-sqlite3', '@node-rs/jieba'],
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'),
},
})