Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion scripts/build/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ async function bundleWithPlugins(
for (const entry of result.logs) log.error(String(entry))
throw new Error('Bundle with plugins failed')
}

// Write package.json into the bundle directory so it's available at runtime.
// Required by @mariozechner/pi-coding-agent which reads package.json at module
// load time via getPackageDir() to extract version and config.
writeFileSync(
join(BUNDLE_DIR, 'package.json'),
JSON.stringify({ type: 'module', version }),
)
}

async function compileTarget(
Expand Down Expand Up @@ -299,7 +307,10 @@ async function build(config: BuildConfig): Promise<void> {
mkdirSync('dist/server', { recursive: true })

// Bun compiled binaries require a package.json next to the executable
writeFileSync('dist/server/package.json', JSON.stringify({ type: 'module' }))
writeFileSync(
'dist/server/package.json',
JSON.stringify({ type: 'module', version }),
)

if (shouldUploadSourceMaps) {
log.step('Building source maps...')
Expand Down
Loading