@@ -98,9 +98,6 @@ type SideEffectsData struct {
98
98
type ResolveResult struct {
99
99
PathPair PathPair
100
100
101
- // If non-empty, this was the result of an "onResolve" plugin
102
- PluginName string
103
-
104
101
// If this was resolved by a plugin, the plugin gets to store its data here
105
102
PluginData interface {}
106
103
@@ -128,130 +125,6 @@ type ResolveResult struct {
128
125
UnusedImportsTS config.UnusedImportsTS
129
126
}
130
127
131
- func prettyPrintPluginName (prefix string , key string , value string ) string {
132
- if value == "" {
133
- return fmt .Sprintf ("%s %q: null," , prefix , key )
134
- }
135
- return fmt .Sprintf ("%s %q: %q," , prefix , key , value )
136
- }
137
-
138
- func prettyPrintPath (prefix string , key string , value logger.Path ) string {
139
- lines := []string {
140
- fmt .Sprintf ("%s %q: {" , prefix , key ),
141
- fmt .Sprintf ("%s \" text\" : %q," , prefix , value .Text ),
142
- fmt .Sprintf ("%s \" namespace\" : %q," , prefix , value .Namespace ),
143
- }
144
- if value .IgnoredSuffix != "" {
145
- lines = append (lines , fmt .Sprintf ("%s \" suffix\" : %q," , prefix , value .IgnoredSuffix ))
146
- }
147
- if value .IsDisabled () {
148
- lines = append (lines , fmt .Sprintf ("%s \" disabled\" : true," , prefix ))
149
- }
150
- lines = append (lines , fmt .Sprintf ("%s }," , prefix ))
151
- return strings .Join (lines , "\n " )
152
- }
153
-
154
- func prettyPrintStringArray (prefix string , key string , value []string ) string {
155
- return fmt .Sprintf ("%s %q: [%s]," , prefix , key , helpers .StringArrayToQuotedCommaSeparatedString (value ))
156
- }
157
-
158
- func prettyPrintTSTarget (prefix string , key string , value * config.TSTarget ) string {
159
- if value == nil {
160
- return fmt .Sprintf ("%s %q: null," , prefix , key )
161
- }
162
- return fmt .Sprintf ("%s %q: %q," , prefix , key , value .Target )
163
- }
164
-
165
- func prettyPrintModuleType (prefix string , key string , value js_ast.ModuleType ) string {
166
- kind := "null"
167
- if value .IsCommonJS () {
168
- kind = "\" commonjs\" "
169
- } else if value .IsESM () {
170
- kind = "\" module\" "
171
- }
172
- return fmt .Sprintf ("%s %q: %s," , prefix , key , kind )
173
- }
174
-
175
- func prettyPrintUnusedImports (prefix string , key string , value config.UnusedImportsTS ) string {
176
- source := "null"
177
- switch value {
178
- case config .UnusedImportsKeepStmtRemoveValues :
179
- source = "{ \" importsNotUsedAsValues\" : \" preserve\" }"
180
- case config .UnusedImportsKeepValues :
181
- source = "{ \" preserveValueImports\" : true }"
182
- }
183
- return fmt .Sprintf ("%s %q: %s," , prefix , key , source )
184
- }
185
-
186
- func (old * ResolveResult ) Compare (new * ResolveResult ) (diff []string ) {
187
- var oldDiff []string
188
- var newDiff []string
189
-
190
- if old .PluginName != new .PluginName {
191
- oldDiff = append (oldDiff , prettyPrintPluginName ("-" , "pluginName" , old .PluginName ))
192
- newDiff = append (newDiff , prettyPrintPluginName ("+" , "pluginName" , new .PluginName ))
193
- }
194
-
195
- if ! old .PathPair .Primary .IsEquivalentTo (new .PathPair .Primary ) {
196
- oldDiff = append (oldDiff , prettyPrintPath ("-" , "path" , old .PathPair .Primary ))
197
- newDiff = append (newDiff , prettyPrintPath ("+" , "path" , new .PathPair .Primary ))
198
- }
199
-
200
- if ! old .PathPair .Secondary .IsEquivalentTo (new .PathPair .Secondary ) {
201
- oldDiff = append (oldDiff , prettyPrintPath ("-" , "secondaryPath" , old .PathPair .Secondary ))
202
- newDiff = append (newDiff , prettyPrintPath ("+" , "secondaryPath" , new .PathPair .Secondary ))
203
- }
204
-
205
- if ! helpers .StringArraysEqual (old .JSXFactory , new .JSXFactory ) {
206
- oldDiff = append (oldDiff , prettyPrintStringArray ("-" , "jsxFactory" , old .JSXFactory ))
207
- newDiff = append (newDiff , prettyPrintStringArray ("+" , "jsxFactory" , new .JSXFactory ))
208
- }
209
-
210
- if ! helpers .StringArraysEqual (old .JSXFragment , new .JSXFragment ) {
211
- oldDiff = append (oldDiff , prettyPrintStringArray ("-" , "jsxFragment" , old .JSXFragment ))
212
- newDiff = append (newDiff , prettyPrintStringArray ("+" , "jsxFragment" , new .JSXFragment ))
213
- }
214
-
215
- if (old .PrimarySideEffectsData != nil ) != (new .PrimarySideEffectsData != nil ) {
216
- oldDiff = append (oldDiff , fmt .Sprintf ("- \" sideEffects\" : %v," , old .PrimarySideEffectsData != nil ))
217
- newDiff = append (newDiff , fmt .Sprintf ("+ \" sideEffects\" : %v," , new .PrimarySideEffectsData != nil ))
218
- }
219
-
220
- if ! old .TSTarget .IsEquivalentTo (new .TSTarget ) {
221
- oldDiff = append (oldDiff , prettyPrintTSTarget ("-" , "tsTarget" , old .TSTarget ))
222
- newDiff = append (newDiff , prettyPrintTSTarget ("+" , "tsTarget" , new .TSTarget ))
223
- }
224
-
225
- if ! old .ModuleTypeData .Type .IsEquivalentTo (new .ModuleTypeData .Type ) {
226
- oldDiff = append (oldDiff , prettyPrintModuleType ("-" , "type" , old .ModuleTypeData .Type ))
227
- newDiff = append (newDiff , prettyPrintModuleType ("+" , "type" , new .ModuleTypeData .Type ))
228
- }
229
-
230
- if old .IsExternal != new .IsExternal {
231
- oldDiff = append (oldDiff , fmt .Sprintf ("- \" external\" : %v," , old .IsExternal ))
232
- newDiff = append (newDiff , fmt .Sprintf ("+ \" external\" : %v," , new .IsExternal ))
233
- }
234
-
235
- if old .UseDefineForClassFieldsTS != new .UseDefineForClassFieldsTS {
236
- oldDiff = append (oldDiff , fmt .Sprintf ("- \" useDefineForClassFields\" : %v," , old .UseDefineForClassFieldsTS ))
237
- newDiff = append (newDiff , fmt .Sprintf ("+ \" useDefineForClassFields\" : %v," , new .UseDefineForClassFieldsTS ))
238
- }
239
-
240
- if old .UnusedImportsTS != new .UnusedImportsTS {
241
- oldDiff = append (oldDiff , prettyPrintUnusedImports ("-" , "unusedImports" , old .UnusedImportsTS ))
242
- newDiff = append (newDiff , prettyPrintUnusedImports ("+" , "unusedImports" , new .UnusedImportsTS ))
243
- }
244
-
245
- if oldDiff != nil {
246
- diff = make ([]string , 0 , 2 + len (oldDiff )+ len (newDiff ))
247
- diff = append (diff , " {" )
248
- diff = append (diff , oldDiff ... )
249
- diff = append (diff , newDiff ... )
250
- diff = append (diff , " }" )
251
- }
252
- return
253
- }
254
-
255
128
type DebugMeta struct {
256
129
suggestionText string
257
130
suggestionMessage string
0 commit comments