fix(packaging): use conditional type exports for dual packages#750
Open
hassiebbot wants to merge 2 commits intomainfrom
Open
fix(packaging): use conditional type exports for dual packages#750hassiebbot wants to merge 2 commits intomainfrom
hassiebbot wants to merge 2 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
hassiebp
reviewed
Mar 16, 2026
hassiebp
reviewed
Mar 16, 2026
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.
Problem
TypeScript
nodenextCommonJS consumers could resolve@langfuse/*packages through their ESM declaration entrypoints because each package exported siblingtypes/import/requireconditions. That caused mixed ESM/CJS type graphs and errors likeCallbackHandlernot being assignable toBaseCallbackHandler.Changes
typesunderimportandrequirein all dual-format package export mapsrequiretypes at./dist/index.d.ctsscripts/check-package-exports.mjsprecommit:checkandciRelease info Sub-libraries affected
Bump level
Libraries affected
Changelog notes
nodenextconsumers by using conditional declaration exports.Verification
pnpm check:exportsprettier --check package.json packages/*/package.json scripts/check-package-exports.mjsgit diff --checkDisclaimer: Experimental PR review
Greptile Summary
Fixes dual-package TypeScript type resolution for CommonJS
nodenextconsumers by nestingtypesconditions underimportandrequirein all 6 package export maps. Previously, a top-leveltypescondition caused CJS consumers to resolve ESM declaration files, leading to mixed type graphs and assignability errors. The CJSrequire.typesnow correctly points to./dist/index.d.cts(generated by tsup'sdts: truefortype: "module"packages).client,core,langchain,openai,otel,tracing) updated with identical conditional export structurescripts/check-package-exports.mjsvalidation script enforces the export map structureprecommit:checkandcipipelinesConfidence Score: 5/5
type: "module"packages with CJS support. tsup v8 withdts: trueandformat: ["cjs", "esm"]generates both.d.tsand.d.ctsfiles fortype: "module"packages, so the referenced declaration files will exist at build time. A new validation script enforces the structure going forward, and it's integrated into both pre-commit and CI.Important Files Changed
check:exportsscript and integrates it intoprecommit:checkandcipipelines.typesunderimport/requireconditions, pointing CJS types to.d.cts. Correct fortype: "module"+ tsupdts: true.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["TypeScript consumer<br/>moduleResolution: nodenext"] --> B{Module system?} B -->|"import"| C["exports['.'].import"] B -->|"require"| D["exports['.'].require"] C --> E["types → ./dist/index.d.ts<br/>(ESM declarations)"] C --> F["default → ./dist/index.mjs"] D --> G["types → ./dist/index.d.cts<br/>(CJS declarations)"] D --> H["default → ./dist/index.cjs"] E --> I["✅ Correct ESM type graph"] G --> J["✅ Correct CJS type graph"]Last reviewed commit: 8d5ec5e