Skip to content

Commit

Permalink
Revert "feat(next/image)!: remove squoosh in favor of sharp as op…
Browse files Browse the repository at this point in the history
…tional dep" (#61810)

Reverts #61696

Closes NEXT-2401
  • Loading branch information
feedthejim authored Feb 8, 2024
1 parent b387842 commit feb27ad
Show file tree
Hide file tree
Showing 63 changed files with 12,988 additions and 976 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/**/*image*/** @timneutkens @ijjk @shuding @styfle @huozhi @ztanner @vercel/devex
/**/*img* @timneutkens @ijjk @shuding @styfle @huozhi @ztanner @vercel/devex
/packages/next/client/use-intersection.tsx @timneutkens @ijjk @shuding @styfle
/packages/next/server/lib/squoosh/ @timneutkens @ijjk @shuding @styfle
/packages/next/server/serve-static.ts @timneutkens @ijjk @shuding @styfle @huozhi @ztanner
/packages/next/server/config.ts @timneutkens @ijjk @shuding @styfle @huozhi @ztanner

Expand Down
2 changes: 2 additions & 0 deletions docs/03-pages/02-api-reference/01-components/image-legacy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ If you need a different provider, you can use the [`loader`](#loader) prop with

> Images can not be optimized at build time using [`output: 'export'`](/docs/pages/building-your-application/deploying/static-exports), only on-demand. To use `next/legacy/image` with `output: 'export'`, you will need to use a different loader than the default. [Read more in the discussion.](https://github.com/vercel/next.js/discussions/19065)
> The `next/legacy/image` component's default loader uses [`squoosh`](https://www.npmjs.com/package/@squoosh/lib) because it is quick to install and suitable for a development environment. When using `next start` in your production environment, it is strongly recommended that you install [`sharp`](https://www.npmjs.com/package/sharp) by running `npm i sharp` in your project directory. This is not necessary for Vercel deployments, as `sharp` is installed automatically.
## Advanced

The following configuration is for advanced use cases and is usually not necessary. If you choose to configure the properties below, you will override any changes to the Next.js defaults in future updates.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"@types/react-dom": "18.2.15",
"@types/relay-runtime": "14.1.13",
"@types/selenium-webdriver": "4.0.15",
"@types/sharp": "0.29.3",
"@types/string-hash": "1.1.1",
"@types/trusted-types": "2.0.3",
"@typescript-eslint/eslint-plugin": "6.14.0",
Expand Down Expand Up @@ -157,7 +158,7 @@
"html-validator": "5.1.18",
"http-proxy": "1.18.1",
"husky": "8.0.0",
"image-size": "1.1.1",
"image-size": "0.9.3",
"is-animated": "2.0.2",
"isomorphic-unfetch": "3.0.0",
"jest": "29.7.0",
Expand Down
6 changes: 2 additions & 4 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@
"optional": true
}
},
"optionalDependencies": {
"sharp": "^0.33.2"
},
"devDependencies": {
"@ampproject/toolbox-optimizer": "2.8.3",
"@babel/code-frame": "7.22.5",
Expand Down Expand Up @@ -232,6 +229,7 @@
"events": "3.3.0",
"find-up": "4.1.0",
"fresh": "0.5.2",
"get-orientation": "1.1.2",
"glob": "7.1.7",
"gzip-size": "5.1.1",
"http-proxy": "1.18.1",
Expand All @@ -240,7 +238,7 @@
"https-proxy-agent": "5.0.1",
"icss-utils": "5.1.0",
"ignore-loader": "0.1.2",
"image-size": "1.1.1",
"image-size": "1.0.0",
"is-docker": "2.0.0",
"is-wsl": "2.2.0",
"jest-worker": "27.5.1",
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/build/collect-build-traces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ export async function collectBuildTraces({
// only ignore image-optimizer code when
// this is being handled outside of next-server
'**/next/dist/server/image-optimizer.js',
'**/next/dist/server/lib/squoosh/**/*.wasm',
]
: []),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function nextImageLoader(this: any, content: Buffer) {

const imageSizeSpan = imageLoaderSpan.traceChild('image-size-calculation')
const imageSize = await imageSizeSpan.traceAsyncFn(() =>
getImageSize(content).catch((err) => err)
getImageSize(content, extension).catch((err) => err)
)

if (imageSize instanceof Error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ async function nextMetadataImageLoader(
}

const imageSize: { width?: number; height?: number } = await getImageSize(
content
content,
extension as 'avif' | 'webp' | 'png' | 'jpeg'
).catch((err) => err)

if (imageSize instanceof Error) {
Expand Down
21 changes: 21 additions & 0 deletions packages/next/src/compiled/get-orientation/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

The MIT License (MIT)
Copyright © 2019 MooYeol Prescott Lee, http://debug.so <mooyoul@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
1 change: 1 addition & 0 deletions packages/next/src/compiled/get-orientation/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/next/src/compiled/get-orientation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"get-orientation","main":"index.js","author":"MooYeol Prescott Lee <mooyoul@gmail.com>","license":"MIT"}
2 changes: 1 addition & 1 deletion packages/next/src/compiled/image-size/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright © 2013-Present Aditya Yadav, http://netroy.in
Copyright © 2017 Aditya Yadav, http://netroy.in

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/compiled/image-size/index.js

Large diffs are not rendered by default.

Loading

0 comments on commit feb27ad

Please sign in to comment.