Skip to content

Conversation

@9aoy
Copy link
Contributor

@9aoy 9aoy commented Feb 10, 2026

Summary

fix(rstest): rstest importActual + import mocked module ordering issue.

import { foo } from './src/foo' // => undefined

import * as actual from './src/foo' with { rstest: 'importActual' };
rstest.mock('./src/foo', () => ({ ...actual }))
  • override rstest ESM import dependency templates for importActual attribute
  • hoist generated StageESMImports fragments to run before mock hoist placeholders
  • add importActual hoist marker comment in generated bundle output
  • update importActualHoisted config case to verify hoisted importActual behavior

Related links

Checklist

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

Copilot AI review requested due to automatic review settings February 10, 2026 08:12
@9aoy 9aoy requested a review from LingyuCoder as a code owner February 10, 2026 08:12
@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 Feb 10, 2026
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

Fixes an ordering issue where importActual ESM imports need to be emitted/initialized before rstest mock-hoist placeholders so that mocked-module factories can safely spread/use the “actual” namespace import.

Changes:

  • Override Rspack’s ESM import dependency templates to hoist StageESMImports init fragments when the import has with { rstest: "importActual" }.
  • Add an importActual hoist marker comment in generated output for easier verification/debugging.
  • Extend rstest mock config-case coverage with a loader rule for importActual import-attributes and a new importActualHoisted entry test.

Reviewed changes

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

Show a summary per file
File Description
tests/rspack-test/configCases/rstest/mock/rspack.config.js Updates test runtime mock implementation; adds loader rule for with { rstest: "importActual" }; adds new test entry.
tests/rspack-test/configCases/rstest/mock/importActualLoader.mjs Adds a passthrough loader used to create a distinct module instance for importActual via import attributes.
tests/rspack-test/configCases/rstest/mock/importActualHoisted.js Adds a regression test for importActual used in a mocked module factory when imports are hoisted.
crates/rspack_plugin_rstest/src/plugin.rs Registers new dependency templates to override ESM import rendering for importActual ordering.
crates/rspack_plugin_rstest/src/lib.rs Wires in the new esm_import_dependency module.
crates/rspack_plugin_rstest/src/esm_import_dependency.rs Implements ESM import template overrides that hoist StageESMImports fragments for importActual.

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 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
ui-components 2.2 MB 0
rome 984.2 KB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 2026

📦 Binary Size-limit

Comparing 65efcb4 to chore(workflow): remove API check from pre commit (#13044) by neverland

❌ Size increased by 6.88KB from 48.68MB to 48.68MB (⬆️0.01%)

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 10, 2026

Merging this PR will not alter performance

✅ 17 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing importActual-hoisted (d868657) with main (2865b34)

Open in CodSpeed

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.

@9aoy 9aoy requested a review from fi3ework February 10, 2026 09:46
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 12, 2026

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

Latest commit: 65efcb4
Status: ✅  Deploy successful!
Preview URL: https://a03ceb40.rspack-v2.pages.dev
Branch Preview URL: https://importactual-hoisted.rspack-v2.pages.dev

View logs

@web-infra-dev web-infra-dev deleted a comment from github-actions bot Feb 12, 2026
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Feb 12, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

📝 Ecosystem CI detail: Open

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

@9aoy 9aoy enabled auto-merge (squash) February 12, 2026 08:00
@chenjiahan chenjiahan disabled auto-merge February 12, 2026 09:24
@chenjiahan chenjiahan merged commit d967d97 into main Feb 12, 2026
169 of 184 checks passed
@chenjiahan chenjiahan deleted the importActual-hoisted branch February 12, 2026 09:25
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