From 34592d9144da35121c852818b190fdfea6d4b0bb Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Wed, 1 Jul 2026 22:53:32 -0400 Subject: [PATCH] fix(build): copy-pdf-worker must never mask the real build error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closeBundle also runs when the build FAILED mid-render (dist/ absent); the plugin's copyFileSync then threw ENOENT and vite reported THAT instead of the actual render error — exactly what hid the real failure in the Windows desktop CI run. Now: warn-and-skip on any error, mkdir the dest dir when copying. Co-Authored-By: Claude Opus 4.8 --- vite.config.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/vite.config.js b/vite.config.js index 871b2faf6..ac4b42d51 100644 --- a/vite.config.js +++ b/vite.config.js @@ -59,9 +59,21 @@ function copyPdfWorker() { return { name: 'copy-pdf-worker', closeBundle() { - const src = path.resolve('node_modules/pdfjs-dist/build/pdf.worker.min.mjs'); - const dest = path.resolve('dist/pdf.worker.min.js'); - if (fs.existsSync(src)) fs.copyFileSync(src, dest); + // Never throw from here: closeBundle also runs when the build FAILED + // mid-render (dist/ absent) and an exception here MASKS the real build + // error in vite's report (seen on the Windows CI runner). Warn and skip. + try { + const src = path.resolve('node_modules/pdfjs-dist/build/pdf.worker.min.mjs'); + const dest = path.resolve('dist/pdf.worker.min.js'); + if (!fs.existsSync(src)) { + console.warn('[copy-pdf-worker] source worker missing, skipped:', src); + return; + } + fs.mkdirSync(path.dirname(dest), { recursive: true }); + fs.copyFileSync(src, dest); + } catch (err) { + console.warn('[copy-pdf-worker] skipped:', err?.message ?? err); + } }, }; }