@vitejs/plugin-rsc 0.5.11 → 0.5.13
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/{chunk-ezxmLbPQ.js → chunk-BFhhoFQb.js} +1 -2
- package/dist/{cjs-DHD_0drE.js → cjs-DH9Oa3zy.js} +2 -2
- package/dist/core/browser.js +1 -1
- package/dist/core/plugin.js +1 -1
- package/dist/core/rsc.js +1 -1
- package/dist/core/ssr.js +1 -1
- package/dist/index.js +4 -4
- package/dist/{picocolors-BxaHL81J.js → picocolors-kt7Y18A3.js} +1 -1
- package/dist/{plugin-BcfVRLx-.js → plugin-DSNqWPmA.js} +174 -119
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.js +4 -4
- package/dist/plugins/cjs.js +1 -1
- package/dist/react/rsc.js +1 -1
- package/dist/{rsc-BRh4PjTs.js → rsc-DRNoX2Q6.js} +1 -1
- package/dist/rsc.js +2 -2
- package/dist/ssr.js +2 -2
- package/dist/transforms/index.js +1 -1
- package/dist/{transforms-BcLQCXiC.js → transforms-D4jDIHgD.js} +1 -1
- package/dist/utils/encryption-runtime.js +3 -3
- package/dist/utils/rpc.js +1 -1
- package/package.json +12 -12
- package/types/index.d.ts +12 -0
- /package/dist/{dist-BRSdGcl7.js → dist-DZUJDIM2.js} +0 -0
- /package/dist/{encryption-utils-6p8t4Xqm.js → encryption-utils-BPYvebX4.js} +0 -0
- /package/dist/{plugin-D1MQNdps.js → plugin-B1AJWrMi.js} +0 -0
- /package/dist/{rpc-CRpYrgKq.js → rpc-DbBe389F.js} +0 -0
- /package/dist/{shared-AtH_QTi7.js → shared-Chot7h9j.js} +0 -0
|
@@ -26,7 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
value: mod,
|
|
27
27
|
enumerable: true
|
|
28
28
|
}) : target, mod));
|
|
29
|
-
var __toDynamicImportESM = (isNodeMode) => (mod) => __toESM(mod.default, isNodeMode);
|
|
30
29
|
|
|
31
30
|
//#endregion
|
|
32
|
-
export {
|
|
31
|
+
export { __toESM as n, __commonJSMin as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as createDebug } from "./dist-
|
|
2
|
-
import { n as parseIdQuery } from "./shared-
|
|
1
|
+
import { t as createDebug } from "./dist-DZUJDIM2.js";
|
|
2
|
+
import { n as parseIdQuery } from "./shared-Chot7h9j.js";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
package/dist/core/browser.js
CHANGED
package/dist/core/plugin.js
CHANGED
package/dist/core/rsc.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as setRequireModule, i as loadServerAction, n as createServerDecodeClientManifest, r as createServerManifest, t as createClientManifest } from "../rsc-
|
|
1
|
+
import { a as setRequireModule, i as loadServerAction, n as createServerDecodeClientManifest, r as createServerManifest, t as createClientManifest } from "../rsc-DRNoX2Q6.js";
|
|
2
2
|
|
|
3
3
|
export { createClientManifest, createServerDecodeClientManifest, createServerManifest, loadServerAction, setRequireModule };
|
package/dist/core/ssr.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import
|
|
4
|
-
import "./
|
|
1
|
+
import "./cjs-DH9Oa3zy.js";
|
|
2
|
+
import { r as vitePluginRsc, t as getPluginApi } from "./plugin-DSNqWPmA.js";
|
|
3
|
+
import "./transforms-D4jDIHgD.js";
|
|
4
|
+
import "./rpc-DbBe389F.js";
|
|
5
5
|
|
|
6
6
|
export { vitePluginRsc as default, getPluginApi };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __commonJSMin } from "./chunk-
|
|
1
|
+
import { t as __commonJSMin } from "./chunk-BFhhoFQb.js";
|
|
2
2
|
|
|
3
3
|
//#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
4
4
|
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { n as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { n as __toESM } from "./chunk-BFhhoFQb.js";
|
|
2
|
+
import { t as createDebug } from "./dist-DZUJDIM2.js";
|
|
3
|
+
import { t as vitePluginRscCore } from "./plugin-B1AJWrMi.js";
|
|
4
|
+
import { t as cjsModuleRunnerPlugin } from "./cjs-DH9Oa3zy.js";
|
|
5
|
+
import { i as toCssVirtual, n as parseIdQuery, r as parseReferenceValidationVirtual, t as parseCssVirtual } from "./shared-Chot7h9j.js";
|
|
6
|
+
import { a as hasDirective, n as transformDirectiveProxyExport, o as transformWrapExport, s as findDirectives, t as transformServerActionServer } from "./transforms-D4jDIHgD.js";
|
|
7
|
+
import { o as generateEncryptionKey, s as toBase64 } from "./encryption-utils-BPYvebX4.js";
|
|
8
|
+
import { n as createRpcServer } from "./rpc-DbBe389F.js";
|
|
9
9
|
import { createRequire } from "node:module";
|
|
10
10
|
import assert from "node:assert";
|
|
11
11
|
import fs from "node:fs";
|
|
12
12
|
import path from "node:path";
|
|
13
13
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
14
|
-
import { toNodeHandler } from "srvx/node";
|
|
15
14
|
import * as esModuleLexer from "es-module-lexer";
|
|
16
15
|
import MagicString from "magic-string";
|
|
16
|
+
import { toNodeHandler } from "srvx/node";
|
|
17
|
+
import { stripLiteral } from "strip-literal";
|
|
17
18
|
import * as vite from "vite";
|
|
18
19
|
import { defaultServerConditions, isCSSRequest, isFileLoadingAllowed, normalizePath, parseAstAsync } from "vite";
|
|
19
20
|
import { crawlFrameworkPkgs } from "vitefu";
|
|
20
21
|
import { walk } from "estree-walker";
|
|
21
22
|
import { stripVTControlCharacters } from "node:util";
|
|
22
23
|
import { createHash } from "node:crypto";
|
|
23
|
-
import { stripLiteral } from "strip-literal";
|
|
24
24
|
|
|
25
25
|
//#region src/plugins/vite-utils.ts
|
|
26
26
|
const VALID_ID_PREFIX = `/@id/`;
|
|
@@ -92,6 +92,128 @@ function evalValue(rawValue) {
|
|
|
92
92
|
}
|
|
93
93
|
const directRequestRE = /(\?|&)direct=?(?:&|$)/;
|
|
94
94
|
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/plugins/find-source-map-url.ts
|
|
97
|
+
function vitePluginFindSourceMapURL() {
|
|
98
|
+
return [{
|
|
99
|
+
name: "rsc:findSourceMapURL",
|
|
100
|
+
apply: "serve",
|
|
101
|
+
configureServer(server) {
|
|
102
|
+
server.middlewares.use(async (req, res, next) => {
|
|
103
|
+
const url = new URL(req.url, `http://localhost`);
|
|
104
|
+
if (url.pathname === "/__vite_rsc_findSourceMapURL") {
|
|
105
|
+
let filename = url.searchParams.get("filename");
|
|
106
|
+
let environmentName = url.searchParams.get("environmentName");
|
|
107
|
+
try {
|
|
108
|
+
const map = await findSourceMapURL(server, filename, environmentName);
|
|
109
|
+
res.setHeader("content-type", "application/json");
|
|
110
|
+
if (!map) res.statusCode = 404;
|
|
111
|
+
res.end(JSON.stringify(map ?? {}));
|
|
112
|
+
} catch (e) {
|
|
113
|
+
next(e);
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
next();
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}];
|
|
121
|
+
}
|
|
122
|
+
async function findSourceMapURL(server, filename, environmentName) {
|
|
123
|
+
if (filename.startsWith("file://")) {
|
|
124
|
+
filename = slash(fileURLToPath(filename));
|
|
125
|
+
if (isFileLoadingAllowed(server.config, filename) && fs.existsSync(filename)) {
|
|
126
|
+
const content = fs.readFileSync(filename, "utf-8");
|
|
127
|
+
return {
|
|
128
|
+
version: 3,
|
|
129
|
+
sources: [filename],
|
|
130
|
+
sourcesContent: [content],
|
|
131
|
+
mappings: "AAAA" + ";AACA".repeat(content.split("\n").length)
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
let mod;
|
|
137
|
+
let map;
|
|
138
|
+
if (environmentName === "Server") {
|
|
139
|
+
mod = server.environments.rsc.moduleGraph.getModuleById(filename);
|
|
140
|
+
map = mod?.transformResult?.map;
|
|
141
|
+
if (map && map.mappings) map = {
|
|
142
|
+
...map,
|
|
143
|
+
mappings: ";;" + map.mappings
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const base = server.config.base.slice(0, -1);
|
|
147
|
+
if (environmentName === "Client") try {
|
|
148
|
+
const url = new URL(filename).pathname.slice(base.length);
|
|
149
|
+
mod = server.environments.client.moduleGraph.urlToModuleMap.get(url);
|
|
150
|
+
map = mod?.transformResult?.map;
|
|
151
|
+
} catch (e) {}
|
|
152
|
+
if (mod && map) return {
|
|
153
|
+
...map,
|
|
154
|
+
sources: [base + mod.url]
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/plugins/resolved-id-proxy.ts
|
|
160
|
+
const RESOLVED_ID_PROXY_PREFIX = "virtual:vite-rsc/resolved-id/";
|
|
161
|
+
function toResolvedIdProxy(resolvedId) {
|
|
162
|
+
return RESOLVED_ID_PROXY_PREFIX + encodeURIComponent(resolvedId);
|
|
163
|
+
}
|
|
164
|
+
function withResolvedIdProxy(resolvedId) {
|
|
165
|
+
return resolvedId.startsWith("\0") ? toResolvedIdProxy(resolvedId) : resolvedId;
|
|
166
|
+
}
|
|
167
|
+
function fromResolvedIdProxy(source) {
|
|
168
|
+
if (!source.startsWith(RESOLVED_ID_PROXY_PREFIX)) return;
|
|
169
|
+
const clean = source.split("?")[0];
|
|
170
|
+
return decodeURIComponent(clean.slice(29));
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Vite plugin that resolves proxy import specifiers to the original resolved IDs.
|
|
174
|
+
*/
|
|
175
|
+
function vitePluginResolvedIdProxy() {
|
|
176
|
+
return {
|
|
177
|
+
name: "rsc:resolved-id-proxy",
|
|
178
|
+
resolveId: { handler(source) {
|
|
179
|
+
const originalId = fromResolvedIdProxy(source);
|
|
180
|
+
if (originalId !== void 0) return originalId;
|
|
181
|
+
} }
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/plugins/scan.ts
|
|
187
|
+
function scanBuildStripPlugin({ manager }) {
|
|
188
|
+
return {
|
|
189
|
+
name: "rsc:scan-strip",
|
|
190
|
+
apply: "build",
|
|
191
|
+
enforce: "post",
|
|
192
|
+
async transform(code, _id, _options) {
|
|
193
|
+
if (!manager.isScanBuild) return;
|
|
194
|
+
return {
|
|
195
|
+
code: await transformScanBuildStrip(code),
|
|
196
|
+
map: { mappings: "" }
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const importGlobRE = /\bimport\.meta\.glob(?:<\w+>)?\s*\(/g;
|
|
202
|
+
async function transformScanBuildStrip(code) {
|
|
203
|
+
const [imports] = esModuleLexer.parse(code);
|
|
204
|
+
let output = imports.map((e) => e.n && `import ${JSON.stringify(e.n)};\n`).filter(Boolean).join("");
|
|
205
|
+
if (importGlobRE.test(code)) {
|
|
206
|
+
walk(await parseAstAsync(code), { enter(node) {
|
|
207
|
+
if (node.type === "CallExpression" && node.callee.type === "MemberExpression" && node.callee.object.type === "MetaProperty" && node.callee.object.meta.type === "Identifier" && node.callee.object.meta.name === "import" && node.callee.object.property.type === "Identifier" && node.callee.object.property.name === "meta" && node.callee.property.type === "Identifier" && node.callee.property.name === "glob") {
|
|
208
|
+
const importMetaGlob = code.slice(node.start, node.end);
|
|
209
|
+
output += `console.log(${importMetaGlob});\n`;
|
|
210
|
+
}
|
|
211
|
+
} });
|
|
212
|
+
output += "";
|
|
213
|
+
}
|
|
214
|
+
return output;
|
|
215
|
+
}
|
|
216
|
+
|
|
95
217
|
//#endregion
|
|
96
218
|
//#region src/plugins/utils.ts
|
|
97
219
|
function sortObject(o) {
|
|
@@ -162,38 +284,6 @@ function getFetchHandlerExport(exports) {
|
|
|
162
284
|
throw new Error("Invalid server handler entry");
|
|
163
285
|
}
|
|
164
286
|
|
|
165
|
-
//#endregion
|
|
166
|
-
//#region src/plugins/scan.ts
|
|
167
|
-
function scanBuildStripPlugin({ manager }) {
|
|
168
|
-
return {
|
|
169
|
-
name: "rsc:scan-strip",
|
|
170
|
-
apply: "build",
|
|
171
|
-
enforce: "post",
|
|
172
|
-
async transform(code, _id, _options) {
|
|
173
|
-
if (!manager.isScanBuild) return;
|
|
174
|
-
return {
|
|
175
|
-
code: await transformScanBuildStrip(code),
|
|
176
|
-
map: { mappings: "" }
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
const importGlobRE = /\bimport\.meta\.glob(?:<\w+>)?\s*\(/g;
|
|
182
|
-
async function transformScanBuildStrip(code) {
|
|
183
|
-
const [imports] = esModuleLexer.parse(code);
|
|
184
|
-
let output = imports.map((e) => e.n && `import ${JSON.stringify(e.n)};\n`).filter(Boolean).join("");
|
|
185
|
-
if (importGlobRE.test(code)) {
|
|
186
|
-
walk(await parseAstAsync(code), { enter(node) {
|
|
187
|
-
if (node.type === "CallExpression" && node.callee.type === "MemberExpression" && node.callee.object.type === "MetaProperty" && node.callee.object.meta.type === "Identifier" && node.callee.object.meta.name === "import" && node.callee.object.property.type === "Identifier" && node.callee.object.property.name === "meta" && node.callee.property.type === "Identifier" && node.callee.property.name === "glob") {
|
|
188
|
-
const importMetaGlob = code.slice(node.start, node.end);
|
|
189
|
-
output += `console.log(${importMetaGlob});\n`;
|
|
190
|
-
}
|
|
191
|
-
} });
|
|
192
|
-
output += "";
|
|
193
|
-
}
|
|
194
|
-
return output;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
287
|
//#endregion
|
|
198
288
|
//#region src/plugins/validate-import.ts
|
|
199
289
|
function validateImportPlugin() {
|
|
@@ -273,69 +363,6 @@ function validateImportChain(chain, environmentName, root) {
|
|
|
273
363
|
throw error;
|
|
274
364
|
}
|
|
275
365
|
|
|
276
|
-
//#endregion
|
|
277
|
-
//#region src/plugins/find-source-map-url.ts
|
|
278
|
-
function vitePluginFindSourceMapURL() {
|
|
279
|
-
return [{
|
|
280
|
-
name: "rsc:findSourceMapURL",
|
|
281
|
-
apply: "serve",
|
|
282
|
-
configureServer(server) {
|
|
283
|
-
server.middlewares.use(async (req, res, next) => {
|
|
284
|
-
const url = new URL(req.url, `http://localhost`);
|
|
285
|
-
if (url.pathname === "/__vite_rsc_findSourceMapURL") {
|
|
286
|
-
let filename = url.searchParams.get("filename");
|
|
287
|
-
let environmentName = url.searchParams.get("environmentName");
|
|
288
|
-
try {
|
|
289
|
-
const map = await findSourceMapURL(server, filename, environmentName);
|
|
290
|
-
res.setHeader("content-type", "application/json");
|
|
291
|
-
if (!map) res.statusCode = 404;
|
|
292
|
-
res.end(JSON.stringify(map ?? {}));
|
|
293
|
-
} catch (e) {
|
|
294
|
-
next(e);
|
|
295
|
-
}
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
next();
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
}];
|
|
302
|
-
}
|
|
303
|
-
async function findSourceMapURL(server, filename, environmentName) {
|
|
304
|
-
if (filename.startsWith("file://")) {
|
|
305
|
-
filename = slash(fileURLToPath(filename));
|
|
306
|
-
if (isFileLoadingAllowed(server.config, filename) && fs.existsSync(filename)) {
|
|
307
|
-
const content = fs.readFileSync(filename, "utf-8");
|
|
308
|
-
return {
|
|
309
|
-
version: 3,
|
|
310
|
-
sources: [filename],
|
|
311
|
-
sourcesContent: [content],
|
|
312
|
-
mappings: "AAAA" + ";AACA".repeat(content.split("\n").length)
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
let mod;
|
|
318
|
-
let map;
|
|
319
|
-
if (environmentName === "Server") {
|
|
320
|
-
mod = server.environments.rsc.moduleGraph.getModuleById(filename);
|
|
321
|
-
map = mod?.transformResult?.map;
|
|
322
|
-
if (map && map.mappings) map = {
|
|
323
|
-
...map,
|
|
324
|
-
mappings: ";;" + map.mappings
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
const base = server.config.base.slice(0, -1);
|
|
328
|
-
if (environmentName === "Client") try {
|
|
329
|
-
const url = new URL(filename).pathname.slice(base.length);
|
|
330
|
-
mod = server.environments.client.moduleGraph.urlToModuleMap.get(url);
|
|
331
|
-
map = mod?.transformResult?.map;
|
|
332
|
-
} catch (e) {}
|
|
333
|
-
if (mod && map) return {
|
|
334
|
-
...map,
|
|
335
|
-
sources: [base + mod.url]
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
|
|
339
366
|
//#endregion
|
|
340
367
|
//#region src/plugin.ts
|
|
341
368
|
const isRolldownVite = "rolldownVersion" in vite;
|
|
@@ -347,6 +374,9 @@ const require = createRequire(import.meta.url);
|
|
|
347
374
|
function resolvePackage(name) {
|
|
348
375
|
return pathToFileURL(require.resolve(name)).href;
|
|
349
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* @experimental
|
|
379
|
+
*/
|
|
350
380
|
var RscPluginManager = class {
|
|
351
381
|
server;
|
|
352
382
|
config;
|
|
@@ -364,6 +394,13 @@ var RscPluginManager = class {
|
|
|
364
394
|
toRelativeId(id) {
|
|
365
395
|
return normalizePath(path.relative(this.config.root, id));
|
|
366
396
|
}
|
|
397
|
+
writeAssetsManifest(environmentNames) {
|
|
398
|
+
const assetsManifestCode = `export default ${serializeValueWithRuntime(this.buildAssetsManifest)}`;
|
|
399
|
+
for (const name of environmentNames) {
|
|
400
|
+
const manifestPath = path.join(this.config.environments[name].build.outDir, BUILD_ASSETS_MANIFEST_NAME);
|
|
401
|
+
fs.writeFileSync(manifestPath, assetsManifestCode);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
367
404
|
};
|
|
368
405
|
/** @experimental */
|
|
369
406
|
function getPluginApi(config) {
|
|
@@ -417,13 +454,14 @@ function vitePluginRscMinimal(rscPluginOptions = {}, manager = new RscPluginMana
|
|
|
417
454
|
}
|
|
418
455
|
} }
|
|
419
456
|
},
|
|
420
|
-
scanBuildStripPlugin({ manager })
|
|
457
|
+
scanBuildStripPlugin({ manager }),
|
|
458
|
+
vitePluginResolvedIdProxy()
|
|
421
459
|
];
|
|
422
460
|
}
|
|
423
461
|
function vitePluginRsc(rscPluginOptions = {}) {
|
|
424
462
|
const manager = new RscPluginManager();
|
|
425
463
|
const buildApp = async (builder) => {
|
|
426
|
-
const colors = await import("./picocolors-
|
|
464
|
+
const colors = await import("./picocolors-kt7Y18A3.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
427
465
|
const logStep = (msg) => {
|
|
428
466
|
builder.config.logger.info(colors.blue(msg));
|
|
429
467
|
};
|
|
@@ -443,9 +481,13 @@ function vitePluginRsc(rscPluginOptions = {}) {
|
|
|
443
481
|
manager.stabilize();
|
|
444
482
|
logStep("[4/4] build client environment...");
|
|
445
483
|
await builder.build(builder.environments.client);
|
|
446
|
-
writeAssetsManifest(["rsc"]);
|
|
484
|
+
manager.writeAssetsManifest(["rsc"]);
|
|
447
485
|
return;
|
|
448
486
|
}
|
|
487
|
+
const rscOutDir = builder.environments.rsc.config.build.outDir;
|
|
488
|
+
const ssrOutDir = builder.environments.ssr.config.build.outDir;
|
|
489
|
+
const rscInsideSsr = path.normalize(rscOutDir).startsWith(path.normalize(ssrOutDir) + path.sep);
|
|
490
|
+
const tempRscOutDir = path.join(builder.config.root, "node_modules", ".vite-rsc-temp", "rsc");
|
|
449
491
|
manager.isScanBuild = true;
|
|
450
492
|
builder.environments.rsc.config.build.write = false;
|
|
451
493
|
builder.environments.ssr.config.build.write = false;
|
|
@@ -458,22 +500,34 @@ function vitePluginRsc(rscPluginOptions = {}) {
|
|
|
458
500
|
builder.environments.ssr.config.build.write = true;
|
|
459
501
|
logStep("[3/5] build rsc environment...");
|
|
460
502
|
await builder.build(builder.environments.rsc);
|
|
503
|
+
if (rscInsideSsr) {
|
|
504
|
+
if (fs.existsSync(tempRscOutDir)) fs.rmSync(tempRscOutDir, { recursive: true });
|
|
505
|
+
fs.mkdirSync(path.dirname(tempRscOutDir), { recursive: true });
|
|
506
|
+
fs.renameSync(rscOutDir, tempRscOutDir);
|
|
507
|
+
}
|
|
461
508
|
manager.stabilize();
|
|
462
509
|
logStep("[4/5] build client environment...");
|
|
463
510
|
await builder.build(builder.environments.client);
|
|
464
511
|
logStep("[5/5] build ssr environment...");
|
|
465
512
|
await builder.build(builder.environments.ssr);
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
for (const name of environmentNames) {
|
|
471
|
-
const manifestPath = path.join(manager.config.environments[name].build.outDir, BUILD_ASSETS_MANIFEST_NAME);
|
|
472
|
-
fs.writeFileSync(manifestPath, assetsManifestCode);
|
|
513
|
+
if (rscInsideSsr) {
|
|
514
|
+
if (fs.existsSync(rscOutDir)) fs.rmSync(rscOutDir, { recursive: true });
|
|
515
|
+
fs.mkdirSync(path.dirname(rscOutDir), { recursive: true });
|
|
516
|
+
fs.renameSync(tempRscOutDir, rscOutDir);
|
|
473
517
|
}
|
|
474
|
-
|
|
518
|
+
manager.writeAssetsManifest(["ssr", "rsc"]);
|
|
519
|
+
};
|
|
475
520
|
let hasReactServerDomWebpack = false;
|
|
476
521
|
return [
|
|
522
|
+
{
|
|
523
|
+
name: "rsc:builder-api",
|
|
524
|
+
buildApp: {
|
|
525
|
+
order: "pre",
|
|
526
|
+
async handler(builder) {
|
|
527
|
+
builder.rsc = { manager };
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
},
|
|
477
531
|
{
|
|
478
532
|
name: "rsc",
|
|
479
533
|
async config(config, env) {
|
|
@@ -555,7 +609,7 @@ function vitePluginRsc(rscPluginOptions = {}) {
|
|
|
555
609
|
}
|
|
556
610
|
}
|
|
557
611
|
},
|
|
558
|
-
builder: {
|
|
612
|
+
builder: rscPluginOptions.customBuildApp ? void 0 : {
|
|
559
613
|
sharedPlugins: true,
|
|
560
614
|
sharedConfigBuild: true,
|
|
561
615
|
async buildApp(builder) {
|
|
@@ -568,6 +622,7 @@ function vitePluginRsc(rscPluginOptions = {}) {
|
|
|
568
622
|
if (Number(vite.version.split(".")[0]) >= 7) rscPluginOptions.useBuildAppHook ??= true;
|
|
569
623
|
},
|
|
570
624
|
buildApp: { async handler(builder) {
|
|
625
|
+
if (rscPluginOptions.customBuildApp) return;
|
|
571
626
|
if (rscPluginOptions.useBuildAppHook) await buildApp(builder);
|
|
572
627
|
} },
|
|
573
628
|
configureServer(server) {
|
|
@@ -1062,7 +1117,7 @@ function vitePluginUseClient(useClientPluginOptions, manager) {
|
|
|
1062
1117
|
};
|
|
1063
1118
|
if (manager.isScanBuild) {
|
|
1064
1119
|
let code$1 = ``;
|
|
1065
|
-
for (const meta of Object.values(manager.clientReferenceMetaMap)) code$1 += `import ${JSON.stringify(meta.importId)};\n`;
|
|
1120
|
+
for (const meta of Object.values(manager.clientReferenceMetaMap)) code$1 += `import ${JSON.stringify(withResolvedIdProxy(meta.importId))};\n`;
|
|
1066
1121
|
return {
|
|
1067
1122
|
code: code$1,
|
|
1068
1123
|
map: null
|
|
@@ -1105,7 +1160,7 @@ function vitePluginUseClient(useClientPluginOptions, manager) {
|
|
|
1105
1160
|
for (const meta of metas) {
|
|
1106
1161
|
const exports = meta.renderedExports.map((name$1) => `${name$1}: import_${meta.referenceKey}.${name$1},\n`).sort().join("");
|
|
1107
1162
|
code += `
|
|
1108
|
-
import * as import_${meta.referenceKey} from ${JSON.stringify(meta.importId)};
|
|
1163
|
+
import * as import_${meta.referenceKey} from ${JSON.stringify(withResolvedIdProxy(meta.importId))};
|
|
1109
1164
|
export const export_${meta.referenceKey} = {${exports}};
|
|
1110
1165
|
`;
|
|
1111
1166
|
}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ type ServerRerferenceMeta = {
|
|
|
17
17
|
referenceKey: string;
|
|
18
18
|
exportNames: string[];
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* @experimental
|
|
22
|
+
*/
|
|
20
23
|
declare class RscPluginManager {
|
|
21
24
|
server: ViteDevServer;
|
|
22
25
|
config: ResolvedConfig;
|
|
@@ -31,6 +34,7 @@ declare class RscPluginManager {
|
|
|
31
34
|
}>;
|
|
32
35
|
stabilize(): void;
|
|
33
36
|
toRelativeId(id: string): string;
|
|
37
|
+
writeAssetsManifest(environmentNames: string[]): void;
|
|
34
38
|
}
|
|
35
39
|
type RscPluginOptions = {
|
|
36
40
|
/**
|
|
@@ -80,6 +84,13 @@ type RscPluginOptions = {
|
|
|
80
84
|
*/
|
|
81
85
|
useBuildAppHook?: boolean;
|
|
82
86
|
/**
|
|
87
|
+
* Skip the default buildApp orchestration and expose utilities on `builder.rsc`
|
|
88
|
+
* for downstream frameworks to implement custom build pipelines.
|
|
89
|
+
* @experimental
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
customBuildApp?: boolean;
|
|
93
|
+
/**
|
|
83
94
|
* Custom environment configuration
|
|
84
95
|
* @experimental
|
|
85
96
|
* @default { browser: 'client', ssr: 'ssr', rsc: 'rsc' }
|
package/dist/plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import
|
|
4
|
-
import "./
|
|
1
|
+
import "./cjs-DH9Oa3zy.js";
|
|
2
|
+
import { i as vitePluginRscMinimal, n as transformRscCssExport, r as vitePluginRsc, t as getPluginApi } from "./plugin-DSNqWPmA.js";
|
|
3
|
+
import "./transforms-D4jDIHgD.js";
|
|
4
|
+
import "./rpc-DbBe389F.js";
|
|
5
5
|
|
|
6
6
|
export { vitePluginRsc as default, getPluginApi, transformRscCssExport, vitePluginRscMinimal };
|
package/dist/plugins/cjs.js
CHANGED
package/dist/react/rsc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as setRequireModule, i as loadServerAction, n as createServerDecodeClientManifest, r as createServerManifest, t as createClientManifest } from "../rsc-
|
|
1
|
+
import { a as setRequireModule, i as loadServerAction, n as createServerDecodeClientManifest, r as createServerManifest, t as createClientManifest } from "../rsc-DRNoX2Q6.js";
|
|
2
2
|
import * as ReactClient from "@vitejs/plugin-rsc/vendor/react-server-dom/client.edge";
|
|
3
3
|
import * as ReactServer from "@vitejs/plugin-rsc/vendor/react-server-dom/server.edge";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as tinyassert, n as memoize } from "./dist-
|
|
1
|
+
import { i as tinyassert, n as memoize } from "./dist-DZUJDIM2.js";
|
|
2
2
|
import { a as setInternalRequire, i as removeReferenceCacheTag, n as SERVER_REFERENCE_PREFIX, r as createReferenceCacheTag, t as SERVER_DECODE_CLIENT_PREFIX } from "./shared-DEpnONZf.js";
|
|
3
3
|
import * as ReactServer from "@vitejs/plugin-rsc/vendor/react-server-dom/server.edge";
|
|
4
4
|
|
package/dist/rsc.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as toReferenceValidationVirtual } from "./shared-
|
|
2
|
-
import { a as setRequireModule, i as loadServerAction, r as createServerManifest, t as createClientManifest } from "./rsc-
|
|
1
|
+
import { a as toReferenceValidationVirtual } from "./shared-Chot7h9j.js";
|
|
2
|
+
import { a as setRequireModule, i as loadServerAction, r as createServerManifest, t as createClientManifest } from "./rsc-DRNoX2Q6.js";
|
|
3
3
|
import { createClientTemporaryReferenceSet, createFromReadableStream, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, encodeReply, registerClientReference, registerServerReference, renderToReadableStream } from "./react/rsc.js";
|
|
4
4
|
import { decryptActionBoundArgs, encryptActionBoundArgs } from "./utils/encryption-runtime.js";
|
|
5
5
|
import serverReferences from "virtual:vite-rsc/server-references";
|
package/dist/ssr.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as toReferenceValidationVirtual, i as toCssVirtual } from "./shared-
|
|
1
|
+
import { a as toReferenceValidationVirtual, i as toCssVirtual } from "./shared-Chot7h9j.js";
|
|
2
2
|
import { createServerConsumerManifest, setRequireModule } from "./core/ssr.js";
|
|
3
3
|
import { callServer, createFromReadableStream, createServerReference, findSourceMapURL } from "./react/ssr.js";
|
|
4
4
|
import * as clientReferences from "virtual:vite-rsc/client-references";
|
|
5
|
-
import assetsManifest from "virtual:vite-rsc/assets-manifest";
|
|
6
5
|
import * as ReactDOM from "react-dom";
|
|
6
|
+
import assetsManifest from "virtual:vite-rsc/assets-manifest";
|
|
7
7
|
|
|
8
8
|
//#region src/ssr.tsx
|
|
9
9
|
initialize();
|
package/dist/transforms/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as hasDirective, c as transformHoistInlineDirective, i as getExportNames, n as transformDirectiveProxyExport, o as transformWrapExport, r as transformProxyExport, s as findDirectives, t as transformServerActionServer } from "../transforms-
|
|
1
|
+
import { a as hasDirective, c as transformHoistInlineDirective, i as getExportNames, n as transformDirectiveProxyExport, o as transformWrapExport, r as transformProxyExport, s as findDirectives, t as transformServerActionServer } from "../transforms-D4jDIHgD.js";
|
|
2
2
|
|
|
3
3
|
export { findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as once } from "../dist-
|
|
2
|
-
import { a as fromBase64, i as encryptBuffer, n as concatArrayStream, r as decryptBuffer, t as arrayToStream } from "../encryption-utils-
|
|
3
|
-
import "../rsc-
|
|
1
|
+
import { r as once } from "../dist-DZUJDIM2.js";
|
|
2
|
+
import { a as fromBase64, i as encryptBuffer, n as concatArrayStream, r as decryptBuffer, t as arrayToStream } from "../encryption-utils-BPYvebX4.js";
|
|
3
|
+
import "../rsc-DRNoX2Q6.js";
|
|
4
4
|
import { createFromReadableStream, renderToReadableStream } from "../react/rsc.js";
|
|
5
5
|
import encryptionKeySource from "virtual:vite-rsc/encryption-key";
|
|
6
6
|
|
package/dist/utils/rpc.js
CHANGED
package/package.json
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-rsc",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.13",
|
|
4
4
|
"description": "React Server Components (RSC) support for Vite.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"vite",
|
|
7
|
-
"vite-plugin",
|
|
8
6
|
"react",
|
|
9
7
|
"react-server-components",
|
|
10
|
-
"rsc"
|
|
8
|
+
"rsc",
|
|
9
|
+
"vite",
|
|
10
|
+
"vite-plugin"
|
|
11
11
|
],
|
|
12
12
|
"homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-rsc",
|
|
13
|
+
"license": "MIT",
|
|
13
14
|
"repository": {
|
|
14
15
|
"type": "git",
|
|
15
16
|
"url": "git+https://github.com/vitejs/vite-plugin-react.git",
|
|
16
17
|
"directory": "packages/plugin-rsc"
|
|
17
18
|
},
|
|
18
|
-
"
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"types"
|
|
22
|
+
],
|
|
19
23
|
"type": "module",
|
|
20
24
|
"exports": {
|
|
21
25
|
"./package.json": "./package.json",
|
|
@@ -24,10 +28,6 @@
|
|
|
24
28
|
"./transforms": "./dist/transforms/index.js",
|
|
25
29
|
"./*": "./dist/*.js"
|
|
26
30
|
},
|
|
27
|
-
"files": [
|
|
28
|
-
"dist",
|
|
29
|
-
"types"
|
|
30
|
-
],
|
|
31
31
|
"scripts": {
|
|
32
32
|
"test": "vitest",
|
|
33
33
|
"test-e2e": "playwright test --project=chromium",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"@playwright/test": "^1.57.0",
|
|
54
54
|
"@tsconfig/strictest": "^2.0.8",
|
|
55
55
|
"@types/estree": "^1.0.8",
|
|
56
|
-
"@types/node": "^24.10.
|
|
57
|
-
"@types/react": "^19.2.
|
|
56
|
+
"@types/node": "^24.10.7",
|
|
57
|
+
"@types/react": "^19.2.8",
|
|
58
58
|
"@types/react-dom": "^19.2.3",
|
|
59
59
|
"@vitejs/plugin-react": "workspace:*",
|
|
60
60
|
"@vitejs/test-dep-cjs-and-esm": "./test-dep/cjs-and-esm",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"react-dom": "^19.2.3",
|
|
64
64
|
"react-server-dom-webpack": "^19.2.3",
|
|
65
65
|
"tinyexec": "^1.0.2",
|
|
66
|
-
"tsdown": "^0.
|
|
66
|
+
"tsdown": "^0.19.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"react": "*",
|
package/types/index.d.ts
CHANGED
|
@@ -17,6 +17,18 @@ declare module 'vite' {
|
|
|
17
17
|
/** Options for `@vitejs/plugin-rsc` */
|
|
18
18
|
rsc?: import('@vitejs/plugin-rsc').RscPluginOptions
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
interface ViteBuilder {
|
|
22
|
+
/**
|
|
23
|
+
* RSC plugin API exposed for custom build pipelines.
|
|
24
|
+
* Available when using `rsc({ customBuildApp: true })`.
|
|
25
|
+
* @experimental
|
|
26
|
+
*/
|
|
27
|
+
rsc: {
|
|
28
|
+
/** Access to internal RscPluginManager for controlling build phases */
|
|
29
|
+
manager: import('@vitejs/plugin-rsc').RscPluginManager
|
|
30
|
+
}
|
|
31
|
+
}
|
|
20
32
|
}
|
|
21
33
|
|
|
22
34
|
export {}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|