Skip to content

Commit

Permalink
Merge pull request #345 from apollographql/pr/lazy-load-SimulatePrelo…
Browse files Browse the repository at this point in the history
…adedQuery
  • Loading branch information
phryneas authored Sep 2, 2024
2 parents cee4e66 + b58bdf7 commit 5a46eff
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type { PreloadQueryOptions } from "./PreloadQuery.js";

const handledRequests = new WeakMap<TransportedOptions, TransportIdentifier>();

export function SimulatePreloadedQuery<T>({
export default function SimulatePreloadedQuery<T>({
options,
result,
children,
Expand Down
14 changes: 14 additions & 0 deletions packages/client-react-streaming/src/index.cc.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use client";

import * as React from "react";

let RealSimulatePreloadedQuery: typeof import("./SimulatePreloadedQuery.cc.js").default;
export const SimulatePreloadedQuery: typeof import("./SimulatePreloadedQuery.cc.js").default =
(props) => {
if (!RealSimulatePreloadedQuery) {
RealSimulatePreloadedQuery = React.lazy(
() => import("./SimulatePreloadedQuery.cc.js")
);
}
return <RealSimulatePreloadedQuery {...props} />;
};
10 changes: 9 additions & 1 deletion packages/client-react-streaming/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ export default defineConfig((options) => {
),
entry("ssr", "src/stream-utils/index.ts", "stream-utils.node"),
{
...entry("browser", "src/index.cc.ts", "index.cc"),
...entry("browser", "src/index.cc.tsx", "index.cc"),
treeshake: false, // would remove the "use client" directive
},
{
...entry(
"browser",
"src/SimulatePreloadedQuery.cc.ts",
"SimulatePreloadedQuery.cc"
),
treeshake: false, // would remove the "use client" directive
},
];
Expand Down

0 comments on commit 5a46eff

Please sign in to comment.