Skip to content

Comments

refactor: update rspack import paths#7072

Merged
chenjiahan merged 7 commits intomainfrom
remove_rspack_cjs_0128
Jan 28, 2026
Merged

refactor: update rspack import paths#7072
chenjiahan merged 7 commits intomainfrom
remove_rspack_cjs_0128

Conversation

@chenjiahan
Copy link
Member

Summary

Previously, rspack was loaded via a local helper module using CommonJS require for performance. Now @rspack/core 2.0 is a pure ESM package, we can remove the require workaround.

Checklist

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

Copilot AI review requested due to automatic review settings January 28, 2026 03:55
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chenjiahan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request modernizes the module import strategy for the rspack dependency. By leveraging the pure ESM support in @rspack/core 2.0, the project eliminates a custom CommonJS require wrapper, simplifying imports and aligning with contemporary JavaScript module standards. This change primarily involves updating import paths and removing the now-obsolete wrapper file.

Highlights

  • Rspack Import Refactor: The way rspack is imported throughout the codebase has been updated. Previously, a local helper module (./rspack) was used to require @rspack/core due to its CommonJS nature.
  • ESM Compatibility: With @rspack/core version 2.0 now being a pure ESM package, the direct import { rspack } from '@rspack/core'; syntax can be used, removing the need for the previous CommonJS workaround.
  • File Removal: The packages/core/src/rspack.ts file, which contained the CommonJS require logic, has been removed as it is no longer necessary.
  • Widespread Import Updates: Numerous files across the packages/core/src directory have been updated to reflect the new direct ESM import path for rspack.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly refactors the import paths for rspack to use the ESM package from @rspack/core, removing the previous CommonJS require workaround. The changes are applied consistently across the codebase. I've added a few suggestions to combine type and value imports from @rspack/core into single statements for better code consistency and readability.

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 removes a local helper module that was previously used to load rspack via CommonJS for performance reasons. With @rspack/core 2.0 being a pure ESM package, the workaround is no longer needed, and all imports can now directly use ESM imports from @rspack/core.

Changes:

  • Removed the packages/core/src/rspack.ts helper module that used CommonJS require
  • Updated all runtime imports of rspack across 13 files to import directly from @rspack/core

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/core/src/rspack.ts Deleted helper module that used CommonJS require for performance
packages/core/src/server/devMiddlewares.ts Updated rspack import to use direct ESM import from @rspack/core
packages/core/src/server/assets-middleware/index.ts Updated rspack import to use direct ESM import from @rspack/core
packages/core/src/rspackConfig.ts Updated rspack import to use direct ESM import from @rspack/core
packages/core/src/rspack-plugins/RsbuildHtmlPlugin.ts Updated rspack import to use direct ESM import from @rspack/core
packages/core/src/plugins/rspackProfile.ts Updated rspack import to use direct ESM import from @rspack/core
packages/core/src/plugins/nonce.ts Updated rspack import to use direct ESM import from @rspack/core
packages/core/src/plugins/moduleFederation.ts Updated rspack import to use direct ESM import from @rspack/core
packages/core/src/pluginHelper.ts Updated rspack import to use direct ESM import from @rspack/core
packages/core/src/initPlugins.ts Updated rspack import to use direct ESM import from @rspack/core
packages/core/src/index.ts Updated rspack import to use direct ESM import from @rspack/core
packages/core/src/helpers/compiler.ts Updated rspack import to use direct ESM import from @rspack/core
packages/core/src/createCompiler.ts Updated rspack import to use direct ESM import from @rspack/core
packages/core/src/build.ts Updated rspack import to use direct ESM import from @rspack/core

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 28, 2026 03:59
chenjiahan and others added 3 commits January 28, 2026 11:59
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chenjiahan chenjiahan merged commit c1e1b4b into main Jan 28, 2026
5 checks passed
@chenjiahan chenjiahan deleted the remove_rspack_cjs_0128 branch January 28, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant