From 0d423aa2f4f0522443f8a37eab3e0828e885029e Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Tue, 9 Sep 2025 16:18:10 +0200 Subject: [PATCH] feat: add experimental configuration and update PDF viewer error message --- apps/infoalloggi/compose_prod.sh | 3 +++ apps/infoalloggi/next.config.mjs | 3 +++ apps/infoalloggi/src/components/pdf-viewer.tsx | 13 +++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 apps/infoalloggi/compose_prod.sh diff --git a/apps/infoalloggi/compose_prod.sh b/apps/infoalloggi/compose_prod.sh new file mode 100644 index 0000000..5776c56 --- /dev/null +++ b/apps/infoalloggi/compose_prod.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +BUILDKIT_PROGRESS=plain docker compose -f dev-docker-compose.yml up -d --force-recreate --build diff --git a/apps/infoalloggi/next.config.mjs b/apps/infoalloggi/next.config.mjs index d81e48c..d3b2a77 100644 --- a/apps/infoalloggi/next.config.mjs +++ b/apps/infoalloggi/next.config.mjs @@ -10,6 +10,9 @@ const nextConfig = { compiler: { removeConsole: false, }, + experimental: { + // esmExternals: "loose", // This if react-pdf gives compilation issues + }, devIndicators: false, headers: async () => { diff --git a/apps/infoalloggi/src/components/pdf-viewer.tsx b/apps/infoalloggi/src/components/pdf-viewer.tsx index b16480f..a4aa567 100644 --- a/apps/infoalloggi/src/components/pdf-viewer.tsx +++ b/apps/infoalloggi/src/components/pdf-viewer.tsx @@ -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={} + noData={ + "Errore nel caricare il documento, riprova più tardi o Scaricalo" + } onLoadSuccess={onDocumentLoadSuccess} options={options} >