tsdown.config.ts 1013 B

12345678910111213141516171819202122232425262728293031
  1. import { defineConfig } from 'tsdown'
  2. /**
  3. * Root-shape lib build plus a css stub: the shell's components import
  4. * .module.css/.css assets that tsc passes through untouched, so the JS under
  5. * lib/types references css files that do not exist there. The browser
  6. * consumer (apps/web) compiles src directly through vite where css is real;
  7. * this node lib build stubs every css import to an empty module — importing
  8. * the lib under plain node must not crash on an asset specifier.
  9. */
  10. export default defineConfig({
  11. entry: ['lib/types/index.js', 'lib/types/invariant.js'],
  12. outDir: 'lib',
  13. format: ['esm'],
  14. platform: 'neutral',
  15. target: 'es2024',
  16. fixedExtension: false,
  17. dts: false,
  18. clean: false,
  19. plugins: [{
  20. name: 'dsh-css-stub',
  21. resolveId(source: string) {
  22. if (!source.endsWith('.css')) return null
  23. return `\0dsh-css-stub:${source}.mjs`
  24. },
  25. load(id: string) {
  26. if (!id.startsWith('\0dsh-css-stub:')) return null
  27. return 'export default {};'
  28. },
  29. }],
  30. })