@vitejs/plugin-rsc 0.4.32 → 0.4.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.
@@ -1,7 +1,8 @@
1
1
  import { createDebug } from "./dist-DiJnRA1C.js";
2
- import { parseIdQuery } from "./shared-AvKUASD5.js";
2
+ import { parseIdQuery } from "./shared-n-ykEs15.js";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
6
  import * as esModuleLexer from "es-module-lexer";
6
7
  import MagicString from "magic-string";
7
8
  import { parseAstAsync } from "vite";
@@ -10,7 +11,8 @@ import { walk } from "estree-walker";
10
11
  import { analyze } from "periscopic";
11
12
 
12
13
  //#region src/transforms/cjs.ts
13
- function transformCjsToEsm(code, ast) {
14
+ const CJS_INTEROP_HELPER = `function __cjs_interop__(m) { return m.__cjs_module_runner_transform ? m.default : m; }`;
15
+ function transformCjsToEsm(code, ast, options) {
14
16
  const output = new MagicString(code);
15
17
  const analyzed = analyze(ast);
16
18
  const parentNodes = [];
@@ -27,12 +29,12 @@ function transformCjsToEsm(code, ast) {
27
29
  if (scope && scope.declarations.has("require")) return;
28
30
  }
29
31
  if (isTopLevel) {
30
- output.update(node.start, node.callee.end, "((await import");
31
- output.appendRight(node.end, ").default)");
32
+ output.update(node.start, node.callee.end, "(__cjs_interop__(await import");
33
+ output.appendRight(node.end, "))");
32
34
  } else {
33
35
  const hoisted = `__cjs_to_esm_hoist_${hoistIndex}`;
34
36
  const importee = code.slice(node.arguments[0].start, node.arguments[0].end);
35
- hoistedCodes.push(`const ${hoisted} = (await import(${importee})).default;\n`);
37
+ hoistedCodes.push(`const ${hoisted} = __cjs_interop__(await import(${importee}));\n`);
36
38
  output.update(node.start, node.end, hoisted);
37
39
  hoistIndex++;
38
40
  }
@@ -43,7 +45,16 @@ function transformCjsToEsm(code, ast) {
43
45
  }
44
46
  });
45
47
  for (const hoisted of hoistedCodes.reverse()) output.prepend(hoisted);
48
+ if (output.hasChanged()) output.prepend(`${CJS_INTEROP_HELPER}\n`);
46
49
  output.prepend(`let exports = {}; const module = { exports };\n`);
50
+ const __filename = fileURLToPath(pathToFileURL(options.id).href);
51
+ const __dirname = path.dirname(__filename);
52
+ output.prepend(`let __filename = ${JSON.stringify(__filename)}; let __dirname = ${JSON.stringify(__dirname)};\n`);
53
+ output.append(`
54
+ ;__vite_ssr_exportAll__(module.exports);
55
+ export default module.exports;
56
+ export const __cjs_module_runner_transform = true;
57
+ `);
47
58
  return { output };
48
59
  }
49
60
 
@@ -74,12 +85,7 @@ function cjsModuleRunnerPlugin() {
74
85
  debug(`non-optimized CJS dependency in '${this.environment.name}' environment: ${id}`);
75
86
  warnedPackages.add(packageKey);
76
87
  }
