@@ -431,6 +431,7 @@ impl CompilerBuilder {
431431 }
432432
433433 /// Build [`Compiler`] from options and plugins.
434+ #[ must_use]
434435 pub fn build ( & mut self ) -> Compiler {
435436 let mut builder_context = BuilderContext :: default ( ) ;
436437 let compiler_options = self . options_builder . build ( & mut builder_context) ;
@@ -455,6 +456,44 @@ impl CompilerBuilder {
455456 }
456457}
457458
459+ #[ cfg( feature = "loader_lightningcss" ) ]
460+ impl CompilerBuilder {
461+ /// Enable support for builtin:lightningcss-loader.
462+ pub fn enable_loader_lightningcss ( & mut self ) -> & mut Self {
463+ self . plugin ( Box :: new (
464+ rspack_loader_lightningcss:: LightningcssLoaderPlugin :: new ( ) ,
465+ ) )
466+ }
467+ }
468+
469+ #[ cfg( feature = "loader_swc" ) ]
470+ impl CompilerBuilder {
471+ /// Enable support for builtin:swc-loader.
472+ pub fn enable_loader_swc ( & mut self ) -> & mut Self {
473+ self . plugin ( Box :: new ( rspack_loader_swc:: SwcLoaderPlugin :: new ( ) ) )
474+ }
475+ }
476+
477+ #[ cfg( feature = "loader_react_refresh" ) ]
478+ impl CompilerBuilder {
479+ /// Enable support for builtin:react-refresh-loader.
480+ pub fn enable_loader_react_refresh ( & mut self ) -> & mut Self {
481+ self . plugin ( Box :: new (
482+ rspack_loader_react_refresh:: ReactRefreshLoaderPlugin :: new ( ) ,
483+ ) )
484+ }
485+ }
486+
487+ #[ cfg( feature = "loader_preact_refresh" ) ]
488+ impl CompilerBuilder {
489+ /// Enable support for builtin:preact-refresh-loader.
490+ pub fn enable_loader_preact_refresh ( & mut self ) -> & mut Self {
491+ self . plugin ( Box :: new (
492+ rspack_loader_preact_refresh:: PreactRefreshLoaderPlugin :: new ( ) ,
493+ ) )
494+ }
495+ }
496+
458497impl Builder for CompilerOptions {
459498 type Item = CompilerOptionsBuilder ;
460499
@@ -838,6 +877,7 @@ impl CompilerOptionsBuilder {
838877 ///
839878 /// [`BuilderContext`]: crate::builder::BuilderContext
840879 /// [`CompilerOptions`]: rspack_core::options::CompilerOptions
880+ #[ must_use]
841881 pub fn build ( & mut self , builder_context : & mut BuilderContext ) -> CompilerOptions {
842882 let name = self . name . take ( ) ;
843883 let context = f ! ( self . context. take( ) , || {
@@ -1480,6 +1520,7 @@ impl NodeOptionBuilder {
14801520 /// Build [`NodeOption`] from options.
14811521 ///
14821522 /// [`NodeOption`]: rspack_core::options::NodeOption
1523+ #[ must_use]
14831524 fn build (
14841525 & mut self ,
14851526 target_properties : & TargetProperties ,
@@ -1606,6 +1647,7 @@ impl ModuleOptionsBuilder {
16061647 /// Normally, you don't need to call this function, it's used internally by [`CompilerBuilder::build`].
16071648 ///
16081649 /// [`ModuleOptions`]: rspack_core::options::ModuleOptions
1650+ #[ must_use]
16091651 fn build (
16101652 & mut self ,
16111653 _builder_context : & mut BuilderContext ,
@@ -2566,6 +2608,7 @@ impl OutputOptionsBuilder {
25662608 ///
25672609 /// [`OutputOptions`]: rspack_core::options::OutputOptions
25682610 #[ allow( clippy:: too_many_arguments, clippy:: fn_params_excessive_bools) ]
2611+ #[ must_use]
25692612 fn build (
25702613 & mut self ,
25712614 builder_context : & mut BuilderContext ,
@@ -3322,6 +3365,7 @@ impl OptimizationOptionsBuilder {
33223365 /// Build [`Optimization`] from options.
33233366 ///
33243367 /// [`Optimization`]: rspack_core::options::Optimization
3368+ #[ must_use]
33253369 fn build (
33263370 & mut self ,
33273371 builder_context : & mut BuilderContext ,
@@ -3669,6 +3713,7 @@ impl ExperimentsBuilder {
36693713 /// Build [`Experiments`] from options.
36703714 ///
36713715 /// [`Experiments`]: rspack_core::options::Experiments
3716+ #[ must_use]
36723717 fn build (
36733718 & mut self ,
36743719 _builder_context : & mut BuilderContext ,
@@ -3759,7 +3804,7 @@ mod test {
37593804
37603805 #[ test]
37613806 fn mutable_builder_into_owned_builder ( ) {
3762- CompilerOptions :: builder ( )
3807+ let _ = CompilerOptions :: builder ( )
37633808 . optimization ( OptimizationOptionsBuilder :: default ( ) . node_env ( "development" . to_string ( ) ) )
37643809 . output ( OutputOptionsBuilder :: default ( ) . charset ( true ) )
37653810 . experiments ( ExperimentsBuilder :: default ( ) . future_defaults ( true ) )
0 commit comments