mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 03:03:24 +08:00
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
import { mkdir } from 'node:fs/promises';
|
|
import { dirname, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
import { build } from 'esbuild';
|
|
|
|
const sourceDirectory = dirname(fileURLToPath(import.meta.url));
|
|
const packageRoot = resolve(sourceDirectory, '../..');
|
|
const outputPath = resolve(packageRoot, 'lib/index.js');
|
|
const externalRuntimePackages = [
|
|
'@tencent-connect/qqbot-connector',
|
|
'@tencent-connect/qqbot-nodejs',
|
|
'@wecom/aibot-node-sdk',
|
|
'dingtalk-stream',
|
|
'qrcode',
|
|
];
|
|
const external = externalRuntimePackages.flatMap((name) => [name, `${name}/*`]);
|
|
|
|
await mkdir(dirname(outputPath), { recursive: true });
|
|
await build({
|
|
entryPoints: [resolve(sourceDirectory, 'index.mjs')],
|
|
bundle: true,
|
|
format: 'esm',
|
|
platform: 'node',
|
|
target: ['node22'],
|
|
mainFields: ['module', 'main'],
|
|
external,
|
|
outfile: outputPath,
|
|
banner: {
|
|
js: [
|
|
"import { createRequire as __dshCreateRequire } from 'node:module';",
|
|
"import { dirname as __dshDirname } from 'node:path';",
|
|
"import { fileURLToPath as __dshFileURLToPath } from 'node:url';",
|
|
'const require = __dshCreateRequire(import.meta.url);',
|
|
'const __filename = __dshFileURLToPath(import.meta.url);',
|
|
'const __dirname = __dshDirname(__filename);',
|
|
].join('\n'),
|
|
},
|
|
sourcemap: false,
|
|
minify: true,
|
|
legalComments: 'eof',
|
|
});
|
|
|
|
console.log(`Wrote ${outputPath}`);
|