Skip to content

build: correct the types export entry#160

Merged
pi0 merged 1 commit intounjs:mainfrom
kricsleo:fix/type-exports
Apr 7, 2026
Merged

build: correct the types export entry#160
pi0 merged 1 commit intounjs:mainfrom
kricsleo:fix/type-exports

Conversation

@kricsleo
Copy link
Copy Markdown
Member

@kricsleo kricsleo commented Apr 7, 2026

resolves #159

Related PR #157, which would error with:
image

Even after changing to:

// ↓ diff
export default defuProxy;
// ↓ diff
export type { Defu, DefuFn, DefuInstance }

It still doesn't seem right:

Semantically incorrect. The CJS runtime (lib/defu.cjs:3) does
module.exports = defu — the function IS the export, not
module.exports.default. export default in .d.cts represents
module.exports.default = ..., which is a different runtime shape. Works with
bundler resolution due to leniency, but misrepresents the actual CJS contract
and may break node16/nodenext consumers.

review by AI

Summary by CodeRabbit

  • Chores
    • Updated TypeScript type definitions source location in package configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

Updated the TypeScript type entry in package.json to reference the built distribution output instead of the library source directory, redirecting type resolution from ./lib/defu.d.cts to ./dist/defu.d.ts.

Changes

Cohort / File(s) Summary
Package Configuration
package.json
Updated types entry path from ./lib/defu.d.cts to ./dist/defu.d.ts to resolve TypeScript type resolution issues with tsconfig paths.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested reviewers

  • pi0

Poem

🐰 A path once lost, now found again,
From lib to dist, the types ascend,
TypeScript whispers, "You're resolved!"
The puzzle of tsconfig: solved! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR correctly addresses issue #159 by updating the types export entry to resolve the type resolution problem when using tsconfig paths, ensuring Defu type imports resolve properly.
Out of Scope Changes check ✅ Passed The changeset contains only a single, focused modification to the types export entry in package.json, which is directly aligned with the linked issue objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title 'build: correct the types export entry' accurately and specifically describes the main change: updating the types entry in package.json from lib/defu.d.cts to dist/defu.d.ts to fix TypeScript type resolution.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (70cffe5) to head (1d16131).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##             main      #160       +/-   ##
============================================
+ Coverage   45.73%   100.00%   +54.26%     
============================================
  Files           4         2        -2     
  Lines         223        46      -177     
  Branches       35        18       -17     
============================================
- Hits          102        46       -56     
+ Misses        119         0      -119     
+ Partials        2         0        -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pi0 pi0 changed the title fix: correct the types export entry build: correct the types export entry Apr 7, 2026
Copy link
Copy Markdown
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks ❤️

@pi0 pi0 merged commit 3d3a7c8 into unjs:main Apr 7, 2026
4 checks passed
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.

Cannot use Defu type when using tsconfig paths

2 participants