tinylibs / tinybench

🔎 A simple, tiny and lightweight benchmarking library!
MIT License
1.73k stars 36 forks source link

fix: build correct types for CommonJS users #85

Closed kanadgupta closed 1 month ago

kanadgupta commented 1 month ago

Hi there! My team is attempting to import this package into a CommonJS file and we're running into TypeScript compilation errors. After doing a bit of investigation, we noticed that tinybench uses the same types for both the CommonJS and ESM builds, which is generally discouraged.

You can check out "Are The Types Wrong?" for a handy analysis of this: https://arethetypeswrong.github.io/?p=tinybench@2.8.0

I also created a minimal reproduction of the error in this repository.

In this pull request, I made the following changes:

I confirmed that these changes fixed the issues by testing this against the "Are The Types Wrong?" CLI.

Before:

CleanShot 2024-08-01 at 09 28 41@2x

After:

CleanShot 2024-08-01 at 09 27 28@2x

Thanks for your work on this tool and thanks in advance for the review!

pkg-pr-new[bot] commented 1 month ago

commit: 1738883

pnpm add https://pkg.pr.new/tinylibs/tinybench@85

Open in Stackblitz