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

Only ignore sharp if it's installed #21762

Closed
wants to merge 2 commits into from

Conversation

vtenfys
Copy link

@vtenfys vtenfys commented Feb 2, 2021

Fixes #20456

PR #20738 should probably be preferred, which I didn't spot before opening this PR

@ijjk
Copy link
Member

ijjk commented Feb 2, 2021

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
buildDuration 8.7s 8.6s -63ms
nodeModulesSize 75 MB 75 MB ⚠️ +297 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
/ failed reqs 0 0
/ total time (seconds) 1.723 1.791 ⚠️ +0.07
/ avg req/sec 1450.7 1395.57 ⚠️ -55.13
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.06 1.077 ⚠️ +0.02
/error-in-render avg req/sec 2357.46 2321.57 ⚠️ -35.89
Client Bundles (main, webpack, commons)
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
677f882d2ed8..49c4.js gzip 13.1 kB 13.1 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 6.63 kB 6.63 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 59.5 kB 59.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_app-2a09aa2..4a98.js gzip 1.28 kB 1.28 kB
_error-8b758..aef6.js gzip 3.46 kB 3.46 kB
hooks-c71ae4..70cd.js gzip 887 B 887 B
index-bbee2f..528b.js gzip 227 B 227 B
link-7faf09b..eba4.js gzip 1.64 kB 1.64 kB
routerDirect..bf84.js gzip 303 B 303 B
withRouter-a..5826.js gzip 302 B 302 B
Overall change 8.09 kB 8.09 kB
Client Build Manifests
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Rendered Page Sizes
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
index.html gzip 615 B 615 B
link.html gzip 621 B 621 B
withRouter.html gzip 609 B 609 B
Overall change 1.84 kB 1.84 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
buildDuration 10.3s 10.4s ⚠️ +139ms
nodeModulesSize 75 MB 75 MB ⚠️ +297 B
Client Bundles (main, webpack, commons)
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
677f882d2ed8..49c4.js gzip 13.1 kB 13.1 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 6.63 kB 6.63 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 59.5 kB 59.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_app-2a09aa2..4a98.js gzip 1.28 kB 1.28 kB
_error-8b758..aef6.js gzip 3.46 kB 3.46 kB
hooks-c71ae4..70cd.js gzip 887 B 887 B
index-bbee2f..528b.js gzip 227 B 227 B
link-7faf09b..eba4.js gzip 1.64 kB 1.64 kB
routerDirect..bf84.js gzip 303 B 303 B
withRouter-a..5826.js gzip 302 B 302 B
Overall change 8.09 kB 8.09 kB
Client Build Manifests
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Serverless bundles
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_error.js 1 MB 1 MB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB
link.js 1.06 MB 1.06 MB
routerDirect.js 1.06 MB 1.06 MB
withRouter.js 1.06 MB 1.06 MB
Overall change 5.19 MB 5.19 MB

Webpack 5 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
buildDuration 10.8s 10.5s -314ms
nodeModulesSize 75 MB 75 MB ⚠️ +297 B
Page Load Tests Overall increase ✓
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
/ failed reqs 0 0
/ total time (seconds) 1.814 1.707 -0.11
/ avg req/sec 1378.53 1464.87 +86.34
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.123 1.083 -0.04
/error-in-render avg req/sec 2226.68 2307.53 +80.85
Client Bundles (main, webpack, commons)
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
597-6c246419..806f.js gzip 13 kB 13 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 6.58 kB 6.58 kB
webpack-HASH.js gzip 954 B 954 B
Overall change 59.9 kB 59.9 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_app-6e0a903..b885.js gzip 1.26 kB 1.26 kB
_error-7a100..a392.js gzip 3.38 kB 3.38 kB
hooks-f7e199..11b9.js gzip 904 B 904 B
index-3dc22c..ffbb.js gzip 232 B 232 B
link-c010d28..b60a.js gzip 1.63 kB 1.63 kB
routerDirect..323a.js gzip 308 B 308 B
withRouter-a..2ef8.js gzip 304 B 304 B
Overall change 8.02 kB 8.02 kB
Client Build Manifests
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_buildManifest.js gzip 299 B 299 B
Overall change 299 B 299 B
Rendered Page Sizes
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
index.html gzip 586 B 586 B
link.html gzip 591 B 591 B
withRouter.html gzip 579 B 579 B
Overall change 1.76 kB 1.76 kB

Diffs

