44afc37670
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) |
||
---|---|---|
.. | ||
error-overlay | ||
amp-dev.js | ||
dev-build-watcher.js | ||
fouc.ts | ||
on-demand-entries-client.js | ||
webpack-hot-middleware-client.js |