feat: add experimental configuration and update PDF viewer error message

This commit is contained in:
Marco Pedone 2025-09-09 16:18:10 +02:00
parent 8c802dcabf
commit 0d423aa2f4
3 changed files with 15 additions and 4 deletions

View file

@ -0,0 +1,3 @@
#!/bin/bash
BUILDKIT_PROGRESS=plain docker compose -f dev-docker-compose.yml up -d --force-recreate --build

View file

@ -10,6 +10,9 @@ const nextConfig = {
compiler: {
removeConsole: false,
},
experimental: {
// esmExternals: "loose", // This if react-pdf gives compilation issues
},
devIndicators: false,
headers: async () => {

View file

@ -6,10 +6,12 @@ import "react-pdf/dist/Page/TextLayer.css";
import type { PDFDocumentProxy } from "pdfjs-dist";
import { LoadingPage } from "./loading";
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
"pdfjs-dist/build/pdf.worker.min.mjs",
import.meta.url,
).toString();
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs`;
// pdfjs.GlobalWorkerOptions.workerSrc = new URL(
// "pdfjs-dist/build/pdf.worker.min.mjs",
// import.meta.url,
// ).toString();
const options = {
cMapUrl: "/cmaps/",
@ -55,6 +57,9 @@ export const PDFViewer = ({ url }: { url: string }) => {
className={"overflow-auto aspect-[1/1.4142]"}
file={file}
loading={<LoadingPage />}
noData={
"Errore nel caricare il documento, riprova più tardi o Scaricalo"
}
onLoadSuccess={onDocumentLoadSuccess}
options={options}
>