@@ -4,25 +4,21 @@ use anyhow::Result;
4
4
use futures_util:: TryFutureExt ;
5
5
use napi:: { JsFunction , bindgen_prelude:: External } ;
6
6
use next_api:: {
7
- module_graph_snapshot:: { ModuleGraphSnapshot , get_module_graph_snapshot} ,
8
7
operation:: OptionEndpoint ,
9
8
paths:: ServerPath ,
10
9
route:: {
11
- Endpoint , EndpointOutputPaths , endpoint_client_changed_operation,
12
- endpoint_server_changed_operation , endpoint_write_to_disk_operation,
10
+ EndpointOutputPaths , endpoint_client_changed_operation, endpoint_server_changed_operation ,
11
+ endpoint_write_to_disk_operation,
13
12
} ,
14
13
} ;
15
14
use tracing:: Instrument ;
16
- use turbo_tasks:: {
17
- Completion , Effects , OperationVc , ReadRef , TryFlatJoinIterExt , TryJoinIterExt , Vc ,
18
- } ;
19
- use turbopack_core:: { diagnostics:: PlainDiagnostic , error:: PrettyPrintError , issue:: PlainIssue } ;
15
+ use turbo_tasks:: { Completion , Effects , OperationVc , ReadRef , Vc } ;
16
+ use turbopack_core:: { diagnostics:: PlainDiagnostic , issue:: PlainIssue } ;
20
17
21
18
use super :: utils:: {
22
19
DetachedVc , NapiDiagnostic , NapiIssue , RootTask , TurbopackResult ,
23
20
strongly_consistent_catch_collectables, subscribe,
24
21
} ;
25
- use crate :: next_api:: module_graph:: NapiModuleGraphSnapshot ;
26
22
27
23
#[ napi( object) ]
28
24
#[ derive( Default ) ]
@@ -85,11 +81,6 @@ impl From<Option<EndpointOutputPaths>> for NapiWrittenEndpoint {
85
81
}
86
82
}
87
83
88
- #[ napi( object) ]
89
- pub struct NapiModuleGraphSnapshots {
90
- pub module_graphs : Vec < NapiModuleGraphSnapshot > ,
91
- }
92
-
93
84
// NOTE(alexkirsz) We go through an extra layer of indirection here because of
94
85
// two factors:
95
86
// 1. rustc currently has a bug where using a dyn trait as a type argument to
@@ -164,105 +155,6 @@ pub async fn endpoint_write_to_disk(
164
155
} )
165
156
}
166
157
167
- #[ turbo_tasks:: value( serialization = "none" ) ]
168
- struct ModuleGraphsWithIssues {
169
- module_graphs : Option < ReadRef < ModuleGraphSnapshots > > ,
170
- issues : Arc < Vec < ReadRef < PlainIssue > > > ,
171
- diagnostics : Arc < Vec < ReadRef < PlainDiagnostic > > > ,
172
- effects : Arc < Effects > ,
173
- }
174
-
175
- #[ turbo_tasks:: function( operation) ]
176
- async fn get_module_graphs_with_issues_operation (
177
- endpoint_op : OperationVc < OptionEndpoint > ,
178
- ) -> Result < Vc < ModuleGraphsWithIssues > > {
179
- let module_graphs_op = get_module_graphs_operation ( endpoint_op) ;
180
- let ( module_graphs, issues, diagnostics, effects) =
181
- strongly_consistent_catch_collectables ( module_graphs_op) . await ?;
182
- Ok ( ModuleGraphsWithIssues {
183
- module_graphs,
184
- issues,
185
- diagnostics,
186
- effects,
187
- }
188
- . cell ( ) )
189
- }
190
-
191
- #[ turbo_tasks:: value( transparent) ]
192
- struct ModuleGraphSnapshots ( Vec < ReadRef < ModuleGraphSnapshot > > ) ;
193
-
194
- #[ turbo_tasks:: function( operation) ]
195
- async fn get_module_graphs_operation (
196
- endpoint_op : OperationVc < OptionEndpoint > ,
197
- ) -> Result < Vc < ModuleGraphSnapshots > > {
198
- let Some ( endpoint) = * endpoint_op. connect ( ) . await ? else {
199
- return Ok ( Vc :: cell ( vec ! [ ] ) ) ;
200
- } ;
201
- let graphs = endpoint. module_graphs ( ) . await ?;
202
- let entries = endpoint. entries ( ) . await ?;
203
- let entry_modules = entries. iter ( ) . flat_map ( |e| e. entries ( ) ) . collect :: < Vec < _ > > ( ) ;
204
- let snapshots = graphs
205
- . iter ( )
206
- . map ( async |& graph| {
207
- let module_graph = graph. await ?;
208
- let entry_modules = entry_modules
209
- . iter ( )
210
- . map ( async |& m| Ok ( module_graph. has_entry ( m) . await ?. then_some ( m) ) )
211
- . try_flat_join ( )
212
- . await ?;
213
- Ok ( ( * graph, entry_modules) )
214
- } )
215
- . try_join ( )
216
- . await ?
217
- . into_iter ( )
218
- . map ( |( graph, entry_modules) | ( graph, Vc :: cell ( entry_modules) ) )
219
- . collect :: < Vec < _ > > ( )
220
- . into_iter ( )
221
- . map ( async |( graph, entry_modules) | {
222
- get_module_graph_snapshot ( graph, Some ( entry_modules) ) . await
223
- } )
224
- . try_join ( )
225
- . await ?;
226
- Ok ( Vc :: cell ( snapshots) )
227
- }
228
-
229
- #[ napi]
230
- pub async fn endpoint_module_graphs (
231
- #[ napi( ts_arg_type = "{ __napiType: \" Endpoint\" }" ) ] endpoint : External < ExternalEndpoint > ,
232
- ) -> napi:: Result < TurbopackResult < NapiModuleGraphSnapshots > > {
233
- let endpoint_op: OperationVc < OptionEndpoint > = * * * endpoint;
234
- let ( module_graphs, issues, diagnostics) = endpoint
235
- . turbopack_ctx ( )
236
- . turbo_tasks ( )
237
- . run_once ( async move {
238
- let module_graphs_op = get_module_graphs_with_issues_operation ( endpoint_op) ;
239
- let ModuleGraphsWithIssues {
240
- module_graphs,
241
- issues,
242
- diagnostics,
243
- effects : _,
244
- } = & * module_graphs_op. connect ( ) . await ?;
245
- Ok ( ( module_graphs. clone ( ) , issues. clone ( ) , diagnostics. clone ( ) ) )
246
- } )
247
- . await
248
- . map_err ( |e| napi:: Error :: from_reason ( PrettyPrintError ( & e) . to_string ( ) ) ) ?;
249
-
250
- Ok ( TurbopackResult {
251
- result : NapiModuleGraphSnapshots {
252
- module_graphs : module_graphs
253
- . into_iter ( )
254
- . flat_map ( |m| m. into_iter ( ) )
255
- . map ( |m| NapiModuleGraphSnapshot :: from ( & * * m) )
256
- . collect ( ) ,
257
- } ,
258
- issues : issues. iter ( ) . map ( |i| NapiIssue :: from ( & * * i) ) . collect ( ) ,
259
- diagnostics : diagnostics
260
- . iter ( )
261
- . map ( |d| NapiDiagnostic :: from ( d) )
262
- . collect ( ) ,
263
- } )
264
- }
265
-
266
158
#[ napi( ts_return_type = "{ __napiType: \" RootTask\" }" ) ]
267
159
pub fn endpoint_server_changed_subscribe (
268
160
#[ napi( ts_arg_type = "{ __napiType: \" Endpoint\" }" ) ] endpoint : External < ExternalEndpoint > ,
0 commit comments