@vitejs/plugin-rsc 0.5.26 → 0.5.27

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { n as CallServerCallback } from "./index-D2a5dlVU.js";
2
- import { t as setRequireModule } from "./browser-CUMAmYC3.js";
1
+ import { n as CallServerCallback } from "./index-BrXJaflA.js";
2
+ import { t as setRequireModule } from "./browser-C_qguV-a.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,5 +1,5 @@
1
1
  import { t as createDebug } from "./dist-rz-Bnebz.js";
2
- import { t as buildScopeTree } from "./scope-DKCDtt0O.js";
2
+ import { t as buildScopeTree } from "./scope-Bwt9GVLP.js";
3
3
  import { n as parseIdQuery } from "./shared-DeahDSXi.js";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
@@ -1,2 +1,2 @@
1
- import { t as setRequireModule } from "../browser-CUMAmYC3.js";
1
+ import { t as setRequireModule } from "../browser-C_qguV-a.js";
2
2
  export { setRequireModule };
@@ -1,5 +1,5 @@
1
1
  import { n as memoize } from "../dist-rz-Bnebz.js";
2
- import { a as setInternalRequire, i as removeReferenceCacheTag } from "../shared-BViDMJTQ.js";
2
+ import { a as setInternalRequire, i as removeReferenceCacheTag } from "../shared-BVLpj0Y8.js";
3
3
  //#region src/core/browser.ts
4
4
  let init = false;
