Repository navigation
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
37 lines (35 loc) · 1.67 KB
/
Copy pathtsdown.config.ts
File metadata and controls
37 lines (35 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { globSync } from 'node:fs'
import { defineConfig } from 'tsdown'
import { typertPlugin } from './packages/typert/generator/lib/types/tsdown-plugin.js'
import { WORKSPACE_TYPERT_FACES } from './scripts/typert-faces.ts'
import { workspacePackageGlobs } from './scripts/workspace-package-globs.ts'
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)
const packages = workspacePackageGlobs(globSync(['vendor/*/package.json', 'packages/*/*/package.json'], { cwd: import.meta.dirname }))
return {
workspace: [...packages, 'apps/cli', ...client ? [] : ['apps/desktop-host']],
entry: client ? '' : ['lib/types/{index,startup}.js'],
outDir: 'lib',
format: ['esm'],
platform: 'node',
target: 'es2024',
fixedExtension: false,
dts: false,
clean: false,
plugins: client ? [] : [typertPlugin({ mode: 'workspace', faces: WORKSPACE_TYPERT_FACES })],
}
})