Skip to content

Commit

Permalink
perf(gatsby-plugin-mdx): lazily fetch file nodes for plugins (#27937)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdz committed Nov 10, 2020
1 parent 9a0546b commit e546e9a
Showing 1 changed file with 3 additions and 5 deletions.
Expand Up @@ -3,8 +3,6 @@ const _ = require(`lodash`)
const debug = require(`debug`)(`get-source-plugins-as-remark-plugins`)
const { interopDefault } = require(`./interop-default`)

let fileNodes

// ensure only one `/` in new url
const withPathPrefix = (url, pathPrefix) =>
(pathPrefix + url).replace(/\/\//, `/`)
Expand Down Expand Up @@ -39,8 +37,6 @@ module.exports = async function getSourcePluginsAsRemarkPlugins({
}
}

fileNodes = getNodesByType(`File`)

// return list of remarkPlugins
const userPlugins = gatsbyRemarkPlugins
.filter(plugin => {
Expand All @@ -62,7 +58,9 @@ module.exports = async function getSourcePluginsAsRemarkPlugins({
markdownNode: mdxNode,
getNode,
getNodesByType,
files: fileNodes,
get files() {
return getNodesByType(`File`)
},
pathPrefix,
reporter,
cache,
Expand Down

0 comments on commit e546e9a

Please sign in to comment.