Diff for index.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "4NqfZXIvJK2cpZv5uw_rO",
+        "buildId": "LnuwP_kr5rQynNqfRoqBz",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/4NqfZXIvJK2cpZv5uw_rO/_buildManifest.js"
+      src="/_next/static/LnuwP_kr5rQynNqfRoqBz/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/4NqfZXIvJK2cpZv5uw_rO/_ssgManifest.js"
+      src="/_next/static/LnuwP_kr5rQynNqfRoqBz/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "4NqfZXIvJK2cpZv5uw_rO",
+        "buildId": "LnuwP_kr5rQynNqfRoqBz",
         "isFallback": false,
         "gip": true
       }
@@ -82,11 +82,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/4NqfZXIvJK2cpZv5uw_rO/_buildManifest.js"
+      src="/_next/static/LnuwP_kr5rQynNqfRoqBz/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/4NqfZXIvJK2cpZv5uw_rO/_ssgManifest.js"
+      src="/_next/static/LnuwP_kr5rQynNqfRoqBz/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "4NqfZXIvJK2cpZv5uw_rO",
+        "buildId": "LnuwP_kr5rQynNqfRoqBz",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/4NqfZXIvJK2cpZv5uw_rO/_buildManifest.js"
+      src="/_next/static/LnuwP_kr5rQynNqfRoqBz/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/4NqfZXIvJK2cpZv5uw_rO/_ssgManifest.js"
+      src="/_next/static/LnuwP_kr5rQynNqfRoqBz/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: 850219e

@ijjk
Copy link
Member

ijjk commented Feb 2, 2021

Stats from current PR

Default Server Mode
General Overall increase ⚠️
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
buildDuration 10s 10.2s ⚠️ +251ms
nodeModulesSize 75.1 MB 75.1 MB ⚠️ +297 B
Page Load Tests Overall increase ✓
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
/ failed reqs 0 0
/ total time (seconds) 2.008 1.973 -0.03
/ avg req/sec 1245.28 1267.11 +21.83
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.231 1.241 ⚠️ +0.01
/error-in-render avg req/sec 2030.59 2013.72 ⚠️ -16.87
Client Bundles (main, webpack, commons)
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
677f882d2ed8..49c4.js gzip 13.1 kB 13.1 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 6.63 kB 6.63 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 59.5 kB 59.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_app-2a09aa2..4a98.js gzip 1.28 kB 1.28 kB
_error-8b758..aef6.js gzip 3.46 kB 3.46 kB
hooks-c71ae4..70cd.js gzip 887 B 887 B
index-bbee2f..528b.js gzip 227 B 227 B
link-7faf09b..eba4.js gzip 1.64 kB 1.64 kB
routerDirect..bf84.js gzip 303 B 303 B
withRouter-a..5826.js gzip 302 B 302 B
Overall change 8.09 kB 8.09 kB
Client Build Manifests
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Rendered Page Sizes
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
index.html gzip 614 B 614 B
link.html gzip 619 B 619 B
withRouter.html gzip 608 B 608 B
Overall change 1.84 kB 1.84 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
buildDuration 12s 11.8s -111ms
nodeModulesSize 75.1 MB 75.1 MB ⚠️ +297 B
Client Bundles (main, webpack, commons)
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
677f882d2ed8..49c4.js gzip 13.1 kB 13.1 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 6.63 kB 6.63 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 59.5 kB 59.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_app-2a09aa2..4a98.js gzip 1.28 kB 1.28 kB
_error-8b758..aef6.js gzip 3.46 kB 3.46 kB
hooks-c71ae4..70cd.js gzip 887 B 887 B
index-bbee2f..528b.js gzip 227 B 227 B
link-7faf09b..eba4.js gzip 1.64 kB 1.64 kB
routerDirect..bf84.js gzip 303 B 303 B
withRouter-a..5826.js gzip 302 B 302 B
Overall change 8.09 kB 8.09 kB
Client Build Manifests
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Serverless bundles
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_error.js 1 MB 1 MB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB
link.js 1.06 MB 1.06 MB
routerDirect.js 1.06 MB 1.06 MB
withRouter.js 1.06 MB 1.06 MB
Overall change 5.19 MB 5.19 MB

