Skip to content

Conversation

@chenjiahan
Copy link
Member

@chenjiahan chenjiahan commented Oct 20, 2025

Summary

Refactors the config file loading logic to use a single import()instead of manually distinguishing between ESM and CommonJS modules.

Before

Rspack determined whether to use require() or import() by checking file extensions and walking up the directory tree to read the nearest package.json to detect "type": "module". This introduced unnecessary complexity and I/O overhead.

Screenshot 2025-10-20 at 22 00 12

After

All config files are now loaded through a unified import() call (the same as Rsbuild), then fallback to require().

This approach leverages Node.js's native module resolution to automatically handle both ESM and CommonJS formats.

Checklist

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

@Copilot Copilot AI review requested due to automatic review settings October 20, 2025 14:16
@chenjiahan chenjiahan requested a review from hardfist as a code owner October 20, 2025 14:16
@github-actions github-actions bot added release: performance release: performance related release(mr only) team The issue/pr is created by the member of Rspack. labels Oct 20, 2025
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 refactors the config file loading logic to use a single unified import() call instead of manually distinguishing between ESM and CommonJS modules. This reduces filesystem I/O overhead by eliminating the need to check file extensions and walk up the directory tree to detect module types.

Key changes:

  • Removed the separate crossImport utility file and inlined a simplified version using pathToFileURL
  • Updated all crossImport() calls to remove the cwd parameter
  • Leverages Node.js's native module resolution to automatically handle both ESM and CommonJS formats

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2025

📦 Binary Size-limit

Comparing 9e55c15 to chore: enable Rslint rule: no-empty-interface (#11915) by Dima Shugaev

🙈 Size remains the same at 47.73MB

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 20, 2025

CodSpeed Performance Report

Merging #11933 will not alter performance

Comparing load_config_perf_1020 (9e55c15) with main (e3199f4)

Summary

✅ 17 untouched

@netlify
Copy link

netlify bot commented Oct 20, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 9e55c15
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/68f64d513d3e5c00088fb639

@chenjiahan chenjiahan marked this pull request as draft October 21, 2025 02:17
@chenjiahan chenjiahan closed this Oct 21, 2025
@chenjiahan chenjiahan deleted the load_config_perf_1020 branch October 21, 2025 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: performance release: performance 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.

1 participant