Skip to content

Commit 3ffc210

Browse files
authored
chore: Deprecate gatsby-image and old image resolvers (#29667)
* chore: Deprecate gatsby-image and old image resolvers * Add plugin name
1 parent b95a199 commit 3ffc210

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

packages/gatsby-image/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## :warning: This package is now deprecated
2+
3+
The `gatsby-image` package is now deprecated. The new [Gatsby image plugin](https://www.gatsbyjs.com/plugins/gatsby-plugin-image) has better performance, cool new features and a simpler API. See [the migration guide](https://www.gatsbyjs.com/docs/reference/release-notes/image-migration-guide/) to learn how to upgrade.
4+
15
# gatsby-image
26

37
Speedy, optimized images without the work.

packages/gatsby-plugin-image/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# gatsby-plugin-image (beta)
2-
3-
_The new Gatsby Image plugin is currently in beta, but you can try it out now_
1+
# gatsby-plugin-image
42

53
Adding responsive images to your site while maintaining high performance scores can be difficult to do manually. The Gatsby Image plugin handles the hard parts of producing images in multiple sizes and formats for you!
64

packages/gatsby-transformer-sharp/src/customize-schema.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ const {
4444
const { stripIndent } = require(`common-tags`)
4545
const { prefixId, CODES } = require(`./error-utils`)
4646

47+
let warnedForDeprecation = false
48+
49+
function warnForDeprecation() {
50+
if (warnedForDeprecation) {
51+
return
52+
}
53+
warnedForDeprecation = true
54+
console.warn(
55+
`[gatsby-transformer-sharp] The "fixed" and "fluid" resolvers are now deprecated. Switch to "gatsby-plugin-image" for better performance and a simpler API. See https://gatsby.dev/migrate-images to learn how.`
56+
)
57+
}
58+
4759
function toArray(buf) {
4860
const arr = new Array(buf.length)
4961

@@ -200,6 +212,7 @@ const fixedNodeType = ({
200212
},
201213
},
202214
resolve: (image, fieldArgs, context) => {
215+
warnForDeprecation()
203216
const file = getNodeAndSavePathDependency(image.parent, context.path)
204217
const args = { ...fieldArgs, pathPrefix }
205218
return Promise.resolve(
@@ -366,6 +379,7 @@ const fluidNodeType = ({
366379
},
367380
},
368381
resolve: (image, fieldArgs, context) => {
382+
warnForDeprecation()
369383
const file = getNodeAndSavePathDependency(image.parent, context.path)
370384
const args = { ...fieldArgs, pathPrefix }
371385
return Promise.resolve(
@@ -386,8 +400,6 @@ const fluidNodeType = ({
386400
}
387401
}
388402

389-
let warnedForBeta = false
390-
391403
const imageNodeType = ({
392404
pathPrefix,
393405
getNodeAndSavePathDependency,
@@ -515,13 +527,6 @@ const imageNodeType = ({
515527
reporter.warn(`Please upgrade gatsby-plugin-sharp`)
516528
return null
517529
}
518-
if (!warnedForBeta) {
519-
reporter.warn(
520-
stripIndent`
521-
Thank you for trying the beta version of the \`gatsbyImageData\` API. Please provide feedback and report any issues at: https://github.com/gatsbyjs/gatsby/discussions/27950`
522-
)
523-
warnedForBeta = true
524-
}
525530
const imageData = await generateImageData({
526531
file,
527532
args: fieldArgs,

0 commit comments

Comments
 (0)