diff --git a/packages/gatsby-source-contentful/src/gatsby-node.js b/packages/gatsby-source-contentful/src/gatsby-node.js index 1ca785d860af0..478172b58a0d5 100644 --- a/packages/gatsby-source-contentful/src/gatsby-node.js +++ b/packages/gatsby-source-contentful/src/gatsby-node.js @@ -333,25 +333,23 @@ exports.sourceNodes = async ( // Create a map of up to date entries and assets function mergeSyncData(previous, current, deleted) { const entryMap = new Map() - previous.forEach( - e => !deleted.includes(e.sys.id) && entryMap.set(e.sys.id, e) - ) - current.forEach( - e => !deleted.includes(e.sys.id) && entryMap.set(e.sys.id, e) - ) + previous.forEach(e => !deleted.has(e.sys.id) && entryMap.set(e.sys.id, e)) + current.forEach(e => !deleted.has(e.sys.id) && entryMap.set(e.sys.id, e)) return [...entryMap.values()] } + const deletedSet = new Set(currentSyncData.deletedEntries.map(e => e.sys.id)) + const mergedSyncData = { entries: mergeSyncData( previousSyncData.entries, currentSyncData.entries, - currentSyncData.deletedEntries.map(e => e.sys.id) + deletedSet ), assets: mergeSyncData( previousSyncData.assets, currentSyncData.assets, - currentSyncData.deletedAssets.map(e => e.sys.id) + deletedSet ), }