Skip to content

fix: revert export default class declaration entry#354

Open
ilyaliao wants to merge 2 commits into
unjs:mainfrom
ilyaliao:fix/revert-320
Open

fix: revert export default class declaration entry#354
ilyaliao wants to merge 2 commits into
unjs:mainfrom
ilyaliao:fix/revert-320

Conversation

@ilyaliao

@ilyaliao ilyaliao commented May 24, 2026

Copy link
Copy Markdown
Contributor

This PR reverts #320, which made findExports return an extra { type: 'declaration' } entry for default-exported classes alongside the default one.

Impact on unimport

For every default-exported class, the extra entry collides with the default one in unimport's dedupeImports, and the wrong one wins. The generated .d.ts then references a non-existent named export instead of .default.

Source:

// path.ts
export default class ClassName {}

Before:

const ClassName: typeof import('./path').ClassName

After:

const ClassName: typeof import('./path').default

Summary by CodeRabbit

  • Refactor
    • Modified default class export detection to use the general default export recognition pattern, affecting how these exports are reported in analysis results.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ecdd8862-e601-44b7-9ee3-92bea65a6cef

📥 Commits

Reviewing files that changed from the base of the PR and between 9aeff6d and 46488a5.

📒 Files selected for processing (1)
  • test/exports.test.ts

📝 Walkthrough

Walkthrough

The PR removes detection of export default class ... declarations from the analyzer. The dedicated regex pattern and corresponding parsing logic in findExports() are deleted, along with the test case validating this behavior.

Changes

Remove export default class detection

Layer / File(s) Summary
Remove export default class parsing
src/analyze.ts, test/exports.test.ts
The EXPORT_DEFAULT_CLASS_RE regex constant is removed, the "Find export default class" block in findExports() is deleted, export-merging logic no longer includes defaultClassExports, and the corresponding test snapshot is updated to expect a default-export representation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A class once exported with flair,
Now parsed no longer with care,
The regex departs,
The test plays its parts,
Simpler exports breathe cleaner air! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'fix: revert export default class declaration entry' directly and accurately describes the main change: reverting the export default class declaration entry logic from a previous PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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

codecov Bot commented May 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.57%. Comparing base (226a47b) to head (46488a5).
⚠️ Report is 112 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #354      +/-   ##
==========================================
- Coverage   88.04%   83.57%   -4.47%     
==========================================
  Files           8        7       -1     
  Lines        1062      487     -575     
  Branches      188      151      -37     
==========================================
- Hits          935      407     -528     
+ Misses        127       73      -54     
- Partials        0        7       +7     

☔ View full report in Codecov by Harness.
📢 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.

@ilyaliao ilyaliao changed the title fix: revert #320 fix: revert export default class declaration entry May 25, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant