rsnext/packages/next/client
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
..
components Ensure smooth scroll is disabled for navigation in new and existing router (#40642) 2022-09-19 15:02:02 +02:00
dev Refine error messages (#40661) 2022-09-19 15:50:03 +02:00
future Implement SWC transformer for server and client graphs (#40603) 2022-09-17 00:12:59 +02:00
portal refactor(portal): remove useRef from portal component (#39792) 2022-08-21 09:39:43 +00:00
add-base-path.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
add-locale.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
app-index.tsx Refactor fetchServerResponse (#40674) 2022-09-19 14:17:20 +02:00
app-next-dev.js Leverage mini css plugin hmr for app dir (#38830) 2022-07-21 14:38:04 +02:00
app-next.js Handle on-demand-entries and error overlay for server components (#38480) 2022-07-10 19:18:48 +02:00
detect-domain-locale.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
get-domain-locale.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
has-base-path.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
head-manager.ts Migrate head side effects to hooks (#37526) 2022-06-08 11:26:57 +00:00
image.tsx Implement SWC transformer for server and client graphs (#40603) 2022-09-17 00:12:59 +02:00
index.tsx Ensure smooth scroll is disabled for navigation in new and existing router (#40642) 2022-09-19 15:02:02 +02:00
link.tsx Implement SWC transformer for server and client graphs (#40603) 2022-09-17 00:12:59 +02:00
next-dev.js Add hard navigation guard and fix middleware rewrite cases (#37815) 2022-06-20 11:31:19 +00:00
next.js Split up & tweak next/client initialization (#33838) 2022-03-07 17:09:55 +00:00
normalize-locale-path.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
normalize-trailing-slash.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
page-loader.ts feat(next): Support has match and locale option on middleware config (#39257) 2022-08-31 11:23:30 -05:00
performance-relayer.ts Send web vitals to Vercel analytics in app (#40669) 2022-09-19 08:16:53 +00:00
remove-base-path.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
remove-locale.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
request-idle-callback.ts upgrade to typescript 4.4.3 (#29112) 2021-09-16 18:06:57 +02:00
route-announcer.tsx Hoist styles for Route Announcer 📢 (#39331) 2022-08-05 09:42:55 +00:00
route-loader.ts feat(next): Support has match and locale option on middleware config (#39257) 2022-08-31 11:23:30 -05:00
router.ts Enable @typescript-eslint/no-use-before-define for functions (#39602) 2022-08-15 10:29:51 -04:00
script.tsx Implement SWC transformer for server and client graphs (#40603) 2022-09-17 00:12:59 +02:00
trusted-types.ts Route Loader Trusted Types Violation Fix (#34730) 2022-05-03 23:22:08 +00:00
use-intersection.tsx refactor(use-intersection): remove useRef usage (#39791) 2022-08-21 10:10:09 +00:00
with-router.tsx Upgrade typescript to 4.8.2 (#39979) 2022-08-29 16:56:02 +00:00