Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade sharp to 0.21.0 #9318

Merged
merged 10 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions docs/docs/gatsby-on-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ further instructions and contact the `node-gyp`team on

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 issues while installing Sharp, try removing ```C:\Users\[user]\AppData\Roaming\npm-cache\_libvips```.

## Windows Subsystem for Linux

If the installation of dependencies or developing on Windows in general gives you headaches, Windows 10 provides a great alternative: [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/about). It lets you run most command-line tools, utilities, and applications in a GNU/Linux environment directly on Windows, unmodified, without the overhead of a virtual machine. In the above scenario you would download e.g. Ubuntu, open the terminal, [install Node](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions), and run `sudo apt-get install build-essential` in the terminal — and the compilation works way more reliable. Please note that you have to delete any existing `node_modules` folder in your project and re-install the dependencies in your WSL environment.
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-manifest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-sharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
27 changes: 18 additions & 9 deletions packages/gatsby-plugin-sharp/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ const processFile = (file, jobs, cb, reporter) => {
}

clonedPipeline
.resize(roundedWidth, roundedHeight)
.crop(args.cropFocus)
.resize(roundedWidth, roundedHeight, {
position: args.cropFocus,
})
.png({
compressionLevel: args.pngCompressionLevel,
adaptiveFiltering: false,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -521,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
Expand Down Expand Up @@ -563,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)) {
Expand Down Expand Up @@ -788,8 +796,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,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-remark-images-contentful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-transformer-sharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
48 changes: 34 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12903,7 +12903,12 @@ 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:
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==
Expand All @@ -12925,6 +12930,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"
Expand Down Expand Up @@ -14804,22 +14814,23 @@ 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==
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.1.6"
rc "^1.2.7"
simple-get "^2.7.0"
tar-fs "^1.13.0"
tunnel-agent "^0.6.0"
Expand Down Expand Up @@ -16753,19 +16764,19 @@ 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==
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.0"
nan "^2.11.1"
npmlog "^4.1.2"
prebuild-install "^4.0.0"
prebuild-install "^5.2.0"
semver "^5.5.1"
simple-get "^2.8.1"
simple-get "^3.0.3"
tar "^4.4.6"
tunnel-agent "^0.6.0"

Expand Down Expand Up @@ -16826,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==
Expand All @@ -16835,6 +16846,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"
Expand Down