-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
Image component custom resolvers #19325
Conversation
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
buildDuration | 10.1s | 10.1s | |
nodeModulesSize | 84.9 MB | 84.9 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.249 | 2.236 | -0.01 |
/ avg req/sec | 1111.42 | 1117.94 | +6.52 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.373 | 1.212 | -0.16 |
/error-in-render avg req/sec | 1820.29 | 2062.2 | +241.91 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
677f882d2ed8..4972.js gzip | 12.7 kB | 12.7 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-f1a49fb..e45e.js gzip | 6.52 kB | 6.52 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 58.9 kB | 58.9 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
index.html gzip | 613 B | 613 B | ✓ |
link.html gzip | 621 B | 621 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 | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
buildDuration | 12s | 11.7s | -289ms |
nodeModulesSize | 84.9 MB | 84.9 MB |
Client Bundles (main, webpack, commons)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
677f882d2ed8..4972.js gzip | 12.7 kB | 12.7 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-f1a49fb..e45e.js gzip | 6.52 kB | 6.52 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 58.9 kB | 58.9 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_error.js | 914 kB | 914 kB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 915 kB | 915 kB | ✓ |
link.js | 973 kB | 973 kB | ✓ |
routerDirect.js | 966 kB | 966 kB | ✓ |
withRouter.js | 966 kB | 966 kB | ✓ |
Overall change | 4.74 MB | 4.74 MB | ✓ |
Failing test suitesCommit: 86e51ed test/integration/image-optimizer/test/index.test.js
Expand output● Image Optimizer › config checks › should error when loader contains invalid value
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to update the failing test to add custom
there too
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
buildDuration | 10.1s | 10.1s | |
nodeModulesSize | 84.9 MB | 84.9 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.173 | 2.255 | |
/ avg req/sec | 1150.64 | 1108.59 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.279 | 1.242 | -0.04 |
/error-in-render avg req/sec | 1954.6 | 2013.49 | +58.89 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
677f882d2ed8..4972.js gzip | 12.7 kB | 12.7 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-f1a49fb..e45e.js gzip | 6.52 kB | 6.52 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 58.9 kB | 58.9 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
index.html gzip | 613 B | 613 B | ✓ |
link.html gzip | 621 B | 621 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 | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
buildDuration | 11.9s | 11.6s | -254ms |
nodeModulesSize | 84.9 MB | 84.9 MB |
Client Bundles (main, webpack, commons)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
677f882d2ed8..4972.js gzip | 12.7 kB | 12.7 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-f1a49fb..e45e.js gzip | 6.52 kB | 6.52 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 58.9 kB | 58.9 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_error.js | 914 kB | 914 kB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 915 kB | 915 kB | ✓ |
link.js | 973 kB | 973 kB | ✓ |
routerDirect.js | 966 kB | 966 kB | ✓ |
withRouter.js | 966 kB | 966 kB | ✓ |
Overall change | 4.74 MB | 4.74 MB | ✓ |
Failing test suitesCommit: d464057 test/integration/image-optimizer/test/index.test.js
Expand output● Image Optimizer › config checks › should error when loader contains invalid value
|
Stats from current PRDefault Server Mode (Decrease detected ✓)General Overall increase
|
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
buildDuration | 10.4s | 10.7s | |
nodeModulesSize | 84.9 MB | 84.9 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.399 | 2.432 | |
/ avg req/sec | 1042.11 | 1027.94 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.528 | 1.617 | |
/error-in-render avg req/sec | 1636.21 | 1545.94 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
677f882d2ed8..4972.js gzip | 12.7 kB | 12.7 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-f1a49fb..e45e.js gzip | 6.52 kB | 6.52 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 58.9 kB | 58.9 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
index.html gzip | 613 B | 613 B | ✓ |
link.html gzip | 621 B | 621 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 | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
buildDuration | 11.9s | 12.1s | |
nodeModulesSize | 84.9 MB | 84.9 MB |
Client Bundles (main, webpack, commons)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
677f882d2ed8..4972.js gzip | 12.7 kB | 12.7 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-f1a49fb..e45e.js gzip | 6.52 kB | 6.52 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 58.9 kB | 58.9 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_error.js | 914 kB | 914 kB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 915 kB | 915 kB | ✓ |
link.js | 973 kB | 973 kB | ✓ |
routerDirect.js | 966 kB | 966 kB | ✓ |
withRouter.js | 966 kB | 966 kB | ✓ |
Overall change | 4.74 MB | 4.74 MB | ✓ |
Failing test suitesCommit: a68391b test/integration/image-optimizer/test/index.test.js
Expand output● Image Optimizer › config checks › should error when loader contains invalid value
|
packages/next/client/image.tsx
Outdated
`registerCustomResolver can only be used if image loader is set to 'custom' in next.config.js` | ||
) | ||
if (configLoader !== 'custom') { | ||
resolverError = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason to delay the error instead of throw here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed when writing the tests that if it throws during _app.js script evaluation, the page renders an internal server error instead of the red box.
Stats from current PRDefault Server Mode (Decrease detected ✓)General Overall increase
|
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
buildDuration | 9.7s | 9.7s | -52ms |
nodeModulesSize | 82.4 MB | 82.4 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 1.908 | 1.947 | |
/ avg req/sec | 1310.15 | 1283.95 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.18 | 1.203 | |
/error-in-render avg req/sec | 2118.15 | 2077.81 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
677f882d2ed8..8b6e.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-3c9ff84..1d7c.js gzip | 6.56 kB | 6.56 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_app-7231d4b..5856.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-fca3d..2eb1.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4591d..e7c2.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-db223d9..dbd7.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
index.html gzip | 614 B | 614 B | ✓ |
link.html gzip | 620 B | 620 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 | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
buildDuration | 11.4s | 11.5s | |
nodeModulesSize | 82.4 MB | 82.4 MB |
Client Bundles (main, webpack, commons)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
677f882d2ed8..8b6e.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-3c9ff84..1d7c.js gzip | 6.56 kB | 6.56 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_app-7231d4b..5856.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-fca3d..2eb1.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4591d..e7c2.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-db223d9..dbd7.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles
vercel/next.js canary | azukaru/next.js image-component-custom-resolvers | Change | |
---|---|---|---|
_error.js | 997 kB | 997 kB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 998 kB | 998 kB | ✓ |
link.js | 1.05 MB | 1.05 MB | ✓ |
routerDirect.js | 1.04 MB | 1.04 MB | ✓ |
withRouter.js | 1.04 MB | 1.04 MB | ✓ |
Overall change | 5.14 MB | 5.14 MB | ✓ |
I think @Timer had some reservations about this implementation and @timneutkens still needs to take a look. Let's discuss on Monday and come up with a solution so we can move forward on PR and unblock others like #19117. |
In keeping with the config-driven approach, I'm wondering whether it's worth having the custom resolver as an optional anonymous function for the {
image: {
loader: ({ src, width }) => {
return `https://foo/${src}/${width}/`;
}
}
} |
Any news regarding this feature? Did you decide how to proceed @styfle ? |
It would be great if the custom resolver function could be used to switch between resolvers based on their origin filename. That would make it flexible to use more than one resolver endpoint and even extend the resolver to use any custom function. Ideally the already existing NextJS resolver functions should be available as a second argument in the custom resolver function, then they could be called on demand. |
@dohomi just out of curiosity .. what is a reason to use multiple resolver? 🤔 |
@schoenwaldnils One of my uses is that I have some static images in my public folder for banners / hero images / placeholders / logo's / etc, and that I have a bunch of user-generated content stored on Cloudinary (or any other CDN / image service), having the ability to tell the Image component which provider / resolver to use would be great so both sources would be optimized. |
@schoenwaldnils I use in one project NextJS with Storyblok CMS and Shopify headless ecommerce. Both headless APIs have 2 different image storages with possible different image proxies. I also think that in the community people already asked for different approaches in one NextJS endpoint. |
I've thought about this problem for a bit in #18606 (comment) and I would like to advise against a config driven approach. To me, it seems like a lot of work injecting configuration at the next.js level when users could configure it via a prop and compose over the next/image component. With this approach, this feature becomes very simple to implement and test. It touches just the image component and there's a nice sense of purity to it. The only down side is that users can no longer just import the Edit: I made a quick draft PR demonstrating the idea in #20213 |
@ItsWendell ah, yes, that makes absolute sense. Building the page with default next/image and CMS images with Contentfuls Image provider for example. @ricokahler this might make it easier to differentiate between loaders 🤔 |
Thanks for the feedback on this ticket. I agree that the composition-based approach with a custom loader prop is the best way to go. I retooled the tests in this branch to use that approach instead and opened a new PR at #20216. |
To build on @ricokahler's approach, the Image component could also look for a loader defined in an ancestor Context. |
This is a #19325 reconfigured to support a loader passed in via a `loader` prop on the Image component, rather than using a config-based approach. The idea is that applications wanting to use a custom loader will create a wrapper element for the image component that incorporates that loader. See a simple example of this pattern in the integration tests. This solution is similar to the one prototyped by @ricokahler in #20213 and described at #18606 (comment) --- Closes #19325 Fixes #18606
import { registerCustomImageLoader } from 'next/image' | ||
|
||
registerCustomImageLoader(({ src, width, quality }) => { | ||
return `https://customresolver.com/${src}?w~~${width},q~~${quality}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to point out that, for security reasons, I suggest to use domains that you can control, even for integration tests. At least one can use example.com for the purpose. 😄
This PR adds support for a "custom" option in the images.loader field of next.config.js, and adds a function that can be called in your _app.js file to register a custom function to resolve image URLs.
Currently this only supports a single, top-level custom function to handle all image component URLs, but the solution should be backwards compatible if we decide to add support for multiple resolvers in the future.