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)
This commit is contained in:
Edouard Vanbelle
2026-05-28 14:17:20 +02:00
parent 636f0b87bd
commit 99da124388
2 changed files with 6 additions and 2 deletions
+1
View File
@@ -517,6 +517,7 @@ export class ResourceListComponent {
const thumb = /** @type {HTMLImageElement | null} */ (el.querySelector('.file-thumb')); const thumb = /** @type {HTMLImageElement | null} */ (el.querySelector('.file-thumb'));
if (thumb) { if (thumb) {
thumb.addEventListener('error', () => { thumb.addEventListener('error', () => {
console.log(`no thumbnail for ${file.id} (${file.name}), request thumbnail generation from client side`);
thumb.classList.add('hidden'); thumb.classList.add('hidden');
thumbnail?.queueGenerate(file, (dataUrl) => { thumbnail?.queueGenerate(file, (dataUrl) => {
thumb.src = dataUrl; thumb.src = dataUrl;
+5 -2
View File
@@ -17,8 +17,11 @@ let _pdfjsLib = null;
*/ */
async function getPdfjsLib() { async function getPdfjsLib() {
if (_pdfjsLib) return _pdfjsLib; if (_pdfjsLib) return _pdfjsLib;
// IMPORTANT: this hack (const lib=...) so tsc will not load vendors library // IMPORTANT: use an absolute path so the import resolves correctly both in
const lib = '../vendors/pdf.min.mjs'; // 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 = /** @type {any} */ (await import(lib));
_pdfjsLib.GlobalWorkerOptions.workerSrc = '/js/vendors/pdf.worker.min.mjs'; _pdfjsLib.GlobalWorkerOptions.workerSrc = '/js/vendors/pdf.worker.min.mjs';
return _pdfjsLib; return _pdfjsLib;