mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-09 05:10:45 +08:00
Node refuses TypeScript stripping inside node_modules; point package main at the host bundle and document GitHub as the default install. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
/**
|
|
* Build lib/index.js (host Cordis plugin) for installs under node_modules.
|
|
* Node refuses to strip TypeScript inside node_modules, so GitHub/npm installs
|
|
* must ship prebuilt JS. Usage: bun run scripts/build-host.mjs
|
|
*/
|
|
import { mkdirSync, writeFileSync } from 'node:fs'
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
const entry = join(root, 'src/index.ts')
|
|
const outFile = join(root, 'lib', 'index.js')
|
|
|
|
const external = [
|
|
'@deepseek-ai/cordis',
|
|
'@deepseek-ai/schemastery',
|
|
'@deepseek-ai/dsh-credentials',
|
|
'@deepseek-ai/dsh-settings',
|
|
'@deepseek-ai/dsh-mcp-client',
|
|
'@deepseek-ai/dsh-tools',
|
|
]
|
|
|
|
const result = await Bun.build({
|
|
entrypoints: [entry],
|
|
target: 'node',
|
|
format: 'esm',
|
|
sourcemap: 'none',
|
|
minify: false,
|
|
external,
|
|
})
|
|
|
|
if (!result.success) {
|
|
console.error(result.logs)
|
|
throw new Error('Bun.build host failed')
|
|
}
|
|
|
|
const text = await result.outputs[0].text()
|
|
mkdirSync(dirname(outFile), { recursive: true })
|
|
writeFileSync(outFile, text, 'utf8')
|
|
console.log(`wrote ${outFile} (${text.length} bytes)`)
|