@vitejs/plugin-rsc 0.5.32 → 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-Dy7j0iU8.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-CKiBgsDn.js → picocolors-D28_L_A0.js} +1 -1
- package/dist/{plugin-DqLpibhH.d.ts → plugin-CKqXjp8D.d.ts} +5 -4
- package/dist/{plugin-C27mwbgw.js → plugin-DarRieDr.js} +9 -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";
|
|
@@ -714,7 +714,7 @@ function vitePluginRscMinimal(rscPluginOptions = {}, manager = new RscPluginMana
|
|
|
714
714
|
function vitePluginRsc(rscPluginOptions = {}) {
|
|
715
715
|
const manager = new RscPluginManager();
|
|
716
716
|
const buildApp = async (builder) => {
|
|
717
|
-
const colors = await import("./picocolors-
|
|
717
|
+
const colors = await import("./picocolors-D28_L_A0.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
718
718
|
const logStep = (msg) => {
|
|
719
719
|
builder.config.logger.info(colors.blue(msg));
|
|
720
720
|
};
|
|
@@ -1149,8 +1149,9 @@ export function createRpcClient(params) {
|
|
|
1149
1149
|
if (id === "\0virtual:vite-rsc/assets-manifest") {
|
|
1150
1150
|
assert(this.environment.name !== "client");
|
|
1151
1151
|
assert(this.environment.mode === "dev");
|
|
1152
|
+
const entryUrl = assetsURL("@id/__x00__" + VIRTUAL_ENTRIES.browser, manager);
|
|
1152
1153
|
const manifest = {
|
|
1153
|
-
|
|
1154
|
+
clientEntryUrl: rscPluginOptions.customClientEntry ? void 0 : entryUrl,
|
|
1154
1155
|
clientReferenceDeps: {},
|
|
1155
1156
|
cssLinkPrecedence: rscPluginOptions.cssLinkPrecedence
|
|
1156
1157
|
};
|
|
@@ -1188,7 +1189,7 @@ export function createRpcClient(params) {
|
|
|
1188
1189
|
css: rscAssetDeps[id]?.deps.css ?? []
|
|
1189
1190
|
}, manager);
|
|
1190
1191
|
const assetDeps = collectAssetDeps(bundle);
|
|
1191
|
-
let
|
|
1192
|
+
let clientEntryUrl;
|
|
1192
1193
|
let clientEntryDeps;
|
|
1193
1194
|
const clientReferenceDeps = {};
|
|
1194
1195
|
for (const meta of Object.values(manager.clientReferenceMetaMap)) {
|
|
@@ -1203,12 +1204,10 @@ export function createRpcClient(params) {
|
|
|
1203
1204
|
if (!entry) throw new Error(`[vite-rsc] Client build must have an entry chunk named "index". Use 'customClientEntry' option to disable this requirement.`);
|
|
1204
1205
|
clientEntryDeps = assetsURLOfDeps(entry.deps, manager);
|
|
1205
1206
|
for (const [key, deps] of Object.entries(clientReferenceDeps)) clientReferenceDeps[key] = mergeAssetDeps(deps, clientEntryDeps);
|
|
1206
|
-
|
|
1207
|
-
if (typeof entryUrl === "string") bootstrapScriptContent = `import(${JSON.stringify(entryUrl)})`;
|
|
1208
|
-
else bootstrapScriptContent = new RuntimeAsset(`"import(" + JSON.stringify(${entryUrl.runtime}) + ")"`);
|
|
1207
|
+
clientEntryUrl = assetsURL(entry.chunk.fileName, manager);
|
|
1209
1208
|
}
|
|
1210
1209
|
manager.buildAssetsManifest = {
|
|
1211
|
-
|
|
1210
|
+
clientEntryUrl,
|
|
1212
1211
|
clientEntryDeps,
|
|
1213
1212
|
clientReferenceDeps,
|
|
1214
1213
|
serverResources,
|
|
@@ -1225,13 +1224,6 @@ export function createRpcClient(params) {
|
|
|
1225
1224
|
}
|
|
1226
1225
|
}
|
|
1227
1226
|
},
|
|
1228
|
-
createVirtualPlugin("vite-rsc/bootstrap-script-content", function() {
|
|
1229
|
-
assert(this.environment.name !== "client");
|
|
1230
|
-
return `\
|
|
1231
|
-
import assetsManifest from "virtual:vite-rsc/assets-manifest";
|
|
1232
|
-
export default assetsManifest.bootstrapScriptContent;
|
|
1233
|
-
`;
|
|
1234
|
-
}),
|
|
1235
1227
|
{
|
|
1236
1228
|
name: "rsc:bootstrap-script-content",
|
|
1237
1229
|
transform: {
|
|
@@ -1245,7 +1237,7 @@ export default assetsManifest.bootstrapScriptContent;
|
|
|
1245
1237
|
const [argStart, argEnd] = match.indices[1];
|
|
1246
1238
|
const argCode = code.slice(argStart, argEnd).trim();
|
|
1247
1239
|
assert(evalValue(argCode), `[vite-rsc] expected 'loadBootstrapScriptContent("index")' but got ${argCode}`);
|
|
1248
|
-
let replacement = `Promise.resolve(__vite_rsc_assets_manifest.
|
|
1240
|
+
let replacement = `Promise.resolve("import(" + JSON.stringify(__vite_rsc_assets_manifest.clientEntryUrl) + ")")`;
|
|
1249
1241
|
const [start, end] = match.indices[0];
|
|
1250
1242
|
output.overwrite(start, end, replacement);
|
|
1251
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 };
|