@@ -44,7 +44,26 @@ export class DtsPlugin implements WebpackPluginInstance {
44
44
apply ( compiler : Compiler ) {
45
45
const { options } = this ;
46
46
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
+ ) ;
48
67
49
68
if ( typeof normalizedDtsOptions !== 'object' ) {
50
69
return ;
@@ -67,22 +86,22 @@ export class DtsPlugin implements WebpackPluginInstance {
67
86
// Because the plugin will delete dist/@mf -types.zip while generating types, which will be used in GenerateTypesPlugin
68
87
// So it should apply after GenerateTypesPlugin
69
88
new DevPlugin (
70
- options ,
89
+ clonedOptions ,
71
90
normalizedDtsOptions ,
72
91
generateTypesPromise ,
73
92
fetchRemoteTypeUrlsPromise ,
74
93
) . apply ( compiler ) ;
75
94
76
95
// The exposes files may use remote types, so it need to consume types first, otherwise the generate types will fail
77
96
new GenerateTypesPlugin (
78
- options ,
97
+ clonedOptions ,
79
98
normalizedDtsOptions ,
80
99
fetchRemoteTypeUrlsPromise ,
81
100
generateTypesPromiseResolve ,
82
101
) . apply ( compiler ) ;
83
102
84
103
new ConsumeTypesPlugin (
85
- options ,
104
+ clonedOptions ,
86
105
normalizedDtsOptions ,
87
106
fetchRemoteTypeUrlsResolve ,
88
107
) . apply ( compiler ) ;
0 commit comments