@@ -736,21 +736,42 @@ pub enum MdxRsOptions {
736
736
#[ turbo_tasks:: value( shared, operation) ]
737
737
#[ derive( Clone , Debug ) ]
738
738
#[ serde( rename_all = "camelCase" ) ]
739
- pub enum ReactCompilerMode {
739
+ pub enum ReactCompilerCompilationMode {
740
740
Infer ,
741
741
Annotation ,
742
742
All ,
743
743
}
744
744
745
- /// Subset of react compiler options
745
+ impl Default for ReactCompilerCompilationMode {
746
+ fn default ( ) -> Self {
747
+ Self :: Infer
748
+ }
749
+ }
750
+
746
751
#[ turbo_tasks:: value( shared, operation) ]
747
752
#[ derive( Clone , Debug ) ]
753
+ #[ serde( rename_all = "snake_case" ) ]
754
+ pub enum ReactCompilerPanicThreshold {
755
+ None ,
756
+ CriticalErrors ,
757
+ AllErrors ,
758
+ }
759
+
760
+ impl Default for ReactCompilerPanicThreshold {
761
+ fn default ( ) -> Self {
762
+ Self :: None
763
+ }
764
+ }
765
+
766
+ /// Subset of react compiler options
767
+ #[ turbo_tasks:: value( shared, operation) ]
768
+ #[ derive( Clone , Debug , Default ) ]
748
769
#[ serde( rename_all = "camelCase" ) ]
749
770
pub struct ReactCompilerOptions {
750
- #[ serde( skip_serializing_if = "Option::is_none" ) ]
751
- pub compilation_mode : Option < ReactCompilerMode > ,
752
- #[ serde( skip_serializing_if = "Option::is_none" ) ]
753
- pub panic_threshold : Option < RcStr > ,
771
+ #[ serde( default ) ]
772
+ pub compilation_mode : ReactCompilerCompilationMode ,
773
+ #[ serde( default ) ]
774
+ pub panic_threshold : ReactCompilerPanicThreshold ,
754
775
}
755
776
756
777
#[ derive(
@@ -1303,6 +1324,14 @@ impl NextConfig {
1303
1324
Ok ( config. cell ( ) )
1304
1325
}
1305
1326
1327
+ #[ turbo_tasks:: function]
1328
+ pub async fn config_file_path (
1329
+ & self ,
1330
+ project_path : FileSystemPath ,
1331
+ ) -> Result < Vc < FileSystemPath > > {
1332
+ Ok ( project_path. join ( & self . config_file_name ) ?. cell ( ) )
1333
+ }
1334
+
1306
1335
#[ turbo_tasks:: function]
1307
1336
pub fn bundle_pages_router_dependencies ( & self ) -> Vc < bool > {
1308
1337
Vc :: cell ( self . bundle_pages_router_dependencies . unwrap_or_default ( ) )
@@ -1387,8 +1416,12 @@ impl NextConfig {
1387
1416
}
1388
1417
1389
1418
#[ turbo_tasks:: function]
1390
- pub async fn webpack_rules ( & self , project_path : FileSystemPath ) -> Result < Vc < WebpackRules > > {
1391
- let Some ( turbo_rules) = self . turbopack . as_ref ( ) . and_then ( |t| t. rules . as_ref ( ) ) else {
1419
+ pub async fn webpack_rules (
1420
+ self : Vc < Self > ,
1421
+ project_path : FileSystemPath ,
1422
+ ) -> Result < Vc < WebpackRules > > {
1423
+ let this = self . await ?;
1424
+ let Some ( turbo_rules) = this. turbopack . as_ref ( ) . and_then ( |t| t. rules . as_ref ( ) ) else {
1392
1425
return Ok ( Vc :: cell ( Vec :: new ( ) ) ) ;
1393
1426
} ;
1394
1427
if turbo_rules. is_empty ( ) {
@@ -1411,7 +1444,6 @@ impl NextConfig {
1411
1444
. collect ( ) ,
1412
1445
)
1413
1446
}
1414
- let config_file_path = || project_path. join ( & self . config_file_name ) ;
1415
1447
for item in & rule_collection. 0 {
1416
1448
match item {
1417
1449
RuleConfigCollectionItem :: Shorthand ( loaders) => {
@@ -1438,7 +1470,10 @@ impl NextConfig {
1438
1470
{
1439
1471
InvalidLoaderRuleRenameAsIssue {
1440
1472
glob : glob. clone ( ) ,
1441
- config_file_path : config_file_path ( ) ?,
1473
+ config_file_path : self
1474
+ . config_file_path ( project_path. clone ( ) )
1475
+ . owned ( )
1476
+ . await ?,
1442
1477
rename_as : rename_as. clone ( ) ,
1443
1478
}
1444
1479
. resolved_cell ( )
@@ -1453,7 +1488,10 @@ impl NextConfig {
1453
1488
} else {
1454
1489
InvalidLoaderRuleConditionIssue {
1455
1490
condition : condition. clone ( ) ,
1456
- config_file_path : config_file_path ( ) ?,
1491
+ config_file_path : self
1492
+ . config_file_path ( project_path. clone ( ) )
1493
+ . owned ( )
1494
+ . await ?,
1457
1495
}
1458
1496
. resolved_cell ( )
1459
1497
. emit ( ) ;
@@ -1604,18 +1642,12 @@ impl NextConfig {
1604
1642
}
1605
1643
1606
1644
#[ turbo_tasks:: function]
1607
- pub fn react_compiler ( & self ) -> Vc < OptionalReactCompilerOptions > {
1645
+ pub fn react_compiler_options ( & self ) -> Vc < OptionalReactCompilerOptions > {
1608
1646
let options = & self . experimental . react_compiler ;
1609
1647
1610
1648
let options = match options {
1611
1649
Some ( ReactCompilerOptionsOrBoolean :: Boolean ( true ) ) => {
1612
- OptionalReactCompilerOptions ( Some (
1613
- ReactCompilerOptions {
1614
- compilation_mode : None ,
1615
- panic_threshold : None ,
1616
- }
1617
- . resolved_cell ( ) ,
1618
- ) )
1650
+ OptionalReactCompilerOptions ( Some ( ReactCompilerOptions :: default ( ) . resolved_cell ( ) ) )
1619
1651
}
1620
1652
Some ( ReactCompilerOptionsOrBoolean :: Option ( options) ) => OptionalReactCompilerOptions (
1621
1653
Some ( ReactCompilerOptions { ..options. clone ( ) } . resolved_cell ( ) ) ,
0 commit comments