fern
fern copied to clipboard
[Feature] Add support for outputting ESM and CJS
Problem description
Fern code generation doesn't support outputting both CJS and ESM builds.
Why would it be useful?
As a company providing API clients to our customers, we have very little say/control over how and where they will use the clients.
For this reason, it's typical (at least until ESM is ubiquitous) that SDKs provide both formats. Some examples of this in the wild.
openai-node posthog-js launchdarkly-js-client-sdk @clerk/react @clerk/sdk-node
Describe the solution (optional)
Providing the outputEsm should also produce the default CJS output.
You can put the CJS output in a cjs directory so that they two output formats don't conflict.
Additional context
This issue is probably also relevant to this: https://github.com/fern-api/fern/issues/3260