Skip to content

Commit 8ae23a0

Browse files
committed
Revert "Use new all_modules_iter function"
This reverts commit 4239c5f.
1 parent 87d55cb commit 8ae23a0

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

packages/next-swc/crates/next-api/src/server_actions.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ use next_core::{
88
util::NextRuntime,
99
};
1010
use next_swc::server_actions::parse_server_actions;
11-
use turbo_tasks::{TryFlatJoinIterExt, Value, ValueToString, Vc};
11+
use turbo_tasks::{
12+
graph::{GraphTraversal, NonDeterministic},
13+
TryFlatJoinIterExt, Value, ValueToString, Vc,
14+
};
1215
use turbopack_binding::{
1316
turbo::tasks_fs::{rope::RopeBuilder, File, FileSystemPath},
1417
turbopack::{
1518
core::{
1619
asset::AssetContent, chunk::EvaluatableAsset, context::AssetContext, module::Module,
17-
output::OutputAsset, reference::all_modules_iter, reference_type::ReferenceType,
18-
virtual_output::VirtualOutputAsset, virtual_source::VirtualSource,
20+
output::OutputAsset, reference::primary_referenced_modules,
21+
reference_type::ReferenceType, virtual_output::VirtualOutputAsset,
22+
virtual_source::VirtualSource,
1923
},
2024
ecmascript::{
2125
chunk::{EcmascriptChunkItemExt, EcmascriptChunkPlaceable, EcmascriptChunkingContext},
@@ -169,8 +173,13 @@ async fn build_manifest(
169173
/// returned along with the module which exports that action.
170174
#[turbo_tasks::function]
171175
async fn get_actions(module: Vc<Box<dyn Module>>) -> Result<Vc<ModuleActionMap>> {
172-
let mut all_actions = all_modules_iter([module].into_iter())
173-
.await?
176+
let mut all_actions = NonDeterministic::new()
177+
.skip_duplicates()
178+
.visit([module], get_referenced_modules)
179+
.await
180+
.completed()?
181+
.into_inner()
182+
.into_iter()
174183
.map(parse_actions_filter_map)
175184
.try_flat_join()
176185
.await?
@@ -181,6 +190,16 @@ async fn get_actions(module: Vc<Box<dyn Module>>) -> Result<Vc<ModuleActionMap>>
181190
Ok(Vc::cell(all_actions))
182191
}
183192

193+
/// Our graph traversal visitor, which finds the primary modules directly
194+
/// referenced by [parent].
195+
async fn get_referenced_modules(
196+
parent: Vc<Box<dyn Module>>,
197+
) -> Result<impl Iterator<Item = Vc<Box<dyn Module>>> + Send> {
198+
primary_referenced_modules(parent)
199+
.await
200+
.map(|modules| modules.clone_value().into_iter())
201+
}
202+
184203
/// Inspects the comments inside [module] looking for the magic actions comment.
185204
/// If found, we return the mapping of every action's hashed id to the name of
186205
/// the exported action function. If not, we return a None.

0 commit comments

Comments
 (0)