77
- const ast = await parseAstAsync(code);
78
- const output = transformCjsToEsm(code, ast).output;
79
- output.append(`
80
- ;__vite_ssr_exportAll__(module.exports);
81
- export default module.exports;
82
- `);
88
+ const output = transformCjsToEsm(code, await parseAstAsync(code), { id }).output;
83
89
  return {
84
90
  code: output.toString(),
85
91
  map: output.generateMap({ hires: "boundary" })
@@ -5,14 +5,11 @@ import encryptionKeySource from "virtual:vite-rsc/encryption-key";
5
5
 
6
6
  //#region src/utils/encryption-runtime.ts
7
7
  async function encryptActionBoundArgs(originalValue) {
8
- const serialized = renderToReadableStream(originalValue);
9
- const serializedBuffer = await concatArrayStream(serialized);
10
- return encryptBuffer(serializedBuffer, await getEncryptionKey());
8
+ return encryptBuffer(await concatArrayStream(renderToReadableStream(originalValue)), await getEncryptionKey());
11
9
  }
12
10
  async function decryptActionBoundArgs(encrypted) {
13
11
  const serializedBuffer = await decryptBuffer(await encrypted, await getEncryptionKey());
14
- const serialized = arrayToStream(new Uint8Array(serializedBuffer));
15
- return createFromReadableStream(serialized);
12
+ return createFromReadableStream(arrayToStream(new Uint8Array(serializedBuffer)));
16
13
  }
17
14
  const getEncryptionKey = /* @__PURE__ */ once(async () => {
18
15
  const resolved = await encryptionKeySource();
package/dist/extra/rsc.js CHANGED
@@ -3,7 +3,7 @@ import "../shared-CXg_u-4h.js";
3
3
  import "../encryption-utils-BDwwcMVT.js";
4
4
  import { loadServerAction } from "../rsc-GFzFWyhT.js";
5
5
  import { createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, renderToReadableStream } from "../rsc-BdCB3621.js";
6
- import "../encryption-runtime-CugTJCLM.js";
6
+ import "../encryption-runtime-DT6dtlC5.js";
7
7
  import "../rsc-CiAoLCx8.js";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
 
@@ -13,11 +13,10 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
13
  */
14
14
  async function renderRequest(request, root, options) {
15
15
  function RscRoot() {
16
- const nonceMeta = options?.nonce && /* @__PURE__ */ jsx("meta", {
16
+ return /* @__PURE__ */ jsxs(Fragment, { children: [options?.nonce && /* @__PURE__ */ jsx("meta", {
17
17
  property: "csp-nonce",
18
18
  nonce: options.nonce
19
- });
20
- return /* @__PURE__ */ jsxs(Fragment, { children: [nonceMeta, root] });
19
+ }), root] });
21
20
  }
22
21
  const url = new URL(request.url);
23
22
  const isAction = request.method === "POST";
@@ -34,8 +33,7 @@ async function renderRequest(request, root, options) {
34
33
  returnValue = await (await loadServerAction(actionId)).apply(null, args);
35
34
  } else {
36
35
  const formData = await request.formData();
37
- const result = await (await decodeAction(formData))();
38
- formState = await decodeFormState(result, formData);
36
+ formState = await decodeFormState(await (await decodeAction(formData))(), formData);
39
37
  }
40
38
  }
41
39
  const rscStream = renderToReadableStream({
package/dist/extra/ssr.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import "../dist-DiJnRA1C.js";
2
2
  import "../shared-CXg_u-4h.js";
3
- import "../shared-AvKUASD5.js";
3
+ import "../shared-n-ykEs15.js";
4
4
  import "../ssr-Cm2FP2zD.js";
5
5
  import { createFromReadableStream } from "../ssr-Cd4SbAaO.js";
6
- import "../ssr-8BA2nj0-.js";
7
- import { injectRSCPayload } from "../server-BTo03tXh.js";
6
+ import "../ssr-BQwZitKq.js";
7
+ import { injectRSCPayload } from "../server-DMhFuTz_.js";
8
8
  import React from "react";
9
9
  import { jsx } from "react/jsx-runtime";
10
10
  import ReactDomServer from "react-dom/server.edge";
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import "./dist-DiJnRA1C.js";
2
2
  import "./plugin-CZbI4rhS.js";
3
- import "./transforms-zLwPjso_.js";
3
+ import "./transforms-CpF3zNE0.js";
4
4
  import "./encryption-utils-BDwwcMVT.js";
5
5
  import "./rpc-CUvSZurk.js";
6
- import { getPluginApi, vitePluginRsc } from "./plugin-CiDpxrwJ.js";
7
- import "./cjs-WQBk0zA_.js";
8
- import "./shared-AvKUASD5.js";
6
+ import { getPluginApi, vitePluginRsc } from "./plugin-BDLEZ1UW.js";
7
+ import "./cjs-BamOAUgw.js";
8
+ import "./shared-n-ykEs15.js";
9
9
 
10
10
  export { vitePluginRsc as default, getPluginApi };
@@ -1,10 +1,10 @@
1
1
  import { createDebug } from "./dist-DiJnRA1C.js";
2
2
  import { vitePluginRscCore } from "./plugin-CZbI4rhS.js";
3
- import { findDirectives, hasDirective, transformDirectiveProxyExport, transformServerActionServer, transformWrapExport } from "./transforms-zLwPjso_.js";
3
+ import { findDirectives, hasDirective, transformDirectiveProxyExport, transformServerActionServer, transformWrapExport } from "./transforms-CpF3zNE0.js";
4
4
  import { generateEncryptionKey, toBase64 } from "./encryption-utils-BDwwcMVT.js";
5
5
  import { createRpcServer } from "./rpc-CUvSZurk.js";
6
- import { cjsModuleRunnerPlugin } from "./cjs-WQBk0zA_.js";
7
- import { parseCssVirtual, parseIdQuery, toCssVirtual } from "./shared-AvKUASD5.js";
6
+ import { cjsModuleRunnerPlugin } from "./cjs-BamOAUgw.js";
7
+ import { parseCssVirtual, parseIdQuery, toCssVirtual } from "./shared-n-ykEs15.js";
8
8
  import { createRequire } from "node:module";
9
9
  import assert from "node:assert";
10
10
  import fs from "node:fs";
@@ -164,8 +164,7 @@ async function transformScanBuildStrip(code) {
164
164
  const [imports] = esModuleLexer.parse(code);
165
165
  let output = imports.map((e) => e.n && `import ${JSON.stringify(e.n)};\n`).filter(Boolean).join("");
166
166
  if (importGlobRE.test(code)) {
167
- const ast = await parseAstAsync(code);
168
- walk(ast, { enter(node) {
167
+ walk(await parseAstAsync(code), { enter(node) {
169
168
  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") {
170
169
  const importMetaGlob = code.slice(node.start, node.end);
171
170
  output += `console.log(${importMetaGlob});\n`;
@@ -205,19 +204,14 @@ function validateImportPlugin() {
205
204
  order: "post",
206
205
  async handler(_code, id) {
207
206
  if (this.environment.mode === "dev") {
208
- if (id.startsWith(`\0virtual:vite-rsc/validate-imports/invalid/`)) {
209
- const chain = getImportChainDev(this.environment, id);
210
- validateImportChain(chain, this.environment.name, this.environment.config.root);
211
- }
207
+ if (id.startsWith(`\0virtual:vite-rsc/validate-imports/invalid/`)) validateImportChain(getImportChainDev(this.environment, id), this.environment.name, this.environment.config.root);
212
208
  }
213
209
  }
214
210
  },
215
211
  buildEnd() {
216
212
  if (this.environment.mode === "build") {
217
- const serverOnly = getImportChainBuild(this, "\0virtual:vite-rsc/validate-imports/invalid/server-only");
218
- validateImportChain(serverOnly, this.environment.name, this.environment.config.root);
219
- const clientOnly = getImportChainBuild(this, "\0virtual:vite-rsc/validate-imports/invalid/client-only");
220
- validateImportChain(clientOnly, this.environment.name, this.environment.config.root);
213
+ validateImportChain(getImportChainBuild(this, "\0virtual:vite-rsc/validate-imports/invalid/server-only"), this.environment.name, this.environment.config.root);
214
+ validateImportChain(getImportChainBuild(this, "\0virtual:vite-rsc/validate-imports/invalid/client-only"), this.environment.name, this.environment.config.root);
221
215
  }
222
216
  }
223
217
  };
@@ -434,22 +428,21 @@ function vitePluginRsc(rscPluginOptions = {}) {
434
428
  name: "rsc",
435
429
  async config(config, env) {
436
430
  if (config.rsc) Object.assign(rscPluginOptions, vite.mergeConfig(config.rsc, rscPluginOptions));
437
- const result = await crawlFrameworkPkgs({
438
- root: process.cwd(),
439
- isBuild: env.command === "build",
440
- isFrameworkPkgByJson(pkgJson) {
441
- if ([PKG_NAME, "react-dom"].includes(pkgJson.name)) return;
442
- const deps = pkgJson["peerDependencies"];
443
- return deps && "react" in deps;
444
- }
445
- });
446
431
  const noExternal = [
447
432
  "react",
448
433
  "react-dom",
449
434
  "server-only",
450
435
  "client-only",
451
436
  PKG_NAME,
452
- ...result.ssr.noExternal.sort()
437
+ ...(await crawlFrameworkPkgs({
438
+ root: process.cwd(),
439
+ isBuild: env.command === "build",
440
+ isFrameworkPkgByJson(pkgJson) {
441
+ if ([PKG_NAME, "react-dom"].includes(pkgJson.name)) return;
442
+ const deps = pkgJson["peerDependencies"];
443
+ return deps && "react" in deps;
444
+ }
445
+ })).ssr.noExternal.sort()
453
446
  ];
454
447
  return {
455
448
  appType: config.appType ?? "custom",
@@ -553,8 +546,7 @@ function vitePluginRsc(rscPluginOptions = {}) {
553
546
  try {
554
547
  const resolved = await environment.pluginContainer.resolveId(source);
555
548
  assert(resolved, `[vite-rsc] failed to resolve server handler '${source}'`);
556
- const mod = await environment.runner.import(resolved.id);
557
- const fetchHandler = getFetchHandlerExport(mod);
549
+ const fetchHandler = getFetchHandlerExport(await environment.runner.import(resolved.id));
558
550
  req.url = req.originalUrl ?? req.url;
559
551
  await createRequestListener(fetchHandler)(req, res);
560
552
  } catch (e) {
@@ -570,10 +562,7 @@ function vitePluginRsc(rscPluginOptions = {}) {
570
562
  environmentName: "rsc",
571
563
  entryName: "index"
572
564
  };
573
- const entryFile = path.join(manager.config.environments[options.environmentName].build.outDir, `${options.entryName}.js`);
574
- const mod = await import(pathToFileURL(entryFile).href);
575
- const fetchHandler = getFetchHandlerExport(mod);
576
- const handler = createRequestListener(fetchHandler);
565
+ const handler = createRequestListener(getFetchHandlerExport(await import(pathToFileURL(path.join(manager.config.environments[options.environmentName].build.outDir, `${options.entryName}.js`)).href)));
577
566
  server.middlewares.use((req, _res, next) => {
578
567
  delete req.headers["accept-encoding"];
579
568
  next();
@@ -654,8 +643,7 @@ function vitePluginRsc(rscPluginOptions = {}) {
654
643
  const { server } = manager;
655
644
  const s = new MagicString(code);
656
645
  for (const match of code.matchAll(/import\.meta\.viteRsc\.loadModule\(([\s\S]*?)\)/dg)) {
657
- const argCode = match[1].trim();
658
- const [environmentName, entryName] = evalValue(`[${argCode}]`);
646
+ const [environmentName, entryName] = evalValue(`[${match[1].trim()}]`);
659
647
  let replacement;
660
648
  if (this.environment.mode === "dev" && rscPluginOptions.loadModuleDevProxy) {
661
649
  const origin = server.resolvedUrls?.local[0];
@@ -710,20 +698,18 @@ function vitePluginRsc(rscPluginOptions = {}) {
710
698
  const source = getEntrySource(environment.config, entryName);
711
699
  const resolvedEntry = await environment.pluginContainer.resolveId(source);
712
700
  assert(resolvedEntry, `[vite-rsc] failed to resolve entry '${source}'`);
713
- const runnerProxy = new Proxy({}, { get(_target, p, _receiver) {
701
+ return createRpcServer(new Proxy({}, { get(_target, p, _receiver) {
714
702
  if (typeof p !== "string" || p === "then") return;
715
703
  return async (...args) => {
716
704
  return (await environment.runner.import(resolvedEntry.id))[p](...args);
717
705
  };
718
- } });
719
- return createRpcServer(runnerProxy);
706
+ } }));
720
707
  }
721
708
  server.middlewares.use(async (req, res, next) => {
722
709
  const url = new URL(req.url ?? "/", `http://localhost`);
723
710
  if (url.pathname === "/__vite_rsc_load_module_dev_proxy") {
724
711
  try {
725
- const handler = await createHandler(url);
726
- createRequestListener(handler)(req, res);
712
+ createRequestListener(await createHandler(url))(req, res);
727
713
  } catch (e) {
728
714
  next(e);
729
715
  }
@@ -748,9 +734,8 @@ function vitePluginRsc(rscPluginOptions = {}) {
748
734
  if (id === "\0virtual:vite-rsc/assets-manifest") {
749
735
  assert(this.environment.name !== "client");
750
736
  assert(this.environment.mode === "dev");
751
- const entryUrl = assetsURL("@id/__x00__" + VIRTUAL_ENTRIES.browser, manager);
752
737
  const manifest = {
753
- bootstrapScriptContent: `import(${serializeValueWithRuntime(entryUrl)})`,
738
+ bootstrapScriptContent: `import(${serializeValueWithRuntime(assetsURL("@id/__x00__" + VIRTUAL_ENTRIES.browser, manager))})`,
754
739
  clientReferenceDeps: {}
755
740
  };
756
741
  return `export default ${JSON.stringify(manifest, null, 2)}`;
@@ -822,8 +807,7 @@ export default assetsManifest.bootstrapScriptContent;
822
807
  const output = new MagicString(code);
823
808
  for (const match of code.matchAll(/import\s*\.\s*meta\s*\.\s*viteRsc\s*\.\s*loadBootstrapScriptContent\(([\s\S]*?)\)/dg)) {
824
809
  const argCode = match[1].trim();
825
- const entryName = evalValue(argCode);
826
- assert(entryName, `[vite-rsc] expected 'loadBootstrapScriptContent("index")' but got ${argCode}`);
810
+ assert(evalValue(argCode), `[vite-rsc] expected 'loadBootstrapScriptContent("index")' but got ${argCode}`);
827
811
  let replacement = `Promise.resolve(__vite_rsc_assets_manifest.bootstrapScriptContent)`;
828
812
  const [start, end] = match.indices[0];
829
813
  output.overwrite(start, end, replacement);
@@ -1138,8 +1122,7 @@ function customOptimizerMetadataPlugin({ setMetadata }) {
1138
1122
  configResolved(config) {
1139
1123
  const file = path.join(config.cacheDir, "deps", MEATADATA_FILE);
1140
1124
  if (fs.existsSync(file)) try {
1141
- const metadata = JSON.parse(fs.readFileSync(file, "utf-8"));
1142
- setMetadata(metadata);
1125
+ setMetadata(JSON.parse(fs.readFileSync(file, "utf-8")));
1143
1126
  } catch (e) {
1144
1127
  this.warn(`failed to load '${file}'`);
1145
1128
  }
@@ -1244,7 +1227,7 @@ function vitePluginUseServer(useServerPluginOptions, manager) {
1244
1227
  }
1245
1228
  const result = withRollupError(this, transformDirectiveProxyExport)(ast, {
1246
1229
  code,
1247
- runtime: (name$1) => `$$ReactClient.createServerReference(${JSON.stringify(getNormalizedId() + "#" + name$1)},$$ReactClient.callServer, undefined, ` + (this.environment.mode === "dev" ? `$$ReactClient.findSourceMapURL,` : "undefined,") + `${JSON.stringify(name$1)})`,
1230
+ runtime: (name) => `$$ReactClient.createServerReference(${JSON.stringify(getNormalizedId() + "#" + name)},$$ReactClient.callServer, undefined, ` + (this.environment.mode === "dev" ? `$$ReactClient.findSourceMapURL,` : "undefined,") + `${JSON.stringify(name)})`,
1248
1231
  directive: "use server",
1249
1232
  rejectNonAsyncFunction: true
1250
1233
  });
@@ -1256,8 +1239,7 @@ function vitePluginUseServer(useServerPluginOptions, manager) {
1256
1239
  referenceKey: getNormalizedId(),
1257
1240
  exportNames: result.exportNames
1258
1241
  };
1259
- const name = this.environment.name === browserEnvironmentName ? "browser" : "ssr";
1260
- const importSource = resolvePackage(`${PKG_NAME}/react/${name}`);
1242
+ const importSource = resolvePackage(`${PKG_NAME}/react/${this.environment.name === browserEnvironmentName ? "browser" : "ssr"}`);
1261
1243
  output.prepend(`import * as $$ReactClient from "${importSource}";\n`);
1262
1244
  return {
1263
1245
  code: output.toString(),
@@ -1424,9 +1406,8 @@ function vitePluginRscCss(rscCssOptions = {}, manager) {
1424
1406
  code
1425
1407
  });
1426
1408
  if (!filter) return;
1427
- const ast = await parseAstAsync(code);
1428
1409
  const result = await transformRscCssExport({
1429
- ast,
1410
+ ast: await parseAstAsync(code),
1430
1411
  code,
1431
1412
  filter
1432
1413
  });
@@ -1463,8 +1444,7 @@ function vitePluginRscCss(rscCssOptions = {}, manager) {
1463
1444
  if (!mod?.id || !mod?.file) return `export default []`;
1464
1445
  const result = collectCss(server.environments.ssr, mod.id);
1465
1446
  for (const file of [mod.file, ...result.visitedFiles]) this.addWatchFile(file);
1466
- const hrefs = result.hrefs.map((href) => assetsURL(href.slice(1), manager));
1467
- return `export default ${serializeValueWithRuntime(hrefs)}`;
1447
+ return `export default ${serializeValueWithRuntime(result.hrefs.map((href) => assetsURL(href.slice(1), manager)))}`;
1468
1448
  }
1469
1449
  }
1470
1450
  },
@@ -1538,12 +1518,10 @@ function vitePluginRscCss(rscCssOptions = {}, manager) {
1538
1518
  if (this.environment.mode === "dev") {
1539
1519
  const result = collectCss(server.environments.rsc, importer);
1540
1520
  for (const file of [importer, ...result.visitedFiles]) this.addWatchFile(file);
1541
- const cssHrefs = result.hrefs.map((href) => href.slice(1));
1542
- const deps = assetsURLOfDeps({
1543
- css: cssHrefs,
1521
+ return generateResourcesCode(serializeValueWithRuntime(assetsURLOfDeps({
1522
+ css: result.hrefs.map((href) => href.slice(1)),
1544
1523
  js: []
1545
- }, manager);
1546
- return generateResourcesCode(serializeValueWithRuntime(deps), manager);
1524
+ }, manager)), manager);
1547
1525
  } else {
1548
1526
  const key = manager.toRelativeId(importer);
1549
1527
  manager.serverResourcesMetaMap[importer] = { key };
package/dist/plugin.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import "./dist-DiJnRA1C.js";
2
2
  import "./plugin-CZbI4rhS.js";
3
- import "./transforms-zLwPjso_.js";
3
+ import "./transforms-CpF3zNE0.js";
4
4
  import "./encryption-utils-BDwwcMVT.js";
5
5
  import "./rpc-CUvSZurk.js";
6
- import { getPluginApi, transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin-CiDpxrwJ.js";
7
- import "./cjs-WQBk0zA_.js";
8
- import "./shared-AvKUASD5.js";
6
+ import { getPluginApi, transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin-BDLEZ1UW.js";
7
+ import "./cjs-BamOAUgw.js";
8
+ import "./shared-n-ykEs15.js";
9
9
 
10
10
  export { vitePluginRsc as default, getPluginApi, transformRscCssExport, vitePluginRscMinimal };
@@ -1,5 +1,5 @@
1
1
  import "../dist-DiJnRA1C.js";
2
- import { cjsModuleRunnerPlugin } from "../cjs-WQBk0zA_.js";
3
- import "../shared-AvKUASD5.js";
2
+ import { cjsModuleRunnerPlugin } from "../cjs-BamOAUgw.js";
3
+ import "../shared-n-ykEs15.js";
4
4
 
5
5
  export { cjsModuleRunnerPlugin };
@@ -1,4 +1,4 @@
1
- import { injectRSCPayload } from "../server-BTo03tXh.js";
1
+ import { injectRSCPayload } from "../server-DMhFuTz_.js";
2
2
 
3
3
  //#region src/rsc-html-stream/ssr.ts
4
4
  /** @deprecated use `rsc-html-stream/server` instead */
package/dist/rsc.js CHANGED
@@ -3,7 +3,7 @@ import "./shared-CXg_u-4h.js";
3
3
  import "./encryption-utils-BDwwcMVT.js";
4
4
  import { createClientManifest, createServerManifest, loadServerAction, setRequireModule } from "./rsc-GFzFWyhT.js";
5
5
  import { createClientTemporaryReferenceSet, createFromReadableStream, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, encodeReply, registerClientReference, registerServerReference, renderToReadableStream } from "./rsc-BdCB3621.js";
6
- import { decryptActionBoundArgs, encryptActionBoundArgs } from "./encryption-runtime-CugTJCLM.js";
6
+ import { decryptActionBoundArgs, encryptActionBoundArgs } from "./encryption-runtime-DT6dtlC5.js";
7
7
  import "./rsc-CiAoLCx8.js";
8
8
 
9
9
  export { createClientManifest, createClientTemporaryReferenceSet, createFromReadableStream, createServerManifest, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, decryptActionBoundArgs, encodeReply, encryptActionBoundArgs, loadServerAction, registerClientReference, registerServerReference, renderToReadableStream, setRequireModule };
@@ -56,8 +56,7 @@ async function writeRSCStream(rscStream, controller, nonce) {
56
56
  for await (let chunk of rscStream) try {
57
57
  writeChunk(JSON.stringify(decoder.decode(chunk, { stream: true })), controller, nonce);
58
58
  } catch (err) {
59
- let base64 = JSON.stringify(btoa(String.fromCodePoint(...chunk)));
60
- writeChunk(`Uint8Array.from(atob(${base64}), m => m.codePointAt(0))`, controller, nonce);
59
+ writeChunk(`Uint8Array.from(atob(${JSON.stringify(btoa(String.fromCodePoint(...chunk)))}), m => m.codePointAt(0))`, controller, nonce);
61
60
  }
62
61
  let remaining = decoder.decode();
63
62
  if (remaining.length) writeChunk(JSON.stringify(remaining), controller, nonce);
@@ -11,10 +11,9 @@ function parseIdQuery(id) {
11
11
  query: {}
12
12
  };
13
13
  const [filename, rawQuery] = id.split(`?`, 2);
14
- const query = Object.fromEntries(new URLSearchParams(rawQuery));
15
14
  return {
16
15
  filename,
17
- query
16
+ query: Object.fromEntries(new URLSearchParams(rawQuery))
18
17
  };
19
18
  }
20
19
 
@@ -1,4 +1,4 @@
1
- import { toCssVirtual } from "./shared-AvKUASD5.js";
1
+ import { toCssVirtual } from "./shared-n-ykEs15.js";
2
2
  import { setRequireModule } from "./ssr-Cm2FP2zD.js";
3
3
  import * as clientReferences from "virtual:vite-rsc/client-references";
4
4
  import assetsManifest from "virtual:vite-rsc/assets-manifest";
@@ -8,29 +8,25 @@ import * as ReactDOM from "react-dom";
8
8
  initialize();
9
9
  function initialize() {
10
10
  setRequireModule({ load: async (id) => {
11
- if (!import.meta.env.__vite_rsc_build__) {
12
- const mod = await import(
13
- /* @vite-ignore */
14
- id
15
- );
16
- const modCss = await import(
11
+ if (!import.meta.env.__vite_rsc_build__) return wrapResourceProxy(await import(
12
+ /* @vite-ignore */
13
+ id
14
+ ), {
15
+ js: [],
16
+ css: (await import(
17
17
  /* @vite-ignore */
18
18
  "/@id/__x00__" + toCssVirtual({
19
19
  id,
20
20
  type: "ssr"
21
21
  })
22
- );
23
- return wrapResourceProxy(mod, {
24
- js: [],
25
- css: modCss.default
26
- });
27
- } else {
22
+ )).default
23
+ });
24
+ else {
28
25
  const import_ = clientReferences.default[id];
29
26
  if (!import_) throw new Error(`client reference not found '${id}'`);
30
27
  const deps = assetsManifest.clientReferenceDeps[id];
31
28
  if (deps) preloadDeps(deps);
32
- const mod = await import_();
33
- return wrapResourceProxy(mod, deps);
29
+ return wrapResourceProxy(await import_(), deps);
34
30
  }
35
31
  } });
36
32
  }
package/dist/ssr.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import "./dist-DiJnRA1C.js";
2
2
  import "./shared-CXg_u-4h.js";
3
- import "./shared-AvKUASD5.js";
3
+ import "./shared-n-ykEs15.js";
4
4
  import { createServerConsumerManifest, setRequireModule } from "./ssr-Cm2FP2zD.js";
5
5
  import { callServer, createFromReadableStream, createServerReference, findSourceMapURL } from "./ssr-Cd4SbAaO.js";
6
- import "./ssr-8BA2nj0-.js";
6
+ import "./ssr-BQwZitKq.js";
7
7
 
8
8
  export { callServer, createFromReadableStream, createServerConsumerManifest, createServerReference, findSourceMapURL, setRequireModule };
@@ -1,4 +1,4 @@
1
1
  import "../dist-DiJnRA1C.js";
2
- import { findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport } from "../transforms-zLwPjso_.js";
2
+ import { findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport } from "../transforms-CpF3zNE0.js";
3
3
 
4
4
  export { findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport };
@@ -290,8 +290,7 @@ function transformProxyExport(ast, options) {
290
290
  }
291
291
  }
292
292
  }
293
- const names = node.declaration.declarations.flatMap((decl) => extract_names(decl.id));
294
- createExport(node, names);
293
+ createExport(node, node.declaration.declarations.flatMap((decl) => extract_names(decl.id)));
295
294
  } else node.declaration;
296
295
  else {
297
296
  /**
@@ -3,6 +3,6 @@ import "../shared-CXg_u-4h.js";
3
3
  import "../encryption-utils-BDwwcMVT.js";
4
4
  import "../rsc-GFzFWyhT.js";
5
5
  import "../rsc-BdCB3621.js";
6
- import { decryptActionBoundArgs, encryptActionBoundArgs } from "../encryption-runtime-CugTJCLM.js";
6
+ import { decryptActionBoundArgs, encryptActionBoundArgs } from "../encryption-runtime-DT6dtlC5.js";
7
7
 
8
8
  export { decryptActionBoundArgs, encryptActionBoundArgs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-rsc",
3
- "version": "0.4.32",
3
+ "version": "0.4.33",
4
4
  "description": "React Server Components (RSC) support for Vite.",
5
5
  "keywords": [
6
6
  "vite",
@@ -39,7 +39,7 @@
39
39
  "prepack": "tsdown"
40
40
  },
41
41
  "dependencies": {
42
- "@remix-run/node-fetch-server": "^0.9.0",
42
+ "@remix-run/node-fetch-server": "^0.10.0",
43
43
  "es-module-lexer": "^1.7.0",
44
44
  "estree-walker": "^3.0.3",
45
45
  "magic-string": "^0.30.19",
@@ -49,19 +49,20 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@hiogawa/utils": "^1.7.0",
52
- "@playwright/test": "^1.55.0",
53
- "@tsconfig/strictest": "^2.0.5",
52
+ "@playwright/test": "^1.55.1",
53
+ "@tsconfig/strictest": "^2.0.6",
54
54
  "@types/estree": "^1.0.8",
55
- "@types/node": "^22.18.6",
56
- "@types/react": "^19.1.13",
55
+ "@types/node": "^22.18.8",
56
+ "@types/react": "^19.1.16",
57
57
  "@types/react-dom": "^19.1.9",
58
58
  "@vitejs/plugin-react": "workspace:*",
59
+ "@vitejs/test-dep-cjs-and-esm": "./test-dep/cjs-and-esm",
59
60
  "react": "^19.1.1",
60
61
  "react-dom": "^19.1.1",
61
62
  "react-server-dom-webpack": "^19.1.1",
62
63
  "rsc-html-stream": "^0.0.7",
63
64
  "tinyexec": "^1.0.1",
64
- "tsdown": "^0.15.4"
65
+ "tsdown": "^0.15.6"
65
66
  },
66
67
  "peerDependencies": {
67
68
  "react": "*",