@@ -8,14 +8,18 @@ use next_core::{
8
8
util:: NextRuntime ,
9
9
} ;
10
10
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
+ } ;
12
15
use turbopack_binding:: {
13
16
turbo:: tasks_fs:: { rope:: RopeBuilder , File , FileSystemPath } ,
14
17
turbopack:: {
15
18
core:: {
16
19
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 ,
19
23
} ,
20
24
ecmascript:: {
21
25
chunk:: { EcmascriptChunkItemExt , EcmascriptChunkPlaceable , EcmascriptChunkingContext } ,
@@ -169,8 +173,13 @@ async fn build_manifest(
169
173
/// returned along with the module which exports that action.
170
174
#[ turbo_tasks:: function]
171
175
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 ( )
174
183
. map ( parse_actions_filter_map)
175
184
. try_flat_join ( )
176
185
. await ?
@@ -181,6 +190,16 @@ async fn get_actions(module: Vc<Box<dyn Module>>) -> Result<Vc<ModuleActionMap>>
181
190
Ok ( Vc :: cell ( all_actions) )
182
191
}
183
192
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
+
184
203
/// Inspects the comments inside [module] looking for the magic actions comment.
185
204
/// If found, we return the mapping of every action's hashed id to the name of
186
205
/// the exported action function. If not, we return a None.
0 commit comments