Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/gatsby-source-contentful/src/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { GatsbyNode } from "gatsby"
import origFetch from "node-fetch"
import fetchRetry from "@vercel/fetch-retry"
import { polyfillImageServiceDevRoutes } from "gatsby-plugin-utils/polyfill-remote-file"
import { hasFeature } from "gatsby-plugin-utils/has-feature"

import { CODES } from "./report"
import { maskText } from "./plugin-options"
Expand Down Expand Up @@ -47,6 +48,17 @@ export const onPreInit: GatsbyNode["onPreInit"] = async (
{ store, reporter, actions },
pluginOptions
) => {
// gatsby version is too old
if (!hasFeature(`track-inline-object-opt-out`)) {
reporter.panic({
id: CODES.GatsbyPluginMissing,
context: {
// TODO update message to reflect the actual version with track-inline-object-opt-out support
sourceMessage: `Used gatsby version is too old and doesn't support required features. Please update to gatsby@>=5.X.0`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be updated before the release once it's clear that Gatsby Version that will contain the addition.

For now it will mean that users will have to use gatsby@ctf-next (once new wave of canary is released that include this change) - so maybe temporarily we can use that version there whatever that will end up being?

},
})
}

// if gatsby-plugin-image is not installed
try {
await import(`gatsby-plugin-image/graphql-utils.js`)
Expand Down
6 changes: 6 additions & 0 deletions packages/gatsby-source-contentful/src/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const CODES = {
ContentTypesMissing: `111006`,
FetchTags: `111007`,
GenericContentfulError: `111008`,
GatsbyTooOld: `111009`,
}

interface IErrorMap {
Expand Down Expand Up @@ -57,4 +58,9 @@ export const ERROR_MAP: IErrorMap = {
level: `ERROR`,
category: `THIRD_PARTY`,
},
[CODES.GatsbyTooOld]: {
text: context => context.sourceMessage,
level: `ERROR`,
category: `USER`,
},
}
1 change: 1 addition & 0 deletions packages/gatsby/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type AvailableFeatures =
| "content-file-path"
| "stateful-source-nodes"
| "adapters"
| "track-inline-object-opt-out"

export {
Link,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/scripts/output-api-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function outputFile() {
}, {})

/** @type {Array<import("../index").AvailableFeatures>} */
output.features = ["image-cdn", "graphql-typegen", "content-file-path", "slices", "stateful-source-nodes", "adapters"];
output.features = ["image-cdn", "graphql-typegen", "content-file-path", "slices", "stateful-source-nodes", "adapters", "track-inline-object-opt-out"];

return fs.writeFile(
path.resolve(OUTPUT_FILE_NAME),
Expand Down