rsnext/packages/next/client/dev
Shu Ding 44afc37670
Refine error messages (#40661)
As per @sebmarkbage's suggestion, this PR refines the error message to
be more readable and friendly:

```
error - ./components/qux.js

You're importing a component that needs useEffect. It only works in a Client Component but none of its parents are marked with "client", so they're Server Components by default.

   ,----
 5 | import { useEffect } from 'react'
   :          ^^^^^^^^^
   `----

Maybe one of these should be marked as a "client" entry:

./components/qux.js
./components/baz.js
./components/bar.js
./app/dashboard/index/page.js
```

It's more ideal to put error codes inside the SWC transform and format
it in the Next.js logging layer. A future improvement is to tweak the
message a bit more for these specific cases:

- [ ] The error already happens inside an entry point (page or layout),
so itself should have "client" added (or removed), not it parents.
- [ ] When importing `"server-only"` inside a client component, we can
directly hint to the user which module in the import chain is marked
with `"client"`.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-09-19 15:50:03 +02:00
..
error-overlay Refine error messages (#40661) 2022-09-19 15:50:03 +02:00
amp-dev.js chore: replace deprecated String.prototype.substr() (#35421) 2022-03-24 17:49:38 -04:00
dev-build-watcher.js Fix build activity indicator position (#36208) 2022-04-15 23:53:00 -05:00
fouc.ts fix: ensure hidden iframe apps render in development mode (#39514) 2022-08-11 16:22:19 -05:00
on-demand-entries-client.js Ensure we don't poll page in development when notFound: true is returned (#34352) 2022-02-16 18:53:48 +00:00
webpack-hot-middleware-client.js Add client HMR tracing for debugging (#36328) 2022-04-21 08:30:23 +00:00