Open
Description
Reproduction
/
System Info
latest remix & vite version
Used Package Manager
npm
Expected Behavior
get error:
[commonjs--resolver] Server-only module referenced by client
'~/data/pdf.server' imported by route 'app/routes/pdf_verify_return.tsx'
Remix automatically removes server-code from these exports:
`loader`, `action`, `headers`
Actual Behavior
here is the code:
import { IPDF_BOOKING_VERIFY, PDF_BUCHUNGS } from "~/data/pdf.server";
export const getPDFVerify = async ({db_name, id, p }: { db_name: DB_NAME_TYPE; id: number; p: IProcessID_DATA; }) => {
// render the PDF as a stream so you do it async
let stream = await renderToStream(<PDF_BUCHUNGS {...d} />);
// and transform it to a Buffer to send in the Response
let body: Buffer = await new Promise((resolve, reject) => {
let buffers: Uint8Array[] = [];
stream.on("data", (data) => {
buffers.push(data);
});
stream.on("end", () => {
resolve(Buffer.concat(buffers));
});
stream.on("error", reject);
});
// finally create the Response with the correct Content-Type header for
// a PDF
return body;
}