@vitejs/plugin-rsc 0.4.24 → 0.4.25

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/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-r-u6Aj3n.js";
3
+ import { transformHoistInlineDirective, vitePluginRsc } from "./plugin--LiSJGtB.js";
4
4
  import "./encryption-utils-BDwwcMVT.js";
5
5
  import "./rpc-tGuLT8PD.js";
6
6
  import "./shared-BWHxNw3Q.js";
@@ -632,6 +632,7 @@ async function findSourceMapURL(server, filename, environmentName) {
632
632
 
633
633
  //#endregion
634
634
  //#region src/plugin.ts
635
+ const isRolldownVite = "rolldownVersion" in vite;
635
636
  const BUILD_ASSETS_MANIFEST_NAME = "__vite_rsc_assets_manifest.js";
636
637
  const PKG_NAME = "@vitejs/plugin-rsc";
637
638
  const REACT_SERVER_DOM_NAME = `${PKG_NAME}/vendor/react-server-dom`;
@@ -777,6 +778,7 @@ function vitePluginRsc(rscPluginOptions = {}) {
777
778
  "react/jsx-runtime",
778
779
  "react/jsx-dev-runtime",
779
780
  "react-dom/server.edge",
781
+ "react-dom/static.edge",
780
782
  `${REACT_SERVER_DOM_NAME}/client.edge`
781
783
  ],
782
784
  exclude: [PKG_NAME]
@@ -815,6 +817,20 @@ function vitePluginRsc(rscPluginOptions = {}) {
815
817
  buildApp: rscPluginOptions.useBuildAppHook ? buildApp : void 0,
816
818
  configureServer(server) {
817
819
  globalThis.__viteRscDevServer = server;
820
+ const oldSend = server.environments.client.hot.send;
821
+ server.environments.client.hot.send = async function(...args) {
822
+ const e = args[0];
823
+ if (e && typeof e === "object" && e.type === "update") {
824
+ for (const update of e.updates) if (update.type === "js-update") {
825
+ const mod = server.environments.client.moduleGraph.urlToModuleMap.get(update.path);
826
+ if (mod && mod.id && manager.clientReferenceMetaMap[mod.id]) {
827
+ const serverMod = server.environments.rsc.moduleGraph.getModuleById(mod.id);
828
+ if (serverMod) server.environments.rsc.moduleGraph.invalidateModule(serverMod);
829
+ }
830
+ }
831
+ }
832
+ return oldSend.apply(this, args);
833
+ };
818
834
  if (rscPluginOptions.disableServerHandler) return;
819
835
  if (rscPluginOptions.serverHandler === false) return;
820
836
  const options = rscPluginOptions.serverHandler ?? {
@@ -1150,17 +1166,9 @@ import.meta.hot.on("rsc:update", () => {
1150
1166
  }),
1151
1167
  {
1152
1168
  name: "rsc:inject-async-local-storage",
1153
- async configureServer() {
1154
- const __viteRscAyncHooks = await import("node:async_hooks");
1155
- globalThis.AsyncLocalStorage = __viteRscAyncHooks.AsyncLocalStorage;
1156
- },
1157
- banner(chunk) {
1158
- if ((this.environment.name === "ssr" || this.environment.name === "rsc") && this.environment.mode === "build" && chunk.isEntry) return `\
1159
- import * as __viteRscAyncHooks from "node:async_hooks";
1160
- globalThis.AsyncLocalStorage = __viteRscAyncHooks.AsyncLocalStorage;
1161
- `;
1162
- return "";
1163
- }
1169
+ transform: { handler(code) {
1170
+ if ((this.environment.name === "ssr" || this.environment.name === "rsc") && code.includes("typeof AsyncLocalStorage") && code.includes("new AsyncLocalStorage()") && !code.includes("__viteRscAyncHooks")) return (this.environment.mode === "build" && !isRolldownVite ? `const __viteRscAyncHooks = require("node:async_hooks");` : `import * as __viteRscAyncHooks from "node:async_hooks";`) + `globalThis.AsyncLocalStorage = __viteRscAyncHooks.AsyncLocalStorage;` + code;
1171
+ } }
1164
1172
  },
1165
1173
  ...vitePluginRscMinimal(rscPluginOptions, manager),
1166
1174
  ...vitePluginFindSourceMapURL(),
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-r-u6Aj3n.js";
3
+ import { transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin--LiSJGtB.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.24",
3
+ "version": "0.4.25",
4
4
  "description": "React Server Components (RSC) support for Vite.",
5
5
  "keywords": [
6
6
  "vite",
@@ -53,7 +53,7 @@
53
53
  "@types/estree": "^1.0.8",
54
54
  "@types/node": "^22.18.0",
55
55
  "@types/react": "^19.1.11",
56
- "@types/react-dom": "^19.1.7",
56
+ "@types/react-dom": "^19.1.8",
57
57
  "@vitejs/plugin-react": "workspace:*",
58
58
  "react": "^19.1.1",
59
59
  "react-dom": "^19.1.1",