@vitejs/plugin-rsc 0.5.31 → 0.5.33
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 +18 -18
- package/dist/{cjs-Cxg_7upE.js → cjs-AWVWfddx.js} +3 -2
- package/dist/{client-reference-DR15qkcN.d.ts → client-reference-DEZtXTv1.d.ts} +1 -1
- package/dist/{index-COzKOTR1.d.ts → index-XXYjyFr6.d.ts} +291 -37
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{picocolors-BVMUFdce.js → picocolors-D28_L_A0.js} +1 -1
- package/dist/{plugin-DQCCjJl0.d.ts → plugin-CKqXjp8D.d.ts} +7 -4
- package/dist/{plugin-DbK8rF7n.js → plugin-DarRieDr.js} +13 -17
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugins/cjs.js +1 -1
- package/dist/rsc/server.d.ts +1 -1
- package/dist/rsc/static.d.ts +1 -1
- package/dist/{scope-Do08R7C2.js → scope-Bdx33sQv.js} +10 -5
- package/dist/ssr.d.ts +3 -2
- package/dist/ssr.js +6 -1
- package/dist/transforms/index.d.ts +2 -2
- package/dist/transforms/index.js +484 -187
- package/package.json +16 -15
- package/types/index.d.ts +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as createDebug } from "./dist-uqdtSkzK.js";
|
|
2
2
|
import vitePluginRscCore from "./core/plugin.js";
|
|
3
|
-
import { i as hasDirective } from "./scope-
|
|
4
|
-
import { t as cjsModuleRunnerPlugin } from "./cjs-
|
|
3
|
+
import { i as hasDirective } from "./scope-Bdx33sQv.js";
|
|
4
|
+
import { t as cjsModuleRunnerPlugin } from "./cjs-AWVWfddx.js";
|
|
5
5
|
import { i as toCssVirtual, n as parseIdQuery, r as parseReferenceValidationVirtual, t as parseCssVirtual } from "./shared-B6H2TbnP.js";
|
|
6
6
|
import { findDirectives, transformDirectiveProxyExport, transformExpandExportAll, transformServerActionServer, transformWrapExport } from "./transforms/index.js";
|
|
7
7
|
import { o as generateEncryptionKey, s as toBase64 } from "./encryption-utils-BNbYHtC4.js";
|
|
@@ -618,6 +618,10 @@ var RscPluginManager = class {
|
|
|
618
618
|
clientReferenceMetaMap = {};
|
|
619
619
|
clientReferenceGroups = {};
|
|
620
620
|
serverReferences = new ServerReferencesManager(this);
|
|
621
|
+
/** @deprecated Use `serverReferences.metaMap` instead. */
|
|
622
|
+
get serverReferenceMetaMap() {
|
|
623
|
+
return Object.fromEntries(this.serverReferences.metaMap);
|
|
624
|
+
}
|
|
621
625
|
serverResourcesMetaMap = {};
|
|
622
626
|
environmentImportMetaMap = {};
|
|
623
627
|
stabilize() {
|
|
@@ -710,7 +714,7 @@ function vitePluginRscMinimal(rscPluginOptions = {}, manager = new RscPluginMana
|
|
|
710
714
|
function vitePluginRsc(rscPluginOptions = {}) {
|
|
711
715
|
const manager = new RscPluginManager();
|
|
712
716
|
const buildApp = async (builder) => {
|
|
713
|
-
const colors = await import("./picocolors-
|
|
717
|
+
const colors = await import("./picocolors-D28_L_A0.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
714
718
|
const logStep = (msg) => {
|
|
715
719
|
builder.config.logger.info(colors.blue(msg));
|
|
716
720
|
};
|
|
@@ -1145,8 +1149,9 @@ export function createRpcClient(params) {
|
|
|
1145
1149
|
if (id === "\0virtual:vite-rsc/assets-manifest") {
|
|
1146
1150
|
assert(this.environment.name !== "client");
|
|
1147
1151
|
assert(this.environment.mode === "dev");
|
|
1152
|
+
const entryUrl = assetsURL("@id/__x00__" + VIRTUAL_ENTRIES.browser, manager);
|
|
1148
1153
|
const manifest = {
|
|
1149
|
-
|
|
1154
|
+
clientEntryUrl: rscPluginOptions.customClientEntry ? void 0 : entryUrl,
|
|
1150
1155
|
clientReferenceDeps: {},
|
|
1151
1156
|
cssLinkPrecedence: rscPluginOptions.cssLinkPrecedence
|
|
1152
1157
|
};
|
|
@@ -1184,7 +1189,7 @@ export function createRpcClient(params) {
|
|
|
1184
1189
|
css: rscAssetDeps[id]?.deps.css ?? []
|
|
1185
1190
|
}, manager);
|
|
1186
1191
|
const assetDeps = collectAssetDeps(bundle);
|
|
1187
|
-
let
|
|
1192
|
+
let clientEntryUrl;
|
|
1188
1193
|
let clientEntryDeps;
|
|
1189
1194
|
const clientReferenceDeps = {};
|
|
1190
1195
|
for (const meta of Object.values(manager.clientReferenceMetaMap)) {
|
|
@@ -1199,12 +1204,10 @@ export function createRpcClient(params) {
|
|
|
1199
1204
|
if (!entry) throw new Error(`[vite-rsc] Client build must have an entry chunk named "index". Use 'customClientEntry' option to disable this requirement.`);
|
|
1200
1205
|
clientEntryDeps = assetsURLOfDeps(entry.deps, manager);
|
|
1201
1206
|
for (const [key, deps] of Object.entries(clientReferenceDeps)) clientReferenceDeps[key] = mergeAssetDeps(deps, clientEntryDeps);
|
|
1202
|
-
|
|
1203
|
-
if (typeof entryUrl === "string") bootstrapScriptContent = `import(${JSON.stringify(entryUrl)})`;
|
|
1204
|
-
else bootstrapScriptContent = new RuntimeAsset(`"import(" + JSON.stringify(${entryUrl.runtime}) + ")"`);
|
|
1207
|
+
clientEntryUrl = assetsURL(entry.chunk.fileName, manager);
|
|
1205
1208
|
}
|
|
1206
1209
|
manager.buildAssetsManifest = {
|
|
1207
|
-
|
|
1210
|
+
clientEntryUrl,
|
|
1208
1211
|
clientEntryDeps,
|
|
1209
1212
|
clientReferenceDeps,
|
|
1210
1213
|
serverResources,
|
|
@@ -1221,13 +1224,6 @@ export function createRpcClient(params) {
|
|
|
1221
1224
|
}
|
|
1222
1225
|
}
|
|
1223
1226
|
},
|
|
1224
|
-
createVirtualPlugin("vite-rsc/bootstrap-script-content", function() {
|
|
1225
|
-
assert(this.environment.name !== "client");
|
|
1226
|
-
return `\
|
|
1227
|
-
import assetsManifest from "virtual:vite-rsc/assets-manifest";
|
|
1228
|
-
export default assetsManifest.bootstrapScriptContent;
|
|
1229
|
-
`;
|
|
1230
|
-
}),
|
|
1231
1227
|
{
|
|
1232
1228
|
name: "rsc:bootstrap-script-content",
|
|
1233
1229
|
transform: {
|
|
@@ -1241,7 +1237,7 @@ export default assetsManifest.bootstrapScriptContent;
|
|
|
1241
1237
|
const [argStart, argEnd] = match.indices[1];
|
|
1242
1238
|
const argCode = code.slice(argStart, argEnd).trim();
|
|
1243
1239
|
assert(evalValue(argCode), `[vite-rsc] expected 'loadBootstrapScriptContent("index")' but got ${argCode}`);
|
|
1244
|
-
let replacement = `Promise.resolve(__vite_rsc_assets_manifest.
|
|
1240
|
+
let replacement = `Promise.resolve("import(" + JSON.stringify(__vite_rsc_assets_manifest.clientEntryUrl) + ")")`;
|
|
1245
1241
|
const [start, end] = match.indices[0];
|
|
1246
1242
|
output.overwrite(start, end, replacement);
|
|
1247
1243
|
}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ResolvedAssetsManifest, c as getPluginApi, d as vitePluginRscMinimal, i as ResolvedAssetDeps, l as transformRscCssExport, n as AssetsManifest, o as RscPluginManager, r as PluginApi, s as RscPluginOptions, t as AssetDeps, u as vitePluginRsc } from "./plugin-
|
|
1
|
+
import { a as ResolvedAssetsManifest, c as getPluginApi, d as vitePluginRscMinimal, i as ResolvedAssetDeps, l as transformRscCssExport, n as AssetsManifest, o as RscPluginManager, r as PluginApi, s as RscPluginOptions, t as AssetDeps, u as vitePluginRsc } from "./plugin-CKqXjp8D.js";
|
|
2
2
|
export { AssetDeps, AssetsManifest, PluginApi, ResolvedAssetDeps, ResolvedAssetsManifest, type RscPluginManager, RscPluginOptions, vitePluginRsc as default, getPluginApi, transformRscCssExport, vitePluginRscMinimal };
|
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-
|
|
1
|
+
import { i as vitePluginRscMinimal, n as transformRscCssExport, r as vitePluginRsc, t as getPluginApi } from "./plugin-DarRieDr.js";
|
|
2
2
|
export { vitePluginRsc as default, getPluginApi, transformRscCssExport, vitePluginRscMinimal };
|
package/dist/plugins/cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as cjsModuleRunnerPlugin } from "../cjs-
|
|
1
|
+
import { t as cjsModuleRunnerPlugin } from "../cjs-AWVWfddx.js";
|
|
2
2
|
export { cjsModuleRunnerPlugin };
|
package/dist/rsc/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as createServerManifest, o as loadServerAction, r as createClientManifest, s as setRequireModule } from "../rsc-C3UdJLOW.js";
|
|
2
2
|
import { a as registerClientReference, i as decodeReply, n as decodeAction, o as registerServerReference, r as decodeFormState, t as createTemporaryReferenceSet } from "../server-ZBjqNTqU.js";
|
|
3
|
-
import { t as OnClientReference } from "../client-reference-
|
|
3
|
+
import { t as OnClientReference } from "../client-reference-DEZtXTv1.js";
|
|
4
4
|
//#region src/rsc/server.d.ts
|
|
5
5
|
declare function renderToReadableStream<T>(data: T, options?: object, extraOptions?: {
|
|
6
6
|
/**
|
package/dist/rsc/static.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { d as RenderToReadableStreamOptions, u as PrerenderResult } from "../index-C5IY2S-e.js";
|
|
2
|
-
import { t as OnClientReference } from "../client-reference-
|
|
2
|
+
import { t as OnClientReference } from "../client-reference-DEZtXTv1.js";
|
|
3
3
|
//#region src/rsc/static.d.ts
|
|
4
4
|
declare function prerender<T>(data: T, options?: RenderToReadableStreamOptions, extraOptions?: {
|
|
5
5
|
/**
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { i as tinyassert } from "./dist-uqdtSkzK.js";
|
|
2
2
|
import { walk } from "estree-walker";
|
|
3
3
|
//#region src/transforms/utils.ts
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function isDirective(node) {
|
|
5
|
+
return node.type === "ExpressionStatement" && "directive" in node;
|
|
6
|
+
}
|
|
7
|
+
function hasDirective(viteBody, directive) {
|
|
8
|
+
return viteBody.some((stmt) => isDirective(stmt) && stmt.directive === directive);
|
|
6
9
|
}
|
|
7
10
|
function extractNames(param) {
|
|
8
11
|
return extractIdentifiers(param).map((n) => n.name);
|
|
@@ -34,8 +37,10 @@ function extractIdentifiers(param, nodes = []) {
|
|
|
34
37
|
return nodes;
|
|
35
38
|
}
|
|
36
39
|
function validateNonAsyncFunction(opts, node) {
|
|
37
|
-
if (!opts.
|
|
38
|
-
|
|
40
|
+
if (node.type === "Literal" || node.type === "ObjectExpression" || node.type === "ArrayExpression" || node.type === "ClassDeclaration" || node.type === "ClassExpression" || (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") && !node.async) rejectNonAsyncFunction(opts, node.start);
|
|
41
|
+
}
|
|
42
|
+
function rejectNonAsyncFunction(opts, pos) {
|
|
43
|
+
if (opts.rejectNonAsyncFunction) throw Object.assign(/* @__PURE__ */ new Error(`unsupported non async function`), { pos });
|
|
39
44
|
}
|
|
40
45
|
//#endregion
|
|
41
46
|
//#region src/transforms/scope.ts
|
|
@@ -174,4 +179,4 @@ function getOutermostBindableReference(id, parentStack) {
|
|
|
174
179
|
return current;
|
|
175
180
|
}
|
|
176
181
|
//#endregion
|
|
177
|
-
export {
|
|
182
|
+
export { isDirective as a, hasDirective as i, extractIdentifiers as n, rejectNonAsyncFunction as o, extractNames as r, validateNonAsyncFunction as s, buildScopeTree as t };
|
package/dist/ssr.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { s as EncodeFormActionCallback } from "./index-C5IY2S-e.js";
|
|
2
2
|
import { createServerConsumerManifest, setRequireModule } from "./core/ssr.js";
|
|
3
|
-
import { i as ResolvedAssetDeps } from "./plugin-
|
|
3
|
+
import { i as ResolvedAssetDeps } from "./plugin-CKqXjp8D.js";
|
|
4
4
|
import { callServer, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL } from "./react/ssr.js";
|
|
5
5
|
//#region src/ssr.d.ts
|
|
6
|
+
declare function getClientEntryUrl(): string;
|
|
6
7
|
/**
|
|
7
8
|
* Callback type for client reference dependency notifications.
|
|
8
9
|
* Called during SSR when a client component's dependencies are loaded.
|
|
@@ -19,4 +20,4 @@ type OnClientReference = (reference: {
|
|
|
19
20
|
*/
|
|
20
21
|
declare function setOnClientReference(callback: OnClientReference | undefined): void;
|
|
21
22
|
//#endregion
|
|
22
|
-
export { type EncodeFormActionCallback, OnClientReference, callServer, createFromReadableStream, createServerConsumerManifest, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, setOnClientReference, setRequireModule };
|
|
23
|
+
export { type EncodeFormActionCallback, OnClientReference, callServer, createFromReadableStream, createServerConsumerManifest, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, getClientEntryUrl, setOnClientReference, setRequireModule };
|
package/dist/ssr.js
CHANGED
|
@@ -5,6 +5,11 @@ import * as clientReferences from "virtual:vite-rsc/client-references";
|
|
|
5
5
|
import * as ReactDOM from "react-dom";
|
|
6
6
|
import assetsManifest from "virtual:vite-rsc/assets-manifest";
|
|
7
7
|
//#region src/ssr.tsx
|
|
8
|
+
function getClientEntryUrl() {
|
|
9
|
+
const url = assetsManifest.clientEntryUrl;
|
|
10
|
+
if (!url) throw new Error(`[vite-rsc] getClientEntryUrl() cannot be used with the 'customClientEntry' option`);
|
|
11
|
+
return url;
|
|
12
|
+
}
|
|
8
13
|
let onClientReference;
|
|
9
14
|
/**
|
|
10
15
|
* Register a callback to be notified when client reference dependencies are loaded.
|
|
@@ -82,4 +87,4 @@ function preloadDeps(deps) {
|
|
|
82
87
|
});
|
|
83
88
|
}
|
|
84
89
|
//#endregion
|
|
85
|
-
export { callServer, createFromReadableStream, createServerConsumerManifest, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, setOnClientReference, setRequireModule };
|
|
90
|
+
export { callServer, createFromReadableStream, createServerConsumerManifest, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, getClientEntryUrl, setOnClientReference, setRequireModule };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { TransformExpandExportAllContext, TransformExpandExportAllOptions, TransformProxyExportOptions, TransformWrapExportFilter, TransformWrapExportOptions, extractIdentifiers, extractNames, findDirectives, hasDirective, transformDirectiveProxyExport, transformExpandExportAll, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport, validateNonAsyncFunction };
|
|
1
|
+
import { A as ModuleExportSpecifier, C as TransformModuleExportEffectFilter, D as ModuleExportEntry, E as transformModuleExportEffect, F as findDirectives, I as transformHoistInlineDirective, M as TransformHoistInlineDirectiveMeta, N as TransformHoistInlineDirectiveOptions, O as ModuleExportGroup, P as TransformHoistInlineDirectiveResult, S as TransformModuleExportEffectContext, T as TransformModuleExportEffectResult, _ as transformProxyExport, a as TransformServerActionServerResult, b as TransformWrapExportResult, c as extractNames, d as rejectNonAsyncFunction, f as validateNonAsyncFunction, g as transformDirectiveProxyExport, h as TransformProxyExportResult, i as TransformServerActionServerOptions, j as scanModuleExports, k as ModuleExportMeta, l as hasDirective, m as TransformProxyExportOptions, n as TransformExpandExportAllOptions, o as transformServerActionServer, p as TransformProxyExportFilter, r as transformExpandExportAll, s as extractIdentifiers, t as TransformExpandExportAllContext, u as isDirective, v as TransformWrapExportFilter, w as TransformModuleExportEffectOptions, x as transformWrapExport, y as TransformWrapExportOptions } from "../index-XXYjyFr6.js";
|
|
2
|
+
export { ModuleExportEntry, ModuleExportGroup, ModuleExportMeta, ModuleExportSpecifier, TransformExpandExportAllContext, TransformExpandExportAllOptions, TransformHoistInlineDirectiveMeta, TransformHoistInlineDirectiveOptions, TransformHoistInlineDirectiveResult, TransformModuleExportEffectContext, TransformModuleExportEffectFilter, TransformModuleExportEffectOptions, TransformModuleExportEffectResult, TransformProxyExportFilter, TransformProxyExportOptions, TransformProxyExportResult, TransformServerActionServerOptions, TransformServerActionServerResult, TransformWrapExportFilter, TransformWrapExportOptions, TransformWrapExportResult, extractIdentifiers, extractNames, findDirectives, hasDirective, isDirective, rejectNonAsyncFunction, scanModuleExports, transformDirectiveProxyExport, transformExpandExportAll, transformHoistInlineDirective, transformModuleExportEffect, transformProxyExport, transformServerActionServer, transformWrapExport, validateNonAsyncFunction };
|