Write ESM and use Rollup or webpack to transpile it down to a single CJS module. Point the
main field inside your
package.json to this CJS bundle. Additionally, use the
module field to point to your original ESMs. If you’re using new language features besides ESM, you should compile it down to ES5 and provide both a CJS and an ESM bundle. This way, users of your library can still profit from tree shaking while not having to transpile your code.