Skip to content

Conversation

@LingyuCoder
Copy link
Contributor

Summary

fix #12612

The RuntimeGlobals should be different between compiler.rspack and the exports of @rspack/core. So we need to create a new exports object for each compiler and should not just assign the new RuntimeGlobals to exports to prevent overriding it.

Related links

Checklist

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

@LingyuCoder LingyuCoder requested a review from hardfist as a code owner January 6, 2026 03:00
@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Jan 6, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @LingyuCoder, 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 PR addresses a critical issue concerning the isolation of RuntimeGlobals within the Rspack compiler. Previously, RuntimeGlobals could be inadvertently shared or overridden, causing unpredictable behavior. The fix introduces a mechanism to create a unique RuntimeGlobals object for each compiler instance, ensuring proper encapsulation and preventing conflicts, thereby stabilizing the compilation process.

Highlights

  • Fixing RuntimeGlobals Isolation: This pull request resolves an issue where RuntimeGlobals were not properly isolated between compiler.rspack and the exports of @rspack/core, leading to potential overrides.
  • Dedicated Compiler Exports: A new exports object is now created for each compiler instance, ensuring that compiler.rspack and compiler.webpack receive their own distinct RuntimeGlobals without affecting the global @rspack/core exports.
  • New Test Case: A new test file, exports.js, has been added to verify that compiler.rspack is a function, contains expected properties, and its RuntimeGlobals are indeed separate from those directly imported from @rspack/core.
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.

@netlify
Copy link

netlify bot commented Jan 6, 2026

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit d408911
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/695c83614a4f0d0008e9d3cf

Copy link

@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 aims to fix an issue with compiler.rspack in multi-compiler setups by ensuring each compiler gets its own RuntimeGlobals. The approach taken correctly identifies that compiler.rspack needs to be a function, but the implementation inadvertently modifies a shared singleton, which would cause issues in the very multi-compiler scenario it's trying to fix. I've provided a critical comment with a suggested fix to create a new function for each compiler instance, ensuring proper isolation. A new test case has also been added which is great for verifying the intended behavior.

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 an issue where RuntimeGlobals should be unique for each compiler instance rather than shared across all exports from @rspack/core. The fix ensures that compiler.rspack and compiler.webpack have compiler-specific RuntimeGlobals instances.

Key changes:

  • Added a test to verify compiler.rspack exports the rspack function with unique RuntimeGlobals
  • Modified Compiler.ts to create compiler-specific rspack exports with per-compiler RuntimeGlobals
  • Changed imports to separate the rspack function from the exports module

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/rspack-test/compilerCases/exports.js Adds test verifying compiler.rspack is a function with unique RuntimeGlobals instance
packages/rspack/src/Compiler.ts Creates compiler-specific rspack exports object with per-compiler RuntimeGlobals and self-references

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
react-1k 825.4 KB 0
react-5k 2.7 MB 0
rome 984.3 KB 0
ui-components 2.1 MB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

📦 Binary Size-limit

Comparing d408911 to refactor: replace UsageCallback closure with InnerGraphUsageOperation enum (#12619) by Fy

🙈 Size remains the same at 47.87MB

LingyuCoder and others added 2 commits January 6, 2026 11:10
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 6, 2026

CodSpeed Performance Report

Merging #12636 will not alter performance

Comparing fix/compiler-exports (d408911) with main (3de0ea5)

Summary

✅ 16 untouched
⏩ 1 skipped1

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@chenjiahan chenjiahan enabled auto-merge (squash) January 6, 2026 03:45
@chenjiahan chenjiahan merged commit 9f09ed1 into main Jan 6, 2026
77 of 79 checks passed
@chenjiahan chenjiahan deleted the fix/compiler-exports branch January 6, 2026 04:36
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.

rspack@1.7: compiler.webpack is not a function

3 participants