Webpack 5 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
buildDuration 12.1s 12.4s ⚠️ +393ms
nodeModulesSize 75.1 MB 75.1 MB ⚠️ +297 B
Page Load Tests Overall increase ✓
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
/ failed reqs 0 0
/ total time (seconds) 2.036 1.985 -0.05
/ avg req/sec 1227.83 1259.54 +31.71
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.303 1.271 -0.03
/error-in-render avg req/sec 1919.28 1967.3 +48.02
Client Bundles (main, webpack, commons)
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
597-6c246419..806f.js gzip 13 kB 13 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 6.58 kB 6.58 kB
webpack-HASH.js gzip 954 B 954 B
Overall change 59.9 kB 59.9 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_app-6e0a903..b885.js gzip 1.26 kB 1.26 kB
_error-7a100..a392.js gzip 3.38 kB 3.38 kB
hooks-f7e199..11b9.js gzip 904 B 904 B
index-3dc22c..ffbb.js gzip 232 B 232 B
link-c010d28..b60a.js gzip 1.63 kB 1.63 kB
routerDirect..323a.js gzip 308 B 308 B
withRouter-a..2ef8.js gzip 304 B 304 B
Overall change 8.02 kB 8.02 kB
Client Build Manifests
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
_buildManifest.js gzip 299 B 299 B
Overall change 299 B 299 B
Rendered Page Sizes
vercel/next.js canary davidbailey00/next.js fix-sharp-require Change
index.html gzip 585 B 585 B
link.html gzip 590 B 590 B
withRouter.html gzip 579 B 579 B
Overall change 1.75 kB 1.75 kB

Diffs

Diff for index.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "6lyMVZ8MNggdP8_ImLudK",
+        "buildId": "JKwPrnswN6UfKJEhfJPZx",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/6lyMVZ8MNggdP8_ImLudK/_buildManifest.js"
+      src="/_next/static/JKwPrnswN6UfKJEhfJPZx/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/6lyMVZ8MNggdP8_ImLudK/_ssgManifest.js"
+      src="/_next/static/JKwPrnswN6UfKJEhfJPZx/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "6lyMVZ8MNggdP8_ImLudK",
+        "buildId": "JKwPrnswN6UfKJEhfJPZx",
         "isFallback": false,
         "gip": true
       }
@@ -82,11 +82,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/6lyMVZ8MNggdP8_ImLudK/_buildManifest.js"
+      src="/_next/static/JKwPrnswN6UfKJEhfJPZx/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/6lyMVZ8MNggdP8_ImLudK/_ssgManifest.js"
+      src="/_next/static/JKwPrnswN6UfKJEhfJPZx/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "6lyMVZ8MNggdP8_ImLudK",
+        "buildId": "JKwPrnswN6UfKJEhfJPZx",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/6lyMVZ8MNggdP8_ImLudK/_buildManifest.js"
+      src="/_next/static/JKwPrnswN6UfKJEhfJPZx/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/6lyMVZ8MNggdP8_ImLudK/_ssgManifest.js"
+      src="/_next/static/JKwPrnswN6UfKJEhfJPZx/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: 1081c0b

@jorrit
Copy link
Contributor

jorrit commented Feb 3, 2021

Duplicate of #20738, but your solution is fine too.

@vtenfys
Copy link
Author

vtenfys commented Feb 3, 2021

@jorrit ah thanks for pointing out - I'll leave you to decide which to merge, although it looks like the other PR may be the better choice seeing as it has a test 👍🏻

@jorrit
Copy link
Contributor

jorrit commented Feb 3, 2021

I'm not a maintainer, I'll leave it to them. The reason my PR was ignored (I think) was because I forgot to un-draft it.

@vtenfys
Copy link
Author

vtenfys commented Feb 16, 2021

Closing due to lack of response from maintainers and I think #20738 should be preferred due to tests - feel free to reopen if this PR is helpful :)

@vtenfys vtenfys closed this Feb 16, 2021
kodiakhq bot pushed a commit that referenced this pull request Feb 18, 2021
This pull request removes the native `sharp` dependency (which doesn't work on some Linux variants, nor **M1 Mac**) and replaces it with a wasm equivalent.

It also reduces Next.js' installed size by 27.3 MB.

The code is adapted from the [Squoosh CLI](https://github.com/GoogleChromeLabs/squoosh).

This PR still supports:

- Rotation normalization
- Resizing
- PNG
- JPEG
- Webp

However, it (temporarily) removes support for:
- Resizing Gifs
- Resizing Tiff

(these formats still get served and rendered correctly by the image component)

---

Fixes #20456
Closes #20738
Closes #21762
@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sharp no longer optional since 10.0.4-canary.7
3 participants