1
0

tsup.config.ts 696 B

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