@vitejs/plugin-rsc 0.4.31 → 0.4.32
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-DWN3vCIQ.d.ts → index-B04iFwO5.d.ts} +3 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{plugin-BI8kK-GE.js → plugin-CiDpxrwJ.js} +5 -1
- package/dist/{plugin-Cfy_9VpM.d.ts → plugin-DCLI7Wh8.d.ts} +1 -1
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.js +2 -2
- package/dist/transforms/index.d.ts +2 -2
- package/dist/transforms/index.js +2 -2
- package/dist/{transforms-D1-2JfCh.js → transforms-zLwPjso_.js} +19 -5
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import MagicString from "magic-string";
|
|
2
|
-
import { Program } from "estree";
|
|
2
|
+
import { Literal, Program } from "estree";
|
|
3
3
|
|
|
4
4
|
//#region src/transforms/hoist.d.ts
|
|
5
5
|
declare function transformHoistInlineDirective(input: string, ast: Program, {
|
|
@@ -19,6 +19,7 @@ declare function transformHoistInlineDirective(input: string, ast: Program, {
|
|
|
19
19
|
output: MagicString;
|
|
20
20
|
names: string[];
|
|
21
21
|
};
|
|
22
|
+
declare function findDirectives(ast: Program, directive: string): Literal[];
|
|
22
23
|
//#endregion
|
|
23
24
|
//#region src/transforms/wrap-export.d.ts
|
|
24
25
|
type ExportMeta = {
|
|
@@ -86,4 +87,4 @@ declare function transformServerActionServer(input: string, ast: Program, option
|
|
|
86
87
|
names: string[];
|
|
87
88
|
};
|
|
88
89
|
//#endregion
|
|
89
|
-
export { TransformProxyExportOptions, TransformWrapExportFilter, TransformWrapExportOptions, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport };
|
|
90
|
+
export { TransformProxyExportOptions, TransformWrapExportFilter, TransformWrapExportOptions, findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { PluginApi, RscPluginOptions, getPluginApi, vitePluginRsc } from "./plugin-
|
|
1
|
+
import "./index-B04iFwO5.js";
|
|
2
|
+
import { PluginApi, RscPluginOptions, getPluginApi, vitePluginRsc } from "./plugin-DCLI7Wh8.js";
|
|
3
3
|
export { type PluginApi, type RscPluginOptions, vitePluginRsc as default, getPluginApi };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./dist-DiJnRA1C.js";
|
|
2
2
|
import "./plugin-CZbI4rhS.js";
|
|
3
|
-
import "./transforms-
|
|
3
|
+
import "./transforms-zLwPjso_.js";
|
|
4
4
|
import "./encryption-utils-BDwwcMVT.js";
|
|
5
5
|
import "./rpc-CUvSZurk.js";
|
|
6
|
-
import { getPluginApi, vitePluginRsc } from "./plugin-
|
|
6
|
+
import { getPluginApi, vitePluginRsc } from "./plugin-CiDpxrwJ.js";
|
|
7
7
|
import "./cjs-WQBk0zA_.js";
|
|
8
8
|
import "./shared-AvKUASD5.js";
|
|
9
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createDebug } from "./dist-DiJnRA1C.js";
|
|
2
2
|
import { vitePluginRscCore } from "./plugin-CZbI4rhS.js";
|
|
3
|
-
import { hasDirective, transformDirectiveProxyExport, transformServerActionServer, transformWrapExport } from "./transforms-
|
|
3
|
+
import { findDirectives, hasDirective, transformDirectiveProxyExport, transformServerActionServer, transformWrapExport } from "./transforms-zLwPjso_.js";
|
|
4
4
|
import { generateEncryptionKey, toBase64 } from "./encryption-utils-BDwwcMVT.js";
|
|
5
5
|
import { createRpcServer } from "./rpc-CUvSZurk.js";
|
|
6
6
|
import { cjsModuleRunnerPlugin } from "./cjs-WQBk0zA_.js";
|
|
@@ -918,6 +918,10 @@ function vitePluginUseClient(useClientPluginOptions, manager) {
|
|
|
918
918
|
delete manager.clientReferenceMetaMap[id];
|
|
919
919
|
return;
|
|
920
920
|
}
|
|
921
|
+
if (code.includes("use server")) {
|
|
922
|
+
const directives = findDirectives(ast, "use server");
|
|
923
|
+
if (directives.length > 0) this.error(`'use server' directive is not allowed inside 'use client'`, directives[0]?.start);
|
|
924
|
+
}
|
|
921
925
|
let importId;
|
|
922
926
|
let referenceKey;
|
|
923
927
|
const packageSource = packageSources.get(id);
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { AssetDeps, AssetsManifest, PluginApi, ResolvedAssetDeps, ResolvedAssetsManifest, RscPluginManager, RscPluginOptions, getPluginApi, transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin-
|
|
1
|
+
import "./index-B04iFwO5.js";
|
|
2
|
+
import { AssetDeps, AssetsManifest, PluginApi, ResolvedAssetDeps, ResolvedAssetsManifest, RscPluginManager, RscPluginOptions, getPluginApi, transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin-DCLI7Wh8.js";
|
|
3
3
|
export { AssetDeps, AssetsManifest, PluginApi, ResolvedAssetDeps, ResolvedAssetsManifest, RscPluginManager, RscPluginOptions, vitePluginRsc as default, getPluginApi, transformRscCssExport, vitePluginRscMinimal };
|
package/dist/plugin.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./dist-DiJnRA1C.js";
|
|
2
2
|
import "./plugin-CZbI4rhS.js";
|
|
3
|
-
import "./transforms-
|
|
3
|
+
import "./transforms-zLwPjso_.js";
|
|
4
4
|
import "./encryption-utils-BDwwcMVT.js";
|
|
5
5
|
import "./rpc-CUvSZurk.js";
|
|
6
|
-
import { getPluginApi, transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin-
|
|
6
|
+
import { getPluginApi, transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin-CiDpxrwJ.js";
|
|
7
7
|
import "./cjs-WQBk0zA_.js";
|
|
8
8
|
import "./shared-AvKUASD5.js";
|
|
9
9
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TransformProxyExportOptions, TransformWrapExportFilter, TransformWrapExportOptions, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport } from "../index-
|
|
2
|
-
export { TransformProxyExportOptions, TransformWrapExportFilter, TransformWrapExportOptions, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport };
|
|
1
|
+
import { TransformProxyExportOptions, TransformWrapExportFilter, TransformWrapExportOptions, findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport } from "../index-B04iFwO5.js";
|
|
2
|
+
export { TransformProxyExportOptions, TransformWrapExportFilter, TransformWrapExportOptions, findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport };
|
package/dist/transforms/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../dist-DiJnRA1C.js";
|
|
2
|
-
import { getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport } from "../transforms-
|
|
2
|
+
import { findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport } from "../transforms-zLwPjso_.js";
|
|
3
3
|
|
|
4
|
-
export { getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport };
|
|
4
|
+
export { findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport };
|
|
@@ -15,7 +15,7 @@ function transformHoistInlineDirective(input, ast, { runtime, rejectNonAsyncFunc
|
|
|
15
15
|
const names = [];
|
|
16
16
|
walk(ast, { enter(node, parent) {
|
|
17
17
|
if ((node.type === "FunctionExpression" || node.type === "FunctionDeclaration" || node.type === "ArrowFunctionExpression") && node.body.type === "BlockStatement") {
|
|
18
|
-
const match = matchDirective(node.body.body, directive);
|
|
18
|
+
const match = matchDirective(node.body.body, directive)?.match;
|
|
19
19
|
if (!match) return;
|
|
20
20
|
if (!node.async && rejectNonAsyncFunction) throw Object.assign(/* @__PURE__ */ new Error(`"${directive}" doesn't allow non async function`), { pos: node.start });
|
|
21
21
|
const scope = analyzed.map.get(node);
|
|
@@ -59,11 +59,25 @@ function transformHoistInlineDirective(input, ast, { runtime, rejectNonAsyncFunc
|
|
|
59
59
|
}
|
|
60
60
|
const exactRegex = (s) => /* @__PURE__ */ new RegExp("^" + s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") + "$");
|
|
61
61
|
function matchDirective(body, directive) {
|
|
62
|
-
for (const
|
|
63
|
-
const match =
|
|
64
|
-
if (match) return
|
|
62
|
+
for (const stmt of body) if (stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string") {
|
|
63
|
+
const match = stmt.expression.value.match(directive);
|
|
64
|
+
if (match) return {
|
|
65
|
+
match,
|
|
66
|
+
node: stmt.expression
|
|
67
|
+
};
|
|
65
68
|
}
|
|
66
69
|
}
|
|
70
|
+
function findDirectives(ast, directive) {
|
|
71
|
+
const directiveRE = exactRegex(directive);
|
|
72
|
+
const nodes = [];
|
|
73
|
+
walk(ast, { enter(node) {
|
|
74
|
+
if (node.type === "Program" || node.type === "BlockStatement") {
|
|
75
|
+
const match = matchDirective(node.body, directiveRE);
|
|
76
|
+
if (match) nodes.push(match.node);
|
|
77
|
+
}
|
|
78
|
+
} });
|
|
79
|
+
return nodes;
|
|
80
|
+
}
|
|
67
81
|
|
|
68
82
|
//#endregion
|
|
69
83
|
//#region src/transforms/wrap-export.ts
|
|
@@ -327,4 +341,4 @@ function transformServerActionServer(input, ast, options) {
|
|
|
327
341
|
}
|
|
328
342
|
|
|
329
343
|
//#endregion
|
|
330
|
-
export { getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport };
|
|
344
|
+
export { findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-rsc",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.32",
|
|
4
4
|
"description": "React Server Components (RSC) support for Vite.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"prepack": "tsdown"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@remix-run/node-fetch-server": "^0.
|
|
42
|
+
"@remix-run/node-fetch-server": "^0.9.0",
|
|
43
43
|
"es-module-lexer": "^1.7.0",
|
|
44
44
|
"estree-walker": "^3.0.3",
|
|
45
|
-
"magic-string": "^0.30.
|
|
45
|
+
"magic-string": "^0.30.19",
|
|
46
46
|
"periscopic": "^4.0.2",
|
|
47
47
|
"turbo-stream": "^3.1.0",
|
|
48
48
|
"vitefu": "^1.1.1"
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"@playwright/test": "^1.55.0",
|
|
53
53
|
"@tsconfig/strictest": "^2.0.5",
|
|
54
54
|
"@types/estree": "^1.0.8",
|
|
55
|
-
"@types/node": "^22.18.
|
|
56
|
-
"@types/react": "^19.1.
|
|
55
|
+
"@types/node": "^22.18.6",
|
|
56
|
+
"@types/react": "^19.1.13",
|
|
57
57
|
"@types/react-dom": "^19.1.9",
|
|
58
58
|
"@vitejs/plugin-react": "workspace:*",
|
|
59
59
|
"react": "^19.1.1",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"react-server-dom-webpack": "^19.1.1",
|
|
62
62
|
"rsc-html-stream": "^0.0.7",
|
|
63
63
|
"tinyexec": "^1.0.1",
|
|
64
|
-
"tsdown": "^0.
|
|
64
|
+
"tsdown": "^0.15.4"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"react": "*",
|