tsdown.config.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { defineConfig } from 'tsdown'
  2. import { typertPlugin } from './packages/typert/generator/lib/types/tsdown-plugin.js'
  3. /**
  4. * JS bundling for vendored Cordis and Harness TypeScript packages.
  5. * TypeScript source is compiled first by `tsc -b` (the root solution); tsdown
  6. * reads only the emitted JS under lib/types and writes the package root and
  7. * invariant companion runtime bundles. Declarations are NOT produced here,
  8. * hence `dts: false`.
  9. *
  10. * Per-package shape overrides live in `<package>/tsdown.config.ts`
  11. * (schemastery: dual ESM+CJS; logger-console: extra browser entry).
  12. */
  13. export default defineConfig({
  14. // Explicit globs keep bundling to vendored Cordis, the TypeScript package tree, and
  15. // the Node CLI assembly. `apps/web` is a Vite application with no lib/types entry;
  16. // `workspace: true` or `apps/*` would incorrectly treat it as a package bundle.
  17. workspace: ['vendor/*', 'packages/*/*', 'apps/cli'],
  18. // The brace glob admits the package companion when present while retaining the
  19. // index-only build for vendored Cordis packages outside the Harness package tree.
  20. entry: ['lib/types/{index,invariant}.js'],
  21. outDir: 'lib',
  22. format: ['esm'],
  23. platform: 'node',
  24. target: 'es2024',
  25. // All packages set "type": "module"; fixedExtension false keeps ESM output
  26. // at .js (not .mjs), matching the package.json main/exports fields.
  27. fixedExtension: false,
  28. dts: false,
  29. clean: false,
  30. // The final pass sees both independent TypeScript faces. Workspace mode
  31. // writes only packages that explicitly publish a Typert/Remote subpath.
  32. plugins: [typertPlugin({ mode: 'workspace' })],
  33. })