Skip to content

Commit 4adc554

Browse files
authored
fix(rstest): always hoist @rstest/core init fragment (#12363)
1 parent 9bc94cc commit 4adc554

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

crates/rspack_plugin_rstest/src/mock_method_dependency.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,8 @@ impl DependencyTemplate for MockMethodDependencyTemplate {
121121
Self::add_placeholder_fragment(init_fragments, flag, request);
122122
}
123123

124-
// Step 2: Hoist @rstest/core import for rs.hoisted() to ensure it appears before the placeholder
125-
if dep.method == MockMethod::Hoisted {
126-
Self::hoist_rstest_core_import(init_fragments);
127-
}
124+
// Step 2: Hoist @rstest/core import to ensure it comes before all hoisted code
125+
Self::hoist_rstest_core_import(init_fragments);
128126

129127
// Step 3: Transform the source code
130128
Self::transform_source(source, dep, &require_name, mock_method, hoist_flag, request);

0 commit comments

Comments
 (0)