@vitejs/plugin-rsc 0.4.26 → 0.4.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{plugin-DmahacLo.d.ts → plugin-Be24jgQb.d.ts} +1 -1
- package/dist/{plugin-uOrnsu6L.js → plugin-CtdHIozK.js} +15 -4
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +3 -3
- package/types/index.d.ts +7 -0
package/README.md
CHANGED
|
@@ -168,6 +168,11 @@ export default async function handler(request: Request): Promise<Response> {
|
|
|
168
168
|
},
|
|
169
169
|
})
|
|
170
170
|
}
|
|
171
|
+
|
|
172
|
+
// add `import.meta.hot.accept` to handle server module change efficiently
|
|
173
|
+
if (import.meta.hot) {
|
|
174
|
+
import.meta.hot.accept()
|
|
175
|
+
}
|
|
171
176
|
```
|
|
172
177
|
|
|
173
178
|
- [`entry.ssr.tsx`](./examples/starter/src/framework/entry.ssr.tsx)
|
|
@@ -355,6 +360,8 @@ import.meta.hot.on('rsc:update', async () => {
|
|
|
355
360
|
|
|
356
361
|
### `@vitejs/plugin-rsc`
|
|
357
362
|
|
|
363
|
+
- Type: `rsc: (options?: RscPluginOptions) => Plugin[]`;
|
|
364
|
+
|
|
358
365
|
```js
|
|
359
366
|
import rsc from '@vitejs/plugin-rsc'
|
|
360
367
|
import { defineConfig } from 'vite'
|
|
@@ -390,8 +397,15 @@ export default defineConfig({
|
|
|
390
397
|
// for example, to obtain a key through environment variable during runtime.
|
|
391
398
|
// cf. https://nextjs.org/docs/app/guides/data-security#overwriting-encryption-keys-advanced
|
|
392
399
|
defineEncryptionKey: 'process.env.MY_ENCRYPTION_KEY',
|
|
400
|
+
|
|
401
|
+
// see `RscPluginOptions` for full options ...
|
|
393
402
|
}),
|
|
394
403
|
],
|
|
404
|
+
// the same options can be also specified via top-level `rsc` property.
|
|
405
|
+
// this allows other plugin to set options via `config` hook.
|
|
406
|
+
rsc: {
|
|
407
|
+
// ...
|
|
408
|
+
},
|
|
395
409
|
})
|
|
396
410
|
```
|
|
397
411
|
|
|
@@ -508,6 +522,26 @@ export default function myRscFrameworkPlugin() {
|
|
|
508
522
|
}
|
|
509
523
|
```
|
|
510
524
|
|
|
525
|
+
## Typescript
|
|
526
|
+
|
|
527
|
+
Types for global API are defined in `@vitejs/plugin-rsc/types`. For example, you can add it to `tsconfig.json` to have types for `import.meta.viteRsc` APIs:
|
|
528
|
+
|
|
529
|
+
```json
|
|
530
|
+
{
|
|
531
|
+
"compilerOptions": {
|
|
532
|
+
"types": ["vite/client", "@vitejs/plugin-rsc/types"]
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
```ts
|
|
538
|
+
import.meta.viteRsc.loadModule
|
|
539
|
+
// ^^^^^^^^^^
|
|
540
|
+
// <T>(environmentName: string, entryName: string) => Promise<T>
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
See also [Vite documentation](https://vite.dev/guide/api-hmr.html#intellisense-for-typescript) for `vite/client` types.
|
|
544
|
+
|
|
511
545
|
## Credits
|
|
512
546
|
|
|
513
547
|
This project builds on fundamental techniques and insights from pioneering Vite RSC implementations.
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./dist-DiJnRA1C.js";
|
|
2
2
|
import "./plugin-CZbI4rhS.js";
|
|
3
|
-
import { transformHoistInlineDirective, vitePluginRsc } from "./plugin-
|
|
3
|
+
import { transformHoistInlineDirective, vitePluginRsc } from "./plugin-CtdHIozK.js";
|
|
4
4
|
import "./encryption-utils-BDwwcMVT.js";
|
|
5
5
|
import "./rpc-tGuLT8PD.js";
|
|
6
6
|
import "./shared-BWHxNw3Q.js";
|
|
@@ -88,7 +88,7 @@ type RscPluginOptions = {
|
|
|
88
88
|
/**
|
|
89
89
|
* use `Plugin.buildApp` hook (introduced on Vite 7) instead of `builder.buildApp` configuration
|
|
90
90
|
* for better composability with other plugins.
|
|
91
|
-
* @default
|
|
91
|
+
* @default true since Vite 7
|
|
92
92
|
*/
|
|
93
93
|
useBuildAppHook?: boolean;
|
|
94
94
|
/**
|
|
@@ -749,6 +749,7 @@ function vitePluginRsc(rscPluginOptions = {}) {
|
|
|
749
749
|
{
|
|
750
750
|
name: "rsc",
|
|
751
751
|
async config(config, env) {
|
|
752
|
+
if (config.rsc) Object.assign(rscPluginOptions, vite.mergeConfig(config.rsc, rscPluginOptions));
|
|
752
753
|
const result = await crawlFrameworkPkgs({
|
|
753
754
|
root: process.cwd(),
|
|
754
755
|
isBuild: env.command === "build",
|
|
@@ -767,7 +768,7 @@ function vitePluginRsc(rscPluginOptions = {}) {
|
|
|
767
768
|
...result.ssr.noExternal.sort()
|
|
768
769
|
];
|
|
769
770
|
return {
|
|
770
|
-
appType: "custom",
|
|
771
|
+
appType: config.appType ?? "custom",
|
|
771
772
|
define: { "import.meta.env.__vite_rsc_build__": JSON.stringify(env.command === "build") },
|
|
772
773
|
environments: {
|
|
773
774
|
client: {
|
|
@@ -825,11 +826,18 @@ function vitePluginRsc(rscPluginOptions = {}) {
|
|
|
825
826
|
builder: {
|
|
826
827
|
sharedPlugins: true,
|
|
827
828
|
sharedConfigBuild: true,
|
|
828
|
-
buildApp
|
|
829
|
+
async buildApp(builder) {
|
|
830
|
+
if (!rscPluginOptions.useBuildAppHook) await buildApp(builder);
|
|
831
|
+
}
|
|
829
832
|
}
|
|
830
833
|
};
|
|
831
834
|
},
|
|
832
|
-
|
|
835
|
+
configResolved() {
|
|
836
|
+
if (Number(vite.version.split(".")[0]) >= 7) rscPluginOptions.useBuildAppHook ??= true;
|
|
837
|
+
},
|
|
838
|
+
buildApp: { async handler(builder) {
|
|
839
|
+
if (rscPluginOptions.useBuildAppHook) await buildApp(builder);
|
|
840
|
+
} },
|
|
833
841
|
configureServer(server) {
|
|
834
842
|
globalThis.__viteRscDevServer = server;
|
|
835
843
|
const oldSend = server.environments.client.hot.send;
|
|
@@ -1184,7 +1192,10 @@ import.meta.hot.on("rsc:update", () => {
|
|
|
1184
1192
|
...vitePluginRscMinimal(rscPluginOptions, manager),
|
|
1185
1193
|
...vitePluginFindSourceMapURL(),
|
|
1186
1194
|
...vitePluginRscCss(rscPluginOptions, manager),
|
|
1187
|
-
|
|
1195
|
+
{
|
|
1196
|
+
...validateImportPlugin(),
|
|
1197
|
+
apply: () => rscPluginOptions.validateImports !== false
|
|
1198
|
+
},
|
|
1188
1199
|
scanBuildStripPlugin({ manager }),
|
|
1189
1200
|
...cjsModuleRunnerPlugin(),
|
|
1190
1201
|
...globalAsyncLocalStoragePlugin()
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AssetDeps, AssetsManifest, ResolvedAssetDeps, ResolvedAssetsManifest, RscPluginManager, RscPluginOptions, transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin-
|
|
1
|
+
import { AssetDeps, AssetsManifest, ResolvedAssetDeps, ResolvedAssetsManifest, RscPluginManager, RscPluginOptions, transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin-Be24jgQb.js";
|
|
2
2
|
export { AssetDeps, AssetsManifest, ResolvedAssetDeps, ResolvedAssetsManifest, RscPluginManager, RscPluginOptions, vitePluginRsc as default, transformRscCssExport, vitePluginRscMinimal };
|
package/dist/plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./dist-DiJnRA1C.js";
|
|
2
2
|
import "./plugin-CZbI4rhS.js";
|
|
3
|
-
import { transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin-
|
|
3
|
+
import { transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin-CtdHIozK.js";
|
|
4
4
|
import "./encryption-utils-BDwwcMVT.js";
|
|
5
5
|
import "./rpc-tGuLT8PD.js";
|
|
6
6
|
import "./shared-BWHxNw3Q.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-rsc",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.27",
|
|
4
4
|
"description": "React Server Components (RSC) support for Vite.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"@tsconfig/strictest": "^2.0.5",
|
|
53
53
|
"@types/estree": "^1.0.8",
|
|
54
54
|
"@types/node": "^22.18.0",
|
|
55
|
-
"@types/react": "^19.1.
|
|
56
|
-
"@types/react-dom": "^19.1.
|
|
55
|
+
"@types/react": "^19.1.12",
|
|
56
|
+
"@types/react-dom": "^19.1.9",
|
|
57
57
|
"@vitejs/plugin-react": "workspace:*",
|
|
58
58
|
"react": "^19.1.1",
|
|
59
59
|
"react-dom": "^19.1.1",
|