tsdown.config.ts 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import { defineConfig } from 'tsdown'
  2. import { typertPlugin } from './packages/typert/generator/lib/types/tsdown-plugin.js'
  3. function isBuildFaceClient(value: unknown): boolean {
  4. if (value === undefined || value === 'host') return false
  5. if (value === 'client') return true
  6. throw new Error(`tsdown: --env.DSH_BUILD_FACE must be host or client, received ${String(value)}`)
  7. }
  8. /**
  9. * The ordinary workspace build consumes JavaScript emitted by the Host
  10. * TypeScript project and runs Typert. The Client pass selects packages that
  11. * declare a browser bundle and lets their package-local configs emit both
  12. * their Node loader entry and browser artifact.
  13. */
  14. export default defineConfig(({ env }) => {
  15. const client = isBuildFaceClient(env?.DSH_BUILD_FACE)
  16. return {
  17. workspace: ['vendor/*', 'packages/*/*', 'apps/cli'],
  18. entry: client ? '' : ['lib/types/{index,invariant,startup}.js'],
  19. outDir: 'lib',
  20. format: ['esm'],
  21. platform: 'node',
  22. target: 'es2024',
  23. fixedExtension: false,
  24. dts: false,
  25. clean: false,
  26. plugins: client ? [] : [typertPlugin({ mode: 'workspace', faces: ['host'] })],
  27. }
  28. })