Difficulties using Pdfjs-dist with SolidStart

I'm trying to use Pdfjs-dist with SolidStart. It works in developer mode but when I try to create a production build it fails with the error in the build-err.txt file I've attached. I've also attached the PdfViewer component code and the route I'm loading the PdfViewer into. I'm already using unstable_clientOnly to load in the module.
1 Reply
AutumnCicada
AutumnCicada12mo ago
For clarity, I do not want these native modules to be loaded at all since i only intend to use pdfjs in the browser It seems to be related to the canvas.node dependency which I do not need and would like to exclude from the bundle I figured it out, my vite config needed to be
import solid from "solid-start/vite";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [solid()],
ssr: {
external: ["pdfjs-dist"],
},
});
import solid from "solid-start/vite";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [solid()],
ssr: {
external: ["pdfjs-dist"],
},
});