feat(typescript): add opt-in esmOnly flag for ESM-only SDK output - #17503
Open
thesandlord wants to merge 1 commit into
Open
feat(typescript): add opt-in esmOnly flag for ESM-only SDK output#17503thesandlord wants to merge 1 commit into
thesandlord wants to merge 1 commit into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Linear ticket: Refs (none — customer request, Auth0 Pylon #22973)
Adds an opt-in
esmOnlycustom config flag to the TypeScript SDK generator. When enabled, the generated package ships only the existing ESM build — decoupling it from the combined CJS package — to avoid the Dual Package Hazard. Nothing changes for the default (CJS + ESM) oroutputEsm: truegenerations;esmOnlyreuses the existing ESM pipeline (tsconfig.esm.json,rename-to-esm-files.mjs/.d.mtsoutput) and simply drops the CJS half.With
esmOnly: truethe generatedpackage.jsonbecomes:{ "type": "module", "main": "./dist/esm/index.mjs", "module": "./dist/esm/index.mjs", "types": "./dist/esm/index.d.mts", "exports": { ".": { "types": "./dist/esm/index.d.mts", "default": "./dist/esm/index.mjs" }, "./package.json": "./package.json" }, "scripts": { "build": "pnpm build:esm" } }tsconfig.cjs.jsonandbuild:cjsare not generated; roottsconfig.jsonextendstsconfig.esm.json. The bundled CJS rename script is emitted asscripts/rename-to-esm-files.cjs(instead of.js) because"type": "module"would otherwise make Node execute the CommonJS script as ESM.Unsupported combinations fail fast with a clear error rather than silently ignoring the flag:
esmOnly + useLegacyExportsesmOnly + bundleChanges Made
esmOnlyadded toTypescriptCustomConfigSchema,SdkCustomConfig, threaded throughSdkGeneratorCli→SdkGenerator→SimpleTypescriptProject/AsIsManagerSimpleTypescriptProject: ESM-onlypackage.json(type,main/types, exports map withoutrequire/CJS conditions, incl. subpackage exports), skiptsconfig.cjs.json, root tsconfig extends ESM config,buildruns onlybuild:esmAsIsManager: emit rename script as.cjswhenesmOnlyis setSdkGeneratorCli: throw onesmOnly + useLegacyExportsandesmOnly + bundlesimple-api/esm-onlyoutput variant (seed/ts-sdk/seed.yml) with generated fixturegenerators/typescript/sdk/changes/unreleased/add-esm-only-flag.ymlTesting
SimpleTypescriptProject.test.tscovering default (dual CJS+ESM),outputEsm: true(still dual), andesmOnly: true; all 33 tests in the package passesm-onlyseed fixture, ranpnpm install && pnpm build(compiles, 126 files renamed to.mjs/.d.mts), verified Nodeimportresolves root and/usersubpath exports, andpublintpasses. Verified default andoutputEsmfixtures are byte-identical to before (no snapshot changes with the flag off). Seed's Docker validator image could not be pulled in this environment (network-restricted), so full seed validation should run in CI.Written by Devin