@vitejs/plugin-rsc 0.5.33 → 0.5.34

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 CHANGED
@@ -26,8 +26,9 @@ npm create vite@latest -- --template rsc
26
26
  **Integration examples:**
27
27
 
28
28
  - [`./examples/basic`](./examples/basic) - Comprehensive showcase of standard RSC features and the primary E2E test fixture.
29
- - [`./examples/use-cache`](./examples/use-cache) - Minimal cache feature inspired by Next.js's `"use cache"`, built with generic transform and RSC runtime APIs.
30
- - [`./examples/use-cache-callable`](./examples/use-cache-callable) - Inline cache wrapper exported as a callable Server Function through a custom transform.
29
+ - [`./examples/use-cache`](./examples/use-cache) - Local cached functions and components demonstrating argument keys, Flight replay, dynamic children, captured values, and invalidation.
30
+ - [`./examples/use-cache-callable`](./examples/use-cache-callable) - Cached server references demonstrating inline and file directives, client invocation, argument admission, and encrypted closure captures.
31
+ - [`./examples/use-cache-persistent`](./examples/use-cache-persistent) - Persistent callable cache entries demonstrating Flight value replay and dependency-aware development invalidation.
31
32
  - [`./examples/custom-server-function`](./examples/custom-server-function) - Third-party Server Function directive integration using server reference claims.
32
33
  - [`./examples/ssg`](./examples/ssg) - Static site generation with MDX and client components for interactivity.
33
34
  - [`./examples/ppr`](./examples/ppr) - Partial prerendering with a reusable static HTML shell and request-time RSC content.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { r as vitePluginRsc, t as getPluginApi } from "./plugin-DarRieDr.js";
1
+ import { r as vitePluginRsc, t as getPluginApi } from "./plugin-Cbs9j6lP.js";
2
2
  export { vitePluginRsc as default, getPluginApi };
@@ -1,4 +1,4 @@
1
- import { a as __commonJSMin } from "./plugin-DarRieDr.js";
1
+ import { a as __commonJSMin } from "./plugin-Cbs9j6lP.js";
2
2
  //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
3
3
  var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4
4
  let p = process || {};
@@ -489,11 +489,7 @@ function aggregateClaims(importId, claims) {
489
489
  exportNames: []
490
490
  };
491
491
  else if (aggregate.importId !== claim.importId || aggregate.referenceKey !== claim.referenceKey) throw new Error(`[vite-rsc] conflicting server reference identity for '${importId}'`);
492
- for (const name of claim.exportNames) {
493
- const existingOwner = exportOwners.get(name);
494
- if (existingOwner && existingOwner !== claimOwner) throw new Error(`[vite-rsc] server reference '${claim.referenceKey}#${name}' is claimed by both '${existingOwner}' and '${claimOwner}'`);
495
- exportOwners.set(name, claimOwner);
496
- }
492
+ for (const name of claim.exportNames) if (!exportOwners.get(name)) exportOwners.set(name, claimOwner);
497
493
  }
498
494
  assert(aggregate);
499
495
  aggregate.exportNames = [...exportOwners.keys()].sort();
