Skip to content

feat: add explicit resource management (using/await using) support#422

Merged
pi0 merged 3 commits into
unjs:mainfrom
re-taro:feat/support-erm
Feb 27, 2026
Merged

feat: add explicit resource management (using/await using) support#422
pi0 merged 3 commits into
unjs:mainfrom
re-taro:feat/support-erm

Conversation

@re-taro

@re-taro re-taro commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Add support for TC39 Explicit Resource Management proposal (ES2026) by integrating @babel/plugin-transform-explicit-resource-management.

  • Add using and await using declaration support
  • Transpiles to try-finally patterns for CJS environments
  • Works with both sync (Disposable) and async (AsyncDisposable) resources

resolves #423

Changes

  • Add @babel/plugin-transform-explicit-resource-management dependency
  • Add type definition for the Babel plugin
  • Register the plugin in src/babel.ts
  • Add test fixture to verify functionality

Test Plan

  • pnpm build succeeds
  • pnpm vitest run passes (31 tests)
  • Manual test confirms using/await using works correctly
  • Resources are disposed in LIFO order as expected

References

@re-taro re-taro marked this pull request as ready for review February 2, 2026 13:23
@re-taro

re-taro commented Feb 9, 2026

Copy link
Copy Markdown
Contributor Author

@pi0

I apologize for disturbing you while you are busy, but I would appreciate it if you could review this.

@re-taro

re-taro commented Feb 23, 2026

Copy link
Copy Markdown
Contributor Author

@pi0 Are you busy? If necessary, I'd like to ask someone else for a review.

@pi0

pi0 commented Feb 23, 2026

Copy link
Copy Markdown
Member

Thanks for the PR. It looks good, although I have to properly test this PR and the atest babel updates (since jiti bundles it) before being able to release.


Please stay patient. (in general, it is better to tell why a change might need priority attention rather than just pinging maintainers. please read this)

@pi0 pi0 left a comment

Copy link
Copy Markdown
Member

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 b66bd23 into unjs:main Feb 27, 2026
7 checks passed
@re-taro re-taro deleted the feat/support-erm branch February 27, 2026 11:42
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.

Support explicit resource management (using / await using)

2 participants