Skip to content
Merged
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
17 changes: 7 additions & 10 deletions examples/react-server/src/features/client-component/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ import type { BundlerConfig, ImportManifestEntry } from "../../types";
// name: Counter

export function registerClientReference(id: string, name: string) {
// reuse everything but $$async: true for simplicity
const reference = ReactServer.registerClientReference({}, id, name);
return Object.defineProperties(
{},
{
...Object.getOwnPropertyDescriptors(reference),
$$async: { value: true },
},
);
return ReactServer.registerClientReference({}, id, name);
}

export function createBundlerConfig(): BundlerConfig {
Expand All @@ -30,7 +22,12 @@ export function createBundlerConfig(): BundlerConfig {
let [id, name] = $$id.split("#");
tinyassert(id);
tinyassert(name);
return { id, name, chunks: [] } satisfies ImportManifestEntry;
return {
id,
name,
chunks: [],
async: true,
} satisfies ImportManifestEntry;
},
},
);
Expand Down
1 change: 1 addition & 0 deletions examples/react-server/src/features/client-component/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function createModuleMap(): ModuleMap {
id,
name,
chunks: [],
async: true,
} satisfies ImportManifestEntry;
},
},
Expand Down
1 change: 1 addition & 0 deletions examples/react-server/src/features/server-action/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function createActionBundlerConfig(): BundlerConfig {
id,
name,
chunks: [],
async: true,
} satisfies ImportManifestEntry;
},
},
Expand Down
2 changes: 1 addition & 1 deletion examples/react-server/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
export interface ImportManifestEntry {
id: string;
name: string;
// TODO
chunks: string[];
async: boolean;
}

export interface BundlerConfig {
Expand Down
5 changes: 0 additions & 5 deletions examples/react-server/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,6 @@ function vitePluginServerAction(): PluginOption {
"__vite_react_server_webpack_chunk_load__",
);

// make server reference async for simplicity (stale chunkCache, etc...)
// see TODO in https://github.com/facebook/react/blob/33a32441e991e126e5e874f831bd3afc237a3ecf/packages/react-server-dom-webpack/src/ReactFlightClientConfigBundlerWebpack.js#L131-L132
code = code.replaceAll("if (isAsyncImport(metadata))", "if (true)");
code = code.replaceAll("4 === metadata.length", "true");

return { code, map: null };
}
return;
Expand Down