Closed HermansJarno closed 5 months ago
I checked the rimraf implementation. Closing issue.
Nevermind, not sure if this is going to have the desired result with the rimraf example since it is mjs only.
I recommend having the bin script be either ESM or CJS, but not both. (Ie, src/bin.cts
or src/bin.mts
, depending on your preference.)
Then just set the bin in package.json to the build location, like "bin": "./dist/esm/bin.mjs"
(or "bin": "./dist/commonjs/bin.cjs"
if you like prefer to write it in CommonJS dialect.)
A bin doesn't need to be loaded in multiple ways, since it's executed by node directly, so there's no need to build it in all dialects. Naming it .cts
or .mjs
will make it only available in the CommonJS or ESM dialects, respectively.
Hi,
I want to use the bin option of package.json to create a custom command. How can i combine with tshy?
Is there a simple option or will i have to keep the bin script away from the src, and check in the bin script if it is esm or commonjs project based on package.json type module?