mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-09 08:00:45 +08:00
Ship prebuilt lib/index.js so GitHub installs load under node_modules.
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>
This commit is contained in:
parent
0fcff2d45a
commit
0040de078c
4 changed files with 150 additions and 7 deletions
40
scripts/build-host.mjs
Normal file
40
scripts/build-host.mjs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* 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)`)
|
||||
Loading…
Add table
Add a link
Reference in a new issue