Skip to content

Comments

fix: suppress ESModulesLinkingError for exports that might be implemented in mock#704

Merged
9aoy merged 2 commits intomainfrom
ESModulesLinkingError
Nov 19, 2025
Merged

fix: suppress ESModulesLinkingError for exports that might be implemented in mock#704
9aoy merged 2 commits intomainfrom
ESModulesLinkingError

Conversation

@9aoy
Copy link
Collaborator

@9aoy 9aoy commented Nov 19, 2025

Summary

suppress ESModulesLinkingError for exports that might be implemented in mock.

ESModulesLinkingError: export 'mockApiClient' (imported as 'mockApiFile') was not found in '../../services' (possible exports...

mock modules:

class MockApiClient extends ApiClient {
  fetch = rstest.fn().mockResolvedValue({ json: () => Promise.resolve({ data: [] }) })
}
export const mockApiClient = new MockApiClient({ baseDomain: 'https://example.com' });

Related Links

#698

Checklist

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

Copilot AI review requested due to automatic review settings November 19, 2025 03:38
@netlify
Copy link

netlify bot commented Nov 19, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit befadcb
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/691d3da0a5c8a400081e3ff0
😎 Deploy Preview https://deploy-preview-704--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.

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 suppresses ESModulesLinkingError warnings that occur when mocked modules export properties that don't exist in the original module by changing the exportsPresence configuration from 'error' to 'warn'.

  • Changed rspack's exportsPresence parser option from 'error' to 'warn' to allow mock modules to add exports not present in the original module
  • Added E2E test to verify that ESModulesLinkingError is not thrown when mocking modules with additional exports
  • Updated test snapshots to reflect the new configuration

Reviewed Changes

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

Show a summary per file
File Description
packages/core/src/core/plugins/basic.ts Added exportsPresence: 'warn' configuration to suppress ESModulesLinkingError when mocks define exports not in the original module
packages/core/tests/core/snapshots/rsbuild.test.ts.snap Updated all 5 snapshot occurrences to reflect the change from "error" to "warn"
e2e/mock/tests/esModulesLinkingError.test.ts Added E2E test that verifies ESModulesLinkingError is not printed when running tests with mocked exports
e2e/mock/fixtures/esModulesLinkingError/index.test.ts Created test fixture that mocks a module with exports not present in the original
e2e/mock/fixtures/esModulesLinkingError/services/index.js Created minimal module that exports a while the mock provides value

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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@9aoy 9aoy requested a review from fi3ework November 19, 2025 03:54
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.

Should we use fix instead of chore in the PR title?

@9aoy 9aoy changed the title chore: suppress ESModulesLinkingError for exports that might be implemented in mock fix: suppress ESModulesLinkingError for exports that might be implemented in mock Nov 19, 2025
@9aoy 9aoy merged commit 8e3349b into main Nov 19, 2025
17 checks passed
@9aoy 9aoy deleted the ESModulesLinkingError branch November 19, 2025 09:01
@9aoy 9aoy mentioned this pull request Nov 20, 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.

2 participants