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 +``` + +