-
Notifications
You must be signed in to change notification settings - Fork 27k
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
The config
arg should not be passed to user-defined loader
function in `next/image
#35115
Comments
@balazsorban44 Just to provide some additional context / info... We are creating a This issue does not occur with |
Hi @ambrauer and @sc-addypathania The It was changed from a global variable to a function parameter in #33559 as an implementation detail, not as a public API. Furthermore, this config is meant for the default Image Optimization API. Since the It sounds like the bug here is that For the purposes of your custom loader, it might be best to ask the user for an explicit |
Here's a concrete example. Consider this Next.js app: module.exports = {
images: {
loader: 'cloudinary',
path: 'https://res.cloudinary.com/myaccount/'
}
} import Image from 'next/image'
import OtherImage from 'other-image'
<Image src="/me.png" width="100" height="100" />
<OtherImage src="/me.png" width="100" height="100" /> The
For the other image imported from a package that wraps
|
Hi @styfle, thanks for clearing this up. We were struggling with the fact that the URL root/path/prefix is defined in the app, while the custom loader is in our SDK. Piggybacking on the default loaders config was a simple solution for us (and made some sense from a DevEx perspective since "path" served the same purpose for us), but your explanation makes sense. One suggestion beyond aligning the config treatment between We will explore other options for providing the root (such as a Thanks again! |
config
arg should not be passed to user-defined loader
function in `next/image
…ccording to Vercel: vercel/next.js#35115). Added whitelisting config for default next/image sizes.
…age` (#36013) The `config` was changed from a global variable to a function parameter of the `loader()` function in PR #33559 as an implementation detail, not as a public API. It was not meant to be used by the end user which is why it was [undocumented](https://nextjs.org/docs/api-reference/next/image#loader). This config is meant for the default Image Optimization API. Since the `loader` prop bypasses the default Image Optimization API in favor of a custom function, that config is no longer be relevant because the function can implement the optimization url however it desires. - Fixes #35115
…age` (vercel#36013) The `config` was changed from a global variable to a function parameter of the `loader()` function in PR vercel#33559 as an implementation detail, not as a public API. It was not meant to be used by the end user which is why it was [undocumented](https://nextjs.org/docs/api-reference/next/image#loader). This config is meant for the default Image Optimization API. Since the `loader` prop bypasses the default Image Optimization API in favor of a custom function, that config is no longer be relevant because the function can implement the optimization url however it desires. - Fixes vercel#35115
* Implement Nextjs Image nextjs package and styleguide * WIP: Implement nextjs image in nextjs package and styleguide * Refactored image loader * Refactor way in which EE markup is applied in react image component to be reused in next image component. * WIP: Start refactoring test for nextjs image also refactor nextjs-styleguide template to use new image component * added tests and completed todos * removed unwanted code and added line to end of file * addressed review comments * fixed unit tests * removed dublicate code * removed extra comments * updated yarn.lock * updated yarn.lock, removed dubplicate interface * removed changes in yarn.lock * updated yarn.lock * updated yarn.lock * fixed linting error * updated deviceSizes comment in next.config * improved comments, added utility to get hostname * removed path and loader from config * added relative path to loader function * added comment for path variable * updated error message, removed extra interface * fixed undefined path variable issue * added test cases for the loader function * renamed next-setup file * updated next.config comments, refactored redundant code * added the fix from vercel regarding access to config in loader function * removed blurDataUrl, made loader function more customizable, fixed tests * Delete yarn.lock * added yarn.lock * updated yarn.lock * changed next version in template * removed redundant comments and files , changed error message * added test case for user custom loader function * added another test case fro custom loader * added test for absolute url, mock loader function * added test for user sent custom loader * removed params object, added afterEach * updated the afterEach call * refactored mock loader tests * created two describes for next image tests * updated tests description * updated the order of tests and describes in next image tests * Simplified loader which does not depend on 'config' (not to be used according to Vercel: vercel/next.js#35115). Added whitelisting config for default next/image sizes. * updated image url, fixed classname bug for EE in next/image * added unit test * remove console.log * resolved merge conflicts in yarn.lock file * refactored util fucntions, removed redundant code * updated yarn.lock, refactored utils * removed url-parse Co-authored-by: CobyPear <[email protected]> Co-authored-by: Adam Brauer <[email protected]>
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Binaries:
Node: 14.17.6
npm: 6.14.15
Yarn: 1.22.17
pnpm: N/A
Relevant packages:
next: 12.1.0
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
The bug for next.config.js not considered for node_modeles was discussed here: https://github.com/vercel/next.js/issues/31065
Fixed in PR:https://github.com/vercel/next.js/pull/33559
After the above fix when trying to build the next app the
config
argument passed in the custom loader function resolves to the default next variables.Expected Behavior
The config argument in the loader function should return the variables configured in the next.config.js coming from the node_modules when trying to build the app statically.
To Reproduce
next build
The config argument in the loader function returns default next.config variables set by vercel.
The text was updated successfully, but these errors were encountered: