You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/plugin-rsc/README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -353,7 +353,7 @@ export default defineConfig({
353
353
// this behavior can be customized by `serverHandler` option.
354
354
serverHandler:false,
355
355
356
-
//this controls build-time validation of 'server-only' and 'client-only' imports.
356
+
//the plugin provides build-time validation of 'server-only' and 'client-only' imports.
357
357
// this is enabled by default. See the "server-only and client-only import" section for details.
358
358
validateImports:true,
359
359
@@ -534,7 +534,7 @@ import { getData } from './server-utils.js' // ❌ This will fail at build time
534
534
the plugin will show an error:
535
535
536
536
```sh
537
-
[rsc:validate-imports] 'server-only' cannot be imported in client build (importer:'/.../client.js', ...)
537
+
'server-only' cannot be imported in client build (importer:'/xxx/client.js', ...)
538
538
```
539
539
540
540
Similarly, `client-only` import can ensure browser-specific code isn't accidentally imported in server environment. For example,
@@ -564,10 +564,10 @@ export function ServerComponent() {
564
564
the plugin will show an error:
565
565
566
566
```sh
567
-
[rsc:virtual-client-package] 'client-only' cannot be imported in server build (importer:'/.../server.js', ...)
567
+
'client-only' cannot be imported in server build (importer:'xxx/server.js', ...)
568
568
```
569
569
570
-
Note that while there are official npm packages [`server-only`](https://www.npmjs.com/package/server-only) and [`client-only`](https://www.npmjs.com/package/client-only) created by React team, they don't need to be installed. The plugin internally overrides these imports and provides build-time validation instead of runtime errors.
570
+
Note that while there are official npm packages [`server-only`](https://www.npmjs.com/package/server-only) and [`client-only`](https://www.npmjs.com/package/client-only) created by React team, they don't need to be installed. The plugin internally overrides these imports and surfaces their runtime errors as build-time errors.
571
571
572
572
This build-time validation is enabled by default and can be disabled by setting `validateImports:false` in the plugin options.
0 commit comments