Skip to content

Conversation

@SyMind
Copy link
Member

@SyMind SyMind commented Nov 18, 2025

Summary

When users have esModuleInterop: false in their TypeScript configuration, importing Node.js built-in modules using default import syntax causes type errors:

Module '"node:http"' has no default export

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:

// Before (fails with esModuleInterop: false)
import type http from "node:http";

// After (compatible with all TypeScript configurations)
import type * as http from "node:http";

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 18, 2025 08:15
@SyMind SyMind requested a review from hardfist as a code owner November 18, 2025 08:15
@netlify
Copy link

netlify bot commented Nov 18, 2025

Deploy Preview for rspack ready!

Name Link
🔨 Latest commit 9892d67
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/691c2ca105c6df00080fd8d2
😎 Deploy Preview https://deploy-preview-12232--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

chenjiahan
chenjiahan previously approved these changes Nov 18, 2025
Copy link
Member

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions bot added the release: bug fix release: bug related release(mr only) label Nov 18, 2025
@chenjiahan chenjiahan changed the title fix(types): use namespace imports for Node.js built-in modules to imp… fix(types): use namespace imports for Node.js built-in modules Nov 18, 2025
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Nov 18, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 18, 2025

📝 Ecosystem CI detail: Open

suite result
examples ✅ success

Copy link
Contributor

Copilot AI left a 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.

@chenjiahan chenjiahan enabled auto-merge (squash) November 18, 2025 08:37
@github-actions
Copy link
Contributor

📦 Binary Size-limit

Comparing 9892d67 to fix: swc-loader should not respect .swcrc (#12222) by CPunisher

🙈 Size remains the same at 47.48MB

@chenjiahan chenjiahan disabled auto-merge November 18, 2025 09:13
@chenjiahan chenjiahan merged commit 1a83ce4 into main Nov 18, 2025
67 of 70 checks passed
@chenjiahan chenjiahan deleted the fix-ts-types branch November 18, 2025 09:13
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 18, 2025

CodSpeed Performance Report

Merging #12232 will not alter performance

Comparing fix-ts-types (9892d67) with main (3875176)1

Summary

✅ 17 untouched

Footnotes

  1. No successful run was found on main (b531d85) during the generation of this report, so 3875176 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants