Skip to content

Commit

Permalink
chore: alias react-server-dom-vite
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 19, 2024
1 parent d63f229 commit a08ddd0
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion react-server-dom-vite-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint-check": "biome check ."
},
"dependencies": {
"@jacob-ebey/react-server-dom-vite": "19.0.0-experimental.14",
"react-server-dom-vite": "npm:@jacob-ebey/react-server-dom-vite@19.0.0-experimental.14",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
Expand Down
6 changes: 3 additions & 3 deletions react-server-dom-vite-example/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion react-server-dom-vite-example/src/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ReactClient from "@jacob-ebey/react-server-dom-vite/client";
import React from "react";
import ReactDomClient from "react-dom/client";
import ReactClient from "react-server-dom-vite/client";
import type { ServerPayload } from "./entry.rsc";
import type { CallServerFn } from "./types";
import { clientReferenceManifest } from "./utils/client-reference";
Expand Down
2 changes: 1 addition & 1 deletion react-server-dom-vite-example/src/entry.rsc.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ReactServer from "@jacob-ebey/react-server-dom-vite/server";
import type { ReactFormState } from "react-dom/client";
import ReactServer from "react-server-dom-vite/server";
import { Router } from "./app/routes";
import type {
ClientReferenceMetadataManifest,
Expand Down
2 changes: 1 addition & 1 deletion react-server-dom-vite-example/src/entry.ssr.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IncomingMessage, ServerResponse } from "node:http";
import ReactClient from "@jacob-ebey/react-server-dom-vite/client";
import ReactDomServer from "react-dom/server";
import ReactClient from "react-server-dom-vite/client";
import type { ModuleRunner } from "vite/module-runner";
import type { ServerPayload } from "./entry.rsc";
import { clientReferenceManifest } from "./utils/client-reference";
Expand Down
4 changes: 2 additions & 2 deletions react-server-dom-vite-example/src/types/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="vite/client" />

declare module "@jacob-ebey/react-server-dom-vite/server" {
declare module "react-server-dom-vite/server" {
export function renderToPipeableStream<T>(
data: T,
manifest: import(".").ClientReferenceMetadataManifest,
Expand All @@ -21,7 +21,7 @@ declare module "@jacob-ebey/react-server-dom-vite/server" {
): Promise<import("react-dom/client").ReactFormState>;
}

declare module "@jacob-ebey/react-server-dom-vite/client" {
declare module "react-server-dom-vite/client" {
export function createFromNodeStream<T>(
stream: import("node:stream").Readable,
manifest: import(".").ClientReferenceManifest,
Expand Down
13 changes: 5 additions & 8 deletions react-server-dom-vite-example/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ export default defineConfig({
environments: {
client: {
optimizeDeps: {
include: [
"react-dom/client",
"@jacob-ebey/react-server-dom-vite/client",
],
include: ["react-dom/client", "react-server-dom-vite/client"],
},
build: {
manifest: true,
Expand All @@ -47,7 +44,7 @@ export default defineConfig({
"react",
"react/jsx-runtime",
"react/jsx-dev-runtime",
"@jacob-ebey/react-server-dom-vite/server",
"react-server-dom-vite/server",
],
},
resolve: {
Expand Down Expand Up @@ -201,7 +198,7 @@ function vitePluginUseClient(): Plugin[] {
...code.matchAll(/export (default) (function|class) /g),
];
const result = [
`import $$ReactServer from "@jacob-ebey/react-server-dom-vite/server"`,
`import $$ReactServer from "react-server-dom-vite/server"`,
...[...matches].map(
([, name]) =>
`export ${name === "default" ? "default" : `const ${name} =`} $$ReactServer.registerClientReference({}, ${JSON.stringify(id)}, ${JSON.stringify(name)})`,
Expand Down Expand Up @@ -234,7 +231,7 @@ function vitePluginUseServer(): Plugin[] {
const matches = code.matchAll(/export async function (\w+)\(/g);
const result = [
code,
`import $$ReactServer from "@jacob-ebey/react-server-dom-vite/server"`,
`import $$ReactServer from "react-server-dom-vite/server"`,
...[...matches].map(
([, name]) =>
`${name} = $$ReactServer.registerServerReference(${name}, ${JSON.stringify(id)}, ${JSON.stringify(name)})`,
Expand All @@ -244,7 +241,7 @@ function vitePluginUseServer(): Plugin[] {
} else {
const matches = code.matchAll(/export async function (\w+)\(/g);
const result = [
`import $$ReactClient from "@jacob-ebey/react-server-dom-vite/client"`,
`import $$ReactClient from "react-server-dom-vite/client"`,
...[...matches].map(
([, name]) =>
`export const ${name} = $$ReactClient.createServerReference(${JSON.stringify(id + "#" + name)}, (...args) => __callServer(...args))`,
Expand Down

0 comments on commit a08ddd0

Please sign in to comment.