From 99da12438868b9aeb882d6c5e8df9800cdc17e44 Mon Sep 17 00:00:00 2001 From: Edouard Vanbelle Date: Thu, 28 May 2026 14:17:20 +0200 Subject: [PATCH] fix(ui/thumbnail): fix thumbnail generation in release - reference to /vendors/ must be absolute path (the bundle isn't the same path as the current library doing the lazy loading) --- static/js/components/resourceList.js | 1 + static/js/features/thumbnail.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/static/js/components/resourceList.js b/static/js/components/resourceList.js index 67f64d8e..a160ac3c 100644 --- a/static/js/components/resourceList.js +++ b/static/js/components/resourceList.js @@ -517,6 +517,7 @@ export class ResourceListComponent { const thumb = /** @type {HTMLImageElement | null} */ (el.querySelector('.file-thumb')); if (thumb) { thumb.addEventListener('error', () => { + console.log(`no thumbnail for ${file.id} (${file.name}), request thumbnail generation from client side`); thumb.classList.add('hidden'); thumbnail?.queueGenerate(file, (dataUrl) => { thumb.src = dataUrl; diff --git a/static/js/features/thumbnail.js b/static/js/features/thumbnail.js index 0d8c3a0d..17f23922 100644 --- a/static/js/features/thumbnail.js +++ b/static/js/features/thumbnail.js @@ -17,8 +17,11 @@ let _pdfjsLib = null; */ async function getPdfjsLib() { if (_pdfjsLib) return _pdfjsLib; - // IMPORTANT: this hack (const lib=...) so tsc will not load vendors library - const lib = '../vendors/pdf.min.mjs'; + // IMPORTANT: use an absolute path so the import resolves correctly both in + // dev mode (native ESM, module at /js/features/thumbnail.js) and in release + // mode (IIFE bundle at /js/app.{hash}.js — relative '../vendors/…' would + // incorrectly resolve to /vendors/… instead of /js/vendors/…). + const lib = '/js/vendors/pdf.min.mjs'; _pdfjsLib = /** @type {any} */ (await import(lib)); _pdfjsLib.GlobalWorkerOptions.workerSrc = '/js/vendors/pdf.worker.min.mjs'; return _pdfjsLib;