@vitejs/plugin-rsc 0.5.18 → 0.5.20
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/browser.d.ts +2 -2
- package/dist/{chunk-Dj_d7TT4.js → chunk-f2BShn47.js} +1 -1
- package/dist/{cjs-D2v1gYgq.js → cjs-v2jRTNln.js} +1 -61
- package/dist/core/browser.d.ts +5 -1
- package/dist/core/browser.js +1 -1
- package/dist/core/plugin.js +25 -1
- package/dist/core/rsc.d.ts +1 -1
- package/dist/core/rsc.js +84 -1
- package/dist/core/ssr.d.ts +1 -1
- package/dist/core/ssr.js +1 -1
- package/dist/import-environment-B994HXEc.d.ts +11 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -4
- package/dist/{picocolors-BRyoHAlU.js → picocolors-B0A1T24z.js} +1 -1
- package/dist/plugin.d.ts +179 -3
- package/dist/plugin.js +1461 -4
- package/dist/plugins/cjs.js +62 -1
- package/dist/react/browser.d.ts +2 -2
- package/dist/react/rsc.js +1 -1
- package/dist/rsc.d.ts +3 -2
- package/dist/rsc.js +2 -2
- package/dist/ssr.d.ts +3 -2
- package/dist/ssr.js +1 -1
- package/dist/transforms/index.d.ts +1 -1
- package/dist/transforms/index.js +1 -1
- package/dist/utils/encryption-runtime.js +1 -2
- package/dist/utils/rpc.js +89 -1
- package/dist/validate-import-DJumtHRw.js +498 -0
- package/package.json +7 -7
- package/dist/browser-s-WcB8A7.d.ts +0 -6
- package/dist/plugin-BGmSmdwL.js +0 -27
- package/dist/plugin-Cp12dr0Z.js +0 -1944
- package/dist/plugin-K7i9F4Fd.d.ts +0 -187
- package/dist/rpc-EIuXyQpO.js +0 -91
- package/dist/rsc-Bhp6O2qz.js +0 -86
- /package/dist/{encryption-utils-DdqSKS_O.js → encryption-utils-Bk5eKdu6.js} +0 -0
- /package/dist/{index-now_lP2V.d.ts → index-BIbdRBfk.d.ts} +0 -0
- /package/dist/{index-CLmWsR1c.d.ts → server-action-B2zS9t-J.d.ts} +0 -0
- /package/dist/{transforms-B2EJTNXG.js → server-action-JkEy-6yW.js} +0 -0
- /package/dist/{shared-rtJPs0Yj.js → shared-Dhw3vs8e.js} +0 -0
- /package/dist/{shared-CGK4coF3.js → shared-d80_k_tn.js} +0 -0
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as CallServerCallback } from "./index-
|
|
2
|
-
import {
|
|
1
|
+
import { n as CallServerCallback } from "./index-BIbdRBfk.js";
|
|
2
|
+
import { setRequireModule } from "./core/browser.js";
|
|
3
3
|
import { callServer, createFromFetch, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, setServerCallback } from "./react/browser.js";
|
|
4
4
|
export { CallServerCallback, callServer, createFromFetch, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, setRequireModule, setServerCallback };
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import { t as createDebug } from "./dist-yW9-EeG1.js";
|
|
2
|
-
import { n as parseIdQuery } from "./shared-CGK4coF3.js";
|
|
3
|
-
import fs from "node:fs";
|
|
4
1
|
import path from "node:path";
|
|
5
2
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
-
import * as esModuleLexer from "es-module-lexer";
|
|
7
3
|
import MagicString from "magic-string";
|
|
8
|
-
import { parseAstAsync } from "vite";
|
|
9
|
-
import { findClosestPkgJsonPath } from "vitefu";
|
|
10
4
|
import { walk } from "estree-walker";
|
|
11
5
|
import { analyze } from "periscopic";
|
|
12
6
|
|
|
@@ -62,58 +56,4 @@ export const __cjs_module_runner_transform = true;
|
|
|
62
56
|
}
|
|
63
57
|
|
|
64
58
|
//#endregion
|
|
65
|
-
|
|
66
|
-
const debug = createDebug("vite-rsc:cjs");
|
|
67
|
-
function cjsModuleRunnerPlugin() {
|
|
68
|
-
const warnedPackages = /* @__PURE__ */ new Set();
|
|
69
|
-
return [{
|
|
70
|
-
name: "cjs-module-runner-transform",
|
|
71
|
-
apply: "serve",
|
|
72
|
-
applyToEnvironment: (env) => env.config.dev.moduleRunnerTransform,
|
|
73
|
-
transform: {
|
|
74
|
-
filter: {
|
|
75
|
-
id: /\/node_modules\//,
|
|
76
|
-
code: /\b(require|exports)\b/
|
|
77
|
-
},
|
|
78
|
-
async handler(code, id) {
|
|
79
|
-
if (id.includes("/node_modules/") && !id.startsWith(this.environment.config.cacheDir) && /\b(require|exports)\b/.test(code)) {
|
|
80
|
-
id = parseIdQuery(id).filename;
|
|
81
|
-
if (!/\.[cm]?js$/.test(id)) return;
|
|
82
|
-
if (id.endsWith(".mjs")) return;
|
|
83
|
-
if (id.endsWith(".js")) {
|
|
84
|
-
const pkgJsonPath = await findClosestPkgJsonPath(path.dirname(id));
|
|
85
|
-
if (pkgJsonPath) {
|
|
86
|
-
if (JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8")).type === "module") return;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const [, , , hasModuleSyntax] = esModuleLexer.parse(code);
|
|
90
|
-
if (hasModuleSyntax) return;
|
|
91
|
-
const packageKey = extractPackageKey(id);
|
|
92
|
-
if (!warnedPackages.has(packageKey)) {
|
|
93
|
-
debug(`non-optimized CJS dependency in '${this.environment.name}' environment: ${id}`);
|
|
94
|
-
warnedPackages.add(packageKey);
|
|
95
|
-
}
|
|
96
|
-
const output = transformCjsToEsm(code, await parseAstAsync(code), { id }).output;
|
|
97
|
-
return {
|
|
98
|
-
code: output.toString(),
|
|
99
|
-
map: output.generateMap({ hires: "boundary" })
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}];
|
|
105
|
-
}
|
|
106
|
-
function extractPackageKey(id) {
|
|
107
|
-
const yarnMatch = id.match(/\/.yarn\/cache\/([^/]+)/);
|
|
108
|
-
if (yarnMatch) return yarnMatch[1];
|
|
109
|
-
if (id.includes("/node_modules")) {
|
|
110
|
-
id = id.split("/node_modules/").at(-1);
|
|
111
|
-
let [x, y] = id.split("/");
|
|
112
|
-
if (x.startsWith("@")) return `${x}/${y}`;
|
|
113
|
-
return x;
|
|
114
|
-
}
|
|
115
|
-
return id;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
//#endregion
|
|
119
|
-
export { cjsModuleRunnerPlugin as t };
|
|
59
|
+
export { transformCjsToEsm as t };
|
package/dist/core/browser.d.ts
CHANGED
package/dist/core/browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as memoize } from "../dist-yW9-EeG1.js";
|
|
2
|
-
import { a as setInternalRequire, i as removeReferenceCacheTag } from "../shared-
|
|
2
|
+
import { a as setInternalRequire, i as removeReferenceCacheTag } from "../shared-Dhw3vs8e.js";
|
|
3
3
|
|
|
4
4
|
//#region src/core/browser.ts
|
|
5
5
|
let init = false;
|
package/dist/core/plugin.js
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/core/plugin.ts
|
|
2
|
+
function vitePluginRscCore() {
|
|
3
|
+
return [{
|
|
4
|
+
name: "rsc:patch-react-server-dom-webpack",
|
|
5
|
+
transform: {
|
|
6
|
+
filter: { code: "__webpack_require__" },
|
|
7
|
+
handler(originalCode, _id, _options) {
|
|
8
|
+
let code = originalCode;
|
|
9
|
+
if (code.includes("__webpack_require__.u")) code = code.replaceAll("__webpack_require__.u", "({}).u");
|
|
10
|
+
if (code.includes("__webpack_require__")) code = code.replaceAll("__webpack_require__", "__vite_rsc_require__");
|
|
11
|
+
if (code !== originalCode) return {
|
|
12
|
+
code,
|
|
13
|
+
map: null
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}, {
|
|
18
|
+
name: "rsc:workaround-linked-dep",
|
|
19
|
+
apply: () => !import.meta.url.includes("/node_modules/"),
|
|
20
|
+
configEnvironment() {
|
|
21
|
+
return { build: { commonjsOptions: { include: [/\/node_modules\//, /\/vendor\/react-server-dom\//] } } };
|
|
22
|
+
}
|
|
23
|
+
}];
|
|
24
|
+
}
|
|
2
25
|
|
|
26
|
+
//#endregion
|
|
3
27
|
export { vitePluginRscCore as default };
|
package/dist/core/rsc.d.ts
CHANGED
package/dist/core/rsc.js
CHANGED
|
@@ -1,3 +1,86 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as tinyassert, n as memoize } from "../dist-yW9-EeG1.js";
|
|
2
|
+
import { a as setInternalRequire, i as removeReferenceCacheTag, n as SERVER_REFERENCE_PREFIX, r as createReferenceCacheTag, t as SERVER_DECODE_CLIENT_PREFIX } from "../shared-Dhw3vs8e.js";
|
|
3
|
+
import * as ReactServer from "@vitejs/plugin-rsc/vendor/react-server-dom/server.edge";
|
|
2
4
|
|
|
5
|
+
//#region src/core/rsc.ts
|
|
6
|
+
let init = false;
|
|
7
|
+
let requireModule;
|
|
8
|
+
function setRequireModule(options) {
|
|
9
|
+
if (init) return;
|
|
10
|
+
init = true;
|
|
11
|
+
requireModule = (id) => {
|
|
12
|
+
return options.load(removeReferenceCacheTag(id));
|
|
13
|
+
};
|
|
14
|
+
globalThis.__vite_rsc_server_require__ = memoize(async (id) => {
|
|
15
|
+
if (id.startsWith(SERVER_DECODE_CLIENT_PREFIX)) {
|
|
16
|
+
id = id.slice(SERVER_DECODE_CLIENT_PREFIX.length);
|
|
17
|
+
id = removeReferenceCacheTag(id);
|
|
18
|
+
const target = {};
|
|
19
|
+
const getOrCreateClientReference = (name) => {
|
|
20
|
+
return target[name] ??= ReactServer.registerClientReference(() => {
|
|
21
|
+
throw new Error(`Unexpectedly client reference export '${name}' is called on server`);
|
|
22
|
+
}, id, name);
|
|
23
|
+
};
|
|
24
|
+
return new Proxy(target, { getOwnPropertyDescriptor(_target, name) {
|
|
25
|
+
if (typeof name !== "string" || name === "then") return Reflect.getOwnPropertyDescriptor(target, name);
|
|
26
|
+
getOrCreateClientReference(name);
|
|
27
|
+
return Reflect.getOwnPropertyDescriptor(target, name);
|
|
28
|
+
} });
|
|
29
|
+
}
|
|
30
|
+
return requireModule(id);
|
|
31
|
+
});
|
|
32
|
+
setInternalRequire();
|
|
33
|
+
}
|
|
34
|
+
async function loadServerAction(id) {
|
|
35
|
+
const [file, name] = id.split("#");
|
|
36
|
+
return (await requireModule(file))[name];
|
|
37
|
+
}
|
|
38
|
+
function createServerManifest() {
|
|
39
|
+
const cacheTag = import.meta.env.DEV ? createReferenceCacheTag() : "";
|
|
40
|
+
return new Proxy({}, { get(_target, $$id, _receiver) {
|
|
41
|
+
tinyassert(typeof $$id === "string");
|
|
42
|
+
let [id, name] = $$id.split("#");
|
|
43
|
+
tinyassert(id);
|
|
44
|
+
tinyassert(name);
|
|
45
|
+
return {
|
|
46
|
+
id: SERVER_REFERENCE_PREFIX + id + cacheTag,
|
|
47
|
+
name,
|
|
48
|
+
chunks: [],
|
|
49
|
+
async: true
|
|
50
|
+
};
|
|
51
|
+
} });
|
|
52
|
+
}
|
|
53
|
+
function createServerDecodeClientManifest() {
|
|
54
|
+
return new Proxy({}, { get(_target, id) {
|
|
55
|
+
return new Proxy({}, { get(_target, name) {
|
|
56
|
+
return {
|
|
57
|
+
id: SERVER_REFERENCE_PREFIX + SERVER_DECODE_CLIENT_PREFIX + id,
|
|
58
|
+
name,
|
|
59
|
+
chunks: [],
|
|
60
|
+
async: true
|
|
61
|
+
};
|
|
62
|
+
} });
|
|
63
|
+
} });
|
|
64
|
+
}
|
|
65
|
+
function createClientManifest(options) {
|
|
66
|
+
const cacheTag = import.meta.env.DEV ? createReferenceCacheTag() : "";
|
|
67
|
+
return new Proxy({}, { get(_target, $$id, _receiver) {
|
|
68
|
+
tinyassert(typeof $$id === "string");
|
|
69
|
+
let [id, name] = $$id.split("#");
|
|
70
|
+
tinyassert(id);
|
|
71
|
+
tinyassert(name);
|
|
72
|
+
options?.onClientReference?.({
|
|
73
|
+
id,
|
|
74
|
+
name
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
id: id + cacheTag,
|
|
78
|
+
name,
|
|
79
|
+
chunks: [],
|
|
80
|
+
async: true
|
|
81
|
+
};
|
|
82
|
+
} });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
3
86
|
export { createClientManifest, createServerDecodeClientManifest, createServerManifest, loadServerAction, setRequireModule };
|
package/dist/core/ssr.d.ts
CHANGED
package/dist/core/ssr.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as memoize } from "../dist-yW9-EeG1.js";
|
|
2
|
-
import { a as setInternalRequire, i as removeReferenceCacheTag } from "../shared-
|
|
2
|
+
import { a as setInternalRequire, i as removeReferenceCacheTag } from "../shared-Dhw3vs8e.js";
|
|
3
3
|
|
|
4
4
|
//#region src/core/ssr.ts
|
|
5
5
|
let init = false;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Plugin, ResolvedConfig } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/import-environment.d.ts
|
|
4
|
+
type EnvironmentImportMeta = {
|
|
5
|
+
resolvedId: string;
|
|
6
|
+
targetEnv: string;
|
|
7
|
+
sourceEnv: string;
|
|
8
|
+
specifier: string;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { EnvironmentImportMeta as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "./
|
|
1
|
+
import "./import-environment-B994HXEc.js";
|
|
2
|
+
import "./server-action-B2zS9t-J.js";
|
|
3
|
+
import vitePluginRsc, { PluginApi, RscPluginOptions, getPluginApi } from "./plugin.js";
|
|
3
4
|
export { type PluginApi, type RscPluginOptions, vitePluginRsc as default, getPluginApi };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./cjs-
|
|
2
|
-
import
|
|
3
|
-
import "./
|
|
4
|
-
import "./
|
|
1
|
+
import "./cjs-v2jRTNln.js";
|
|
2
|
+
import "./validate-import-DJumtHRw.js";
|
|
3
|
+
import "./server-action-JkEy-6yW.js";
|
|
4
|
+
import vitePluginRsc, { getPluginApi } from "./plugin.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-f2BShn47.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) => {
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,3 +1,179 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
|
|
1
|
+
import { t as EnvironmentImportMeta } from "./import-environment-B994HXEc.js";
|
|
2
|
+
import { s as TransformWrapExportFilter } from "./server-action-B2zS9t-J.js";
|
|
3
|
+
import "./transforms/index.js";
|
|
4
|
+
import MagicString from "magic-string";
|
|
5
|
+
import { Plugin, ResolvedConfig, Rollup, ViteDevServer, parseAstAsync } from "vite";
|
|
6
|
+
|
|
7
|
+
//#region src/plugin.d.ts
|
|
8
|
+
type ClientReferenceMeta = {
|
|
9
|
+
importId: string;
|
|
10
|
+
referenceKey: string;
|
|
11
|
+
packageSource?: string;
|
|
12
|
+
exportNames: string[];
|
|
13
|
+
renderedExports: string[];
|
|
14
|
+
serverChunk?: string;
|
|
15
|
+
groupChunkId?: string;
|
|
16
|
+
};
|
|
17
|
+
type ServerRerferenceMeta = {
|
|
18
|
+
importId: string;
|
|
19
|
+
referenceKey: string;
|
|
20
|
+
exportNames: string[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @experimental
|
|
24
|
+
*/
|
|
25
|
+
declare class RscPluginManager {
|
|
26
|
+
server: ViteDevServer;
|
|
27
|
+
config: ResolvedConfig;
|
|
28
|
+
bundles: Record<string, Rollup.OutputBundle>;
|
|
29
|
+
buildAssetsManifest: AssetsManifest | undefined;
|
|
30
|
+
isScanBuild: boolean;
|
|
31
|
+
clientReferenceMetaMap: Record<string, ClientReferenceMeta>;
|
|
32
|
+
clientReferenceGroups: Record<string, ClientReferenceMeta[]>;
|
|
33
|
+
serverReferenceMetaMap: Record<string, ServerRerferenceMeta>;
|
|
34
|
+
serverResourcesMetaMap: Record<string, {
|
|
35
|
+
key: string;
|
|
36
|
+
}>;
|
|
37
|
+
environmentImportMetaMap: Record<string, Record<string, Record<string, EnvironmentImportMeta>>>;
|
|
38
|
+
stabilize(): void;
|
|
39
|
+
toRelativeId(id: string): string;
|
|
40
|
+
writeAssetsManifest(environmentNames: string[]): void;
|
|
41
|
+
writeEnvironmentImportsManifest(): void;
|
|
42
|
+
}
|
|
43
|
+
type RscPluginOptions = {
|
|
44
|
+
/**
|
|
45
|
+
* shorthand for configuring `environments.(name).build.rollupOptions.input.index`
|
|
46
|
+
*/
|
|
47
|
+
entries?: Partial<Record<"client" | "ssr" | "rsc", string>>; /** @default { enviornmentName: "rsc", entryName: "index" } */
|
|
48
|
+
serverHandler?: {
|
|
49
|
+
environmentName: string;
|
|
50
|
+
entryName: string;
|
|
51
|
+
} | false; /** @default false */
|
|
52
|
+
loadModuleDevProxy?: boolean;
|
|
53
|
+
rscCssTransform?: false | {
|
|
54
|
+
filter?: (id: string) => boolean;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated This option is a no-op and will be removed in a future major.
|
|
58
|
+
*/
|
|
59
|
+
copyServerAssetsToClient?: (fileName: string) => boolean;
|
|
60
|
+
/**
|
|
61
|
+
* This option allows disabling action closure encryption for debugging purpose.
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
64
|
+
enableActionEncryption?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* By default, the plugin uses a build-time generated encryption key for
|
|
67
|
+
* "use server" closure argument binding.
|
|
68
|
+
* This can be overwritten by configuring `defineEncryptionKey` option,
|
|
69
|
+
* for example, to obtain a key through environment variable during runtime.
|
|
70
|
+
* cf. https://nextjs.org/docs/app/guides/data-security#overwriting-encryption-keys-advanced
|
|
71
|
+
*/
|
|
72
|
+
defineEncryptionKey?: string; /** Escape hatch for Waku's `allowServer` */
|
|
73
|
+
keepUseCientProxy?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Enable build-time validation of 'client-only' and 'server-only' imports
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
78
|
+
validateImports?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* use `Plugin.buildApp` hook (introduced on Vite 7) instead of `builder.buildApp` configuration
|
|
81
|
+
* for better composability with other plugins.
|
|
82
|
+
* @default true since Vite 7
|
|
83
|
+
*/
|
|
84
|
+
useBuildAppHook?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Skip the default buildApp orchestration for downstream frameworks
|
|
87
|
+
* to implement custom build pipelines using `getPluginApi()`.
|
|
88
|
+
* @experimental
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
customBuildApp?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Custom environment configuration
|
|
94
|
+
* @experimental
|
|
95
|
+
* @default { browser: 'client', ssr: 'ssr', rsc: 'rsc' }
|
|
96
|
+
*/
|
|
97
|
+
environment?: {
|
|
98
|
+
browser?: string;
|
|
99
|
+
ssr?: string;
|
|
100
|
+
rsc?: string;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Custom chunking strategy for client reference modules.
|
|
104
|
+
*
|
|
105
|
+
* This function allows you to group multiple client components into
|
|
106
|
+
* custom chunks instead of having each module in its own chunk.
|
|
107
|
+
* By default, client chunks are grouped by `meta.serverChunk`.
|
|
108
|
+
*/
|
|
109
|
+
clientChunks?: (meta: {
|
|
110
|
+
/** client reference module id */id: string; /** normalized client reference module id */
|
|
111
|
+
normalizedId: string; /** server chunk which includes a corresponding client reference proxy module */
|
|
112
|
+
serverChunk: string;
|
|
113
|
+
}) => string | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Controls whether CSS links use React's `precedence` attribute.
|
|
116
|
+
* @experimental
|
|
117
|
+
* @default true
|
|
118
|
+
*/
|
|
119
|
+
cssLinkPrecedence?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Opt out of the default "index" client entry convention.
|
|
122
|
+
* When enabled, the plugin will not:
|
|
123
|
+
* - Require an entry chunk named "index"
|
|
124
|
+
* - Automatically include client entry deps in each client reference's dependencies
|
|
125
|
+
*
|
|
126
|
+
* Note: `import.meta.viteRsc.loadBootstrapScriptContent` cannot be used with this option.
|
|
127
|
+
*
|
|
128
|
+
* Use this when you manually handle client entry setup and preloading.
|
|
129
|
+
*
|
|
130
|
+
* @experimental
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
133
|
+
customClientEntry?: boolean;
|
|
134
|
+
};
|
|
135
|
+
type PluginApi = {
|
|
136
|
+
manager: RscPluginManager;
|
|
137
|
+
};
|
|
138
|
+
/** @experimental */
|
|
139
|
+
declare function getPluginApi(config: Pick<ResolvedConfig, "plugins">): PluginApi | undefined;
|
|
140
|
+
/** @experimental */
|
|
141
|
+
declare function vitePluginRscMinimal(rscPluginOptions?: RscPluginOptions, manager?: RscPluginManager): Plugin[];
|
|
142
|
+
declare global {
|
|
143
|
+
function __VITE_ENVIRONMENT_RUNNER_IMPORT__(environmentName: string, id: string): Promise<any>;
|
|
144
|
+
}
|
|
145
|
+
declare function vitePluginRsc(rscPluginOptions?: RscPluginOptions): Plugin[];
|
|
146
|
+
declare class RuntimeAsset {
|
|
147
|
+
runtime: string;
|
|
148
|
+
constructor(value: string);
|
|
149
|
+
}
|
|
150
|
+
type AssetsManifest = {
|
|
151
|
+
bootstrapScriptContent: string | RuntimeAsset;
|
|
152
|
+
clientReferenceDeps: Record<string, AssetDeps>;
|
|
153
|
+
serverResources?: Record<string, Pick<AssetDeps, "css">>;
|
|
154
|
+
cssLinkPrecedence?: boolean;
|
|
155
|
+
};
|
|
156
|
+
type AssetDeps = {
|
|
157
|
+
js: (string | RuntimeAsset)[];
|
|
158
|
+
css: (string | RuntimeAsset)[];
|
|
159
|
+
};
|
|
160
|
+
type ResolvedAssetsManifest = {
|
|
161
|
+
bootstrapScriptContent: string;
|
|
162
|
+
clientReferenceDeps: Record<string, ResolvedAssetDeps>;
|
|
163
|
+
serverResources?: Record<string, Pick<ResolvedAssetDeps, "css">>;
|
|
164
|
+
cssLinkPrecedence?: boolean;
|
|
165
|
+
};
|
|
166
|
+
type ResolvedAssetDeps = {
|
|
167
|
+
js: string[];
|
|
168
|
+
css: string[];
|
|
169
|
+
};
|
|
170
|
+
declare function transformRscCssExport(options: {
|
|
171
|
+
ast: Awaited<ReturnType<typeof parseAstAsync>>;
|
|
172
|
+
code: string;
|
|
173
|
+
id?: string;
|
|
174
|
+
filter: TransformWrapExportFilter;
|
|
175
|
+
}): Promise<{
|
|
176
|
+
output: MagicString;
|
|
177
|
+
} | undefined>;
|
|
178
|
+
//#endregion
|
|
179
|
+
export { AssetDeps, AssetsManifest, PluginApi, ResolvedAssetDeps, ResolvedAssetsManifest, type RscPluginManager, RscPluginOptions, vitePluginRsc as default, getPluginApi, transformRscCssExport, vitePluginRscMinimal };
|