From ac5a8a0863152256281a569e1e1a7c471cbc2a37 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 13 Sep 2026 17:04:37 +0000 Subject: [PATCH] docs(typescript): document esmOnly generator option Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../sdks/generators/typescript/configuration.mdx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fern/products/sdks/generators/typescript/configuration.mdx b/fern/products/sdks/generators/typescript/configuration.mdx index c5c100575..d01231486 100644 --- a/fern/products/sdks/generators/typescript/configuration.mdx +++ b/fern/products/sdks/generators/typescript/configuration.mdx @@ -88,6 +88,22 @@ const bar: MyRootType.Foo.Bar = {}; ``` + +Ships only the ECMAScript module (ESM) build of the generated package. By default, the generator publishes both CommonJS and ESM builds, which exposes consumers to the [dual package hazard](https://github.com/GeoffreyBooth/dual-package-hazard). When enabled, `package.json` sets `"type": "module"`, `main`, `module`, and `types` point at `./dist/esm/index.mjs` and `./dist/esm/index.d.mts`, the `exports` map (including subpackage exports) has no `require` conditions, and no `tsconfig.cjs.json` or `build:cjs` script is generated. + +`esmOnly` can't be combined with `useLegacyExports: true` or `bundle: true`; generation fails with an error. + +```yml title="generators.yml" +groups: + ts-sdk: + generators: + - name: fern-typescript-sdk + version: + config: + esmOnly: true +``` + +