@@ -25,6 +25,21 @@ module.exports = (a, b) => {
25
25
// return the fully merged config
26
26
return mergedConfig
27
27
}
28
+
29
+ /**
30
+ * Normalize plugin spec before comparing so
31
+ * - `gatsby-plugin-name`
32
+ * - { resolve: `gatsby-plugin-name` }
33
+ * - { resolve: `gatsby-plugin-name`, options: {} }
34
+ * are all considered equal
35
+ */
36
+ const normalizePluginEntry = entry =>
37
+ _ . isString ( entry )
38
+ ? { resolve : entry , options : { } }
39
+ : _ . isObject ( entry )
40
+ ? { options : { } , ...entry }
41
+ : entry
42
+
28
43
const howToMerge = {
29
44
/**
30
45
* pick a truthy value by default.
@@ -34,6 +49,9 @@ const howToMerge = {
34
49
byDefault : ( a , b ) => b || a ,
35
50
siteMetadata : ( objA , objB ) => _ . merge ( { } , objA , objB ) ,
36
51
// plugins are concatenated and uniq'd, so we don't get two of the same plugin value
37
- plugins : ( a = [ ] , b = [ ] ) => _ . uniqWith ( a . concat ( b ) , _ . isEqual ) ,
52
+ plugins : ( a = [ ] , b = [ ] ) =>
53
+ _ . uniqWith ( a . concat ( b ) , ( a , b ) =>
54
+ _ . isEqual ( normalizePluginEntry ( a ) , normalizePluginEntry ( b ) )
55
+ ) ,
38
56
mapping : ( objA , objB ) => _ . merge ( { } , objA , objB ) ,
39
57
}
0 commit comments