@@ -67,8 +67,11 @@ use rspack_plugin_ignore::IgnorePlugin;
6767use rspack_plugin_javascript:: {
6868 FlagDependencyExportsPlugin , FlagDependencyUsagePlugin , InferAsyncModulesPlugin ,
6969 InlineExportsPlugin , JsPlugin , MangleExportsPlugin , ModuleConcatenationPlugin ,
70- SideEffectsFlagPlugin , api_plugin:: APIPlugin , define_plugin:: DefinePlugin ,
71- provide_plugin:: ProvidePlugin , url_plugin:: URLPlugin ,
70+ SideEffectsFlagPlugin ,
71+ api_plugin:: APIPlugin ,
72+ define_plugin:: { DefinePlugin , DefineValue } ,
73+ provide_plugin:: ProvidePlugin ,
74+ url_plugin:: URLPlugin ,
7275} ;
7376use rspack_plugin_json:: JsonPlugin ;
7477use rspack_plugin_library:: enable_library_plugin;
@@ -301,11 +304,9 @@ impl<'a> BuiltinPlugin<'a> {
301304 match name {
302305 // webpack also have these plugins
303306 BuiltinPluginName :: DefinePlugin => {
304- let plugin = DefinePlugin :: new (
305- downcast_into ( self . options )
306- . map_err ( |report| napi:: Error :: from_reason ( report. to_string ( ) ) ) ?,
307- )
308- . boxed ( ) ;
307+ let definitions: DefineValue = downcast_into ( self . options )
308+ . map_err ( |report| napi:: Error :: from_reason ( report. to_string ( ) ) ) ?;
309+ let plugin = DefinePlugin :: new ( & definitions) . boxed ( ) ;
309310 plugins. push ( plugin) ;
310311 }
311312 BuiltinPluginName :: ProvidePlugin => {
@@ -393,12 +394,14 @@ impl<'a> BuiltinPlugin<'a> {
393394 BuiltinPluginName :: ElectronTargetPlugin => {
394395 let context = downcast_into :: < String > ( self . options )
395396 . map_err ( |report| napi:: Error :: from_reason ( report. to_string ( ) ) ) ?;
396- electron_target_plugin ( context. into ( ) , plugins) ;
397+ let context: ElectronTargetContext = context. into ( ) ;
398+ electron_target_plugin ( & context, plugins) ;
397399 }
398400 BuiltinPluginName :: EnableChunkLoadingPlugin => {
399401 let chunk_loading_type = downcast_into :: < String > ( self . options )
400402 . map_err ( |report| napi:: Error :: from_reason ( report. to_string ( ) ) ) ?;
401- enable_chunk_loading_plugin ( chunk_loading_type. as_str ( ) . into ( ) , plugins) ;
403+ let chunk_loading_type: ChunkLoadingType = chunk_loading_type. as_str ( ) . into ( ) ;
404+ enable_chunk_loading_plugin ( & chunk_loading_type, plugins) ;
402405 }
403406 BuiltinPluginName :: EnableLibraryPlugin => {
404407 let library_type = downcast_into :: < String > ( self . options )
@@ -408,9 +411,8 @@ impl<'a> BuiltinPlugin<'a> {
408411 BuiltinPluginName :: EnableWasmLoadingPlugin => {
409412 let wasm_loading_type = downcast_into :: < String > ( self . options )
410413 . map_err ( |report| napi:: Error :: from_reason ( report. to_string ( ) ) ) ?;
411- plugins. push ( enable_wasm_loading_plugin (
412- wasm_loading_type. as_str ( ) . into ( ) ,
413- ) ) ;
414+ let wasm_loading_type: WasmLoadingType = wasm_loading_type. as_str ( ) . into ( ) ;
415+ plugins. push ( enable_wasm_loading_plugin ( & wasm_loading_type) ) ;
414416 }
415417 BuiltinPluginName :: FetchCompileAsyncWasmPlugin => {
416418 plugins. push ( FetchCompileAsyncWasmPlugin :: default ( ) . boxed ( ) ) ;
@@ -580,7 +582,7 @@ impl<'a> BuiltinPlugin<'a> {
580582 . map_err ( |report| napi:: Error :: from_reason ( report. to_string ( ) ) ) ?
581583 . into ( ) ;
582584 plugins. push (
583- SourceMapDevToolModuleOptionsPlugin :: new ( SourceMapDevToolModuleOptionsPluginOptions {
585+ SourceMapDevToolModuleOptionsPlugin :: new ( & SourceMapDevToolModuleOptionsPluginOptions {
584586 module : options. module ,
585587 cheap : !options. columns ,
586588 } )
@@ -594,7 +596,7 @@ impl<'a> BuiltinPlugin<'a> {
594596 . map_err ( |report| napi:: Error :: from_reason ( report. to_string ( ) ) ) ?
595597 . into ( ) ;
596598 plugins. push (
597- SourceMapDevToolModuleOptionsPlugin :: new ( SourceMapDevToolModuleOptionsPluginOptions {
599+ SourceMapDevToolModuleOptionsPlugin :: new ( & SourceMapDevToolModuleOptionsPluginOptions {
598600 module : options. module ,
599601 cheap : !options. columns ,
600602 } )
0 commit comments