@@ -284,7 +284,7 @@ pub struct JsxSpecs {
284284
285285#[ derive( Debug , Clone , Eq , PartialEq ) ]
286286pub enum SourceMapConfig {
287- Bool ( bool ) ,
287+ Disabled ,
288288 Options ( SourceMapOptions ) ,
289289}
290290
@@ -295,7 +295,10 @@ impl<'de> Deserialize<'de> for SourceMapConfig {
295295 {
296296 let value = serde_json:: Value :: deserialize ( deserializer) ?;
297297 match value {
298- serde_json:: Value :: Bool ( value) => Ok ( SourceMapConfig :: Bool ( value) ) ,
298+ serde_json:: Value :: Bool ( false ) => Ok ( SourceMapConfig :: Disabled ) ,
299+ serde_json:: Value :: Bool ( true ) => Err ( DeError :: custom (
300+ "sourceMap true is unsupported; use an object such as { \" enabled\" : \" dev\" , \" mode\" : \" linked\" } or false" ,
301+ ) ) ,
299302 serde_json:: Value :: Object ( _) => SourceMapOptions :: deserialize ( value)
300303 . map ( SourceMapConfig :: Options )
301304 . map_err ( DeError :: custom) ,
@@ -877,12 +880,9 @@ impl Config {
877880
878881 if let Some ( source_map) = & self . source_map {
879882 match source_map {
880- SourceMapConfig :: Bool ( false ) => {
883+ SourceMapConfig :: Disabled => {
881884 args. extend ( [ "-bs-source-map" . to_string ( ) , "false" . to_string ( ) ] ) ;
882885 }
883- SourceMapConfig :: Bool ( true ) => {
884- panic ! ( "sourceMap true is unsupported; use {{ \" mode\" : \" linked\" }}" )
885- }
886886 SourceMapConfig :: Options ( options) => {
887887 let Some ( mode) = self . effective_source_map_mode ( command) else {
888888 return vec ! [ "-bs-source-map" . to_string( ) , "false" . to_string( ) ] ;
@@ -916,9 +916,6 @@ impl Config {
916916 } ;
917917 source_map_enabled. then_some ( options. mode )
918918 }
919- Some ( SourceMapConfig :: Bool ( true ) ) => {
920- panic ! ( "sourceMap true is unsupported; use {{ \" mode\" : \" linked\" }}" )
921- }
922919 _ => None ,
923920 }
924921 }
@@ -1807,7 +1804,6 @@ pub mod tests {
18071804 }
18081805
18091806 #[ test]
1810- #[ should_panic( expected = "sourceMap true is unsupported" ) ]
18111807 fn test_source_map_rejects_true_for_nested_config ( ) {
18121808 let json = r#"
18131809 {
@@ -1817,8 +1813,11 @@ pub mod tests {
18171813 }
18181814 "# ;
18191815
1820- let config = serde_json:: from_str :: < Config > ( json) . unwrap ( ) ;
1821- let _ = config. get_source_map_args ( SourceMapCommand :: Build ) ;
1816+ let error = serde_json:: from_str :: < Config > ( json) . unwrap_err ( ) ;
1817+ assert ! (
1818+ error. to_string( ) . contains( "sourceMap true is unsupported" ) ,
1819+ "unexpected error: {error}"
1820+ ) ;
18221821 }
18231822
18241823 #[ test]
0 commit comments