tsup.config.ts 622 B

1234567891011121314151617181920212223242526
  1. import { env } from 'node:process';
  2. import { defineConfig, Options } from 'tsup';
  3. const SHARED_OPTIONS: Options = {
  4. define: { __VERSION__: `"${env.npm_package_version}"` },
  5. entry: ['./src/index.ts'],
  6. outDir: './dist/src',
  7. outExtension: ({ format }) => ({ js: format === 'cjs' ? '.js' : '.mjs' }),
  8. sourcemap: true,
  9. treeshake: true,
  10. };
  11. export default defineConfig(() => [
  12. // Source.
  13. { ...SHARED_OPTIONS, format: 'cjs' },
  14. { ...SHARED_OPTIONS, format: 'esm' },
  15. // Tests.
  16. {
  17. ...SHARED_OPTIONS,
  18. bundle: false,
  19. entry: ['./test/**/*.ts'],
  20. format: 'cjs',
  21. outDir: './dist/test',
  22. },
  23. ]);