Skip to content

Document esmOnly option for the TypeScript SDK generator - #6942

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1789319077-ts-esm-only
Open

Document esmOnly option for the TypeScript SDK generator#6942
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1789319077-ts-esm-only

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

The TypeScript SDK generator gained an opt-in esmOnly config option that makes the generated package ship only an ESM build instead of the default dual CommonJS + ESM output. This matters for customers whose consumers are ESM-only: it avoids the dual package hazard (two copies of the same module loaded via require and import) and yields a smaller, single-format package. Default behavior is unchanged when the flag is omitted.

Implements docs for: feat(typescript): add opt-in esmOnly flag for ESM-only SDK output (fern-api/fern#17503) — fern-api/fern#17503

Details

  • fern/products/sdks/generators/typescript/configuration.mdx: new <ParamField path="esmOnly" type="boolean" default="false"> entry, placed alphabetically between enableInlineTypes and extraDependencies. Covers the package.json / exports / build-script effects, the dual package hazard motivation, the incompatibility with useLegacyExports: true and bundle: true, and a generators.yml example. The page has no outputEsm entry, so no contrast was added.
  • No changelog entry (SDK changelogs are auto-generated).

Vale: the only remaining findings in the new block are FernStyles.Acronyms suggestions for ESM, which is defined on first use. fern check --warnings passes with 0 errors.

Link to Devin session: https://app.devin.ai/sessions/9854c806214d470da26ea53336829309
Open in Devin Desktop: https://app.devin.ai/desktop/session/9854c806214d470da26ea53336829309?variant=devin

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

</ParamField>

<ParamField path="esmOnly" type="boolean" default="false" toc={true}>
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] <FernStyles.Acronyms> reported by reviewdog 🐶
'ESM' has no definition.

</ParamField>

<ParamField path="esmOnly" type="boolean" default="false" toc={true}>
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] <FernStyles.Acronyms> reported by reviewdog 🐶
'ESM' has no definition.

@github-actions

Copy link
Copy Markdown
Contributor

🌿 Preview your docs: https://fern-preview-devin-1789319077-ts-esm-only.docs.buildwithfern.com/learn

Here are the markdown pages you've updated:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants