fix(build): copy-pdf-worker must never mask the real build error
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 <noreply@anthropic.com>
This commit is contained in:
+13
-1
@@ -59,9 +59,21 @@ function copyPdfWorker() {
|
|||||||
return {
|
return {
|
||||||
name: 'copy-pdf-worker',
|
name: 'copy-pdf-worker',
|
||||||
closeBundle() {
|
closeBundle() {
|
||||||
|
// 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 src = path.resolve('node_modules/pdfjs-dist/build/pdf.worker.min.mjs');
|
||||||
const dest = path.resolve('dist/pdf.worker.min.js');
|
const dest = path.resolve('dist/pdf.worker.min.js');
|
||||||
if (fs.existsSync(src)) fs.copyFileSync(src, dest);
|
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);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user