Skip to content

fix(rstest): avoid async wrapper for sync mock factories#13764

Merged
fi3ework merged 2 commits intomainfrom
9aoy/fix-rstest-sync-mock-factory
Apr 20, 2026
Merged

fix(rstest): avoid async wrapper for sync mock factories#13764
fi3ework merged 2 commits intomainfrom
9aoy/fix-rstest-sync-mock-factory

Conversation

@9aoy
Copy link
Copy Markdown
Contributor

@9aoy 9aoy commented Apr 20, 2026

Summary

This PR stops hoisted rs.mock(..., () => ({ ... })) calls from marking rstest entries as async modules, which removed the unnecessary async wrapper from the generated bundle. It also strengthens the rstest mock case to assert the emitted bundle1.js is still hoisted correctly and does not contain async module runtime markers.

Related links

None.

Checklist

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

Copilot AI review requested due to automatic review settings April 20, 2026 07:28
@9aoy 9aoy requested a review from LingyuCoder as a code owner April 20, 2026 07:28
Copy link
Copy Markdown
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

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates the rstest parser behavior to avoid marking hoisted synchronous rs.mock() calls as async modules, and tightens regression coverage by asserting the emitted bundle remains hoisted and free of async-module runtime markers.

Changes:

  • Removed logic that marked modules as having top-level await when encountering hoisted rstest mocks.
  • Strengthened the rstest mock config case to assert correct hoist ordering and absence of async-module runtime wrappers.

Reviewed changes

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

File Description
tests/rspack-test/configCases/rstest/mock/test.js Expands assertions around hoisting order and verifies no async-module runtime markers are emitted.
crates/rspack_plugin_rstest/src/parser_plugin.rs Stops hoisted mocks from unconditionally setting async/top-level-await metadata.

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

Comment thread crates/rspack_plugin_rstest/src/parser_plugin.rs
Comment thread tests/rspack-test/configCases/rstest/mock/test.js Outdated
Comment thread tests/rspack-test/configCases/rstest/mock/test.js Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 553ae60190

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/rspack_plugin_rstest/src/parser_plugin.rs
@github-actions github-actions bot added the release: bug fix release: bug related release(mr only) label Apr 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 20, 2026

📦 Binary Size-limit

Comparing 834808f to chore: bump swc_core from 62 to 64 (#13760) by CPunisher

🙈 Size remains the same at 62.81MB

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Apr 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 20, 2026

Rsdoctor Bundle Diff Analysis

Found 6 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
popular-libs 1.7 MB 0
react-10k 5.7 MB 0
react-1k 826.1 KB 0
react-5k 2.7 MB 0
rome 1.6 MB 0
ui-components 4.8 MB 0

Generated by Rsdoctor GitHub Action

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 20, 2026

Merging this PR will not alter performance

✅ 34 untouched benchmarks


Comparing 9aoy/fix-rstest-sync-mock-factory (834808f) with main (86caffb)

Open in CodSpeed

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 20, 2026

📝 Rspack Ecosystem CI: Open

suite result
rsbuild ✅ success
rsdoctor ✅ success
modernjs ✅ success
rspress ✅ success
rstest ✅ success
plugin ✅ success
lynx-stack ❌ failure
examples ✅ success
rsbuild-rsc-plugin ✅ success
devserver ✅ success
rslib ✅ success

@fi3ework fi3ework merged commit 1e5679c into main Apr 20, 2026
38 checks passed
@fi3ework fi3ework deleted the 9aoy/fix-rstest-sync-mock-factory branch April 20, 2026 09:07
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.

3 participants