@@ -15,7 +15,7 @@ use swc_core::{
1515} ;
1616use turbo_rcstr:: { RcStr , rcstr} ;
1717use turbo_tasks:: {
18- NonLocalValue , ResolvedVc , TryJoinIterExt , ValueDefault , Vc , trace:: TraceRawVcs ,
18+ NonLocalValue , ResolvedVc , TaskInput , TryJoinIterExt , ValueDefault , Vc , trace:: TraceRawVcs ,
1919 util:: WrapFuture ,
2020} ;
2121use turbo_tasks_fs:: FileSystemPath ;
@@ -281,10 +281,29 @@ impl Issue for NextSegmentConfigParsingIssue {
281281 }
282282}
283283
284+ #[ derive(
285+ Debug ,
286+ Clone ,
287+ Copy ,
288+ PartialEq ,
289+ Eq ,
290+ Hash ,
291+ Serialize ,
292+ Deserialize ,
293+ TaskInput ,
294+ NonLocalValue ,
295+ TraceRawVcs ,
296+ ) ]
297+ pub enum ParseSegmentMode {
298+ Base ,
299+ // Disallows "use client + generateStatic" and ignores/warns about `export const config`
300+ App ,
301+ }
302+
284303#[ turbo_tasks:: function]
285304pub async fn parse_segment_config_from_source (
286305 source : ResolvedVc < Box < dyn Source > > ,
287- is_app_router : bool ,
306+ mode : ParseSegmentMode ,
288307) -> Result < Vc < NextSegmentConfig > > {
289308 let path = source. ident ( ) . path ( ) . await ?;
290309
@@ -334,16 +353,7 @@ pub async fn parse_segment_config_from_source(
334353 let mut config = NextSegmentConfig :: default ( ) ;
335354
336355 let mut parse = async |ident, init, span| {
337- parse_config_value (
338- source,
339- is_app_router,
340- & mut config,
341- eval_context,
342- ident,
343- init,
344- span,
345- )
346- . await
356+ parse_config_value ( source, mode, & mut config, eval_context, ident, init, span) . await
347357 } ;
348358
349359 for item in & module_ast. body {
@@ -425,7 +435,7 @@ pub async fn parse_segment_config_from_source(
425435 )
426436 . await ?;
427437
428- if is_app_router
438+ if mode == ParseSegmentMode :: App
429439 && let Some ( span) = config. generate_static_params
430440 && module_ast
431441 . body
@@ -491,7 +501,7 @@ async fn invalid_config(
491501
492502async fn parse_config_value (
493503 source : ResolvedVc < Box < dyn Source > > ,
494- is_app_router : bool ,
504+ mode : ParseSegmentMode ,
495505 config : & mut NextSegmentConfig ,
496506 eval_context : & EvalContext ,
497507 key : & str ,
@@ -534,7 +544,7 @@ async fn parse_config_value(
534544 . await ;
535545 } ;
536546
537- if is_app_router {
547+ if mode == ParseSegmentMode :: App {
538548 return invalid_config (
539549 source,
540550 "config" ,
@@ -1258,7 +1268,9 @@ async fn parse_segment_config_from_loader_tree_internal(
12581268 . flatten ( )
12591269 {
12601270 let source = Vc :: upcast ( FileSource :: new ( path. clone ( ) ) ) ;
1261- config. apply_parent_config ( & * parse_segment_config_from_source ( source, true ) . await ?) ;
1271+ config. apply_parent_config (
1272+ & * parse_segment_config_from_source ( source, ParseSegmentMode :: App ) . await ?,
1273+ ) ;
12621274 }
12631275
12641276 Ok ( config)
0 commit comments