mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Allow, optionally, using worker-modules during local development
Until PR 12563 is deemed safe to land, I'd still like to be able to use worker-modules in the viewer during local development. Hence this patch which *temporarily* adds a new `workerModules` hash-parameter, only available in non-PRODUCTION mode, that allows using worker-modules in the development viewer. To enable this functionality, simply use http://localhost:8888/web/viewer.html#workerModules=true
This commit is contained in:
parent
3d35b48f46
commit
5e88228767
4 changed files with 19 additions and 8 deletions
|
@ -304,7 +304,12 @@ const PDFViewerApplication = {
|
|||
const { mainContainer, viewerContainer } = this.appConfig,
|
||||
params = parseQueryString(hash);
|
||||
|
||||
if (params.get("disableworker") === "true") {
|
||||
if (
|
||||
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) &&
|
||||
params.get("workermodules") === "true"
|
||||
) {
|
||||
AppOptions.set("workerSrc", "../src/pdf.worker.js");
|
||||
} else if (params.get("disableworker") === "true") {
|
||||
try {
|
||||
await loadFakeWorker();
|
||||
} catch (ex) {
|
||||
|
@ -2143,7 +2148,7 @@ async function loadFakeWorker() {
|
|||
GlobalWorkerOptions.workerSrc ||= AppOptions.get("workerSrc");
|
||||
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
||||
window.pdfjsWorker = await import("pdfjs/core/worker.js");
|
||||
window.pdfjsWorker = await import("pdfjs/pdf.worker.js");
|
||||
return;
|
||||
}
|
||||
await loadScript(PDFWorker.workerSrc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue