rsnext/test/e2e/app-dir/loader-file-named-export-custom-loader-error
Jeongjin Oh 04c87ae2d7
fix: show the error message if images.loaderFile doesn't export a default function (#64036)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

-->

fixes #63803 

## What I do?

- If the loader file export the function as `named`, Next.js throws the
error.
- But this error is a bit confusing for the developers.
- So I open this PR for showing the accurate error message.

## AS-IS / TO-BE

### AS-IS

```
TypeError: Cannot use 'in' operator to search for '__next_img_default' in undefined
```
<img width="1202" alt="스크린샷 2024-03-28 16 10 53"
src="https://github.com/vercel/next.js/assets/33178048/e7c81cb5-7976-46ff-b86f-9c8fd9a7a681">

### TO-BE

```
Error: The loader file must export a default function that returns a string.
See more info here: https://nextjs.org/docs/messages/invalid-images-config
```
<img width="500" alt="스크린샷 2024-03-28 16 10 53"
src="https://github.com/vercel/next.js/assets/33178048/c391e61b-6a44-4f85-8600-28ab6cb5b0eb">

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-04-10 18:11:38 +00:00
..
app fix: show the error message if images.loaderFile doesn't export a default function (#64036) 2024-04-10 18:11:38 +00:00
public fix: show the error message if images.loaderFile doesn't export a default function (#64036) 2024-04-10 18:11:38 +00:00
dummy-loader.ts fix: show the error message if images.loaderFile doesn't export a default function (#64036) 2024-04-10 18:11:38 +00:00
loader-file-named-export-custom-loader-error.test.ts fix: show the error message if images.loaderFile doesn't export a default function (#64036) 2024-04-10 18:11:38 +00:00
next.config.js fix: show the error message if images.loaderFile doesn't export a default function (#64036) 2024-04-10 18:11:38 +00:00