change-case
change-case copied to clipboard
Add CommonJS output
I have several projects which, for various reasons:
- use
change-case
, - need to use CommonJS,
- and need
change-case
synchronously (ie.import()
isn't good enough).
So, I've been keeping them back on version 4.1.2, just like 90% of your users:
It's actually very easy to publish a package that supports both ESM and CJS nowadays; a lot has changed since sindresorhus swapped all their packages to ESM (largely thanks to all the difficulties that caused...)
To publish both ESM and CJS, you output with TypeScript twice, then set the package.json's main
field to a CommonJS file, and the exports
field to ESM file(s). That's it.
This PR adds CommonJS support to all the packages in the change-case monorepo, by:
- Instructing ts-scripts to use an additional tsconfig for the build step, via its project config key
- Adding a tiny
tsconfig-cjs.json
for each package which extends the normal one, changing only the output module format and the output dir - Changing the
main
field in each package.json to point to the CommonJS output. Theexports
field remains the same.
Would you please consider accepting this PR? The time for "Pure ESM packages" has passed, and 4.6 million of your users are ready to move out of 2020.