diff --git a/packages/gatsby-transformer-remark/src/gatsby-node.js b/packages/gatsby-transformer-remark/src/gatsby-node.js index 97d50d35857db..f5c1d64afd7c0 100644 --- a/packages/gatsby-transformer-remark/src/gatsby-node.js +++ b/packages/gatsby-transformer-remark/src/gatsby-node.js @@ -1,6 +1,6 @@ -const { onCreateNode, shouldOnCreateNode } = require(`./on-node-create`) +const { onCreateNode, unstableShouldOnCreateNode } = require(`./on-node-create`) exports.onCreateNode = onCreateNode -exports.shouldOnCreateNode = shouldOnCreateNode +exports.unstableShouldOnCreateNode = unstableShouldOnCreateNode exports.createSchemaCustomization = require(`./create-schema-customization`) exports.setFieldsOnGraphQLNodeType = require(`./extend-node-type`) diff --git a/packages/gatsby-transformer-remark/src/on-node-create.js b/packages/gatsby-transformer-remark/src/on-node-create.js index f8fad4797fb28..d588afb01d09d 100644 --- a/packages/gatsby-transformer-remark/src/on-node-create.js +++ b/packages/gatsby-transformer-remark/src/on-node-create.js @@ -1,7 +1,7 @@ const grayMatter = require(`gray-matter`) const _ = require(`lodash`) -function shouldOnCreateNode(node) { +function unstableShouldOnCreateNode(node) { return ( node.internal.mediaType === `text/markdown` || node.internal.mediaType === `text/x-markdown` @@ -22,7 +22,7 @@ module.exports.onCreateNode = async function onCreateNode( const { createNode, createParentChildLink } = actions // We only care about markdown content. - if (!shouldOnCreateNode(node)) { + if (!unstableShouldOnCreateNode(node)) { return {} } @@ -81,4 +81,4 @@ module.exports.onCreateNode = async function onCreateNode( } } -module.exports.shouldOnCreateNode = shouldOnCreateNode +module.exports.unstableShouldOnCreateNode = unstableShouldOnCreateNode diff --git a/packages/gatsby-transformer-sharp/src/gatsby-node.js b/packages/gatsby-transformer-sharp/src/gatsby-node.js index 22e30bcbfcc45..9328f3b1358e4 100644 --- a/packages/gatsby-transformer-sharp/src/gatsby-node.js +++ b/packages/gatsby-transformer-sharp/src/gatsby-node.js @@ -1,5 +1,5 @@ -const { onCreateNode, shouldOnCreateNode } = require(`./on-node-create`) +const { onCreateNode, unstableShouldOnCreateNode } = require(`./on-node-create`) exports.onCreateNode = onCreateNode -exports.shouldOnCreateNode = shouldOnCreateNode +exports.unstableShouldOnCreateNode = unstableShouldOnCreateNode exports.createSchemaCustomization = require(`./customize-schema`) exports.createResolvers = require(`./create-resolvers`) diff --git a/packages/gatsby-transformer-sharp/src/on-node-create.js b/packages/gatsby-transformer-sharp/src/on-node-create.js index 2d75b0a97f440..aa8f6ef697cbf 100644 --- a/packages/gatsby-transformer-sharp/src/on-node-create.js +++ b/packages/gatsby-transformer-sharp/src/on-node-create.js @@ -1,6 +1,6 @@ const { supportedExtensions } = require(`./supported-extensions`) -function shouldOnCreateNode(node) { +function unstableShouldOnCreateNode(node) { return !!supportedExtensions[node.extension] } @@ -11,7 +11,7 @@ module.exports.onCreateNode = async function onCreateNode({ }) { const { createNode, createParentChildLink } = actions - if (!shouldOnCreateNode(node)) { + if (!unstableShouldOnCreateNode(node)) { return } @@ -31,4 +31,4 @@ module.exports.onCreateNode = async function onCreateNode({ return } -module.exports.shouldOnCreateNode = shouldOnCreateNode +module.exports.unstableShouldOnCreateNode = unstableShouldOnCreateNode diff --git a/packages/gatsby/index.d.ts b/packages/gatsby/index.d.ts index 39ed24b4db943..05b60169ac9b0 100644 --- a/packages/gatsby/index.d.ts +++ b/packages/gatsby/index.d.ts @@ -311,11 +311,11 @@ export interface GatsbyNode { * then Gatsby will not schedule the `onCreateNode` callback for this node for this plugin. * Note: this API does not receive the regular `api` that other callbacks get as first arg. * - * @gatsbyVersion 2.24.79 + * @gatsbyVersion 2.24.80 * @example - * exports.shouldOnCreateNode = (node, pluginOptions) => node.internal.type === 'Image' + * exports.unstableShouldOnCreateNode = (node, pluginOptions) => node.internal.type === 'Image' */ - shouldOnCreateNode?( + unstableShouldOnCreateNode?( node: TNode, ): boolean diff --git a/packages/gatsby/scripts/__tests__/api.js b/packages/gatsby/scripts/__tests__/api.js index ef90801d52e45..485ee7b235127 100644 --- a/packages/gatsby/scripts/__tests__/api.js +++ b/packages/gatsby/scripts/__tests__/api.js @@ -58,8 +58,8 @@ it("generates the expected api output", done => { "preprocessSource": Object {}, "resolvableExtensions": Object {}, "setFieldsOnGraphQLNodeType": Object {}, - "shouldOnCreateNode": Object { - "version": "2.24.79", + "unstableShouldOnCreateNode": Object { + "version": "2.24.80", }, "sourceNodes": Object {}, }, diff --git a/packages/gatsby/src/utils/api-node-docs.ts b/packages/gatsby/src/utils/api-node-docs.ts index ebc907636c081..d14630bc56664 100644 --- a/packages/gatsby/src/utils/api-node-docs.ts +++ b/packages/gatsby/src/utils/api-node-docs.ts @@ -138,11 +138,11 @@ export const onCreateNode = true * then Gatsby will not schedule the `onCreateNode` callback for this node for this plugin. * Note: this API does not receive the regular `api` that other callbacks get as first arg. * - * @gatsbyVersion 2.24.79 + * @gatsbyVersion 2.24.80 * @example - * exports.shouldOnCreateNode = (node, pluginOptions) => node.internal.type === 'Image' + * exports.unstableShouldOnCreateNode = (node, pluginOptions) => node.internal.type === 'Image' */ -export const shouldOnCreateNode = true +export const unstableShouldOnCreateNode = true /** * Called when a new page is created. This extension API is useful diff --git a/packages/gatsby/src/utils/api-runner-node.js b/packages/gatsby/src/utils/api-runner-node.js index 313d413e36f0c..53e2503261c4b 100644 --- a/packages/gatsby/src/utils/api-runner-node.js +++ b/packages/gatsby/src/utils/api-runner-node.js @@ -539,8 +539,8 @@ module.exports = async (api, args = {}, { pluginSource, activity } = {}) => // TODO: rethink createNode API to handle this better if ( api === `onCreateNode` && - gatsbyNode?.shouldOnCreateNode && // Don't bail if this api is not exported - !gatsbyNode.shouldOnCreateNode(args.node, plugin.pluginOptions) + gatsbyNode?.unstableShouldOnCreateNode && // Don't bail if this api is not exported + !gatsbyNode.unstableShouldOnCreateNode(args.node, plugin.pluginOptions) ) { // Do not try to schedule an async event for this node for this plugin return null