Skip to content

Commit 22d303a

Browse files
committed
move safe-sharp to gatsby/sharp when available
1 parent 40b5e89 commit 22d303a

File tree

17 files changed

+197
-207
lines changed

17 files changed

+197
-207
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"npm-packlist": "^2.1.5",
6363
"npm-run-all": "4.1.5",
6464
"plop": "^1.9.1",
65-
"prettier": "2.5.1",
65+
"prettier": "^2.5.1",
6666
"remark": "^13.0.0",
6767
"remark-cli": "^9.0.0",
6868
"remark-frontmatter": "^3.0.0",

packages/gatsby-plugin-manifest/src/gatsby-node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as fs from "fs"
22
import * as path from "path"
3+
// TODO V5 use gatsby/sharp
34
import sharp from "./safe-sharp"
45
import { createContentDigest, slash } from "gatsby-core-utils"
56
import { defaultIcons, addDigestToPath, favicons } from "./common"

packages/gatsby-plugin-manifest/src/safe-sharp.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ try {
157157
originalConsoleError(msg, ...args)
158158
handleMessage(msg)
159159
}
160-
sharp = require(`sharp`)
160+
try {
161+
sharp = require(`gatsby/sharp`)
162+
} catch (e) {
163+
sharp = require(`sharp`)
164+
}
161165
} catch (e) {
162166
handleMessage(e.toString())
163167
throw e

packages/gatsby-plugin-sharp/src/duotone.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// TODO V5 use gatsby/sharp
12
const sharp = require(`./safe-sharp`)
23
const { reportError } = require(`./report-error`)
34

packages/gatsby-plugin-sharp/src/image-data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Reporter } from "gatsby/reporter"
55
import fs from "fs-extra"
66
import { rgbToHex, calculateImageSizes, getSrcSet, getSizes } from "./utils"
77
import { traceSVG, getImageSizeAsync, base64, batchQueueImageResizing } from "."
8+
// TODO V5 use gatsby/sharp
89
import sharp from "./safe-sharp"
910
import {
1011
createTransformObject,

packages/gatsby-plugin-sharp/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// TODO V5 use gatsby/sharp
12
const sharp = require(`./safe-sharp`)
23
const { generateImageData } = require(`./image-data`)
34
const imageSize = require(`probe-image-size`)

packages/gatsby-plugin-sharp/src/process-file.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// TODO V5 use gatsby/sharp
12
const sharp = require(`./safe-sharp`)
23
const fs = require(`fs-extra`)
34
const path = require(`path`)

packages/gatsby-plugin-sharp/src/safe-sharp.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ try {
157157
originalConsoleError(msg, ...args)
158158
handleMessage(msg)
159159
}
160-
sharp = require(`sharp`)
160+
try {
161+
sharp = require(`gatsby/sharp`)
162+
} catch (e) {
163+
sharp = require(`sharp`)
164+
}
161165
} catch (e) {
162166
handleMessage(e.toString())
163167
throw e

packages/gatsby-plugin-sharp/src/trace-svg.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const fs = require(`fs-extra`)
33
const _ = require(`lodash`)
44
const tmpDir = require(`os`).tmpdir()
55
const path = require(`path`)
6+
// TODO V5 use gatsby/sharp
67
const sharp = require(`./safe-sharp`)
78
const filenamify = require(`filenamify`)
89
const duotone = require(`./duotone`)

packages/gatsby-plugin-sharp/src/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// TODO V5 use gatsby/sharp
12
import sharp from "./safe-sharp"
23
import fs from "fs-extra"
34

0 commit comments

Comments
 (0)