Unverified Commit 7e44fe35 authored by Josh Story's avatar Josh Story Committed by GitHub

disallow unstable_rootParams in client components (#79471)

unstable_rootParams is a server component API and should not be allowed
to be accessed from client components. This change adds a compiler error
if this import is detected within the client module graph.
parent ca6280dc
...@@ -640,7 +640,7 @@ impl ReactServerComponentValidator { ...@@ -640,7 +640,7 @@ impl ReactServerComponentValidator {
invalid_client_imports: vec![Atom::from("server-only"), Atom::from("next/headers")], invalid_client_imports: vec![Atom::from("server-only"), Atom::from("next/headers")],
invalid_client_lib_apis_mapping: FxHashMap::from_iter([ invalid_client_lib_apis_mapping: FxHashMap::from_iter([
("next/server", vec!["after"]), ("next/server", vec!["after", "unstable_rootParams"]),
( (
"next/cache", "next/cache",
vec![ vec![
......
// This is a comment.
'use strict'
/**
* This is a comment.
*/
import { unstable_rootParams } from 'next/server'
export default function () {
return null
}
// This is a comment.
'use strict';
/**
* This is a comment.
*/ import { unstable_rootParams } from 'next/server';
export default function() {
return null;
}
x You're importing a component that needs "unstable_rootParams". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/
| building-your-application/rendering/server-components
|
|
,-[input.js:9:1]
8 |
9 | import { unstable_rootParams } from 'next/server'
: ^^^^^^^^^^^^^^^^^^^
`----
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment