From 0f3fa4e6aca1e250da7bce5cf8de0d24b0d9af44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20R=C3=B6tsch?= Date: Wed, 7 Apr 2021 12:26:44 +0200 Subject: [PATCH] fix(contentful): make gatsby-plugin-image a peer dependency (#30709) fixes #30519 --- packages/gatsby-source-contentful/package.json | 2 +- .../gatsby-source-contentful/src/extend-node-type.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/gatsby-source-contentful/package.json b/packages/gatsby-source-contentful/package.json index 6d16fdb432471..d5ad72bd5ac9b 100644 --- a/packages/gatsby-source-contentful/package.json +++ b/packages/gatsby-source-contentful/package.json @@ -18,7 +18,6 @@ "contentful": "^8.1.7", "fs-extra": "^9.1.0", "gatsby-core-utils": "^2.3.0-next.0", - "gatsby-plugin-image": "^1.3.0-next.1", "gatsby-plugin-utils": "^1.3.0-next.0", "gatsby-source-filesystem": "^3.3.0-next.0", "is-online": "^8.5.1", @@ -45,6 +44,7 @@ "license": "MIT", "peerDependencies": { "gatsby": "^3.0.0-next.0", + "gatsby-plugin-image": "^1.3.0-next.1", "gatsby-plugin-sharp": "^3.0.0-next.0", "sharp": "^0.26.0" }, diff --git a/packages/gatsby-source-contentful/src/extend-node-type.js b/packages/gatsby-source-contentful/src/extend-node-type.js index ca87598d2ab1c..fb7b2ab28a6f8 100644 --- a/packages/gatsby-source-contentful/src/extend-node-type.js +++ b/packages/gatsby-source-contentful/src/extend-node-type.js @@ -15,10 +15,6 @@ const { GraphQLList, } = require(`gatsby/graphql`) const qs = require(`qs`) -const { generateImageData } = require(`gatsby-plugin-image`) -const { - getGatsbyImageFieldConfig, -} = require(`gatsby-plugin-image/graphql-utils`) const { stripIndent } = require(`common-tags`) const cacheImage = require(`./cache-image`) @@ -720,6 +716,8 @@ exports.extendNodeType = ({ type, store }) => { const resolveGatsbyImageData = async (image, options) => { if (!isImage(image)) return null + const { generateImageData } = require(`gatsby-plugin-image`) + const { baseUrl, contentType, width, height } = getBasicImageProps( image, options @@ -773,6 +771,10 @@ exports.extendNodeType = ({ type, store }) => { // gatsby-plugin-image const getGatsbyImageData = () => { + const { + getGatsbyImageFieldConfig, + } = require(`gatsby-plugin-image/graphql-utils`) + const fieldConfig = getGatsbyImageFieldConfig(resolveGatsbyImageData, { jpegProgressive: { type: GraphQLBoolean,