@@ -26,7 +26,6 @@ use swc_core::{
26
26
#[ serde( deny_unknown_fields, rename_all = "camelCase" ) ]
27
27
pub struct Config {
28
28
pub is_react_server_layer : bool ,
29
- pub enabled : bool ,
30
29
pub hash_salt : String ,
31
30
}
32
31
@@ -266,7 +265,6 @@ impl<C: Comments> ServerActions<C> {
266
265
& mut is_action_fn,
267
266
& mut cache_type,
268
267
& mut span,
269
- self . config . enabled ,
270
268
) ;
271
269
272
270
if !self . config . is_react_server_layer {
@@ -1303,7 +1301,6 @@ impl<C: Comments> VisitMut for ServerActions<C> {
1303
1301
& mut self . in_cache_file ,
1304
1302
& mut self . has_action ,
1305
1303
& mut self . has_cache ,
1306
- self . config . enabled ,
1307
1304
) ;
1308
1305
1309
1306
// If we're in a "use cache" file, collect all original IDs from export
@@ -2358,7 +2355,6 @@ fn remove_server_directive_index_in_module(
2358
2355
in_cache_file : & mut Option < String > ,
2359
2356
has_action : & mut bool ,
2360
2357
has_cache : & mut bool ,
2361
- enabled : bool ,
2362
2358
) {
2363
2359
let mut is_directive = true ;
2364
2360
@@ -2372,16 +2368,6 @@ fn remove_server_directive_index_in_module(
2372
2368
if is_directive {
2373
2369
* in_action_file = true ;
2374
2370
* has_action = true ;
2375
- if !enabled {
2376
- HANDLER . with ( |handler| {
2377
- handler
2378
- . struct_span_err (
2379
- * span,
2380
- "To use Server Actions, please enable the feature flag in your Next.js config. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching/forms-and-mutations#convention" ,
2381
- )
2382
- . emit ( )
2383
- } ) ;
2384
- }
2385
2371
return false ;
2386
2372
} else {
2387
2373
HANDLER . with ( |handler| {
@@ -2397,16 +2383,12 @@ fn remove_server_directive_index_in_module(
2397
2383
// `use cache` or `use cache: foo`
2398
2384
if value == "use cache" || value. starts_with ( "use cache: " ) {
2399
2385
if is_directive {
2400
- * in_cache_file = Some (
2401
- if value == "use cache" {
2402
- "default" . into ( )
2403
- } else {
2404
- // Slice the value after "use cache: "
2405
- value. split_at (
2406
- "use cache: " . len ( ) ,
2407
- ) . 1 . into ( )
2408
- }
2409
- ) ;
2386
+ * in_cache_file = Some ( if value == "use cache" {
2387
+ "default" . into ( )
2388
+ } else {
2389
+ // Slice the value after "use cache: "
2390
+ value. split_at ( "use cache: " . len ( ) ) . 1 . into ( )
2391
+ } ) ;
2410
2392
* has_cache = true ;
2411
2393
return false ;
2412
2394
} else {
@@ -2427,8 +2409,8 @@ fn remove_server_directive_index_in_module(
2427
2409
. struct_span_err (
2428
2410
* span,
2429
2411
format ! (
2430
- "Did you mean \" use cache\" ? \" {value}\" is not a supported \
2431
- directive name."
2412
+ "Did you mean \" use cache\" ? \" {value}\" is not a \
2413
+ supported directive name."
2432
2414
)
2433
2415
. as_str ( ) ,
2434
2416
)
@@ -2475,8 +2457,7 @@ fn remove_server_directive_index_in_module(
2475
2457
handler
2476
2458
. struct_span_err (
2477
2459
* span,
2478
- "The \" use cache\" directive cannot be wrapped in \
2479
- parentheses.",
2460
+ "The \" use cache\" directive cannot be wrapped in parentheses." ,
2480
2461
)
2481
2462
. emit ( ) ;
2482
2463
} )
@@ -2537,7 +2518,6 @@ fn remove_server_directive_index_in_fn(
2537
2518
is_action_fn : & mut bool ,
2538
2519
cache_type : & mut Option < String > ,
2539
2520
action_span : & mut Option < Span > ,
2540
- enabled : bool ,
2541
2521
) {
2542
2522
let mut is_directive = true ;
2543
2523
@@ -2552,16 +2532,6 @@ fn remove_server_directive_index_in_fn(
2552
2532
2553
2533
if is_directive {
2554
2534
* is_action_fn = true ;
2555
- if !enabled {
2556
- HANDLER . with ( |handler| {
2557
- handler
2558
- . struct_span_err (
2559
- * span,
2560
- "To use Server Actions, please enable the feature flag in your Next.js config. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching/forms-and-mutations#convention" ,
2561
- )
2562
- . emit ( )
2563
- } ) ;
2564
- }
2565
2535
return false ;
2566
2536
} else {
2567
2537
HANDLER . with ( |handler| {
@@ -2575,31 +2545,27 @@ fn remove_server_directive_index_in_fn(
2575
2545
} ) ;
2576
2546
}
2577
2547
} else if detect_similar_strings ( value, "use server" ) {
2578
- // Detect typo of "use server"
2579
- HANDLER . with ( |handler| {
2580
- handler
2581
- . struct_span_err (
2582
- * span,
2583
- format ! (
2584
- "Did you mean \" use server\" ? \" {value}\" is not a supported \
2585
- directive name."
2586
- )
2587
- . as_str ( ) ,
2548
+ // Detect typo of "use server"
2549
+ HANDLER . with ( |handler| {
2550
+ handler
2551
+ . struct_span_err (
2552
+ * span,
2553
+ format ! (
2554
+ "Did you mean \" use server\" ? \" {value}\" is not a supported \
2555
+ directive name."
2588
2556
)
2589
- . emit ( ) ;
2590
- } ) ;
2557
+ . as_str ( ) ,
2558
+ )
2559
+ . emit ( ) ;
2560
+ } ) ;
2591
2561
} else if value == "use cache" || value. starts_with ( "use cache: " ) {
2592
2562
if is_directive {
2593
- * cache_type = Some (
2594
- if value == "use cache" {
2595
- "default" . into ( )
2596
- } else {
2597
- // Slice the value after "use cache: "
2598
- value. split_at (
2599
- "use cache: " . len ( ) ,
2600
- ) . 1 . into ( )
2601
- } ,
2602
- ) ;
2563
+ * cache_type = Some ( if value == "use cache" {
2564
+ "default" . into ( )
2565
+ } else {
2566
+ // Slice the value after "use cache: "
2567
+ value. split_at ( "use cache: " . len ( ) ) . 1 . into ( )
2568
+ } ) ;
2603
2569
return false ;
2604
2570
} else {
2605
2571
HANDLER . with ( |handler| {
0 commit comments