fern icon indicating copy to clipboard operation
fern copied to clipboard

[Feature] Add support for outputting ESM and CJS

Open joemckenney opened this issue 1 year ago • 1 comments

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

joemckenney avatar Jan 24 '24 23:01 joemckenney

This issue is probably also relevant to this: https://github.com/fern-api/fern/issues/3260

mstade avatar Mar 25 '24 00:03 mstade