Skip to content

Commit

Permalink
tmp test
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Jan 25, 2022
1 parent 34d1fc5 commit 9d0a414
Showing 1 changed file with 31 additions and 24 deletions.
55 changes: 31 additions & 24 deletions packages/gatsby-transformer-remark/src/extend-node-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,35 +188,42 @@ module.exports = function remarkExtendNodeType(
context
) {
const depCacheKey = getCacheKey(CACHE_TYPE_NODE_DEPS, markdownNode)
const dependencies = await cache.get(depCacheKey)

if (dependencies && context) {
for (const depNodeId of Object.keys(dependencies)) {
// get current contentDigest
const depNode = context.nodeModel.getNodeById({
id: depNodeId,
type: `File`,
})

if (!depNode) {
// the depNode was not found, probably deleted
// invalidate the cache so we can re-map dependencies
return undefined
}
try {
const dependencies = await cache.get(depCacheKey)

if (dependencies && context) {
for (const depNodeId of Object.keys(dependencies)) {
// get current contentDigest
const depNode = context.nodeModel.getNodeById({
id: depNodeId,
type: `File`,
})

if (!depNode) {
// the depNode was not found, probably deleted
// invalidate the cache so we can re-map dependencies
return undefined
}

const curDepDigest = depNode.internal.contentDigest
const prevDepDigest = dependencies[depNodeId]
const curDepDigest = depNode.internal.contentDigest
const prevDepDigest = dependencies[depNodeId]

// if the contentDigests don't match, we'll invalidate the cache
// this also causes a check of the depNodes, so we don't need to set them here
if (prevDepDigest !== curDepDigest) {
return undefined
// if the contentDigests don't match, we'll invalidate the cache
// this also causes a check of the depNodes, so we don't need to set them here
if (prevDepDigest !== curDepDigest) {
return undefined
}
}
}
}

const cachedValue = await cache.get(cacheKey)
return cachedValue
const cachedValue = await cache.get(cacheKey)
return cachedValue
} catch (e) {
console.log(`keys`, { depCacheKey, cacheKey })
console.log(`keys`, { depCacheKey, cacheKey })
console.log(`keys`, { depCacheKey, cacheKey })
throw e
}
}

async function getAST(markdownNode, context) {
Expand Down

0 comments on commit 9d0a414

Please sign in to comment.