Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(react-server): identity bundler config #72

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions examples/react-server/src/entry-ssr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { splitFirst } from "@hiogawa/utils";
import React from "react";
import reactDomServer from "react-dom/server.edge";
import type { ReactServerHandlerResult, StreamData } from "./entry-server";
import {
createModuleMap,
initializeWebpackServer,
} from "./features/use-client/ssr";
import { initializeWebpackServer } from "./features/use-client/ssr";
import { injectStreamScript } from "./features/utils/stream-script";
import { $__global } from "./global";

Expand Down Expand Up @@ -33,7 +30,7 @@ async function renderHtml(result: ReactServerHandlerResult) {
rscStream1,
{
ssrManifest: {
moduleMap: createModuleMap(),
moduleMap: null,
moduleLoading: null,
},
},
Expand Down
25 changes: 0 additions & 25 deletions examples/react-server/src/features/use-client/ssr.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { memoize, tinyassert } from "@hiogawa/utils";
import type { ImportManifestEntry, ModuleMap } from "../../types";

// In contrast to old dev ssr, new module runner's dynamic `import`
// with `vite-ignore` joins in a module graph.
Expand Down Expand Up @@ -27,27 +26,3 @@ export function initializeWebpackServer() {
},
});
}

export function createModuleMap(): ModuleMap {
return new Proxy(
{},
{
get(_target, id, _receiver) {
return new Proxy(
{},
{
get(_target, name, _receiver) {
tinyassert(typeof id === "string");
tinyassert(typeof name === "string");
return {
id,
name,
chunks: [],
} satisfies ImportManifestEntry;
},
},
);
},
},
);
}
4 changes: 2 additions & 2 deletions examples/react-server/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export type ModuleMap = {
};

export interface SsrManifest {
moduleMap: ModuleMap;
// TODO
// identity mapping should suffice?
moduleMap: ModuleMap | null;
moduleLoading: null;
}

Expand Down