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

feat(next/image)!: remove squoosh in favor of sharp as optional dependency #63321

Merged
merged 13 commits into from
Apr 25, 2024
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
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
/**/*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: 0 additions & 2 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,8 +443,6 @@ 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: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
"@types/react-dom": "18.2.23",
"@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 @@ -160,7 +159,7 @@
"html-validator": "5.1.18",
"http-proxy": "1.18.1",
"husky": "8.0.0",
"image-size": "0.9.3",
"image-size": "1.1.1",
"is-animated": "2.0.2",
"isomorphic-unfetch": "3.0.0",
"jest": "29.7.0",
Expand Down
6 changes: 4 additions & 2 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
"optional": true
}
},
"optionalDependencies": {
"sharp": "^0.33.3"
},
"devDependencies": {
"@ampproject/toolbox-optimizer": "2.8.3",
"@babel/code-frame": "7.22.5",
Expand Down Expand Up @@ -234,7 +237,6 @@
"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 @@ -243,7 +245,7 @@
"https-proxy-agent": "5.0.1",
"icss-utils": "5.1.0",
"ignore-loader": "0.1.2",
"image-size": "1.0.0",
"image-size": "1.1.1",
"is-docker": "2.0.0",
"is-wsl": "2.2.0",
"jest-worker": "27.5.1",
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/build/collect-build-traces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ 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, extension).catch((err) => err)
getImageSize(content).catch((err) => err)
)

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

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

if (imageSize instanceof Error) {
Expand Down
21 changes: 0 additions & 21 deletions packages/next/src/compiled/get-orientation/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/src/compiled/get-orientation/index.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/src/compiled/get-orientation/package.json

This file was deleted.

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 © 2017 Aditya Yadav, http://netroy.in
Copyright © 2013-Present 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
Loading