Skip to content

Conversation

@fi3ework
Copy link
Member

@fi3ework fi3ework commented Oct 22, 2025

Summary

when there are multiple bundled entry points (such as rstest.setup.ts and index.test.ts), the project's module may exist in exports.modules of each chunk, which can lead to the following problem:

load rstest.setup.ts (it mocks module A) ->
module A been mocked ->
load index.test.ts ->
module A is re-installed since it's duplicated in this chunk, so it overwriting the mock ->
mocking module A in index.test.ts will not work

this PR modifies the internal logic of installChunk to no longer forcibly overwrite modules that have already been mocked. and because the use of RemoveDuplicateModulesPlugin has been removed, the overall chunk is now simpler, so the watch test has also been rolled back.

Related Links

Checklist

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

@netlify
Copy link

netlify bot commented Oct 22, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 7da6b94
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/68f87cf4158e100008e568db
😎 Deploy Preview https://deploy-preview-637--rstest-dev.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.

@fi3ework fi3ework marked this pull request as ready for review October 22, 2025 06:49
Copilot AI review requested due to automatic review settings October 22, 2025 06:49
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 a critical bug where mocked modules could be overwritten when loading new chunks that contain duplicate module definitions. Previously, when multiple bundled entry points existed, modules present in multiple chunks would be re-installed, overwriting any existing mocks. The solution modifies the chunk loading runtime to skip reinstalling modules that have already been mocked.

Key Changes:

  • Modified chunk loading runtime to prevent reinstallation of already-mocked modules
  • Removed RemoveDuplicateModulesPlugin configuration as it's no longer needed
  • Updated plugin names for better clarity

Reviewed Changes

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

File Description
packages/core/src/core/rsbuild.ts Removed RemoveDuplicateModulesPlugin and its import
packages/core/src/core/plugins/moduleCacheControl.ts Updated plugin names from generic "CustomPlugin" to descriptive names
packages/core/src/core/plugins/mockRuntime.ts Added runtime module hook to modify chunk loading behavior and prevent mocked module overwrites
e2e/watch/index.test.ts Updated test expectations to reflect simpler chunk behavior without duplicate module removal

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

@fi3ework fi3ework requested a review from 9aoy October 22, 2025 07:06
@fi3ework fi3ework merged commit 375186a into main Oct 22, 2025
17 checks passed
@fi3ework fi3ework deleted the mock-over branch October 22, 2025 07:33
@9aoy 9aoy mentioned this pull request Oct 27, 2025
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.

3 participants