@@ -44,7 +44,26 @@ export class DtsPlugin implements WebpackPluginInstance {
4444 apply ( compiler : Compiler ) {
4545 const { options } = this ;
4646
47- const normalizedDtsOptions = normalizeDtsOptions ( options , compiler . context ) ;
47+ // Create a shallow clone of the options object to avoid mutating the original
48+ const clonedOptions = { ...options } ;
49+
50+ // Clean up query parameters in exposes paths without mutating original
51+ if ( options . exposes && typeof options . exposes === 'object' ) {
52+ const cleanedExposes : Record < string , any > = { } ;
53+ Object . entries ( options . exposes ) . forEach ( ( [ key , value ] ) => {
54+ if ( typeof value === 'string' ) {
55+ cleanedExposes [ key ] = value . split ( '?' ) [ 0 ] ;
56+ } else {
57+ cleanedExposes [ key ] = value ;
58+ }
59+ } ) ;
60+ clonedOptions . exposes = cleanedExposes ;
61+ }
62+
63+ const normalizedDtsOptions = normalizeDtsOptions (
64+ clonedOptions ,
65+ compiler . context ,
66+ ) ;
4867
4968 if ( typeof normalizedDtsOptions !== 'object' ) {
5069 return ;
@@ -67,22 +86,22 @@ export class DtsPlugin implements WebpackPluginInstance {
6786 // Because the plugin will delete dist/@mf -types.zip while generating types, which will be used in GenerateTypesPlugin
6887 // So it should apply after GenerateTypesPlugin
6988 new DevPlugin (
70- options ,
89+ clonedOptions ,
7190 normalizedDtsOptions ,
7291 generateTypesPromise ,
7392 fetchRemoteTypeUrlsPromise ,
7493 ) . apply ( compiler ) ;
7594
7695 // The exposes files may use remote types, so it need to consume types first, otherwise the generate types will fail
7796 new GenerateTypesPlugin (
78- options ,
97+ clonedOptions ,
7998 normalizedDtsOptions ,
8099 fetchRemoteTypeUrlsPromise ,
81100 generateTypesPromiseResolve ,
82101 ) . apply ( compiler ) ;
83102
84103 new ConsumeTypesPlugin (
85- options ,
104+ clonedOptions ,
86105 normalizedDtsOptions ,
87106 fetchRemoteTypeUrlsResolve ,
88107 ) . apply ( compiler ) ;
0 commit comments