Files
deepseek-harness/tsdown.config.ts
T
winewill 06717aebbb build(desktop): bundle the main process after the workspace tsdown pass
The root tsdown workspace pass builds every member concurrently, so the
Desktop main bundle could resolve its inlined workspace devDependencies
(dsh-home-paths, dsh-app-boot, dsh-deepseek-account) before their lib/
output existed. rolldown then kept them as external imports, which the
asar does not ship, and the packaged application failed at launch with
ERR_MODULE_NOT_FOUND on a clean checkout; stale lib/ output on long-lived
checkouts hid the defect.

apps/desktop leaves the root workspace list and build:lib:host bundles it
after the Host pass. Every Desktop bundle now runs a rolldown plugin that
fails the build when a chunk imports a bare specifier the packaged
application cannot resolve: electron and the manifest dependencies for
the main bundle, electron alone for sandboxed preloads.
2026-09-22 20:11:51 +08:00

36 lines
1.4 KiB
TypeScript

import { defineConfig } from 'tsdown'
import { typertPlugin } from './packages/typert/generator/lib/types/tsdown-plugin.js'
function isBuildFaceClient(value: unknown): boolean {
if (value === undefined || value === 'host') return false
if (value === 'client') return true
throw new Error(`tsdown: --env.DSH_BUILD_FACE must be host or client, received ${String(value)}`)
}
/**
* The ordinary workspace build consumes JavaScript emitted by the Host
* TypeScript project and runs Typert. The Client pass selects packages that
* declare a browser bundle and lets their package-local configs emit both
* their Node loader entry and browser artifact. `apps/desktop` bundles after
* this pass (root package.json `build:lib:host`): its main bundle inlines
* workspace devDependencies from their lib/ output, and tsdown builds
* workspace members concurrently without ordering them.
*/
export default defineConfig(({ env }) => {
const client = isBuildFaceClient(env?.DSH_BUILD_FACE)
return {
workspace: client
? ['vendor/*', 'packages/*/*', 'apps/cli']
: ['vendor/*', 'packages/*/*', 'apps/cli', 'apps/desktop-host'],
entry: client ? '' : ['lib/types/{index,invariant,startup}.js'],
outDir: 'lib',
format: ['esm'],
platform: 'node',
target: 'es2024',
fixedExtension: false,
dts: false,
clean: false,
plugins: client ? [] : [typertPlugin({ mode: 'workspace', faces: ['host'] })],
}
})