From d34a9f084d61611049e8b0f837306972bc6236c3 Mon Sep 17 00:00:00 2001 From: Waylon Walker Date: Sun, 7 Oct 2018 18:35:18 -0500 Subject: [PATCH 1/9] Clear _libvips cache on windows This will help folks having installation issues on windows resolve without opening an issue. This issue has been seen in Issue https://github.com/lovell/sharp/issues/1382, https://github.com/lovell/sharp/issues/1387, and in #8325. --- docs/docs/gatsby-on-windows.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/docs/gatsby-on-windows.md b/docs/docs/gatsby-on-windows.md index 9ec2d576e4283..e796bca564f22 100644 --- a/docs/docs/gatsby-on-windows.md +++ b/docs/docs/gatsby-on-windows.md @@ -78,3 +78,8 @@ further instructions and contact the `node-gyp`team on ## gatsby-plugin-sharp requires Node x64 Some plugins which depend on native NPM dependencies require the Node x64 build of Node.js. If you're struggling to install gatsby-plugin-sharp, try installing Node x64 and removing `node_modules` and running `npm install`. + +## gatsby-plugin-sharp requires libvips + +Sharp uses a c library, libvips, if you are having issuees while installing sharp try removing ```C:\Users\[user]\AppData\Roaming\npm-cache\_libvips``` + From ca54dd62c09c1ee98c6d27177e1dd90670c0a94c Mon Sep 17 00:00:00 2001 From: Waylon Walker Date: Mon, 8 Oct 2018 20:45:28 -0500 Subject: [PATCH 2/9] updating to sharp 0.21.0 Changes per @lovell to update to sharp ```^0.21.0``` - .resize(options.width, options.height) - .crop(options.cropFocus) + .resize(options.width, options.height, { + position: options.cropFocus + }) ** note I was unable to clone the full repo due to poor connection... attempting from the github interface. --- packages/gatsby-plugin-sharp/src/index.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/gatsby-plugin-sharp/src/index.js b/packages/gatsby-plugin-sharp/src/index.js index 8f5fed6e6ab84..ae29a460294c7 100644 --- a/packages/gatsby-plugin-sharp/src/index.js +++ b/packages/gatsby-plugin-sharp/src/index.js @@ -143,8 +143,9 @@ const processFile = (file, jobs, cb, reporter) => { } clonedPipeline - .resize(roundedWidth, roundedHeight) - .crop(args.cropFocus) + .resize(roundedWidth, roundedHeight, { + position: options.cropFocus + }) .png({ compressionLevel: args.pngCompressionLevel, adaptiveFiltering: false, @@ -444,8 +445,9 @@ async function notMemoizedbase64({ file, args = {}, reporter }) { } pipeline - .resize(options.width, options.height) - .crop(options.cropFocus) + .resize(options.width, options.height, { + position: options.cropFocus + }) .png({ compressionLevel: options.pngCompressionLevel, adaptiveFiltering: false, @@ -769,8 +771,9 @@ async function notMemoizedtraceSVG({ file, args, fileArgs, reporter }) { } pipeline - .resize(options.width, options.height) - .crop(options.cropFocus) + .resize(options.width, options.height, { + position: options.cropFocus + }) .png({ compressionLevel: options.pngCompressionLevel, adaptiveFiltering: false, From 3e9003066fbf4d0cdbf8d497527a39594f9ffac6 Mon Sep 17 00:00:00 2001 From: Waylon Walker Date: Mon, 8 Oct 2018 20:46:17 -0500 Subject: [PATCH 3/9] Updated sharp version --- packages/gatsby-plugin-sharp/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby-plugin-sharp/package.json b/packages/gatsby-plugin-sharp/package.json index ed9bc739e8f6e..4005a1d3867b0 100644 --- a/packages/gatsby-plugin-sharp/package.json +++ b/packages/gatsby-plugin-sharp/package.json @@ -20,7 +20,7 @@ "potrace": "^2.1.1", "probe-image-size": "^4.0.0", "progress": "^1.1.8", - "sharp": "^0.20.2", + "sharp": "^0.21.0", "svgo": "^0.7.2" }, "devDependencies": { From de0c7b1f3ac4b07ce0c62aa7b5ebdd37c01d531e Mon Sep 17 00:00:00 2001 From: Waylon Walker Date: Mon, 8 Oct 2018 21:26:27 -0500 Subject: [PATCH 4/9] Fixed trailing commas added trailing commas to linting test --- packages/gatsby-plugin-sharp/src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/gatsby-plugin-sharp/src/index.js b/packages/gatsby-plugin-sharp/src/index.js index ae29a460294c7..08b8063d97e26 100644 --- a/packages/gatsby-plugin-sharp/src/index.js +++ b/packages/gatsby-plugin-sharp/src/index.js @@ -144,7 +144,7 @@ const processFile = (file, jobs, cb, reporter) => { clonedPipeline .resize(roundedWidth, roundedHeight, { - position: options.cropFocus + position: options.cropFocus, }) .png({ compressionLevel: args.pngCompressionLevel, @@ -446,7 +446,7 @@ async function notMemoizedbase64({ file, args = {}, reporter }) { pipeline .resize(options.width, options.height, { - position: options.cropFocus + position: options.cropFocus, }) .png({ compressionLevel: options.pngCompressionLevel, @@ -772,7 +772,7 @@ async function notMemoizedtraceSVG({ file, args, fileArgs, reporter }) { pipeline .resize(options.width, options.height, { - position: options.cropFocus + position: options.cropFocus, }) .png({ compressionLevel: options.pngCompressionLevel, From 1619af39824b619e33d81cbf2f2a177d2b00022a Mon Sep 17 00:00:00 2001 From: Waylon Walker Date: Mon, 8 Oct 2018 21:27:58 -0500 Subject: [PATCH 5/9] fix options is not defined added options to jobs.forEach block --- packages/gatsby-plugin-sharp/src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/gatsby-plugin-sharp/src/index.js b/packages/gatsby-plugin-sharp/src/index.js index 08b8063d97e26..62a6d35ee7a3b 100644 --- a/packages/gatsby-plugin-sharp/src/index.js +++ b/packages/gatsby-plugin-sharp/src/index.js @@ -124,6 +124,7 @@ const processFile = (file, jobs, cb, reporter) => { jobs.forEach(async job => { const args = job.args + const options = healOptions(args, {}) let clonedPipeline if (jobs.length > 1) { clonedPipeline = pipeline.clone() From 4d57968af93324bd9437745e898765f391490cd1 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Tue, 23 Oct 2018 18:15:37 +0200 Subject: [PATCH 6/9] upgrade sharp package everywhere --- packages/gatsby-plugin-manifest/package.json | 2 +- .../package.json | 2 +- .../gatsby-transformer-sharp/package.json | 2 +- yarn.lock | 57 +++++++++++++++++++ 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/packages/gatsby-plugin-manifest/package.json b/packages/gatsby-plugin-manifest/package.json index f4e4151e106e3..8b3dff1c200c1 100644 --- a/packages/gatsby-plugin-manifest/package.json +++ b/packages/gatsby-plugin-manifest/package.json @@ -9,7 +9,7 @@ "dependencies": { "@babel/runtime": "^7.0.0", "bluebird": "^3.5.0", - "sharp": "^0.20.2" + "sharp": "^0.21.0" }, "devDependencies": { "@babel/cli": "^7.0.0", diff --git a/packages/gatsby-remark-images-contentful/package.json b/packages/gatsby-remark-images-contentful/package.json index ad5822701145c..eed9df47e36e7 100644 --- a/packages/gatsby-remark-images-contentful/package.json +++ b/packages/gatsby-remark-images-contentful/package.json @@ -14,7 +14,7 @@ "cheerio": "^1.0.0-rc.2", "is-relative-url": "^2.0.0", "lodash": "^4.17.10", - "sharp": "^0.20.2", + "sharp": "^0.21.0", "unist-util-select": "^1.5.0" }, "devDependencies": { diff --git a/packages/gatsby-transformer-sharp/package.json b/packages/gatsby-transformer-sharp/package.json index c85e4b7586108..e219897a77d79 100644 --- a/packages/gatsby-transformer-sharp/package.json +++ b/packages/gatsby-transformer-sharp/package.json @@ -12,7 +12,7 @@ "fs-extra": "^4.0.2", "potrace": "^2.1.1", "probe-image-size": "^4.0.0", - "sharp": "^0.20.2" + "sharp": "^0.21.0" }, "devDependencies": { "@babel/cli": "^7.0.0", diff --git a/yarn.lock b/yarn.lock index 4b6f284d61303..f419016960da8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12912,6 +12912,11 @@ nan@^2.11.0, nan@^2.9.2: resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.0.tgz#574e360e4d954ab16966ec102c0c049fd961a099" integrity sha512-F4miItu2rGnV2ySkXOQoA8FKz/SR2Q2sWP0sbTxNxz/tuokeC8WxOhPMcwi0qIyGtVn/rrSeLbvVkznqCdwYnw== +nan@^2.11.1: + version "2.11.1" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.1.tgz#90e22bccb8ca57ea4cd37cc83d3819b52eea6766" + integrity sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA== + nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" @@ -12929,6 +12934,11 @@ nanomatch@^1.2.9: snapdragon "^0.8.1" to-regex "^3.0.1" +napi-build-utils@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.1.tgz#1381a0f92c39d66bf19852e7873432fc2123e508" + integrity sha512-boQj1WFgQH3v4clhu3mTNfP+vOBxorDlE8EKiMjUlLG3C4qAESnn9AxIOkFgTR2c9LtzNjPrjS60cT27ZKBhaA== + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" @@ -14819,6 +14829,28 @@ prebuild-install@^4.0.0: tunnel-agent "^0.6.0" which-pm-runs "^1.0.0" +prebuild-install@^5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-5.2.1.tgz#87ba8cf17c65360a75eefeb3519e87973bf9791d" + integrity sha512-9DAccsInWHB48TBQi2eJkLPE049JuAI6FjIH0oIrij4bpDVEbX6JvlWRAcAAlUqBHhjgq0jNqA3m3bBXWm9v6w== + dependencies: + detect-libc "^1.0.3" + expand-template "^1.0.2" + github-from-package "0.0.0" + minimist "^1.2.0" + mkdirp "^0.5.1" + napi-build-utils "^1.0.1" + node-abi "^2.2.0" + noop-logger "^0.1.1" + npmlog "^4.0.1" + os-homedir "^1.0.1" + pump "^2.0.1" + rc "^1.2.7" + simple-get "^2.7.0" + tar-fs "^1.13.0" + tunnel-agent "^0.6.0" + which-pm-runs "^1.0.0" + prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -16756,6 +16788,22 @@ sharp@^0.20.2: tar "^4.4.6" tunnel-agent "^0.6.0" +sharp@^0.21.0: + version "0.21.0" + resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.21.0.tgz#e3cf2e4cb9382caf78efb3d45252381730e899c4" + integrity sha512-qr6yMl0ju8EGMtjIj5U1Ojj8sKuZ99/DQaNKWmoFHxqg3692AFSrEiPI/yr0O05OWtGD8LuCw8WSGmnZcNrZaA== + dependencies: + color "^3.0.0" + detect-libc "^1.0.3" + fs-copy-file-sync "^1.1.1" + nan "^2.11.1" + npmlog "^4.1.2" + prebuild-install "^5.2.0" + semver "^5.5.1" + simple-get "^3.0.3" + tar "^4.4.6" + tunnel-agent "^0.6.0" + shebang-command@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" @@ -16822,6 +16870,15 @@ simple-get@^2.7.0, simple-get@^2.8.1: once "^1.3.1" simple-concat "^1.0.0" +simple-get@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-3.0.3.tgz#924528ac3f9d7718ce5e9ec1b1a69c0be4d62efa" + integrity sha512-Wvre/Jq5vgoz31Z9stYWPLn0PqRqmBDpFSdypAnHu5AvRVCYPRYGnvryNLiXu8GOBNDH82J2FRHUGMjjHUpXFw== + dependencies: + decompress-response "^3.3.0" + once "^1.3.1" + simple-concat "^1.0.0" + simple-swizzle@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" From c02967fc36deced4cefe7cf952b5a9178d772552 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Tue, 23 Oct 2018 18:18:47 +0200 Subject: [PATCH 7/9] update yarn.lock --- yarn.lock | 49 ++++++------------------------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/yarn.lock b/yarn.lock index 0293d2789da3d..49f878e267a66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12903,16 +12903,16 @@ name-all-modules-plugin@^1.0.1: resolved "https://registry.yarnpkg.com/name-all-modules-plugin/-/name-all-modules-plugin-1.0.1.tgz#0abfb6ad835718b9fb4def0674e06657a954375c" integrity sha1-Cr+2rYNXGLn7Te8GdOBmV6lUN1w= -nan@^2.11.0, nan@^2.9.2: - version "2.11.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.0.tgz#574e360e4d954ab16966ec102c0c049fd961a099" - integrity sha512-F4miItu2rGnV2ySkXOQoA8FKz/SR2Q2sWP0sbTxNxz/tuokeC8WxOhPMcwi0qIyGtVn/rrSeLbvVkznqCdwYnw== - nan@^2.11.1: version "2.11.1" resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.1.tgz#90e22bccb8ca57ea4cd37cc83d3819b52eea6766" integrity sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA== +nan@^2.9.2: + version "2.11.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.0.tgz#574e360e4d954ab16966ec102c0c049fd961a099" + integrity sha512-F4miItu2rGnV2ySkXOQoA8FKz/SR2Q2sWP0sbTxNxz/tuokeC8WxOhPMcwi0qIyGtVn/rrSeLbvVkznqCdwYnw== + nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" @@ -14814,27 +14814,6 @@ potrace@^2.1.1: dependencies: jimp "^0.2.24" -prebuild-install@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-4.0.0.tgz#206ce8106ce5efa4b6cf062fc8a0a7d93c17f3a8" - integrity sha512-7tayxeYboJX0RbVzdnKyGl2vhQRWr6qfClEXDhOkXjuaOKCw2q8aiuFhONRYVsG/czia7KhpykIlI2S2VaPunA== - dependencies: - detect-libc "^1.0.3" - expand-template "^1.0.2" - github-from-package "0.0.0" - minimist "^1.2.0" - mkdirp "^0.5.1" - node-abi "^2.2.0" - noop-logger "^0.1.1" - npmlog "^4.0.1" - os-homedir "^1.0.1" - pump "^2.0.1" - rc "^1.1.6" - simple-get "^2.7.0" - tar-fs "^1.13.0" - tunnel-agent "^0.6.0" - which-pm-runs "^1.0.0" - prebuild-install@^5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-5.2.1.tgz#87ba8cf17c65360a75eefeb3519e87973bf9791d" @@ -16785,22 +16764,6 @@ shallowequal@^1.0.2: resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8" integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ== -sharp@^0.20.2: - version "0.20.8" - resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.20.8.tgz#e853f10b53b730824f0c3c5e453c79fa0812a48b" - integrity sha512-A8NaPGWRDKpmHTi8sl2xzozYXhTQWBb/GaJ8ZPU7L/vKW8wVvd4Yq+isJ0c7p9sX5gnjPQcM3eOfHuvvnZ2fOQ== - dependencies: - color "^3.0.0" - detect-libc "^1.0.3" - fs-copy-file-sync "^1.1.1" - nan "^2.11.0" - npmlog "^4.1.2" - prebuild-install "^4.0.0" - semver "^5.5.1" - simple-get "^2.8.1" - tar "^4.4.6" - tunnel-agent "^0.6.0" - sharp@^0.21.0: version "0.21.0" resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.21.0.tgz#e3cf2e4cb9382caf78efb3d45252381730e899c4" @@ -16874,7 +16837,7 @@ simple-concat@^1.0.0: resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.0.tgz#7344cbb8b6e26fb27d66b2fc86f9f6d5997521c6" integrity sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY= -simple-get@^2.7.0, simple-get@^2.8.1: +simple-get@^2.7.0: version "2.8.1" resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-2.8.1.tgz#0e22e91d4575d87620620bc91308d57a77f44b5d" integrity sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw== From a1cd2f97daa59d2133dccac649784cbb3285fcf9 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Tue, 23 Oct 2018 19:06:51 +0200 Subject: [PATCH 8/9] don't heal options at this stage --- packages/gatsby-plugin-sharp/src/index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/gatsby-plugin-sharp/src/index.js b/packages/gatsby-plugin-sharp/src/index.js index 37687f82f1323..88b899e23263a 100644 --- a/packages/gatsby-plugin-sharp/src/index.js +++ b/packages/gatsby-plugin-sharp/src/index.js @@ -124,7 +124,6 @@ const processFile = (file, jobs, cb, reporter) => { jobs.forEach(async job => { const args = job.args - const options = healOptions(args, {}) let clonedPipeline if (jobs.length > 1) { clonedPipeline = pipeline.clone() @@ -145,7 +144,7 @@ const processFile = (file, jobs, cb, reporter) => { clonedPipeline .resize(roundedWidth, roundedHeight, { - position: options.cropFocus, + position: args.cropFocus, }) .png({ compressionLevel: args.pngCompressionLevel, @@ -524,7 +523,11 @@ async function fluid({ file, args = {}, reporter }) { options.maxWidth === undefined ? `maxHeight` : `maxWidth` if (options[fixedDimension] < 1) { - throw new Error(`${fixedDimension} has to be a positive int larger than zero (> 0), now it's ${options[fixedDimension]}`) + throw new Error( + `${fixedDimension} has to be a positive int larger than zero (> 0), now it's ${ + options[fixedDimension] + }` + ) } let presentationWidth, presentationHeight @@ -566,9 +569,11 @@ async function fluid({ file, args = {}, reporter }) { fluidSizes.push(options[fixedDimension] * 2) fluidSizes.push(options[fixedDimension] * 3) } else { - options.srcSetBreakpoints.forEach((breakpoint) => { + options.srcSetBreakpoints.forEach(breakpoint => { if (breakpoint < 1) { - throw new Error(`All ints in srcSetBreakpoints should be positive ints larger than zero (> 0), found ${breakpoint}`) + throw new Error( + `All ints in srcSetBreakpoints should be positive ints larger than zero (> 0), found ${breakpoint}` + ) } // ensure no duplicates are added if (fluidSizes.includes(breakpoint)) { From a8e71b0eddc1ecd1c6994292c190eacb78bcefb1 Mon Sep 17 00:00:00 2001 From: shannonbux <32467162+shannonbux@users.noreply.github.com> Date: Tue, 23 Oct 2018 16:59:41 -0600 Subject: [PATCH 9/9] minor punctuation --- docs/docs/gatsby-on-windows.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/gatsby-on-windows.md b/docs/docs/gatsby-on-windows.md index 9580078017ea1..845c87102045e 100644 --- a/docs/docs/gatsby-on-windows.md +++ b/docs/docs/gatsby-on-windows.md @@ -81,7 +81,7 @@ Some plugins which depend on native NPM dependencies require the Node x64 build ## gatsby-plugin-sharp requires libvips -Sharp uses a c library, libvips, if you are having issuees while installing sharp try removing ```C:\Users\[user]\AppData\Roaming\npm-cache\_libvips``` +Sharp uses a c library, libvips. If you are having issues while installing Sharp, try removing ```C:\Users\[user]\AppData\Roaming\npm-cache\_libvips```. ## Windows Subsystem for Linux