-
-
Notifications
You must be signed in to change notification settings - Fork 746
fix(types): use namespace imports for Node.js built-in modules #12232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…rove TypeScript compatibility
✅ Deploy Preview for rspack ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
chenjiahan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes TypeScript compatibility issues when esModuleInterop: false is configured by changing Node.js built-in module imports from default imports to namespace imports and adding the node: prefix.
- Changed from default import syntax (
import type X from "Y") to namespace import syntax (import type * as X from "node:Y") for Node.js built-in modules - Added
node:prefix to all affected imports for consistency with modern Node.js best practices - Ensures type compatibility across different TypeScript configurations
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Binary Size-limit
🙈 Size remains the same at 47.48MB |
CodSpeed Performance ReportMerging #12232 will not alter performanceComparing Summary
Footnotes |
Summary
When users have
esModuleInterop: falsein their TypeScript configuration, importing Node.js built-in modules using default import syntax causes type errors:This happens because Node.js built-in modules use CommonJS format and don't have default exports.
Solution
Changed from default imports to namespace imports for Node.js built-in modules:
Related links
Checklist