5
5
  function setRequireModule(options) {
@@ -1,4 +1,4 @@
1
- import { c as ModuleMap, t as BundlerConfig } from "../index-D2a5dlVU.js";
1
+ import { c as ModuleMap, t as BundlerConfig } from "../index-BrXJaflA.js";
2
2
 
3
3
  //#region src/core/rsc.d.ts
4
4
  declare function setRequireModule(options: {
package/dist/core/rsc.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as tinyassert, n as memoize } from "../dist-rz-Bnebz.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-BViDMJTQ.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-BVLpj0Y8.js";
3
3
  import * as ReactServer from "@vitejs/plugin-rsc/vendor/react-server-dom/server.edge";
4
4
  //#region src/core/rsc.ts
5
5
  let init = false;
@@ -1,4 +1,4 @@
1
- import { u as ServerConsumerManifest } from "../index-D2a5dlVU.js";
1
+ import { u as ServerConsumerManifest } from "../index-BrXJaflA.js";
2
2
 
3
3
  //#region src/core/ssr.d.ts
4
4
  declare function setRequireModule(options: {
package/dist/core/ssr.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as memoize } from "../dist-rz-Bnebz.js";
2
- import { a as setInternalRequire, i as removeReferenceCacheTag } from "../shared-BViDMJTQ.js";
2
+ import { a as setInternalRequire, i as removeReferenceCacheTag } from "../shared-BVLpj0Y8.js";
3
3
  //#region src/core/ssr.ts
4
4
  let init = false;
5
5
  function setRequireModule(options) {
@@ -1,6 +1,6 @@
1
1
  import MagicString from "magic-string";
2
2
 
3
- //#region ../../node_modules/.pnpm/@types+estree@1.0.8/node_modules/@types/estree/index.d.ts
3
+ //#region ../../node_modules/.pnpm/@types+estree@1.0.9/node_modules/@types/estree/index.d.ts
4
4
  // This definition file follows a somewhat unusual format. ESTree allows
5
5
  // runtime type checks based on the `type` parameter. In order to explain this
6
6
  // to typescript we want to use discriminated union types:
@@ -250,7 +250,7 @@ interface PrivateIdentifier extends BaseNode {
250
250
  }
251
251
  interface Property extends BaseNode {
252
252
  type: "Property";
253
- key: Expression | PrivateIdentifier;
253
+ key: Expression;
254
254
  value: Expression | Pattern; // Could be an AssignmentProperty
255
255
  kind: "init" | "get" | "set";
256
256
  method: boolean;
@@ -589,11 +589,6 @@ declare function transformProxyExport(ast: Program, options: TransformProxyExpor
589
589
  //#endregion
590
590
  //#region src/transforms/utils.d.ts
591
591
  declare function hasDirective(body: Program["body"], directive: string): boolean;
592
- declare function getExportNames(ast: Program, options: {
593
- ignoreExportAllDeclaration?: boolean;
594
- }): {
595
- exportNames: string[];
596
- };
597
592
  declare function extractNames(param: Pattern): string[];
598
593
  declare function extractIdentifiers(param: Pattern, nodes?: Identifier[]): Identifier[];
599
594
  declare function validateNonAsyncFunction(opts: {
@@ -614,4 +609,18 @@ declare function transformServerActionServer(input: string, ast: Program, option
614
609
  names: string[];
615
610
  };
616
611
  //#endregion
617
- export { hasDirective as a, transformDirectiveProxyExport as c, TransformWrapExportOptions as d, transformWrapExport as f, getExportNames as i, transformProxyExport as l, transformHoistInlineDirective as m, extractIdentifiers as n, validateNonAsyncFunction as o, findDirectives as p, extractNames as r, TransformProxyExportOptions as s, transformServerActionServer as t, TransformWrapExportFilter as u };
612
+ //#region src/transforms/expand-export-all.d.ts
613
+ interface TransformExpandExportAllContext {
614
+ resolve: (source: string, importer: string) => Promise<string | undefined>;
615
+ load: (id: string) => Promise<Program>;
616
+ }
617
+ interface TransformExpandExportAllOptions extends TransformExpandExportAllContext {
618
+ code: string;
619
+ ast: Program;
620
+ importer: string;
621
+ }
622
+ declare function transformExpandExportAll(options: TransformExpandExportAllOptions): Promise<{
623
+ code: string;
624
+ } | undefined>;
625
+ //#endregion
626
+ export { extractIdentifiers as a, validateNonAsyncFunction as c, transformProxyExport as d, TransformWrapExportFilter as f, transformHoistInlineDirective as g, findDirectives as h, transformServerActionServer as i, TransformProxyExportOptions as l, transformWrapExport as m, TransformExpandExportAllOptions as n, extractNames as o, TransformWrapExportOptions as p, transformExpandExportAll as r, hasDirective as s, TransformExpandExportAllContext as t, transformDirectiveProxyExport as u };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { c as getPluginApi, r as PluginApi, s as RscPluginOptions, u as vitePluginRsc } from "./plugin-DGxRH4Nv.js";
1
+ import { c as getPluginApi, r as PluginApi, s as RscPluginOptions, u as vitePluginRsc } from "./plugin-Bm-Fb4g7.js";
2
2
  export { type PluginApi, type RscPluginOptions, vitePluginRsc as default, getPluginApi };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { r as vitePluginRsc, t as getPluginApi } from "./plugin-BhzHKRFo.js";
1
+ import { r as vitePluginRsc, t as getPluginApi } from "./plugin-BK29Va7z.js";
2
2
  export { vitePluginRsc as default, getPluginApi };
@@ -1,4 +1,4 @@
1
- import { t as __commonJSMin } from "./chunk-DpdyVxdi.js";
1
+ import { a as __commonJSMin } from "./plugin-BK29Va7z.js";
2
2
  //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
3
3
  var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4
4
  let p = process || {}, argv = p.argv || [], env = p.env || {};
@@ -1,11 +1,10 @@
1
- import { n as __toESM } from "./chunk-DpdyVxdi.js";
2
1
  import { t as createDebug } from "./dist-rz-Bnebz.js";
3
2
  import vitePluginRscCore from "./core/plugin.js";
4
- import { a as hasDirective } from "./scope-DKCDtt0O.js";
5
- import { t as cjsModuleRunnerPlugin } from "./cjs-BdahOUyh.js";
3
+ import { i as hasDirective } from "./scope-Bwt9GVLP.js";
4
+ import { t as cjsModuleRunnerPlugin } from "./cjs-BspwazE6.js";
6
5
  import { i as toCssVirtual, n as parseIdQuery, r as parseReferenceValidationVirtual, t as parseCssVirtual } from "./shared-DeahDSXi.js";
7
- import { findDirectives, transformDirectiveProxyExport, transformServerActionServer, transformWrapExport } from "./transforms/index.js";
8
- import { o as generateEncryptionKey, s as toBase64 } from "./encryption-utils-BblioYEx.js";
6
+ import { findDirectives, transformDirectiveProxyExport, transformExpandExportAll, transformServerActionServer, transformWrapExport } from "./transforms/index.js";
7
+ import { o as generateEncryptionKey, s as toBase64 } from "./encryption-utils-CRBgMeBq.js";
9
8
  import { createRpcServer } from "./utils/rpc.js";
10
9
  import { createRequire } from "node:module";
11
10
  import assert from "node:assert";
@@ -23,6 +22,29 @@ import { crawlFrameworkPkgs } from "vitefu";
23
22
  import { walk } from "estree-walker";
24
23
  import { stripVTControlCharacters } from "node:util";
25
24
  import { createHash } from "node:crypto";
25
+ //#region \0rolldown/runtime.js
26
+ var __create = Object.create;
27
+ var __defProp = Object.defineProperty;
28
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
29
+ var __getOwnPropNames = Object.getOwnPropertyNames;
30
+ var __getProtoOf = Object.getPrototypeOf;
31
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
32
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
33
+ var __copyProps = (to, from, except, desc) => {
34
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
35
+ key = keys[i];
36
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
37
+ get: ((k) => from[k]).bind(null, key),
38
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
39
+ });
40
+ }
41
+ return to;
42
+ };
43
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
44
+ value: mod,
45
+ enumerable: true
46
+ }) : target, mod));
47
+ //#endregion
26
48
  //#region src/plugins/vite-utils.ts
27
49
  const VALID_ID_PREFIX = `/@id/`;
28
50
  const NULL_BYTE_PLACEHOLDER = `__x00__`;
@@ -605,7 +627,7 @@ function vitePluginRscMinimal(rscPluginOptions = {}, manager = new RscPluginMana
605
627
  function vitePluginRsc(rscPluginOptions = {}) {
606
628
  const manager = new RscPluginManager();
607
629
  const buildApp = async (builder) => {
608
- const colors = await import("./picocolors-BDx0CW3k.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
630
+ const colors = await import("./picocolors-CEw5D0BV.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
609
631
  const logStep = (msg) => {
610
632
  builder.config.logger.info(colors.blue(msg));
611
633
  };
@@ -1202,6 +1224,17 @@ function globalAsyncLocalStoragePlugin() {
1202
1224
  }
1203
1225
  }];
1204
1226
  }
1227
+ function createTransformExpandExportAllContext(ctx) {
1228
+ return {
1229
+ resolve: async (source, importer) => {
1230
+ return (await ctx.resolve(source, importer))?.id;
1231
+ },
1232
+ load: async (id) => {
1233
+ const raw = await fs.promises.readFile(id, "utf-8");
1234
+ return parseAstAsync((await (vite.transformWithOxc ?? vite.transformWithEsbuild)(raw, id, { sourcemap: false })).code);
1235
+ }
1236
+ };
1237
+ }
1205
1238
  function vitePluginUseClient(useClientPluginOptions, manager) {
1206
1239
  const packageSources = /* @__PURE__ */ new Map();
1207
1240
  const bareImportRE = /^(?![a-zA-Z]:)[\w@](?!.*:\/\/)/;
@@ -1222,7 +1255,7 @@ function vitePluginUseClient(useClientPluginOptions, manager) {
1222
1255
  delete manager.clientReferenceMetaMap[id];
1223
1256
  return;
1224
1257
  }
1225
- const ast = await parseAstAsync(code);
1258
+ let ast = await parseAstAsync(code);
1226
1259
  if (!hasDirective(ast.body, "use client")) {
1227
1260
  delete manager.clientReferenceMetaMap[id];
1228
1261
  return;
@@ -1231,6 +1264,16 @@ function vitePluginUseClient(useClientPluginOptions, manager) {
1231
1264
  const directives = findDirectives(ast, "use server");
1232
1265
  if (directives.length > 0) this.error(`'use server' directive is not allowed inside 'use client'`, directives[0]?.start);
1233
1266
  }
1267
+ const expanded = await transformExpandExportAll({
1268
+ code,
1269
+ ast,
1270
+ importer: id,
1271
+ ...createTransformExpandExportAllContext(this)
1272
+ });
1273
+ if (expanded) {
1274
+ code = expanded.code;
1275
+ ast = await parseAstAsync(code);
1276
+ }
1234
1277
  let importId;
1235
1278
  let referenceKey;
1236
1279
  const packageSource = packageSources.get(id);
@@ -1521,7 +1564,19 @@ function vitePluginUseServer(useServerPluginOptions, manager) {
1521
1564
  delete manager.serverReferenceMetaMap[id];
1522
1565
  return;
1523
1566
  }
1524
- const ast = await parseAstAsync(code);
1567
+ let ast = await parseAstAsync(code);
1568
+ if (hasDirective(ast.body, "use server")) {
1569
+ const expanded = await transformExpandExportAll({
1570
+ code,
1571
+ ast,
1572
+ importer: id,
1573
+ ...createTransformExpandExportAllContext(this)
1574
+ });
1575
+ if (expanded) {
1576
+ code = expanded.code;
1577
+ ast = await parseAstAsync(code);
1578
+ }
1579
+ }
1525
1580
  let normalizedId_;
1526
1581
  const getNormalizedId = () => {
1527
1582
  if (!normalizedId_) {
@@ -1967,4 +2022,4 @@ function __vite_rsc_wrap_css__(value, name) {
1967
2022
  }
1968
2023
  }
1969
2024
  //#endregion
1970
- export { vitePluginRscMinimal as i, transformRscCssExport as n, vitePluginRsc as r, getPluginApi as t };
2025
+ export { __commonJSMin as a, vitePluginRscMinimal as i, transformRscCssExport as n, vitePluginRsc as r, getPluginApi as t };
@@ -1,4 +1,4 @@
1
- import { u as TransformWrapExportFilter } from "./index-2GoUFmVR.js";
1
+ import { f as TransformWrapExportFilter } from "./index-DViteJjw.js";
2
2
  import MagicString from "magic-string";
3
3
  import { Plugin, ResolvedConfig, Rollup, ViteDevServer, parseAstAsync } from "vite";
4
4
 
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-DGxRH4Nv.js";
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-Bm-Fb4g7.js";
2
2
  export { AssetDeps, AssetsManifest, PluginApi, ResolvedAssetDeps, ResolvedAssetsManifest, 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-BhzHKRFo.js";
1
+ import { i as vitePluginRscMinimal, n as transformRscCssExport, r as vitePluginRsc, t as getPluginApi } from "./plugin-BK29Va7z.js";
2
2
  export { vitePluginRsc as default, getPluginApi, transformRscCssExport, vitePluginRscMinimal };
@@ -1,2 +1,2 @@
1
- import { t as cjsModuleRunnerPlugin } from "../cjs-BdahOUyh.js";
1
+ import { t as cjsModuleRunnerPlugin } from "../cjs-BspwazE6.js";
2
2
  export { cjsModuleRunnerPlugin };
@@ -1,5 +1,5 @@
1
- import { i as CreateFromReadableStreamBrowserOptions, n as CallServerCallback, r as ClientTemporaryReferenceSet, s as EncodeReplyFunction } from "../index-D2a5dlVU.js";
2
- import { t as setRequireModule } from "../browser-CUMAmYC3.js";
1
+ import { i as CreateFromReadableStreamBrowserOptions, n as CallServerCallback, r as ClientTemporaryReferenceSet, s as EncodeReplyFunction } from "../index-BrXJaflA.js";
2
+ import { t as setRequireModule } from "../browser-C_qguV-a.js";
3
3
 
4
4
  //#region src/react/browser.d.ts
5
5
  declare function createFromReadableStream<T>(stream: ReadableStream<Uint8Array>, options?: CreateFromReadableStreamBrowserOptions): Promise<T>;
@@ -1,4 +1,4 @@
1
- import { a as CreateFromReadableStreamEdgeOptions, d as ServerTemporaryReferenceSet, l as RenderToReadableStreamOptions, o as DecodeReplyFunction, r as ClientTemporaryReferenceSet, s as EncodeReplyFunction } from "../index-D2a5dlVU.js";
1
+ import { a as CreateFromReadableStreamEdgeOptions, d as ServerTemporaryReferenceSet, l as RenderToReadableStreamOptions, o as DecodeReplyFunction, r as ClientTemporaryReferenceSet, s as EncodeReplyFunction } from "../index-BrXJaflA.js";
2
2
  import { loadServerAction, setRequireModule } from "../core/rsc.js";
3
3
  import { ReactFormState } from "react-dom/client";
4
4
 
@@ -1,4 +1,4 @@
1
- import { a as CreateFromReadableStreamEdgeOptions } from "../index-D2a5dlVU.js";
1
+ import { a as CreateFromReadableStreamEdgeOptions } from "../index-BrXJaflA.js";
2
2
  import { setRequireModule } from "../core/ssr.js";
3
3
 
4
4
  //#region src/react/ssr.d.ts
package/dist/rsc.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createClientManifest, createServerManifest, loadServerAction, setRequireModule } from "./core/rsc.js";
2
- import { i as ResolvedAssetDeps } from "./plugin-DGxRH4Nv.js";
2
+ import { i as ResolvedAssetDeps } from "./plugin-Bm-Fb4g7.js";
3
3
  import { createClientTemporaryReferenceSet, createFromReadableStream, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, encodeReply, registerClientReference, registerServerReference } from "./react/rsc.js";
4
4
  import { decryptActionBoundArgs, encryptActionBoundArgs } from "./utils/encryption-runtime.js";
5
5
 
@@ -4,42 +4,6 @@ import { walk } from "estree-walker";
4
4
  function hasDirective(body, directive) {
5
5
  return !!body.find((stmt) => stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && stmt.expression.value === directive);
6
6
  }
7
- function getExportNames(ast, options) {
8
- const exportNames = [];
9
- for (const node of ast.body) {
10
- if (node.type === "ExportNamedDeclaration") if (node.declaration) if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration")
11
- /**
12
- * export function foo() {}
13
- */
14
- exportNames.push(node.declaration.id.name);
15
- else if (node.declaration.type === "VariableDeclaration")
16
- /**
17
- * export const foo = 1, bar = 2
18
- */
19
- for (const decl of node.declaration.declarations) exportNames.push(...extractNames(decl.id));
20
- else node.declaration;
21
- else
22
- /**
23
- * export { foo, bar as car } from './foo'
24
- * export { foo, bar as car }
25
- */
26
- for (const spec of node.specifiers) {
27
- tinyassert(spec.exported.type === "Identifier");
28
- exportNames.push(spec.exported.name);
29
- }
30
- /**
31
- * export * from './foo'
32
- */
33
- if (!options.ignoreExportAllDeclaration && node.type === "ExportAllDeclaration") throw new Error("unsupported ExportAllDeclaration");
34
- /**
35
- * export default function foo() {}
36
- * export default class Foo {}
37
- * export default () => {}
38
- */
39
- if (node.type === "ExportDefaultDeclaration") exportNames.push("default");
40
- }
41
- return { exportNames };
42
- }
43
7
  function extractNames(param) {
44
8
  return extractIdentifiers(param).map((n) => n.name);
45
9
  }
@@ -76,6 +40,8 @@ function validateNonAsyncFunction(opts, node) {
76
40
  //#endregion
77
41
  //#region src/transforms/scope.ts
78
42
  var Scope = class {
43
+ parent;
44
+ isFunction;
79
45
  declarations = /* @__PURE__ */ new Set();
80
46
  constructor(parent, isFunction) {
81
47
  this.parent = parent;
@@ -208,4 +174,4 @@ function getOutermostBindableReference(id, parentStack) {
208
174
  return current;
209
175
  }
210
176
  //#endregion
211
- export { hasDirective as a, getExportNames as i, extractIdentifiers as n, validateNonAsyncFunction as o, extractNames as r, buildScopeTree as t };
177
+ export { validateNonAsyncFunction as a, hasDirective as i, extractIdentifiers as n, extractNames as r, buildScopeTree as t };
package/dist/ssr.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createServerConsumerManifest, setRequireModule } from "./core/ssr.js";
2
- import { i as ResolvedAssetDeps } from "./plugin-DGxRH4Nv.js";
2
+ import { i as ResolvedAssetDeps } from "./plugin-Bm-Fb4g7.js";
3
3
  import { callServer, createFromReadableStream, createServerReference, findSourceMapURL } from "./react/ssr.js";
4
4
 
5
5
  //#region src/ssr.d.ts
@@ -1,2 +1,2 @@
1
- import { a as hasDirective, c as transformDirectiveProxyExport, d as TransformWrapExportOptions, f as transformWrapExport, i as getExportNames, l as transformProxyExport, m as transformHoistInlineDirective, n as extractIdentifiers, o as validateNonAsyncFunction, p as findDirectives, r as extractNames, s as TransformProxyExportOptions, t as transformServerActionServer, u as TransformWrapExportFilter } from "../index-2GoUFmVR.js";
2
- export { TransformProxyExportOptions, TransformWrapExportFilter, TransformWrapExportOptions, extractIdentifiers, extractNames, findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport, validateNonAsyncFunction };
1
+ import { a as extractIdentifiers, c as validateNonAsyncFunction, d as transformProxyExport, f as TransformWrapExportFilter, g as transformHoistInlineDirective, h as findDirectives, i as transformServerActionServer, l as TransformProxyExportOptions, m as transformWrapExport, n as TransformExpandExportAllOptions, o as extractNames, p as TransformWrapExportOptions, r as transformExpandExportAll, s as hasDirective, t as TransformExpandExportAllContext, u as transformDirectiveProxyExport } from "../index-DViteJjw.js";
2
+ export { TransformExpandExportAllContext, TransformExpandExportAllOptions, TransformProxyExportOptions, TransformWrapExportFilter, TransformWrapExportOptions, extractIdentifiers, extractNames, findDirectives, hasDirective, transformDirectiveProxyExport, transformExpandExportAll, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport, validateNonAsyncFunction };
@@ -1,5 +1,5 @@
1
1
  import { i as tinyassert } from "../dist-rz-Bnebz.js";
2
- import { a as hasDirective, i as getExportNames, n as extractIdentifiers, o as validateNonAsyncFunction, r as extractNames, t as buildScopeTree } from "../scope-DKCDtt0O.js";
2
+ import { a as validateNonAsyncFunction, i as hasDirective, n as extractIdentifiers, r as extractNames, t as buildScopeTree } from "../scope-Bwt9GVLP.js";
3
3
  import MagicString from "magic-string";
4
4
  import { walk } from "estree-walker";
5
5
  //#region src/transforms/hoist.ts
@@ -217,7 +217,7 @@ function transformWrapExport(input, ast, options) {
217
217
  output.remove(node.start, node.end);
218
218
  for (const spec of node.specifiers) {
219
219
  tinyassert(spec.local.type === "Identifier");
220
- tinyassert(spec.exported.type === "Identifier");
220
+ if (spec.exported.type !== "Identifier") throw Object.assign(/* @__PURE__ */ new Error("unsupported string literal export name"), { pos: spec.exported.start });
221
221
  const name = spec.local.name;
222
222
  toAppend.push(`import { ${name} as $$import_${name} } from ${node.source.raw}`);
223
223
  wrapExport(`$$import_${name}`, spec.exported.name);
@@ -229,14 +229,17 @@ function transformWrapExport(input, ast, options) {
229
229
  output.remove(node.start, node.end);
230
230
  for (const spec of node.specifiers) {
231
231
  tinyassert(spec.local.type === "Identifier");
232
- tinyassert(spec.exported.type === "Identifier");
232
+ if (spec.exported.type !== "Identifier") throw Object.assign(/* @__PURE__ */ new Error("unsupported string literal export name"), { pos: spec.exported.start });
233
233
  wrapExport(spec.local.name, spec.exported.name);
234
234
  }
235
235
  }
236
236
  /**
237
+ * export * as ns from './foo'
237
238
  * export * from './foo'
238
239
  */
239
- if (!options.ignoreExportAllDeclaration && node.type === "ExportAllDeclaration") throw Object.assign(/* @__PURE__ */ new Error("unsupported ExportAllDeclaration"), { pos: node.start });
240
+ if (node.type === "ExportAllDeclaration") {
241
+ if (!options.ignoreExportAllDeclaration) throw Object.assign(/* @__PURE__ */ new Error("unsupported ExportAllDeclaration"), { pos: node.start });
242
+ }
240
243
  /**
241
244
  * export default function foo() {}
242
245
  * export default class Foo {}
@@ -325,7 +328,7 @@ function transformProxyExport(ast, options) {
325
328
  */
326
329
  const names = [];
327
330
  for (const spec of node.specifiers) {
328
- tinyassert(spec.exported.type === "Identifier");
331
+ if (spec.exported.type !== "Identifier") throw Object.assign(/* @__PURE__ */ new Error("unsupported string literal export name"), { pos: spec.exported.start });
329
332
  names.push(spec.exported.name);
330
333
  }
331
334
  createExport(node, names);
@@ -333,9 +336,16 @@ function transformProxyExport(ast, options) {
333
336
  continue;
334
337
  }
335
338
  /**
339
+ * export * as ns from './foo'
336
340
  * export * from './foo'
337
341
  */
338
- if (!options.ignoreExportAllDeclaration && node.type === "ExportAllDeclaration") throw new Error("unsupported ExportAllDeclaration");
342
+ if (node.type === "ExportAllDeclaration") {
343
+ if (node.exported?.type === "Identifier") {
344
+ createExport(node, [node.exported.name]);
345
+ continue;
346
+ }
347
+ if (!options.ignoreExportAllDeclaration) throw new Error("unsupported ExportAllDeclaration");
348
+ }
339
349
  /**
340
350
  * export default function foo() {}
341
351
  * export default class Foo {}
@@ -364,4 +374,82 @@ function transformServerActionServer(input, ast, options) {
364
374
  });
365
375
  }
366
376
  //#endregion
367
- export { extractIdentifiers, extractNames, findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport, validateNonAsyncFunction };
377
+ //#region src/transforms/expand-export-all.ts
378
+ async function transformExpandExportAll(options) {
379
+ const { plans } = resolveStarExports(await scanModuleExports(options.ast, options.importer, options));
380
+ if (plans.length === 0) return;
381
+ const output = new MagicString(options.code);
382
+ for (const item of plans) {
383
+ const newExport = `export {${item.names.join(", ")}} from ${JSON.stringify(item.node.source.value)};`;
384
+ output.update(item.node.start, item.node.end, newExport);
385
+ }
386
+ return { code: output.toString() };
387
+ }
388
+ async function scanModuleExports(ast, importer, context, seen = /* @__PURE__ */ new Set()) {
389
+ const starSources = [];
390
+ const bareStars = ast.body.filter((n) => n.type === "ExportAllDeclaration" && !n.exported);
391
+ for (const node of bareStars) {
392
+ const source = node.source.value;
393
+ const resolved = await context.resolve(source, importer);
394
+ if (!resolved) throw Object.assign(/* @__PURE__ */ new Error(`failed to resolve export-all source ${JSON.stringify(source)}`), { pos: node.start });
395
+ starSources.push({
396
+ node,
397
+ scan: await collectExportScan(resolved, context, new Set(seen))
398
+ });
399
+ }
400
+ return {
401
+ explicitNames: collectExplicitExportNames(ast),
402
+ starSources
403
+ };
404
+ }
405
+ async function collectExportScan(resolvedId, context, seen) {
406
+ if (seen.has(resolvedId)) return {
407
+ names: [],
408
+ ambiguousNames: /* @__PURE__ */ new Set()
409
+ };
410
+ seen.add(resolvedId);
411
+ const scan = await scanModuleExports(await context.load(resolvedId), resolvedId, context, seen);
412
+ const resolved = resolveStarExports(scan);
413
+ return {
414
+ names: [...scan.explicitNames, ...resolved.plans.flatMap((item) => item.names)],
415
+ ambiguousNames: resolved.ambiguousNames
416
+ };
417
+ }
418
+ function collectExplicitExportNames(ast) {
419
+ const names = /* @__PURE__ */ new Set();
420
+ for (const node of ast.body) if (node.type === "ExportNamedDeclaration") if (node.declaration) {
421
+ if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") {
422
+ if (node.declaration.id) names.add(node.declaration.id.name);
423
+ } else if (node.declaration.type === "VariableDeclaration") for (const decl of node.declaration.declarations) for (const name of extractNames(decl.id)) names.add(name);
424
+ } else for (const spec of node.specifiers) if (spec.exported.type === "Identifier") names.add(spec.exported.name);
425
+ else throw Object.assign(/* @__PURE__ */ new Error("unsupported string literal export name"), { pos: spec.exported.start });
426
+ else if (node.type === "ExportDefaultDeclaration") names.add("default");
427
+ else if (node.type === "ExportAllDeclaration") {
428
+ if (node.exported?.type === "Identifier") names.add(node.exported.name);
429
+ }
430
+ return names;
431
+ }
432
+ function resolveStarExports(scan) {
433
+ const seenStarNames = /* @__PURE__ */ new Set();
434
+ const ambiguousNames = /* @__PURE__ */ new Set();
435
+ for (const source of scan.starSources) for (const name of source.scan.names) {
436
+ if (name === "default" || scan.explicitNames.has(name)) continue;
437
+ if (seenStarNames.has(name)) ambiguousNames.add(name);
438
+ else seenStarNames.add(name);
439
+ }
440
+ for (const source of scan.starSources) for (const name of source.scan.ambiguousNames) if (!scan.explicitNames.has(name)) ambiguousNames.add(name);
441
+ const plans = [];
442
+ for (const source of scan.starSources) {
443
+ const names = source.scan.names.filter((name) => name !== "default" && !scan.explicitNames.has(name) && !ambiguousNames.has(name));
444
+ plans.push({
445
+ node: source.node,
446
+ names
447
+ });
448
+ }
449
+ return {
450
+ ambiguousNames,
451
+ plans
452
+ };
453
+ }
454
+ //#endregion
455
+ export { extractIdentifiers, extractNames, findDirectives, hasDirective, transformDirectiveProxyExport, transformExpandExportAll, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport, validateNonAsyncFunction };
@@ -1,5 +1,5 @@
1
1
  import { r as once } from "../dist-rz-Bnebz.js";
2
- import { a as fromBase64, i as encryptBuffer, n as concatArrayStream, r as decryptBuffer, t as arrayToStream } from "../encryption-utils-BblioYEx.js";
2
+ import { a as fromBase64, i as encryptBuffer, n as concatArrayStream, r as decryptBuffer, t as arrayToStream } from "../encryption-utils-CRBgMeBq.js";
3
3
  import { createFromReadableStream, renderToReadableStream } from "../react/rsc.js";
4
4
  import encryptionKeySource from "virtual:vite-rsc/encryption-key";
5
5
  //#region src/utils/encryption-runtime.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-rsc",
3
- "version": "0.5.26",
3
+ "version": "0.5.27",
4
4
  "description": "React Server Components (RSC) support for Vite.",
5
5
  "keywords": [
6
6
  "react",
@@ -39,7 +39,7 @@
39
39
  "prepack": "tsdown"
40
40
  },
41
41
  "dependencies": {
42
- "@rolldown/pluginutils": "1.0.0-rc.18",
42
+ "@rolldown/pluginutils": "^1.0.1",
43
43
  "es-module-lexer": "^2.1.0",
44
44
  "estree-walker": "^3.0.3",
45
45
  "magic-string": "^0.30.21",
@@ -50,11 +50,11 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@hiogawa/utils": "^1.7.0",
53
- "@playwright/test": "^1.59.1",
53
+ "@playwright/test": "^1.60.0",
54
54
  "@tsconfig/strictest": "^2.0.8",
55
- "@types/estree": "^1.0.8",
56
- "@types/node": "^24.12.2",
57
- "@types/react": "^19.2.14",
55
+ "@types/estree": "^1.0.9",
56
+ "@types/node": "^24.12.4",
57
+ "@types/react": "^19.2.15",
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",
@@ -64,7 +64,7 @@
64
64
  "react-dom": "^19.2.6",
65
65
  "react-server-dom-webpack": "^19.2.6",
66
66
  "tinyexec": "^1.1.2",
67
- "tsdown": "^0.21.10"
67
+ "tsdown": "^0.22.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "*",
@@ -1,25 +0,0 @@
1
- import "node:module";
2
- //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
21
- value: mod,
22
- enumerable: true
23
- }) : target, mod));
24
- //#endregion
25
- export { __toESM as n, __commonJSMin as t };
File without changes