"chore: 升级 Rollup 版本并优化构建配置"

This commit is contained in:
2025-05-26 02:58:40 +08:00
parent 6ced3676ab
commit 0c885e9012
11 changed files with 820 additions and 220 deletions

View File

@@ -1,25 +1,37 @@
// @ts-check
// https://bun.sh/docs/bundler
// @ts-ignore
import { resolvePath } from '@kevisual/use-config/env';
import pkg from './package.json';
import { execSync } from 'node:child_process';
// bun run src/index.ts --
const entry = 'src/index.ts';
const naming = 'app';
const external = ['sequelize', 'pg', 'sqlite3', 'ioredis', 'pm2'];
/**
* @type {import('bun').BuildConfig}
*/
await Bun.build({
target: 'node',
format: 'esm',
entrypoints: [resolvePath('./src/provider/index.ts')],
outdir: resolvePath('./dist'),
entrypoints: [resolvePath(entry, { meta: import.meta })],
outdir: resolvePath('./dist', { meta: import.meta }),
naming: {
entry: 'ai-provider.mjs',
entry: `${naming}.js`,
},
define: {
ENVISION_VERSION: JSON.stringify(pkg.version),
},
env: 'ENVISION_*',
external,
env: 'KEVISUAL_*',
});
const cmd = 'dts -i src/provider/index.ts -o ai-provider.d.ts';
execSync(cmd, { stdio: 'inherit' });
// const cmd = `dts -i src/index.ts -o app.d.ts`;
// const cmd = `dts -i ${entry} -o ${naming}.d.ts`;
// execSync(cmd, { stdio: 'inherit' });
await Bun.build({
target: 'node',
format: 'esm',
entrypoints: [resolvePath('./src/run.ts', { meta: import.meta })],
outdir: resolvePath('./dist', { meta: import.meta }),
naming: {
entry: `${'run'}.js`,
},
external,
env: 'KEVISUAL_*',
});