tsdown.config.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { defineConfig } from 'tsdown'
  2. /**
  3. * Package-shape override (see the root tsdown.config.ts): besides the
  4. * default lib/index.js bundle, the worker BOOTSTRAP ships as its own
  5. * sibling CommonJS entry — `new Worker(fileURLToPath(new URL('./worker.cjs', import.meta.url)))`
  6. * loads it as a file, so it cannot be part of the index bundle. pkg's VFS
  7. * Worker hook compiles string-path entries as CommonJS, so an ESM worker is
  8. * not viable inside the executable. TWO
  9. * single-entry builds, not one two-entry build: a multi-entry build emits
  10. * the shared bootstrap module as a `lib/bootstrap-*.js` chunk both bundles
  11. * import, which the package.json `files` whitelist (deliberately exact)
  12. * would omit from the packed artifact — each single-entry build inlines its
  13. * own bootstrap copy instead, keeping every shipped file self-contained.
  14. */
  15. export default defineConfig([
  16. {
  17. entry: ['lib/types/index.js'],
  18. outDir: 'lib',
  19. format: ['esm'],
  20. platform: 'node',
  21. target: 'es2024',
  22. fixedExtension: false,
  23. dts: false,
  24. clean: false,
  25. },
  26. {
  27. entry: ['lib/types/worker.js'],
  28. outDir: 'lib',
  29. format: ['cjs'],
  30. platform: 'node',
  31. target: 'es2024',
  32. fixedExtension: false,
  33. dts: false,
  34. clean: false,
  35. },
  36. ])