@@ -714,7 +710,7 @@ function vitePluginRscMinimal(rscPluginOptions = {}, manager = new RscPluginMana
714
710
  function vitePluginRsc(rscPluginOptions = {}) {
715
711
  const manager = new RscPluginManager();
716
712
  const buildApp = async (builder) => {
717
- const colors = await import("./picocolors-D28_L_A0.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
713
+ const colors = await import("./picocolors-391UXIDd.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
718
714
  const logStep = (msg) => {
719
715
  builder.config.logger.info(colors.blue(msg));
720
716
  };
package/dist/plugin.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as vitePluginRscMinimal, n as transformRscCssExport, r as vitePluginRsc, t as getPluginApi } from "./plugin-DarRieDr.js";
1
+ import { i as vitePluginRscMinimal, n as transformRscCssExport, r as vitePluginRsc, t as getPluginApi } from "./plugin-Cbs9j6lP.js";
2
2
  export { vitePluginRsc as default, getPluginApi, transformRscCssExport, vitePluginRscMinimal };
@@ -86,9 +86,10 @@ function transformHoistInlineDirective(input, viteAst, { runtime, rejectNonAsync
86
86
  if ((node.type === "FunctionExpression" || node.type === "FunctionDeclaration" || node.type === "ArrowFunctionExpression") && node.body.type === "BlockStatement") {
87
87
  const match = matchDirective(node.body.body, directive)?.match;
88
88
  if (!match) return;
89
+ const methodInfo = getMethodInfo(node, parent, match[0]);
89
90
  if (!node.async && rejectNonAsyncFunction) throw Object.assign(/* @__PURE__ */ new Error(`"${directive}" doesn't allow non async function`), { pos: node.start });
90
91
  const declName = node.type === "FunctionDeclaration" && node.id.name;
91
- const originalName = declName || parent?.type === "VariableDeclarator" && parent.id.type === "Identifier" && parent.id.name || "anonymous_server_function";
92
+ const originalName = declName || methodInfo?.name || parent?.type === "VariableDeclarator" && parent.id.type === "Identifier" && parent.id.name || "anonymous_server_function";
92
93
  const bindVars = getBindVars(node, scopeTree);
93
94
  let newParams = [...bindVars.map((b) => b.root), ...node.params.map((n) => input.slice(n.start, n.end))].join(", ");
94
95
  if (bindVars.length > 0 && options.decode) {
@@ -111,7 +112,13 @@ function transformHoistInlineDirective(input, viteAst, { runtime, rejectNonAsync
111
112
  const bindArgs = options.encode ? options.encode("[" + bindVars.map((b) => b.expr).join(", ") + "]") : bindVars.map((b) => b.expr).join(", ");
112
113
  newCode = `${newCode}.bind(null, ${bindArgs})`;
113
114
  }
114
- if (declName) {
115
+ if (methodInfo) {
116
+ const isStatic = methodInfo.node.type === "MethodDefinition";
117
+ const key = input.slice(methodInfo.node.key.start, methodInfo.node.key.end);
118
+ const propertyKey = !methodInfo.node.computed && methodInfo.node.key.type === "Identifier" ? `["${key}"]` : `[${key}]`;
119
+ output.update(methodInfo.node.start, node.start, `${isStatic ? "static " : ""}${propertyKey}${isStatic ? " = " : ": "}`);
120
+ if (isStatic) newCode += ";";
121
+ } else if (declName) {
115
122
  newCode = `const ${declName} = ${newCode};`;
116
123
  if (parent?.type === "ExportDefaultDeclaration") {
117
124
  output.remove(parent.start, node.start);
@@ -127,6 +134,21 @@ function transformHoistInlineDirective(input, viteAst, { runtime, rejectNonAsync
127
134
  names
128
135
  };
129
136
  }
137
+ function getMethodInfo(node, parent, directive) {
138
+ if (node.type !== "FunctionExpression") return;
139
+ let method;
140
+ if (parent?.type === "Property" && parent.value === node && (parent.method || parent.kind !== "init")) method = parent;
141
+ else if (parent?.type === "MethodDefinition") method = parent;
142
+ else return;
143
+ if (method.type === "MethodDefinition" && !method.static) throw Object.assign(/* @__PURE__ */ new Error(`It is not allowed to define inline ${JSON.stringify(directive)} class instance methods.`), { pos: method.start });
144
+ if (method.type === "MethodDefinition" && method.key.type === "PrivateIdentifier") throw Object.assign(/* @__PURE__ */ new Error(`It is not allowed to define inline ${JSON.stringify(directive)} private class methods.`), { pos: method.start });
145
+ if (method.type === "Property" && method.kind !== "init" || method.type === "MethodDefinition" && method.kind !== "method") throw Object.assign(/* @__PURE__ */ new Error(`It is not allowed to define inline ${JSON.stringify(directive)} getters or setters.`), { pos: method.start });
146
+ const keyName = !method.computed && method.key.type === "Identifier" ? method.key.name : void 0;
147
+ return {
148
+ node: method,
149
+ name: keyName
150
+ };
151
+ }
130
152
  function getRuntimeHoistPosition(ast) {
131
153
  for (const statement of ast.body) if (!isDirective(statement)) return statement.start;
132
154
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-rsc",
3
- "version": "0.5.33",
3
+ "version": "0.5.34",
4
4
  "description": "React Server Components (RSC) support for Vite.",
5
5
  "keywords": [
6
6
  "react",